KVM: VMX: Introduce pi_is_pir_empty() helper
authorJoao Martins <joao.m.martins@oracle.com>
Mon, 11 Nov 2019 17:20:12 +0000 (17:20 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 12 Nov 2019 09:17:41 +0000 (10:17 +0100)
Streamline the PID.PIR check and change its call sites to use
the newly added helper.

Suggested-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/vmx/vmx.h

index 54458c5d5a01a00f36d9a1dcf1b485475b1071fe..04a8212704c17d0961f51b75f6151d9a831efc8c 100644 (file)
@@ -1305,7 +1305,7 @@ after_clear_sn:
         */
        smp_mb__after_atomic();
 
-       if (!bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS))
+       if (!pi_is_pir_empty(pi_desc))
                pi_set_on(pi_desc);
 }
 
@@ -6184,8 +6184,7 @@ static bool vmx_dy_apicv_has_pending_interrupt(struct kvm_vcpu *vcpu)
        struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
 
        return pi_test_on(pi_desc) ||
-               (pi_test_sn(pi_desc) &&
-               !bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS));
+               (pi_test_sn(pi_desc) && !pi_is_pir_empty(pi_desc));
 }
 
 static void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap)
index 1e32ab54fc2ddc1514903b7815caab4b3ec8ec8c..5a0f34b1e2261885c8fbe55c6e65740d5d29e19a 100644 (file)
@@ -355,6 +355,11 @@ static inline int pi_test_and_set_pir(int vector, struct pi_desc *pi_desc)
        return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
 }
 
+static inline bool pi_is_pir_empty(struct pi_desc *pi_desc)
+{
+       return bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS);
+}
+
 static inline void pi_set_sn(struct pi_desc *pi_desc)
 {
        set_bit(POSTED_INTR_SN,