Re: [GIT PULL] KVM: x86: Misc changes for 7.2

From: Paolo Bonzini

Date: Fri Jun 12 2026 - 04:15:46 EST


On Fri, Jun 12, 2026 at 2:48 AM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> By patch count, the register API cleanup dominates, but the most notable change
> here is the SNP and TDX hypercall return code handling from Vishal+Sagi. To
> allow userspace to tell the guest to "retry", the changes interpret the return
> code from userspace as an errno value, and explicitly recognize only EAGAIN and
> EINVAL. All other errnos are now reserved. This is a change in uABI, but as
> far as we know, it won't break any VMMs that support SNP or TDX
>
> The following changes since commit b7fbe9a1bf9ee6c967ef77d366ca58c35fcf1887:
>
> Merge branch 'kvm-apx-prepare' into HEAD (2026-05-13 12:38:31 -0400)
>
> are available in the Git repository at:
>
> https://github.com/kvm-x86/linux.git tags/kvm-x86-misc-7.2
>
> for you to fetch changes up to 65aa483f32ec674f0506658329d43403cafe5eb0:
>
> Documentation: KVM: Synchronize x86 VM types (2026-06-08 09:20:19 -0700)
>
> ----------------------------------------------------------------
> KVM misc x86 changes for 7.2
>
> - Handle EXIT_FASTPATH_EXIT_USERSPACE in vendor code to ensure vendor code
> gets a chance to handle things like reaping the PML buffer.
>
> - Ensure KVM's copy of CR0 and CR3 are up-to-date on SVM prior to invoking
> fastpath handlers.
>
> - Update KVM's view of PV async enabling if and only if the MSR write fully
> succeeds.
>
> - Fix a variety of issues where the emulator doesn't honor guest-debug state,
> and clean up related code along the way.
>
> - Synthesize EPT Violation and #NPF "error code" bits when injecting faults
> into L1 that didn't originate in hardware (in which case the VMCS/VMCB
> doesn't hold relevant information).
>
> - Add support for virtualizing (well, emulating) AMD's flavor of CPL>0 CPUID
> faulting.
>
> - Clean up the GPR APIs so that KVM's use of "raw" is consistent, and fix a
> variety of minor bugs along the way.
>
> - Fix an OOB memory access due to not checking the VP ID when handling a
> Hyper-V PV TLB flush for L2.
>
> - Fix a bug in the mediated PMU's handling of fixed counters that allowed the
> guest to bypass the PMU event filter.
>
> - Allow userspace to return EAGAIN when handling SNP and TDX hypercalls, so
> the KVM can forward a "retry" status code to the guest, and reserve all
> unused error codes for future usage.
>
> - Misc fixes and cleanups.
>
> ----------------------------------------------------------------

Pulled, thanks.

Paolo

