linux-brain/arch/x86/kvm
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
..
vmx KVM: nVMX: Unconditionally clear nested.pi_pending on nested VM-Enter 2021-09-15 09:47:41 +02:00
Kconfig kvm: x86: add host poll control msrs 2019-06-18 11:43:46 +02:00
Makefile KVM: x86: fix TRACE_INCLUDE_PATH and remove -I. header search paths 2019-01-25 19:12:37 +01:00
cpuid.c KVM: x86: Use guest MAXPHYADDR from CPUID.0x8000_0008 iff TDP is enabled 2021-07-20 16:10:40 +02:00
cpuid.h KVM: x86: reinstate vendor-agnostic check on SPEC_CTRL cpuid bits 2021-01-06 14:48:36 +01:00
debugfs.c KVM: no need to check return value of debugfs_create functions 2019-08-05 12:55:49 +02:00
emulate.c KVM: x86: Update emulator context mode if SYSENTER xfers to 64-bit mode 2021-02-10 09:25:31 +01:00
hyperv.c KVM: x86: Protect kvm_hv_msr_[get|set]_crash_data() from Spectre-v1/L1TF attacks 2020-02-11 04:35:38 -08:00
hyperv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 499 2019-06-19 17:09:53 +02:00
i8254.c kvm: x86: Add memcg accounting to KVM allocations 2019-02-20 22:48:30 +01:00
i8254.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
i8259.c KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks 2020-02-11 04:35:37 -08:00
ioapic.c x86/kvm: fix vcpu-id indexed array sizes 2021-08-04 12:27:37 +02:00
ioapic.h x86/kvm: fix vcpu-id indexed array sizes 2021-08-04 12:27:37 +02:00
irq.c KVM: x86: Fix split-irqchip vs interrupt injection window request 2020-12-02 08:49:46 +01:00
irq.h KVM/arm updates for 5.3 2019-07-11 15:14:16 +02:00
irq_comm.c KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI 2020-02-28 17:22:22 +01:00
kvm_cache_regs.h KVM: x86: Mark CR4.TSD as being possibly owned by the guest 2020-07-16 08:16:44 +02:00
lapic.c kvm: LAPIC: Restore guard to prevent illegal APIC register access 2021-06-23 14:41:23 +02:00
lapic.h KVM: SVM: Fix potential wrong physical id in avic_handle_ldr_update 2019-10-22 18:47:50 +02:00
mmu.c KVM: x86/mmu: Treat NX as used (not reserved) for all !TDP shadow MMUs 2021-09-03 10:08:16 +02:00
mmu.h KVM: x86: fix shift out of bounds reported by UBSAN 2021-01-12 20:16:25 +01:00
mmu_audit.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 499 2019-06-19 17:09:53 +02:00
mmutrace.h KVM: x86: fix incorrect comparison in trace event 2020-10-01 13:17:35 +02:00
mtrr.c KVM: x86: Protect MSR-based index computations in fixed_msr_to_seg_unit() from Spectre-v1/L1TF attacks 2020-02-11 04:35:39 -08:00
page_track.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 499 2019-06-19 17:09:53 +02:00
paging_tmpl.h KVM: X86: MMU: Use the correct inherited permissions to get shadow page 2021-08-15 13:08:04 +02:00
pmu.c KVM: x86: Add fixed counters to PMU filter 2019-07-20 09:00:48 +02:00
pmu.h KVM: x86: Protect MSR-based index computations in pmu.h from Spectre-v1/L1TF attacks 2020-02-11 04:35:38 -08:00
pmu_amd.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 499 2019-06-19 17:09:53 +02:00
svm.c KVM: nSVM: always intercept VMLOAD/VMSAVE when nested (CVE-2021-3656) 2021-08-18 08:57:04 +02:00
trace.h KVM: x86: Ensure liveliness of nested VM-Enter fail tracepoint message 2021-06-16 11:59:44 +02:00
tss.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
x86.c KVM: x86: Update vCPU's hv_clock before back to guest when tsc_offset is adjusted 2021-09-15 09:47:40 +02:00
x86.h kvm: x86: replace kvm_spec_ctrl_test_value with runtime test on the host 2021-03-04 10:26:09 +01:00