]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: nVMX: Emulate HLT in L2 if it's not intercepted
authorSean Christopherson <seanjc@google.com>
Sat, 1 Feb 2025 01:55:11 +0000 (17:55 -0800)
committerSean Christopherson <seanjc@google.com>
Mon, 24 Feb 2025 17:01:07 +0000 (09:01 -0800)
commitf43f7a215af0586e196253555fc614efb0588858
tree239aed36c5aa3d5605d8193246400f1b5dceda38
parent3244616aac8dc69b3d7e4a4ee541e767b974af43
KVM: nVMX: Emulate HLT in L2 if it's not intercepted

Extend VMX's nested intercept logic for emulated instructions to handle
HLT interception, primarily for testing purposes.  Failure to allow
emulation of HLT isn't all that interesting, as emulating HLT while L2 is
active either requires forced emulation (and no #UD intercept in L1), TLB
games in the guest to coerce KVM into emulating the wrong instruction, or
a bug elsewhere in KVM.

E.g. without commit 47ef3ef843c0 ("KVM: VMX: Handle event vectoring
error in check_emulate_instruction()"), KVM can end up trying to emulate
HLT if RIP happens to point at a HLT when a vectored event arrives with
L2's IDT pointing at emulated MMIO.

Note, vmx_check_intercept() is still 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 HLT, punt on it for now.

Link: https://lore.kernel.org/r/20250201015518.689704-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/vmx.c