> Carlos López (2):
> KVM: x86: Take PIC lock on KVM_GET_IRQCHIP path
> Documentation: KVM: Synchronize x86 VM types
>
> Ethan Yang (1):
> KVM: x86: Don't leave APF half-enabled on bad APF data GPA
>
> Hou Wenlong (7):
> KVM: x86: Capture "struct x86_exception" in inject_emulated_exception()
> KVM: x86: Set guest DR6 by kvm_queue_exception_p() in instruction emulation
> KVM: x86: Honor KVM_GUESTDBG_USE_HW_BP when emulating MOV DR (in emulator)
> KVM: x86: Honor KVM_GUESTDBG_USE_HW_BP when checking for code breakpoints in emulation
> KVM: x86: Move KVM_GUESTDBG_SINGLESTEP handling into kvm_inject_emulated_db()
> KVM: selftests: Verify guest debug DR7.GD checking during instruction emulation
> KVM: selftests: Verify VMX's GUEST_PENDING_DBG_EXCEPTIONS.BS Consistency Check
>
> Hyunwoo Kim (1):
> KVM: x86: hyper-v: Bound the bank index when querying sparse banks
>
> Jim Mattson (4):
> KVM: x86: Prioritize CPUID faulting over CPUID VM-exits in nested VMX
> KVM: x86: Remove supports_cpuid_fault() helper
> KVM: x86: Virtualize AMD CPUID faulting
> KVM: selftests: Update hwcr_msr_test for CPUID faulting bit
>
> Kai Huang (1):
> KVM: x86: Use <linux/lockdep.h> for lockdep header inclusion
>
> Kevin Cheng (4):
> KVM: x86: Widen x86_exception's error_code to 64 bits
> KVM: SVM: Fix nested NPF injection of PFERR_GUEST_{PAGE,FINAL}_MASK bits
> KVM: VMX: Synthesize nested EPT violation GVA_IS_VALID/GVA_TRANSLATED bits
> KVM: selftests: Add nested page fault injection test
>
> Krzysztof Kozlowski (1):
> MAINTAINERS: KVM: Include maintainer profile
>
> Li RongQing (3):
> KVM: x86: Fix wrong return value type in guest_cpuid_has()
> KVM: x86: Use fls() instead of ffs() for rmaps histogram bucketing
> KVM: x86: ioapic: Use old_dest_mode consistently in ioapic_write_indirect()
>
> Sagi Shahar (1):
> KVM: SEV: Restrict userspace return codes for KVM_HC_MAP_GPA_RANGE
>
> Sean Christopherson (28):
> KVM: x86: Ensure vendor's exit handler runs before fastpath userspace exits
> KVM: SVM: Refresh vcpu->arch.cr{0,3} prior to invoking fastpath handler
> KVM: x86: Drop superfluous caching of KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT
> KVM: x86: Drop superfluous caching of KVM_ASYNC_PF_SEND_ALWAYS
> KVM: VMX: Refresh GUEST_PENDING_DBG_EXCEPTIONS.BS on all injected #DBs
> KVM: x86: Drop kvm_vcpu_do_singlestep() now that it's been gutted
> KVM: selftests: Add all (known) EFLAGS bit definitions
> KVM: x86: Remove unused X86EMUL_MODE_HOST define
> KVM: x86: Tell ->inject_page_fault() whether or a fault came from hardware
> KVM: x86: Consolidate CPUID fault handling for emulator and interception logic
> KVM: SVM: Truncate INVLPGA address in compatibility mode
> KVM: x86/xen: Bug the VM if 32-bit KVM observes a 64-bit mode hypercall
> KVM: x86/xen: Don't truncate RAX when handling hypercall from protected guest
> KVM: VMX: Read 32-bit GPR values for ENCLS instructions outside of 64-bit mode
> KVM: x86: Trace hypercall register *after* truncating values for 32-bit
> KVM: x86: Rename kvm_cache_regs.h => regs.h
> KVM: x86: Move inlined GPR, CR, and DR helpers from x86.h to regs.h
> KVM: x86: Add mode-aware versions of kvm_<reg>_{read,write}() helpers
> KVM: x86: Drop non-raw kvm_<reg>_write() helpers
> KVM: nSVM: Use kvm_rax_read() now that it's mode-aware
> Revert "KVM: VMX: Read 32-bit GPR values for ENCLS instructions outside of 64-bit mode"
> KVM: x86: Harden is_64_bit_hypercall() against bugs on 32-bit kernels
> KVM: x86: Move update_cr8_intercept() to lapic.c
> KVM: x86: Move async #PF helpers to x86.h (as inlines)
> KVM: x86: Drop defunct vcpu_tsc_khz() declaration
> KVM: x86: Remove defunct kvm_load_segment_descriptor() declaration.
> KVM: x86/pmu: Use hardware value when reprogramming for FIXED_CTR_CTRL changes
> KVM: selftests: Add regression test for mediated PMU fixed counter filter bug
>
> Vishal Annapurve (2):
> KVM: x86: Treat KVM's virtual PMU as disabled for TDX VMs
> KVM: TDX: Allow userspace to return errors to guest for MAPGPA
>
> Documentation/virt/kvm/api.rst | 5 +
> MAINTAINERS | 1 +
> arch/x86/include/asm/kvm_host.h | 27 +-
> arch/x86/include/asm/msr-index.h | 1 +
> arch/x86/kvm/cpuid.c | 21 +-
> arch/x86/kvm/cpuid.h | 20 +-
> arch/x86/kvm/debugfs.c | 2 +-
> arch/x86/kvm/emulate.c | 22 +-
> arch/x86/kvm/hyperv.c | 26 +-
> arch/x86/kvm/hyperv.h | 4 +-
> arch/x86/kvm/ioapic.c | 2 +-
> arch/x86/kvm/irq.c | 4 +
> arch/x86/kvm/kvm_emulate.h | 17 +-
> arch/x86/kvm/lapic.c | 28 +-
> arch/x86/kvm/lapic.h | 1 +
> arch/x86/kvm/mmu.h | 2 +-
> arch/x86/kvm/mmu/mmu.c | 2 +-
> arch/x86/kvm/mmu/paging_tmpl.h | 36 +-
> arch/x86/kvm/{kvm_cache_regs.h => regs.h} | 198 +++++++++--
> arch/x86/kvm/smm.c | 2 +-
> arch/x86/kvm/svm/nested.c | 46 ++-
> arch/x86/kvm/svm/sev.c | 12 +-
> arch/x86/kvm/svm/svm.c | 34 +-
> arch/x86/kvm/svm/svm.h | 2 +-
> arch/x86/kvm/vmx/nested.c | 39 ++-
> arch/x86/kvm/vmx/nested.h | 2 +-
> arch/x86/kvm/vmx/pmu_intel.c | 10 +-
> arch/x86/kvm/vmx/sgx.c | 6 +-
> arch/x86/kvm/vmx/tdx.c | 52 ++-
> arch/x86/kvm/vmx/vmx.c | 40 ++-
> arch/x86/kvm/vmx/vmx.h | 2 +-
> arch/x86/kvm/x86.c | 374 +++++++++------------
> arch/x86/kvm/x86.h | 134 ++------
> arch/x86/kvm/xen.c | 39 ++-
> tools/testing/selftests/kvm/Makefile.kvm | 1 +
> .../testing/selftests/kvm/include/x86/processor.h | 29 +-
> tools/testing/selftests/kvm/lib/x86/processor.c | 2 +-
> tools/testing/selftests/kvm/lib/x86/vmx.c | 2 +-
> tools/testing/selftests/kvm/x86/debug_regs.c | 88 ++++-
> tools/testing/selftests/kvm/x86/hwcr_msr_test.c | 9 +-
> .../selftests/kvm/x86/nested_tdp_fault_test.c | 313 +++++++++++++++++
> .../selftests/kvm/x86/pmu_event_filter_test.c | 6 +
> 42 files changed, 1116 insertions(+), 547 deletions(-)
> rename arch/x86/kvm/{kvm_cache_regs.h => regs.h} (59%)
> create mode 100644 tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c
>