Skip to content

Commit 982caaa

Browse files
sean-jcbonzini
authored andcommitted
KVM: nVMX: Process events on nested VM-Exit if injectable IRQ or NMI is pending
Process pending events on nested VM-Exit if the vCPU has an injectable IRQ or NMI, as the event may have become pending while L2 was active, i.e. may not be tracked in the context of vmcs01. E.g. if L1 has passed its APIC through to L2 and an IRQ arrives while L2 is active, then KVM needs to request an IRQ window prior to running L1, otherwise delivery of the IRQ will be delayed until KVM happens to process events for some other reason. The missed failure is detected by vmx_apic_passthrough_tpr_threshold_test in KVM-Unit-Tests, but has effectively been masked due to a flaw in KVM's PIC emulation that causes KVM to make spurious KVM_REQ_EVENT requests (and apparently no one ever ran the test with split IRQ chips). Cc: [email protected] Signed-off-by: Sean Christopherson <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 17bcd71 commit 982caaa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arch/x86/kvm/vmx/nested.c

+11
Original file line numberDiff line numberDiff line change
@@ -5084,6 +5084,17 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
50845084

50855085
load_vmcs12_host_state(vcpu, vmcs12);
50865086

5087+
/*
5088+
* Process events if an injectable IRQ or NMI is pending, even
5089+
* if the event is blocked (RFLAGS.IF is cleared on VM-Exit).
5090+
* If an event became pending while L2 was active, KVM needs to
5091+
* either inject the event or request an IRQ/NMI window. SMIs
5092+
* don't need to be processed as SMM is mutually exclusive with
5093+
* non-root mode. INIT/SIPI don't need to be checked as INIT
5094+
* is blocked post-VMXON, and SIPIs are ignored.
5095+
*/
5096+
if (kvm_cpu_has_injectable_intr(vcpu) || vcpu->arch.nmi_pending)
5097+
kvm_make_request(KVM_REQ_EVENT, vcpu);
50875098
return;
50885099
}
50895100

0 commit comments

Comments
 (0)