Skip to content

Commit a56953e

Browse files
sean-jcbonzini
authored andcommitted
KVM: nVMX: Make an event request if INIT or SIPI is pending on VM-Enter
Evaluate interrupts, i.e. set KVM_REQ_EVENT, if INIT or SIPI is pending when emulating nested VM-Enter. INIT is blocked while the CPU is in VMX root mode, but not in VMX non-root, i.e. becomes unblocked on VM-Enter. This bug has been masked by KVM calling ->check_nested_events() in the core run loop, but that hack will be fixed in the near future. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20220921003201.1441511-8-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 0bba8fc commit a56953e

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

arch/x86/kvm/vmx/nested.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,6 +3377,8 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
33773377
(CPU_BASED_INTR_WINDOW_EXITING | CPU_BASED_NMI_WINDOW_EXITING);
33783378
if (likely(!evaluate_pending_interrupts) && kvm_vcpu_apicv_active(vcpu))
33793379
evaluate_pending_interrupts |= vmx_has_apicv_interrupt(vcpu);
3380+
if (!evaluate_pending_interrupts)
3381+
evaluate_pending_interrupts |= kvm_apic_has_pending_init_or_sipi(vcpu);
33803382

33813383
if (!vmx->nested.nested_run_pending ||
33823384
!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
@@ -3457,18 +3459,10 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
34573459
}
34583460

34593461
/*
3460-
* If L1 had a pending IRQ/NMI until it executed
3461-
* VMLAUNCH/VMRESUME which wasn't delivered because it was
3462-
* disallowed (e.g. interrupts disabled), L0 needs to
3463-
* evaluate if this pending event should cause an exit from L2
3464-
* to L1 or delivered directly to L2 (e.g. In case L1 don't
3465-
* intercept EXTERNAL_INTERRUPT).
3466-
*
3467-
* Usually this would be handled by the processor noticing an
3468-
* IRQ/NMI window request, or checking RVI during evaluation of
3469-
* pending virtual interrupts. However, this setting was done
3470-
* on VMCS01 and now VMCS02 is active instead. Thus, we force L0
3471-
* to perform pending event evaluation by requesting a KVM_REQ_EVENT.
3462+
* Re-evaluate pending events if L1 had a pending IRQ/NMI/INIT/SIPI
3463+
* when it executed VMLAUNCH/VMRESUME, as entering non-root mode can
3464+
* effectively unblock various events, e.g. INIT/SIPI cause VM-Exit
3465+
* unconditionally.
34723466
*/
34733467
if (unlikely(evaluate_pending_interrupts))
34743468
kvm_make_request(KVM_REQ_EVENT, vcpu);

0 commit comments

Comments
 (0)