Skip to content

Commit 7c6a98d

Browse files
matosattibonzini
authored andcommitted
KVM: x86: add method to test PIR bitmap vector
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>
1 parent b4eef9b commit 7c6a98d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ struct kvm_x86_ops {
753753
void (*set_virtual_x2apic_mode)(struct kvm_vcpu *vcpu, bool set);
754754
void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu, hpa_t hpa);
755755
void (*deliver_posted_interrupt)(struct kvm_vcpu *vcpu, int vector);
756+
bool (*test_posted_interrupt)(struct kvm_vcpu *vcpu, int vector);
756757
void (*sync_pir_to_irr)(struct kvm_vcpu *vcpu);
757758
int (*set_tss_addr)(struct kvm *kvm, unsigned int addr);
758759
int (*get_tdp_level)(void);

arch/x86/kvm/vmx.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ static int pi_test_and_set_pir(int vector, struct pi_desc *pi_desc)
435435
return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
436436
}
437437

438+
static int pi_test_pir(int vector, struct pi_desc *pi_desc)
439+
{
440+
return test_bit(vector, (unsigned long *)pi_desc->pir);
441+
}
442+
438443
struct vcpu_vmx {
439444
struct kvm_vcpu vcpu;
440445
unsigned long host_rsp;
@@ -5897,6 +5902,7 @@ static __init int hardware_setup(void)
58975902
kvm_x86_ops->hwapic_irr_update = NULL;
58985903
kvm_x86_ops->hwapic_isr_update = NULL;
58995904
kvm_x86_ops->deliver_posted_interrupt = NULL;
5905+
kvm_x86_ops->test_posted_interrupt = NULL;
59005906
kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
59015907
}
59025908

@@ -6968,6 +6974,13 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
69686974
return 1;
69696975
}
69706976

6977+
static bool vmx_test_pir(struct kvm_vcpu *vcpu, int vector)
6978+
{
6979+
struct vcpu_vmx *vmx = to_vmx(vcpu);
6980+
6981+
return pi_test_pir(vector, &vmx->pi_desc);
6982+
}
6983+
69716984
/*
69726985
* The exit handlers return 1 if the exit was handled fully and guest execution
69736986
* 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 = {
95629575
.hwapic_isr_update = vmx_hwapic_isr_update,
95639576
.sync_pir_to_irr = vmx_sync_pir_to_irr,
95649577
.deliver_posted_interrupt = vmx_deliver_posted_interrupt,
9578+
.test_posted_interrupt = vmx_test_pir,
95659579

95669580
.set_tss_addr = vmx_set_tss_addr,
95679581
.get_tdp_level = get_ept_level,

0 commit comments

Comments
 (0)