linux-yocto/arch/x86
Sean Christopherson f994e9c790 KVM: SVM: Skip fastpath emulation on VM-Exit if next RIP isn't valid
commit 0910dd7c9ad45a2605c45fd2bf3d1bcac087687c upstream.

Skip the WRMSR and HLT fastpaths in SVM's VM-Exit handler if the next RIP
isn't valid, e.g. because KVM is running with nrips=false.  SVM must
decode and emulate to skip the instruction if the CPU doesn't provide the
next RIP, and getting the instruction bytes to decode requires reading
guest memory.  Reading guest memory through the emulator can fault, i.e.
can sleep, which is disallowed since the fastpath handlers run with IRQs
disabled.

 BUG: sleeping function called from invalid context at ./include/linux/uaccess.h:106
 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 32611, name: qemu
 preempt_count: 1, expected: 0
 INFO: lockdep is turned off.
 irq event stamp: 30580
 hardirqs last  enabled at (30579): [<ffffffffc08b2527>] vcpu_run+0x1787/0x1db0 [kvm]
 hardirqs last disabled at (30580): [<ffffffffb4f62e32>] __schedule+0x1e2/0xed0
 softirqs last  enabled at (30570): [<ffffffffb4247a64>] fpu_swap_kvm_fpstate+0x44/0x210
 softirqs last disabled at (30568): [<ffffffffb4247a64>] fpu_swap_kvm_fpstate+0x44/0x210
 CPU: 298 UID: 0 PID: 32611 Comm: qemu Tainted: G     U              6.16.0-smp--e6c618b51cfe-sleep #782 NONE
 Tainted: [U]=USER
 Hardware name: Google Astoria-Turin/astoria, BIOS 0.20241223.2-0 01/17/2025
 Call Trace:
  <TASK>
  dump_stack_lvl+0x7d/0xb0
  __might_resched+0x271/0x290
  __might_fault+0x28/0x80
  kvm_vcpu_read_guest_page+0x8d/0xc0 [kvm]
  kvm_fetch_guest_virt+0x92/0xc0 [kvm]
  __do_insn_fetch_bytes+0xf3/0x1e0 [kvm]
  x86_decode_insn+0xd1/0x1010 [kvm]
  x86_emulate_instruction+0x105/0x810 [kvm]
  __svm_skip_emulated_instruction+0xc4/0x140 [kvm_amd]
  handle_fastpath_invd+0xc4/0x1a0 [kvm]
  vcpu_run+0x11a1/0x1db0 [kvm]
  kvm_arch_vcpu_ioctl_run+0x5cc/0x730 [kvm]
  kvm_vcpu_ioctl+0x578/0x6a0 [kvm]
  __se_sys_ioctl+0x6d/0xb0
  do_syscall_64+0x8a/0x2c0
  entry_SYSCALL_64_after_hwframe+0x4b/0x53
 RIP: 0033:0x7f479d57a94b
  </TASK>

Note, this is essentially a reapply of commit 5c30e8101e ("KVM: SVM:
Skip WRMSR fastpath on VM-Exit if next RIP isn't valid"), but with
different justification (KVM now grabs SRCU when skipping the instruction
for other reasons).

Fixes: b439eb8ab5 ("Revert "KVM: SVM: Skip WRMSR fastpath on VM-Exit if next RIP isn't valid"")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250805190526.1453366-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-10-15 12:00:22 +02:00
..
boot x86/sev: Evict cache lines during SNP memory validation 2025-08-15 12:14:12 +02:00
coco x86/sev: Ensure SVSM reserved fields in a page validation entry are initialized to zero 2025-08-28 16:31:03 +02:00
configs tinyconfig: remove unnecessary 'is not set' for choice blocks 2024-09-01 20:34:38 +09:00
crypto crypto: lib/Kconfig - Hide arch options from user 2025-05-02 07:59:32 +02:00
entry x86/bugs: Rename MDS machinery to something more generic 2025-07-10 16:05:14 +02:00
events perf/x86/intel: Fix crash in icl_update_topdown_event() 2025-09-25 11:13:44 +02:00
hyperv x86/hyperv: Fix APIC ID and VP index confusion in hv_snp_boot_ap() 2025-08-01 09:48:46 +01:00
ia32
include x86/vdso: Fix output operand size of RDPID 2025-10-15 11:59:55 +02:00
kernel x86/bugs: KVM: Add support for SRSO_MSR_FIX 2025-09-25 11:13:49 +02:00
kvm KVM: SVM: Skip fastpath emulation on VM-Exit if next RIP isn't valid 2025-10-15 12:00:22 +02:00
lib x86/bugs: KVM: Add support for SRSO_MSR_FIX 2025-09-25 11:13:49 +02:00
math-emu x86/math-emu: Fix function cast warnings 2024-04-08 16:06:22 +02:00
mm x86/mm/64: define ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() 2025-09-09 18:58:15 +02:00
net x86/its: FineIBT-paranoid vs ITS 2025-05-18 08:25:00 +02:00
pci PCI/MSI: Convert pci_msi_ignore_mask to per MSI domain flag 2025-05-02 07:58:56 +02:00
platform x86/pvh: Call C code via the kernel virtual mapping 2024-12-05 14:01:12 +01:00
power x86/fred: Fix system hang during S4 resume with FRED enabled 2025-05-29 11:02:02 +02:00
purgatory Kbuild updates for v6.10 2024-05-18 12:39:20 -07:00
ras
realmode Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
tools x86/tools: Drop duplicate unlikely() definition in insn_decoder_test.c 2025-06-27 11:11:41 +01:00
um um: Add cmpxchg8b_emu and checksum functions to asm-prototypes.h 2025-07-06 11:01:34 +02:00
video arch: Fix name collision with ACPI's video.o 2024-05-20 21:17:06 +00:00
virt x86/virt/tdx: Avoid indirect calls to TDX assembly functions 2025-06-27 11:11:38 +01:00
xen x86/xen: disable CPU idle and frequency drivers for PVH dom0 2025-05-02 07:59:23 +02:00
.gitignore
Kbuild x86/build: Use obj-y to descend into arch/x86/virt/ 2024-03-30 10:41:49 +01:00
Kconfig x86/vmscape: Enable the mitigation 2025-09-11 17:21:46 +02:00
Kconfig.assembler x86/kconfig: Add as-instr64 macro to properly evaluate AS_WRUSS 2024-06-20 19:48:18 +02:00
Kconfig.cpu x86/Kconfig: Add cmpxchg8b support back to Geode CPUs 2025-04-10 14:39:37 +02:00
Kconfig.debug x86/kconfig: Select ARCH_WANT_FRAME_POINTERS again when UNWINDER_FRAME_POINTER=y 2024-05-20 11:37:23 +02:00
Makefile x86/stackprotector: Work around strict Clang TLS symbol requirements 2024-11-08 13:16:00 +01:00
Makefile_32.cpu
Makefile.postlink
Makefile.um um: Pass the correct Rust target and options with gcc 2025-04-10 14:39:25 +02:00