linux-brain/arch/x86/kvm/vmx
Sean Christopherson 06dad664d4 KVM: nVMX: Unconditionally clear nested.pi_pending on nested VM-Enter
commit f7782bb8d818d8f47c26b22079db10599922787a upstream.

Clear nested.pi_pending on nested VM-Enter even if L2 will run without
posted interrupts enabled.  If nested.pi_pending is left set from a
previous L2, vmx_complete_nested_posted_interrupt() will pick up the
stale flag and exit to userspace with an "internal emulation error" due
the new L2 not having a valid nested.pi_desc.

Arguably, vmx_complete_nested_posted_interrupt() should first check for
posted interrupts being enabled, but it's also completely reasonable that
KVM wouldn't screw up a fundamental flag.  Not to mention that the mere
existence of nested.pi_pending is a long-standing bug as KVM shouldn't
move the posted interrupt out of the IRR until it's actually processed,
e.g. KVM effectively drops an interrupt when it performs a nested VM-Exit
with a "pending" posted interrupt.  Fixing the mess is a future problem.

Prior to vmx_complete_nested_posted_interrupt() interpreting a null PI
descriptor as an error, this was a benign bug as the null PI descriptor
effectively served as a check on PI not being enabled.  Even then, the
new flow did not become problematic until KVM started checking the result
of kvm_check_nested_events().

Fixes: 705699a139 ("KVM: nVMX: Enable nested posted interrupt processing")
Fixes: 966eefb89657 ("KVM: nVMX: Disable vmcs02 posted interrupts if vmcs12 PID isn't mappable")
Fixes: 47d3530f86c0 ("KVM: x86: Exit to userspace when kvm_check_nested_events fails")
Cc: stable@vger.kernel.org
Cc: Jim Mattson <jmattson@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210810144526.2662272-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-15 09:47:41 +02:00
..
capabilities.h KVM: nVMX: clear PIN_BASED_POSTED_INTR from nested pinbased_ctls only when apicv is globally disabled 2020-02-28 17:22:23 +01:00
evmcs.c x86/kvm/nVMX: fix VMCLEAR when Enlightened VMCS is in use 2019-07-02 18:56:00 +02:00
evmcs.h KVM/Hyper-V/VMX: Add direct tlb flush support 2019-09-24 13:37:14 +02:00
nested.c KVM: nVMX: Unconditionally clear nested.pi_pending on nested VM-Enter 2021-09-15 09:47:41 +02:00
nested.h KVM: nVMX: clear PIN_BASED_POSTED_INTR from nested pinbased_ctls only when apicv is globally disabled 2020-02-28 17:22:23 +01:00
ops.h x86/kvm: fix a missing-prototypes "vmread_error" 2020-05-10 10:31:31 +02:00
pmu_intel.c KVM: x86/pmu: Fix UBSAN shift-out-of-bounds warning in intel_pmu_refresh() 2021-02-03 23:25:57 +01:00
vmcs_shadow_fields.h KVM: nVMX: shadow pin based execution controls 2019-06-18 17:10:50 +02:00
vmcs.h KVM: VMX: Leave preemption timer running when it's disabled 2019-06-18 17:10:46 +02:00
vmcs12.c KVM: nVMX: Move vmcs12 code to dedicated files 2018-12-14 12:34:30 +01:00
vmcs12.h KVM/arm updates for 5.3 2019-07-11 15:14:16 +02:00
vmenter.S KVM: VMX: Explicitly clear RFLAGS.CF and RFLAGS.ZF in VM-Exit RSB path 2020-05-14 07:58:25 +02:00
vmx.c kvm: x86: replace kvm_spec_ctrl_test_value with runtime test on the host 2021-03-04 10:26:09 +01:00
vmx.h KVM: VMX: Use current VMCS to query WAITPKG support for MSR emulation 2021-08-18 08:57:03 +02:00