Skip to content

Commit 967235d

Browse files
committed
KVM: vmx: clear pending interrupts on KVM_SET_LAPIC
Pending interrupts might be in the PI descriptor when the LAPIC is restored from an external state; we do not want them to be injected. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent db1c056 commit 967235d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

arch/x86/kvm/lapic.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,8 +2204,7 @@ int kvm_apic_set_state(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s)
22042204
1 : count_vectors(apic->regs + APIC_ISR);
22052205
apic->highest_isr_cache = -1;
22062206
if (vcpu->arch.apicv_active) {
2207-
if (kvm_x86_ops->apicv_post_state_restore)
2208-
kvm_x86_ops->apicv_post_state_restore(vcpu);
2207+
kvm_x86_ops->apicv_post_state_restore(vcpu);
22092208
kvm_x86_ops->hwapic_irr_update(vcpu,
22102209
apic_find_highest_irr(apic));
22112210
kvm_x86_ops->hwapic_isr_update(vcpu,

arch/x86/kvm/vmx.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8749,6 +8749,14 @@ static void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap)
87498749
vmcs_write64(EOI_EXIT_BITMAP3, eoi_exit_bitmap[3]);
87508750
}
87518751

8752+
static void vmx_apicv_post_state_restore(struct kvm_vcpu *vcpu)
8753+
{
8754+
struct vcpu_vmx *vmx = to_vmx(vcpu);
8755+
8756+
pi_clear_on(&vmx->pi_desc);
8757+
memset(vmx->pi_desc.pir, 0, sizeof(vmx->pi_desc.pir));
8758+
}
8759+
87528760
static void vmx_complete_atomic_exit(struct vcpu_vmx *vmx)
87538761
{
87548762
u32 exit_intr_info;
@@ -11574,6 +11582,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
1157411582
.get_enable_apicv = vmx_get_enable_apicv,
1157511583
.refresh_apicv_exec_ctrl = vmx_refresh_apicv_exec_ctrl,
1157611584
.load_eoi_exitmap = vmx_load_eoi_exitmap,
11585+
.apicv_post_state_restore = vmx_apicv_post_state_restore,
1157711586
.hwapic_irr_update = vmx_hwapic_irr_update,
1157811587
.hwapic_isr_update = vmx_hwapic_isr_update,
1157911588
.sync_pir_to_irr = vmx_sync_pir_to_irr,

0 commit comments

Comments
 (0)