[GIT PULL] KVM: x86: Misc changes for 6.15
From: Sean Christopherson
Date: Tue Mar 18 2025 - 14:06:22 EST
A variety of cleanups and minor fixes, and improved support (and fixes) for
honoring L1 intercepts when emulating instructions on behalf of L2.
FWIW, unless I'm missing something, the severity of the L2 emulation bugs means
that emulating instructions while L2 is active is _very_ rare for real world
use cases. I.e. the fixes are not urgent.
The following changes since commit a64dcfb451e254085a7daee5fe51bf22959d52d3:
Linux 6.14-rc2 (2025-02-09 12:45:03 -0800)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-misc-6.15
for you to fetch changes up to e6c8728a8e2d20b262209c70a8ca67719a628833:
KVM: x86: Remove the unreachable case for 0x80000022 leaf in __do_cpuid_func() (2025-03-04 09:19:49 -0800)
----------------------------------------------------------------
KVM x86 misc changes for 6.15:
- Fix a bug in PIC emulation that caused KVM to emit a spurious KVM_REQ_EVENT.
- Add a helper to consolidate handling of mp_state transitions, and use it to
clear pv_unhalted whenever a vCPU is made RUNNABLE.
- Defer runtime CPUID updates until KVM emulates a CPUID instruction, to
coalesce updates when multiple pieces of vCPU state are changing, e.g. as
part of a nested transition.
- Fix a variety of nested emulation bugs, and add VMX support for synthesizing
nested VM-Exit on interception (instead of injecting #UD into L2).
- Drop "support" for PV Async #PF with proctected guests without SEND_ALWAYS,
as KVM can't get the current CPL.
- Misc cleanups
----------------------------------------------------------------
Ethan Zhao (1):
KVM: x86/cpuid: add type suffix to decimal const 48 fix building warning
Jim Mattson (2):
KVM: x86: Introduce kvm_set_mp_state()
KVM: x86: Clear pv_unhalted on all transitions to KVM_MP_STATE_RUNNABLE
Li RongQing (1):
KVM: x86: Use kvfree_rcu() to free old optimized APIC map
Liam Ni (1):
KVM: x86: Wake vCPU for PIC interrupt injection iff a valid IRQ was found
Sean Christopherson (19):
KVM: x86: Use for-loop to iterate over XSTATE size entries
KVM: x86: Apply TSX_CTRL_CPUID_CLEAR if and only if the vCPU has RTM or HLE
KVM: x86: Query X86_FEATURE_MWAIT iff userspace owns the CPUID feature bit
KVM: x86: Defer runtime updates of dynamic CPUID bits until CPUID emulation
KVM: nVMX: Check PAUSE_EXITING, not BUS_LOCK_DETECTION, on PAUSE emulation
KVM: nSVM: Pass next RIP, not current RIP, for nested VM-Exit on emulation
KVM: nVMX: Allow emulating RDPID on behalf of L2
KVM: nVMX: Emulate HLT in L2 if it's not intercepted
KVM: nVMX: Consolidate missing X86EMUL_INTERCEPTED logic in L2 emulation
KVM: x86: Plumb the src/dst operand types through to .check_intercept()
KVM: x86: Plumb the emulator's starting RIP into nested intercept checks
KVM: x86: Add a #define for the architectural max instruction length
KVM: nVMX: Allow the caller to provide instruction length on nested VM-Exit
KVM: nVMX: Synthesize nested VM-Exit for supported emulation intercepts
KVM: selftests: Add a nested (forced) emulation intercept test for x86
KVM: x86: Don't inject PV async #PF if SEND_ALWAYS=0 and guest state is protected
KVM: x86: Rename and invert async #PF's send_user_only flag to send_always
KVM: x86: Use a dedicated flow for queueing re-injected exceptions
KVM: x86: Always set mp_state to RUNNABLE on wakeup from HLT
Ted Chen (1):
KVM: x86: Remove unused iommu_domain and iommu_noncoherent from kvm_arch
Xiaoyao Li (1):
KVM: x86: Remove the unreachable case for 0x80000022 leaf in __do_cpuid_func()
arch/x86/include/asm/kvm_host.h | 9 +-
arch/x86/kvm/cpuid.c | 52 ++++----
arch/x86/kvm/cpuid.h | 9 +-
arch/x86/kvm/emulate.c | 5 +-
arch/x86/kvm/i8259.c | 2 +-
arch/x86/kvm/kvm_emulate.h | 7 +-
arch/x86/kvm/lapic.c | 17 +--
arch/x86/kvm/smm.c | 2 +-
arch/x86/kvm/svm/nested.c | 2 +-
arch/x86/kvm/svm/sev.c | 7 +-
arch/x86/kvm/svm/svm.c | 17 ++-
arch/x86/kvm/trace.h | 14 +-
arch/x86/kvm/vmx/nested.c | 18 +--
arch/x86/kvm/vmx/nested.h | 22 +++-
arch/x86/kvm/vmx/vmx.c | 120 ++++++++++++-----
arch/x86/kvm/x86.c | 136 +++++++++----------
arch/x86/kvm/x86.h | 7 +
arch/x86/kvm/xen.c | 4 +-
tools/testing/selftests/kvm/Makefile.kvm | 1 +
.../selftests/kvm/x86/nested_emulation_test.c | 146 +++++++++++++++++++++
20 files changed, 416 insertions(+), 181 deletions(-)
create mode 100644 tools/testing/selftests/kvm/x86/nested_emulation_test.c