KVM: x86: add method to test PIR bitmap vector
authorMarcelo Tosatti <mtosatti@redhat.com>
Tue, 16 Dec 2014 14:08:14 +0000 (09:08 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 8 Jan 2015 21:45:18 +0000 (22:45 +0100)
kvm_x86_ops->test_posted_interrupt() returns true/false depending
whether 'vector' is set.

Next patch makes use of this interface.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/vmx.c

index d89c6b828c96492a414fe9a3d92ca7ec3791b53c..cb19d05af3cd3d50686b72d6f61bbfb7291b963e 100644 (file)
@@ -753,6 +753,7 @@ struct kvm_x86_ops {
        void (*set_virtual_x2apic_mode)(struct kvm_vcpu *vcpu, bool set);
        void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu, hpa_t hpa);
        void (*deliver_posted_interrupt)(struct kvm_vcpu *vcpu, int vector);
+       bool (*test_posted_interrupt)(struct kvm_vcpu *vcpu, int vector);
        void (*sync_pir_to_irr)(struct kvm_vcpu *vcpu);
        int (*set_tss_addr)(struct kvm *kvm, unsigned int addr);
        int (*get_tdp_level)(void);
index 6e71fac27d4eea41cf3f580b3b5f721ab948ff66..3b97f8b3065ee564e0f7ae28ec4fd65d413a203f 100644 (file)
@@ -435,6 +435,11 @@ static 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 int pi_test_pir(int vector, struct pi_desc *pi_desc)
+{
+       return test_bit(vector, (unsigned long *)pi_desc->pir);
+}
+
 struct vcpu_vmx {
        struct kvm_vcpu       vcpu;
        unsigned long         host_rsp;
@@ -5897,6 +5902,7 @@ static __init int hardware_setup(void)
                kvm_x86_ops->hwapic_irr_update = NULL;
                kvm_x86_ops->hwapic_isr_update = NULL;
                kvm_x86_ops->deliver_posted_interrupt = NULL;
+               kvm_x86_ops->test_posted_interrupt = NULL;
                kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
        }
 
@@ -6968,6 +6974,13 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
        return 1;
 }
 
+static bool vmx_test_pir(struct kvm_vcpu *vcpu, int vector)
+{
+       struct vcpu_vmx *vmx = to_vmx(vcpu);
+
+       return pi_test_pir(vector, &vmx->pi_desc);
+}
+
 /*
  * The exit handlers return 1 if the exit was handled fully and guest execution
  * may resume.  Otherwise they set the kvm_run parameter to indicate what needs
@@ -9562,6 +9575,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
        .hwapic_isr_update = vmx_hwapic_isr_update,
        .sync_pir_to_irr = vmx_sync_pir_to_irr,
        .deliver_posted_interrupt = vmx_deliver_posted_interrupt,
+       .test_posted_interrupt = vmx_test_pir,
 
        .set_tss_addr = vmx_set_tss_addr,
        .get_tdp_level = get_ept_level,