linux-stable/arch/x86/kvm
Sean Christopherson a18bdaca46 KVM: nVMX: Emulate NOPs in L2, and PAUSE if it's not intercepted
commit 4984563823 upstream.

Extend VMX's nested intercept logic for emulated instructions to handle
"pause" interception, in quotes because KVM's emulator doesn't filter out
NOPs when checking for nested intercepts.  Failure to allow emulation of
NOPs results in KVM injecting a #UD into L2 on any NOP that collides with
the emulator's definition of PAUSE, i.e. on all single-byte NOPs.

For PAUSE itself, honor L1's PAUSE-exiting control, but ignore PLE to
avoid unnecessarily injecting a #UD into L2.  Per the SDM, the first
execution of PAUSE after VM-Entry is treated as the beginning of a new
loop, i.e. will never trigger a PLE VM-Exit, and so L1 can't expect any
given execution of PAUSE to deterministically exit.

  ... the processor considers this execution to be the first execution of
  PAUSE in a loop. (It also does so for the first execution of PAUSE at
  CPL 0 after VM entry.)

All that said, the PLE side of things is currently a moot point, as KVM
doesn't expose PLE to L1.

Note, vmx_check_intercept() is still wildly broken when L1 wants to
intercept an instruction, as KVM injects a #UD instead of synthesizing a
nested VM-Exit.  That issue extends far beyond NOP/PAUSE and needs far
more effort to fix, i.e. is a problem for the future.

Fixes: 07721feee4 ("KVM: nVMX: Don't emulate instructions in guest mode")
Cc: Mathias Krause <minipli@grsecurity.net>
Cc: stable@vger.kernel.org
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Link: https://lore.kernel.org/r/20230405002359.418138-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-11 23:00:18 +09:00
..
mmu KVM: x86/mmu: Fix race condition in direct_page_fault 2022-12-08 11:28:43 +01:00
svm KVM: SVM: Process ICR on AVIC IPI delivery failure due to invalid target 2023-03-17 08:48:49 +01:00
vmx KVM: nVMX: Emulate NOPs in L2, and PAUSE if it's not intercepted 2023-05-11 23:00:18 +09:00
cpuid.c KVM: x86: Do not return host topology information from KVM_GET_SUPPORTED_CPUID 2023-01-18 11:48:57 +01:00
cpuid.h KVM: x86: Move reverse CPUID helpers to separate header file 2021-04-26 05:27:13 -04:00
debugfs.c KVM: x86: Check for rmaps allocation 2022-01-11 15:35:15 +01:00
emulate.c KVM: x86: emulator: update the emulation mode after CR0 write 2022-11-10 18:15:42 +01:00
fpu.h KVM: x86: Move FPU register accessors into fpu.h 2021-06-17 13:09:24 -04:00
hyperv.c KVM: x86: hyper-v: Avoid calling kvm_make_vcpus_request_mask() with vcpu_mask==NULL 2023-03-30 12:47:58 +02:00
hyperv.h KVM: x86: Query vcpu->vcpu_idx directly and drop its accessor 2021-09-22 10:33:11 -04:00
i8254.c KVM: x86: Migrate the PIT only if vcpu0 is migrated, not any BSP 2021-08-02 11:01:51 -04:00
i8254.h
i8259.c x86: Fix typo s/ECLR/ELCR/ for the PIC register 2021-08-10 23:31:44 +02:00
ioapic.c Revert "x86/kvm: fix vcpu-id indexed array sizes" 2021-11-12 15:05:47 +01:00
ioapic.h x86/kvm: remove unused ack_notifier callbacks 2021-12-22 09:32:34 +01:00
irq.c
irq.h x86/kvm: remove unused ack_notifier callbacks 2021-12-22 09:32:34 +01:00
irq_comm.c
Kconfig ARM: 2021-06-28 15:40:51 -07:00
kvm_cache_regs.h KVM: x86: Introduce KVM_GET_SREGS2 / KVM_SET_SREGS2 2021-06-17 13:09:47 -04:00
kvm_emulate.h KVM: x86/emulator: Emulate RDPID only if it is enabled in guest 2022-04-13 20:59:00 +02:00
kvm_onhyperv.c KVM: x86: hyper-v: Move the remote TLB flush logic out of vmx 2021-06-17 13:09:36 -04:00
kvm_onhyperv.h KVM: x86: hyper-v: Move the remote TLB flush logic out of vmx 2021-06-17 13:09:36 -04:00
lapic.c KVM: x86: Purge "highest ISR" cache when updating APICv state 2023-04-05 11:25:01 +02:00
lapic.h KVM: x86: Add a return code to kvm_apic_accept_events 2021-06-17 13:09:31 -04:00
Makefile KVM: stats: Add fd-based API to read binary stats data 2021-06-24 11:47:57 -04:00
mmu.h KVM: x86: Reinitialize context if host userspace toggles EFER.LME 2022-04-08 14:24:03 +02:00
mtrr.c
pmu.c KVM: x86/pmu: Fix and isolate TSX-specific performance event logic 2022-04-13 20:59:00 +02:00
pmu.h KVM: x86/pmu: Update AMD PMC sample period to fix guest NMI-watchdog 2022-04-27 14:39:00 +02:00
reverse_cpuid.h KVM: SEV: Mask CPUID[0x8000001F].eax according to supported features 2021-04-26 05:27:15 -04:00
trace.h KVM: x86: Trace re-injected exceptions 2022-11-10 18:15:24 +01:00
tss.h
x86.c KVM: VMX: Move preemption timer <=> hrtimer dance to common x86 2023-04-05 11:25:01 +02:00
x86.h lockdep: Fix -Wunused-parameter for _THIS_IP_ 2022-09-20 12:39:42 +02:00
xen.c KVM: x86/xen: Fix runstate updates to be atomic when preempting vCPU 2022-02-23 12:03:07 +01:00
xen.h KVM: x86: do not set st->preempted when going back to user space 2022-08-11 13:07:51 +02:00