* [GIT PULL] KVM: x86: Timekeeping fixes+cleanups for 7.4
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
@ 2026-10-16 4:44 ` Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: guest_memfd and CoCo changes " Sean Christopherson
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sean Christopherson @ 2026-10-16 4:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Part 1 of 2 (or maybe 3) of David's war on kvmclock. Ugh, and when looking at
the shortlog, I realized I botched the author on these:
KVM: x86: Use kernel timekeeping snapshot for monotonic clock
KVM: x86: Use kernel timekeeping snapshot to get walltime+TSC
Holler if you would prefer a fixup to get the author right; these have been in
-next for over a month, so I opted to send them as-is instead of doing a super
last minute rewrite.
The following changes since commit d4b7fb647204f0c81dfeae2d1a708e4d858e0c94:
Merge branch 'kvm-xen-longmode' into HEAD (2026-09-04 17:35:03 +0200)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-clocks-7.4
for you to fetch changes up to d7841275e1fb4ad1e1877e56725ebda5b6e3143d:
KVM: x86: Use kernel timekeeping snapshot to get walltime+TSC (2026-09-11 11:46:19 -0700)
----------------------------------------------------------------
KVM x86 timekeeping fixes and cleanups for 7.4
Fix a variety of warts in KVM's handling of guest TSC, kvmclock, and
timekeeping in general, as a (big) first step towards addressing several
longstanding problems with the kvmclock implementation.
Most notably, fix a precision issue where get_kvmclock_ns() computed the
clock from the *host* TSC without applying guest TSC scaling, causing
systemic drift from the values the guest computes from its own TSC.
As a bonus cleanup, rip out the whole pvclock_gtod_data hack, which was
shadowing the kernel's timekeeping, and use ktime snapshots.
----------------------------------------------------------------
David Woodhouse (14):
KVM: x86: Improve accuracy of KVM clock when TSC scaling is in force
KVM: x86: Explicitly disable TSC scaling without CONSTANT_TSC
KVM: x86: Activate master clock immediately on vCPU creation
KVM: x86: Compute kvmclock base without pvclock_gtod_data
KVM: x86: Avoid NTP frequency skew for KVM clock on 32-bit host
KVM: x86: Wrap all of __get_kvmclock_master_clock() with CONFIG_X86_64=y
KVM: x86: Fall back to non-master-clock if clockread fails in get_kvmclock()
KVM: x86: Fix KVM clock precision in get_kvmclock() with TSC scaling
KVM: x86: Use get_kvmclock() in kvm_get_wall_clock_epoch()
KVM: x86: Fix compute_guest_tsc() to handle negative time deltas
KVM: x86: Upscale TSC to "now", not master clock when updating PV clocks
KVM: x86: Simplify and comment kvm_get_time_scale()
KVM: x86: Remove implicit rdtsc() from kvm_compute_l1_tsc_offset()
KVM: x86: Use kernel timekeeping snapshots for getting kvmclock time since boot
Sean Christopherson (7):
KVM: x86: Update "last guest TSC" snapshot prior to enabling IRQs/preemption
KVM: x86: Drop unnecessary CPU pinning when computing/getting kvmclock
KVM: x86: Move "no master clock" fallback from __get_kvmclock() to get_kvmclock()
KVM: x86: Disable preemption, not IRQs, when getting TSC+freq pair
KVM: x86: Make master clock logic in guest PV clock updates 64-bit only
KVM: x86: Use kernel timekeeping snapshot for monotonic clock
KVM: x86: Use kernel timekeeping snapshot to get walltime+TSC
arch/x86/include/asm/kvm_host.h | 6 +-
arch/x86/kvm/cpuid.c | 1 +
arch/x86/kvm/msrs.c | 3 +-
arch/x86/kvm/svm/svm.c | 3 +-
arch/x86/kvm/vmx/vmx.c | 10 +
arch/x86/kvm/x86.c | 480 ++++++++++++++++++----------------------
arch/x86/kvm/x86.h | 3 +-
7 files changed, 240 insertions(+), 266 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread* [GIT PULL] KVM: guest_memfd and CoCo changes for 7.4
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: x86: Timekeeping fixes+cleanups " Sean Christopherson
@ 2026-10-16 4:44 ` Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: x86: Misc " Sean Christopherson
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sean Christopherson @ 2026-10-16 4:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
In-place conversion support is the obvious highlight. The rest of the changes
are either fixes (mostly found by AI) or prep work related to in-place conversions.
Note, this is based on 7.3-rc4 as it has a hard dependency on commit fc6415a384f0
("mm/gup: factor out LRU cache draining for folio into lru_cache_drain_for_folio()").
Note #2, this will conflict with the "vmx" pull request. More details in that
pull request (I do my local merges in alphabetical order, so I always see the
conflict when merging in the "vmx" branch).
Note #3, there's a deadlock splat with SNP[1] that isn't resolved here. The CCP
driver holds its system-wide mutex (that guards PSP firmware calls) while doing
a variety of might-fault operations, which leads to an ABBA locking issue when
KVM attempts to issue SNP_LAUNCH_UPDATE while holding a gmem's lock. The plan
is to either temporarily disable SNP[2], or (much) better, fastrack a series to
fix the deadlock by having the driver hold sev_cmd_mutex only when it absolutely
needs to[3].
[1] https://lore.kernel.org/all/asz8GKNO9aQANr5E@google.com
[2] https://lore.kernel.org/all/as0FedYcvJvdOaq2@google.com
[3] https://lore.kernel.org/all/20261014132145.1726322-1-michael.roth@amd.com
The following changes since commit 93f51579e7df248780214094418f205253383cc5:
Linux 7.3-rc4 (2026-09-20 13:48:15 -0700)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-coco-7.4
for you to fetch changes up to a6270ed4bec0caa25913082e71ce22254e9cd3ed:
KVM: selftests: Support guest_memfd in-place conversion (2026-10-12 08:08:29 -0700)
----------------------------------------------------------------
KVM guest_memfd and CoCo changes for 7.4
- Take the invalidate lock when unbinding a dying file to fix a race with
kvm_gmem_invalidate_end() that results in KVM leaving the MMU invalidation
count elevated. Not taking the lock in the first place was pure misguided
paranoid.
- When binding a memslot, purge the bindings if storing the new memslot fails,
as Xarray's "store range" API can subtly fail partway through.
- Establish memslot<=>guest_memfd bindings *after* the memslot is ready, as
the memslot becomes reachable the instant the binding is installed.
- Don't grab a page refcount when reloading an SNP VMSA and stop returning a
"struct page" from guest_memfd's PFN lookup altogether, to ensure that KVM
doesn't hold any unnecessary refcounts (the lifetime of the page is ensured
by MMU notifiers and similar hooks). Preventing unnecessary refcounts
greatly simplifies supporting in-place SHARED=>PRIVATE conversions.
- Add support for in-place PRIVATE<=>SHARED conversion, i.e. allow a single
guest_memfd instance to be used for both PRIVATE and SHARED variations of
CoCo guests' memory (though not at the same time). This eliminates the need
to double allocate guest memory for TDX and SNP, and is basically a hard
requirement for pKVM, which relies on being able to preserve memory contents
on conversions.
- Hack-a-fix a deadlock bug in ->error_remove_folio() by returning -EBUSY if
the filemap invalidate lock is contended. Punt on a proper fix for the
moment, as a proper fix likely involves reworking truncate_error_folio().
- Add a pile of selftests for in-place conversions.
- Misc guest_memfd cleanups
----------------------------------------------------------------
Ackerley Tng (25):
KVM: SEV: Treat unassigned RMP entry as benign race on PSMASH failure
KVM: SEV: Check for invalidation before warning on unassigned RMP entry
KVM: SEV: Drop page refcount early in VMSA reload
KVM: Rename kvm_mem_is_private() to kvm_is_private_gfn()
KVM: guest_memfd: Always fault from guest_memfd if in-place conversion is enabled
KVM: guest_memfd: Pass mapping type filter to invalidation helper
KVM: guest_memfd: Add base support for KVM_SET_MEMORY_ATTRIBUTES2
KVM: guest_memfd: Ensure pages are not in use before conversion
KVM: guest_memfd: Call arch make_shared callback for to-shared conversion
KVM: guest_memfd: Return early if range already has requested attributes
KVM: guest_memfd: Zero page while getting pfn
KVM: TDX: Make source page optional for KVM_TDX_INIT_MEM_REGION
KVM: selftests: Test basic single-page conversion flow
KVM: selftests: Test conversion flow when INIT_SHARED
KVM: selftests: Test conversion precision in guest_memfd
KVM: selftests: Test conversion before allocation
KVM: selftests: Convert with allocated folios in different layouts
KVM: selftests: Test that truncation does not change shared/private status
KVM: selftests: Add helpers to pin pages with CONFIG_GUP_TEST
KVM: selftests: Test conversion with elevated page refcount
KVM: selftests: Reset shared memory after hole-punching
KVM: selftests: Provide function to look up guest_memfd details from gpa
KVM: selftests: Make TEST_EXPECT_SIGBUS thread-safe
KVM: selftests: Set up page size and alignment independently for guest_memfd
KVM: selftests: Update private_mem_conversions_test for in-place conversions
Fuad Tabba (1):
KVM: guest_memfd: Fix the in-place conversion documentation
Hao Zhang (1):
KVM: guest_memfd: Avoid deadlock in error_remove_folio()
Lisa Wang (1):
KVM: selftests: Support guest_memfd in-place conversion
Michael Roth (1):
KVM: SEV: Make 'uaddr' parameter optional for KVM_SEV_SNP_LAUNCH_UPDATE
Sean Christopherson (30):
KVM: guest_memfd: Elaborate on how release() vs. get_pfn() is safe against UAF
KVM: guest_memfd: Gracefully handle xarray errors when binding a memslot
KVM: Use goto to handle errors during memslot preparation
KVM: Only bind memslot to guest_memfd instance for CREATE operations
KVM: guest_memfd: Split bind() into prepare()+commit() phases
KVM: guest_memfd: Establish memslot<=>guest_memfd bindings *after* memslot is ready
KVM: guest_memfd: Drop superfluous WRITE_ONCE() when binding a memslot
KVM: SEV: Drop page refcount early during RMP fault handling
KVM: guest_memfd: Stop returning struct page from PFN lookup
KVM: guest_memfd: Optimize away conversion overheads via dead-code elimination
KVM: guest_memfd: Use kvm_mem_is_private() when populating guest_memfd memory
KVM: guest_memfd: Introduce per-gmem attributes, use to guard user mappings
KVM: Rename KVM_GENERIC_MEMORY_ATTRIBUTES to KVM_VM_MEMORY_ATTRIBUTES
KVM: Enumerate support for PRIVATE memory iff kvm_arch_has_private_mem is defined
KVM: Rename memory attribute APIs to prepare for in-place gmem conversion
KVM: Provide generic interface for checking memory private/shared status
KVM: guest_memfd: Stub in ability to enable in-place shared<=>private conversion
KVM: Consolidate private memory and guest_memfd ifdeffery in kvm_host.h
KVM: guest_memfd: Invalidate both SHARED and PRIVATE mappings for in-place conversions
KVM: Move KVM_VM_MEMORY_ATTRIBUTES config definition to x86
KVM: Let userspace disable per-VM mem attributes, enable per-gmem attributes
KVM: guest_memfd: Enable INIT_SHARED on guest_memfd for x86 Coco VMs
KVM: selftests: Create gmem fd before "regular" fd when adding memslot
KVM: selftests: Rename guest_memfd{,_offset} to gmem_{fd,offset}
KVM: selftests: Add support for mmap() on guest_memfd in core library
KVM: selftests: Add selftests global for guest memory attributes capability
KVM: selftests: Add helpers for calling ioctls on guest_memfd
KVM: selftests: Test that shared/private status is consistent across processes
KVM: selftests: Provide common function to set memory attributes
KVM: selftests: Update private memory exits test to work with per-gmem attributes
Shivank Garg (1):
KVM: guest_memfd: take the invalidate lock when unbinding a dying file
Documentation/admin-guide/kernel-parameters.txt | 26 +++++
Documentation/virt/kvm/api.rst | 116 ++++++++++++++++--
Documentation/virt/kvm/x86/amd-memory-encryption.rst | 14 ++-
Documentation/virt/kvm/x86/intel-tdx.rst | 4 +
arch/arm64/kvm/mmu.c | 4 +-
arch/arm64/kvm/nested.c | 4 +-
arch/x86/include/asm/kvm-x86-ops.h | 2 +-
arch/x86/include/asm/kvm_host.h | 9 +-
arch/x86/kvm/Kconfig | 15 ++-
arch/x86/kvm/mmu/mmu.c | 30 ++---
arch/x86/kvm/svm/sev.c | 66 ++++++-----
arch/x86/kvm/vmx/tdx.c | 8 +-
arch/x86/kvm/x86.c | 20 ++--
include/linux/kvm_host.h | 91 ++++++++-------
include/trace/events/kvm.h | 6 +-
include/uapi/linux/kvm.h | 16 +++
tools/testing/selftests/kvm/Makefile.kvm | 1 +
tools/testing/selftests/kvm/include/kvm_util.h | 139 +++++++++++++++++++---
tools/testing/selftests/kvm/include/test_util.h | 32 ++---
tools/testing/selftests/kvm/lib/kvm_util.c | 237 ++++++++++++++++++++++++-------------
tools/testing/selftests/kvm/lib/test_util.c | 7 --
tools/testing/selftests/kvm/x86/guest_memfd_conversions_test.c | 512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/testing/selftests/kvm/x86/private_mem_conversions_test.c | 66 ++++++++---
tools/testing/selftests/kvm/x86/private_mem_kvm_exits_test.c | 36 +++++-
virt/kvm/Kconfig | 3 -
virt/kvm/guest_memfd.c | 653 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
virt/kvm/guest_memfd.h | 19 ++-
virt/kvm/kvm_main.c | 157 +++++++++++++++++--------
28 files changed, 1875 insertions(+), 418 deletions(-)
create mode 100644 tools/testing/selftests/kvm/x86/guest_memfd_conversions_test.c
^ permalink raw reply [flat|nested] 10+ messages in thread* [GIT PULL] KVM: x86: Misc changes for 7.4
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: x86: Timekeeping fixes+cleanups " Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: guest_memfd and CoCo changes " Sean Christopherson
@ 2026-10-16 4:44 ` Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: x86: MMU " Sean Christopherson
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sean Christopherson @ 2026-10-16 4:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
This one really lives up to its name. There's a lot of smallish stuff all over.
There's a minor conflict between this and the "vmx" branch, more details in the
"vmx" pull request.
The following changes since commit d4b7fb647204f0c81dfeae2d1a708e4d858e0c94:
Merge branch 'kvm-xen-longmode' into HEAD (2026-09-04 17:35:03 +0200)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-misc-7.4
for you to fetch changes up to 88b23a2e8286b7016c3b58dc10093cf28c22aa3d:
KVM: x86: Request event processing for exception VM-Exits (2026-10-02 07:49:40 -0700)
----------------------------------------------------------------
KVM x86 misc changes for 7.4
- Mask off the address space ID when checking for illegal usage of
kvm_set_internal_memslot() to prevent false negatives on the sanity check.
- Explicitly zero reserved flags when delivering a SynIC message to avoid
leaking a byte of stack information to the guest.
- Rework TDX's handling of the canonical MMU root level to not rely on
userspace to fill CPUID correctly, as doing so lets userspace trivially
trigger a KVM_BUG_ON().
- Reject KVM_SET_NESTED_STATE if userspace "restores" L1 with EFER.LMA=1 &&
EFER.LME=0, which confuses KVM into trying to configure an 64-bit MMU
without PAE.
- Ignore EFER.LMA (clear it from KVM's cached save state) if EFER.LME=0 when
preparing L2 state, to fix another way to confuse KVM's MMU (and because
real hardware also ignores EFER.LMA).
- Improve KVM's sanity checks for a misconfigured MMU to (hopefully) detect
all of the ways KVM can botch EFER.LMA vs. CR4.PAE.
- Remove the "full" out-param from kvm_x86_ops.flush_tlb_gva() as the param
is only used to avoid what effectively amounts to a single memory write.
- Fix a mostly-benign bug where KVM can write through a guest's read-only
mapping due to not checking the error code when expediting emulated MMIO
page faults.
- Honor the guest's view of the "EFER.LMSLE must be zero" defeature so that
userspace can provide migration compatibility between Rome and Milan+.
- Pend a KVM_REQ_EVENT request when an exception is morphed into a nested
VM-Exit, otherwise KVM can fail to actually deliver the nested VM-Exit,
e.g. when injecting a page fault.
- Add support for PML on SVM.
- Add support for virtualizating Bus Lock Detect on SVM, and fix a number of
DR6 bugs and warts along the way.
- Misc fixes and cleanups.
----------------------------------------------------------------
Hao Xiang (1):
KVM: x86: Rename CPUID feature bit AVX10_VNNI_INT to AVX10_V1_AUX
Jim Mattson (4):
KVM: x86: Advertise EFER_LMSLE_MBZ when KVM disallows EFER.LMSLE
KVM: x86: Honor the guest's EFER_LMSLE_MBZ
KVM: selftests: Rename svm_nested_clear_efer_svme to svm_nested_efer_test
KVM: selftests: Add coverage for the EFER_LMSLE_MBZ defeature
Karl Mehltretter (2):
Documentation: KVM: SEV: Use the uapi structure names
Documentation: KVM: x86: Use struct kvm_clock_pairing in hypercalls.rst
Kyle Zeng (1):
KVM: x86: Restrict saved GPA writes to hardware write faults
Loc Nguyen (1):
KVM: x86: Request event processing for exception VM-Exits
Luka Absandze (1):
KVM: x86/pmu: Don't retry a counter whose config was rejected
Nikunj A Dadhania (7):
KVM: x86: Move PML page to common vcpu arch structure
KVM: x86: Carve out PML flush routine
KVM: VMX: Use cpu_dirty_log_size instead of enable_pml for PML checks
KVM: x86: Carve out common dirty logging update
x86/cpufeatures: Add Page modification logging
KVM: SVM: Use BIT_ULL for 64-bit misc_ctl bit definitions
KVM: SVM: Add Page modification logging support
Paolo Bonzini (1):
KVM: x86: remove "full" out-argument from flush_tlb_gva
Ravi Bangoria (1):
KVM: SVM: Add support for virtualizating Bus Lock Detect
Sean Christopherson (20):
KVM: x86: Zero reserved synic flags when delivering message to avoid stack leak
KVM: x86: Track kvm_vcpu_arch.pending_ioapic_eoi as a u8 to drop dead BUG_ON()
KVM: x86/mmu: Use KVM's max TDP level to determine need for 32-bit TDP root
KVM: VMX: Explicitly track TDX VMs' root level instead of guessing it from CPUID
KVM: VMX: Drop TDX_SHARED_BIT_PWL_{4,5} and dedup related code
KVM: nSVM: Reject KVM_SET_NESTED_STATE if L1 has EFER.LMA=1 && EFER.LME=0
KVM: nSVM: Ignore EFER.LMA if EFER.LME=0 when preparing L2 state
KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the MMU has
KVM: x86/mmu: Bug the VM if KVM calcs a CPU role with EFER.LMA=1 && CR4.PAE=0
KVM: x86/mmu: Convert MMU walker's bounds check from BUG_ON() to KVM_BUG_ON()
KVM: VMX: Pass @vcpu, not @vmx to init_vmcs()
KVM: x86: Preserve DR6.BLD (Bus Lock Detect) when delivering #DB payload
KVM: x86: Rename kvm_dr6_fixed() => kvm_get_dr6_fixed_1()
KVM: Return an "unsigned long", not "u64" for the fixed-1 DR6 bits
KVM: x86: Force fixed-1 bits in DR6 after synchronizing with hardware
KVM: x86: Set guest's fixed-1 DR6 bits when delivering #DB payload
KVM: x86: Kill off DR6_FIXED_1 to prevent future misuse
KVM: SVM: Add helper to query if LBR virtualization needs to be enabled
KVM: nSVM: Open code check on LBR virtualization being enabled in vmcb12
KVM: selftests: Add module param API to check if nested virtualization is enabled
Shivansh Dhiman (3):
KVM: nSVM: Disable LBRV in nested control cache when unsupported
KVM: nSVM: Don't assume all active-low bits DR6 are fixed-1
KVM: SVM: Add a vCPU-aware helper to get supported DEBUGCTL bits
Tharit Tangkijwanichakul (2):
KVM: x86: Reject reserved CR8 bits in KVM_SET_SREGS
KVM: selftests: Add CR8 reserved-bit checks to set_sregs_test
Zeng Chi (1):
KVM: Mask off the address space ID in kvm_set_internal_memslot() check
Documentation/virt/kvm/api.rst | 25 ++
.../virt/kvm/x86/amd-memory-encryption.rst | 8 +-
Documentation/virt/kvm/x86/hypercalls.rst | 2 +-
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/include/asm/kvm_host.h | 10 +-
arch/x86/include/asm/svm.h | 14 +-
arch/x86/include/uapi/asm/svm.h | 2 +
arch/x86/kernel/cpu/scattered.c | 1 +
arch/x86/kvm/cpuid.c | 36 +--
arch/x86/kvm/cpuid.h | 1 -
arch/x86/kvm/hyperv.c | 9 +-
arch/x86/kvm/kvm_emulate.h | 4 +-
arch/x86/kvm/lapic.c | 4 +-
arch/x86/kvm/lapic.h | 2 +-
arch/x86/kvm/mmu/mmu.c | 29 ++-
arch/x86/kvm/mmu/paging_tmpl.h | 17 +-
arch/x86/kvm/msrs.c | 12 +-
arch/x86/kvm/pmu.c | 14 +-
arch/x86/kvm/regs.c | 16 +-
arch/x86/kvm/regs.h | 11 +-
arch/x86/kvm/reverse_cpuid.h | 2 +-
arch/x86/kvm/svm/nested.c | 46 ++--
arch/x86/kvm/svm/sev.c | 7 +-
arch/x86/kvm/svm/svm.c | 162 ++++++++++++-
arch/x86/kvm/svm/svm.h | 13 +-
arch/x86/kvm/vmx/main.c | 8 +-
arch/x86/kvm/vmx/tdx.c | 21 +-
arch/x86/kvm/vmx/vmx.c | 94 +++-----
arch/x86/kvm/vmx/vmx.h | 9 +-
arch/x86/kvm/vmx/x86_ops.h | 4 +-
arch/x86/kvm/x86.c | 130 +++++++---
arch/x86/kvm/x86.h | 10 +
tools/testing/selftests/kvm/Makefile.kvm | 2 +-
.../testing/selftests/kvm/include/x86/processor.h | 14 ++
tools/testing/selftests/kvm/x86/set_sregs_test.c | 11 +
.../selftests/kvm/x86/svm_nested_clear_efer_svme.c | 50 ----
.../selftests/kvm/x86/svm_nested_efer_test.c | 266 +++++++++++++++++++++
virt/kvm/kvm_main.c | 2 +-
38 files changed, 803 insertions(+), 266 deletions(-)
delete mode 100644 tools/testing/selftests/kvm/x86/svm_nested_clear_efer_svme.c
create mode 100644 tools/testing/selftests/kvm/x86/svm_nested_efer_test.c
^ permalink raw reply [flat|nested] 10+ messages in thread* [GIT PULL] KVM: x86: MMU changes for 7.4
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
` (2 preceding siblings ...)
2026-10-16 4:44 ` [GIT PULL] KVM: x86: Misc " Sean Christopherson
@ 2026-10-16 4:44 ` Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: selftests: Add PPC support Sean Christopherson
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sean Christopherson @ 2026-10-16 4:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
The following changes since commit d4b7fb647204f0c81dfeae2d1a708e4d858e0c94:
Merge branch 'kvm-xen-longmode' into HEAD (2026-09-04 17:35:03 +0200)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-mmu-7.4
for you to fetch changes up to 31adfe155db60a58b61e5b3d472cf85336ff3daf:
KVM: x86/mmu: Fix NX page unaccounting for TDP MMU pages (2026-09-29 06:29:11 -0700)
----------------------------------------------------------------
KVM x86 MMU changes for 7.4
- Grab KVM's SRCU "lock" in kvm_zap_gfn_range() to fix a recurring bug where
callers fail to do so.
- Fix a variety of issues in the pre-fault code that are mostly benign in the
current code base, but will show up in big ways if/when the pre-faulting
logic is used to implementing prefetch-on-fault for the TDP MMU.
- Guard rmaps with mmu_lock for PREEMPT_RT=y kernels to fix a longstanding
issue introducing by "lockless aging" where KVM would take its effective
raw bit-spinlock with preemption enabled (because mmu_lock gets turned into
a sleepable lock).
- Prepare a memory_fault exit (paired with -EFAULT) when KVM hits an error
PFN, e.g. so that userspace can resolve transient issues instead of killing
the guest. Convert a variety of WARN()+EFAULT paths into KVM_BUG_ON()+EIO
so that KVM can hard commit to filling memory_fault on -EFAULTs that occur
in the page fault path.
- Fix a NX hugepage un-accounting bug where KVM would always uncharge the
shadow MMU, even when handling TDP MMU pages.
----------------------------------------------------------------
Anish Moorthy (1):
KVM: x86/mmu: Report a memory fault exit when the fault handler EFAULTs
Carlos López (1):
KVM: x86/mmu: Fix NX page unaccounting for TDP MMU pages
Chengfeng Ye (1):
KVM: x86: Take SRCU in kvm_zap_gfn_range()
Mikhail Malyshev (1):
KVM: x86/mmu: Convert can't-happen fault path EFAULTs to KVM_BUG_ON() + -EIO
Sean Christopherson (6):
KVM: x86/mmu: Reload MMU on *every* page pre-fault attempt/iteration
KVM: x86/mmu: Harden "map private PFN" against unexpected root invalidation
KVM: x86/mmu: Top-up memory caches when retrying "map private PFN"
KVM: x86/mmu: Add sanity check to detect stale page faults in "map private PFN"
KVM: x86/mmu: Always guard rmaps with mmu_lock on PREEMPT_RT=y kernels
KVM: x86/mmu: Bug the VM if KVM attempts to unsync an upper-level shadow page
arch/x86/kvm/mmu/mmu.c | 124 +++++++++++++++++++++++++++++++----------
arch/x86/kvm/mmu/paging_tmpl.h | 4 +-
arch/x86/kvm/x86.c | 2 -
3 files changed, 97 insertions(+), 33 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread* [GIT PULL] KVM: selftests: Add PPC support
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
` (3 preceding siblings ...)
2026-10-16 4:44 ` [GIT PULL] KVM: x86: MMU " Sean Christopherson
@ 2026-10-16 4:44 ` Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: Selftests changes for 7.4 Sean Christopherson
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sean Christopherson @ 2026-10-16 4:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Add PPC selftests support. I grabbed the patches because it seemed easier
overall than coordinating a stable tag with maintainers that don't usually
send you pull requests. The expectation going forward is that PPC selftests
changes will be routed through the KVM tree[1], since KVM selftests tend to
have a lot more cross-arch interactions/collisions than KVM proper
The memory regions rework will also show up in the "selftests" pull request
(I don't know why I didn't throw those changes in a dedicated branch), and
they have a silent conflict with kvm/master[2] due to the new vgic_its_save
arm64 test that came in through a 7.3 fixes pull request. This is roughly
the resolution we've been using in next.
+static void setup_memslot(size_t sz)
+{
+ size_t pages = sz / vm->page_size;
+
+ gpa_base = ((vm_compute_max_gfn(vm) + 1) * vm->page_size) - sz;
- vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, gpa_base,
- TEST_MEMSLOT_INDEX, pages, 0);
++ vm_override_mem_region(vm, MEM_REGION_TEST_EXTRA, VM_MEM_SRC_ANONYMOUS,
++ gpa_base, TEST_MEMSLOT_INDEX, pages);
+}
+
+static gpa_t alloc_64k(size_t nr)
+{
+ size_t pages_per_64k = vm_calc_num_guest_pages(vm->mode, SZ_64K);
- gpa_t gpa = vm_phy_pages_alloc(vm, nr * pages_per_64k, gpa_base,
- TEST_MEMSLOT_INDEX);
++ gpa_t gpa = vm_phy_pages_alloc(vm, nr * pages_per_64k,
++ MEM_REGION_TEST_EXTRA);
+
+ TEST_ASSERT(IS_ALIGNED(gpa, SZ_64K),
+ "Allocation at 0x%lx is not 64K aligned, GITS_BASER cannot address it",
+ gpa);
+ return gpa;
+}
[1] https://lore.kernel.org/all/ld8fjt6w.ritesh.list@gmail.com
[2] https://lore.kernel.org/all/aqqap3DngKznNrSA@sirena.org.uk
The following changes since commit d4b7fb647204f0c81dfeae2d1a708e4d858e0c94:
Merge branch 'kvm-xen-longmode' into HEAD (2026-09-04 17:35:03 +0200)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-ppc_selftests-7.4
for you to fetch changes up to 23140d6e54ac31e2f4ef3bcd7fb586a14360be34:
KVM: selftests: Enable hardware disable test PPC (without pSeries LPAR) (2026-10-13 12:07:29 -0700)
----------------------------------------------------------------
KVM PPC selftests support for 7.4
Rework KVM selftest's handling of memory regions all so that PPC can force its
page table allocations to be naturally aligned, and then add initial selftests
support for PPC.
----------------------------------------------------------------
Hisam Mehboob (1):
KVM: selftests: Replace ulong with unsigned long
Nicholas Piggin (2):
KVM: selftests: Use goto instead of do-while to retry finding unused physical pages
KVM: PPC: selftests: add support for powerpc
Ritesh Harjani (IBM) (7):
KVM: selftests: Don't limit LE dirty-bitmap bitops to s390x
KVM: selftests: Move memslot_perf_test off the 256M ELF load address
KVM: selftests: Skip the max vCPU ID test when KVM_CAP_PPC_SMT is set
KVM: selftests: Add helper for checking if running on powerpc pseries LPAR
KVM: selftests: Skip kvm_create_max_vcpus on powerpc pseries LPAR
KVM: selftests: Enable access tracking perf test for PPC (with LPAR clause)
KVM: selftests: Enable hardware disable test PPC (without pSeries LPAR)
Sean Christopherson (19):
KVM: selftests: Use MEM_REGION_PT memslot instead of '0' for s390 regions/segments
KVM: selftests: Use the common minimum GPA for page tables on LoongArch
KVM: selftests: Use vm_alloc_page_table() to allocate LoongArch page tables
KVM: selftests: Rename "num" param to "nr_pages" for physical page allocators
KVM: selftests: Extend page allocator to support naturally aligned allocations
KVM: selftests: Make the single-page allocator APIs static inline
KVM: selftests: Use the innermost page allocator API in the memslot perf test
KVM: selftests: Use the innermost page allocator API in s390's IRQ routing test
KVM: selftests: Add a wrapper API to allocate multiple page table pages
KVM: selftests: Initialize vm->memslots[] with invalid memslots during creation
KVM: selftests: Add APIs to override memory region types with custom memslots
KVM: selftests: Add TEST_EXTRA memory region type for "special" memslots
KVM: selftests: Use TEST_EXTRA region in arm64's vGIC LPI stress test
KVM: selftests: Use TEST_EXTRA region in x86's smaller MAXPHYADDR test
KVM: selftests: Use TEST_EXTRA region in set memory region test
KVM: selftests: Take the memory region type, not memslot, in page allocators
KVM: selftests: Use TEST_ASSERT(), not assert(), in vm_get_mem_region()
KVM: selftests: Automatically pick min_gpa for allocations based on region type
KVM: selftests: Add arch hook to force page tables to be naturally aligned
MAINTAINERS | 2 +
tools/testing/selftests/kvm/Makefile | 2 +-
tools/testing/selftests/kvm/Makefile.kvm | 9 +
.../selftests/kvm/access_tracking_perf_test.c | 10 +
tools/testing/selftests/kvm/arm64/hypercalls.c | 2 +-
.../testing/selftests/kvm/arm64/page_fault_test.c | 18 +-
.../testing/selftests/kvm/arm64/vgic_lpi_stress.c | 21 +-
tools/testing/selftests/kvm/dirty_log_test.c | 12 +-
.../testing/selftests/kvm/hardware_disable_test.c | 3 +
tools/testing/selftests/kvm/include/kvm_util.h | 132 +++++-
.../testing/selftests/kvm/include/powerpc/hcall.h | 17 +
.../selftests/kvm/include/powerpc/kvm_util_arch.h | 22 +
.../selftests/kvm/include/powerpc/ppc_asm.h | 32 ++
.../selftests/kvm/include/powerpc/processor.h | 39 ++
.../testing/selftests/kvm/include/powerpc/ucall.h | 21 +
tools/testing/selftests/kvm/include/x86/smm.h | 2 +-
tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 14 +-
tools/testing/selftests/kvm/lib/arm64/processor.c | 4 +-
tools/testing/selftests/kvm/lib/guest_modes.c | 20 +-
tools/testing/selftests/kvm/lib/kvm_util.c | 135 ++++--
.../selftests/kvm/lib/loongarch/processor.c | 5 +-
tools/testing/selftests/kvm/lib/powerpc/handlers.S | 93 ++++
tools/testing/selftests/kvm/lib/powerpc/hcall.c | 45 ++
.../testing/selftests/kvm/lib/powerpc/processor.c | 512 +++++++++++++++++++++
tools/testing/selftests/kvm/lib/powerpc/ucall.c | 22 +
tools/testing/selftests/kvm/lib/riscv/processor.c | 4 +-
tools/testing/selftests/kvm/lib/s390/processor.c | 7 +-
tools/testing/selftests/kvm/lib/x86/processor.c | 15 +-
tools/testing/selftests/kvm/memslot_perf_test.c | 7 +-
tools/testing/selftests/kvm/s390/cmma_test.c | 19 +-
tools/testing/selftests/kvm/s390/irq_routing.c | 2 +-
.../testing/selftests/kvm/set_memory_region_test.c | 8 +-
tools/testing/selftests/kvm/steal_time.c | 20 +-
tools/testing/selftests/kvm/x86/amx_test.c | 2 +-
tools/testing/selftests/kvm/x86/cpuid_test.c | 2 +-
tools/testing/selftests/kvm/x86/hyperv_clock.c | 2 +-
tools/testing/selftests/kvm/x86/hyperv_evmcs.c | 4 +-
tools/testing/selftests/kvm/x86/hyperv_svm_test.c | 2 +-
tools/testing/selftests/kvm/x86/set_boot_cpu_id.c | 2 +-
.../kvm/x86/smaller_maxphyaddr_emulation_test.c | 9 +-
tools/testing/selftests/kvm/x86/state_test.c | 4 +-
tools/testing/selftests/kvm/x86/tsc_msrs_test.c | 2 +-
.../selftests/kvm/x86/vmx_nested_la57_state_test.c | 2 +-
.../selftests/kvm/x86/vmx_preemption_timer_test.c | 4 +-
44 files changed, 1144 insertions(+), 167 deletions(-)
create mode 100644 tools/testing/selftests/kvm/include/powerpc/hcall.h
create mode 100644 tools/testing/selftests/kvm/include/powerpc/kvm_util_arch.h
create mode 100644 tools/testing/selftests/kvm/include/powerpc/ppc_asm.h
create mode 100644 tools/testing/selftests/kvm/include/powerpc/processor.h
create mode 100644 tools/testing/selftests/kvm/include/powerpc/ucall.h
create mode 100644 tools/testing/selftests/kvm/lib/powerpc/handlers.S
create mode 100644 tools/testing/selftests/kvm/lib/powerpc/hcall.c
create mode 100644 tools/testing/selftests/kvm/lib/powerpc/processor.c
create mode 100644 tools/testing/selftests/kvm/lib/powerpc/ucall.c
^ permalink raw reply [flat|nested] 10+ messages in thread* [GIT PULL] KVM: Selftests changes for 7.4
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
` (4 preceding siblings ...)
2026-10-16 4:44 ` [GIT PULL] KVM: selftests: Add PPC support Sean Christopherson
@ 2026-10-16 4:44 ` Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: x86: SVM " Sean Christopherson
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Sean Christopherson @ 2026-10-16 4:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Note, there are five actual KVM changes lurking in here. They're all relatively
small/minor and were accompanied by large selftests cleanups, so I plopped them
into "selftests" to avoid having significant selftests changes in 4+ branches.
As mentioned in the PPC selftests pull request, the memory regions rework will
silently conflict with kvm/master:
+static void setup_memslot(size_t sz)
+{
+ size_t pages = sz / vm->page_size;
+
+ gpa_base = ((vm_compute_max_gfn(vm) + 1) * vm->page_size) - sz;
- vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, gpa_base,
- TEST_MEMSLOT_INDEX, pages, 0);
++ vm_override_mem_region(vm, MEM_REGION_TEST_EXTRA, VM_MEM_SRC_ANONYMOUS,
++ gpa_base, TEST_MEMSLOT_INDEX, pages);
+}
+
+static gpa_t alloc_64k(size_t nr)
+{
+ size_t pages_per_64k = vm_calc_num_guest_pages(vm->mode, SZ_64K);
- gpa_t gpa = vm_phy_pages_alloc(vm, nr * pages_per_64k, gpa_base,
- TEST_MEMSLOT_INDEX);
++ gpa_t gpa = vm_phy_pages_alloc(vm, nr * pages_per_64k,
++ MEM_REGION_TEST_EXTRA);
+
+ TEST_ASSERT(IS_ALIGNED(gpa, SZ_64K),
+ "Allocation at 0x%lx is not 64K aligned, GITS_BASER cannot address it",
+ gpa);
+ return gpa;
+}
The VMX APIs purge will also conflict with kvm/master, thanks to the newly
minted nested_x2apic_test.c. The resolution is straightfoward, but tedious
and ugly:
+static void l1_vmx_code(struct vmx_pages *vmx, struct hyperv_test_pages *hv_pages)
+{
+ u64 control;
+
+ if (hv_pages) {
+ wrmsr(HV_X64_MSR_GUEST_OS_ID, HYPERV_LINUX_OS_ID);
+ enable_vp_assist(hv_pages->vp_assist_gpa, hv_pages->vp_assist);
+ evmcs_enable();
+ }
+
- GUEST_ASSERT_EQ(prepare_for_vmx_operation(vmx), true);
++ prepare_for_vmx_operation(vmx);
+
+ if (hv_pages) {
- GUEST_ASSERT(load_evmcs(hv_pages));
++ load_evmcs(hv_pages);
+ current_evmcs->hv_enlightenments_control.msr_bitmap = 1;
+ } else {
- GUEST_ASSERT(load_vmcs(vmx));
++ load_vmcs(vmx);
+ }
+
+ prepare_vmcs(vmx, NULL);
- GUEST_ASSERT_EQ(vmwrite(GUEST_RIP, (unsigned long)l2_guest_code), 0);
++ vmwrite(GUEST_RIP, (unsigned long)l2_guest_code);
+
- control = vmreadz(PIN_BASED_VM_EXEC_CONTROL);
++ control = vmread(PIN_BASED_VM_EXEC_CONTROL);
+ control |= PIN_BASED_EXT_INTR_MASK;
+ vmwrite(PIN_BASED_VM_EXEC_CONTROL, control);
+
- control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
++ control = vmread(CPU_BASED_VM_EXEC_CONTROL);
+ control |= CPU_BASED_USE_MSR_BITMAPS | CPU_BASED_TPR_SHADOW;
- GUEST_ASSERT_EQ(vmwrite(CPU_BASED_VM_EXEC_CONTROL, control), 0);
++ vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
+
- control = vmreadz(SECONDARY_VM_EXEC_CONTROL);
++ control = vmread(SECONDARY_VM_EXEC_CONTROL);
+ control |= SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE |
+ SECONDARY_EXEC_APIC_REGISTER_VIRT |
+ SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY;
+ control &= (rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2) >> 32);
- GUEST_ASSERT_EQ(vmwrite(SECONDARY_VM_EXEC_CONTROL, control), 0);
++ vmwrite(SECONDARY_VM_EXEC_CONTROL, control);
+
- GUEST_ASSERT(!vmlaunch());
- GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_CPUID);
- GUEST_ASSERT_EQ(vmwrite(GUEST_RIP,
- vmreadz(GUEST_RIP) + vmreadz(VM_EXIT_INSTRUCTION_LEN)), 0);
++ vmlaunch();
++ GUEST_ASSERT_EQ(vmread(VM_EXIT_REASON), EXIT_REASON_CPUID);
++ vmwrite(GUEST_RIP, vmread(GUEST_RIP) + vmread(VM_EXIT_INSTRUCTION_LEN));
+}
+
+static void l1_vmx_code_part2(void)
+{
+ u64 control;
+
- control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
++ control = vmread(CPU_BASED_VM_EXEC_CONTROL);
+ control &= ~CPU_BASED_TPR_SHADOW;
- GUEST_ASSERT_EQ(vmwrite(CPU_BASED_VM_EXEC_CONTROL, control), 0);
++ vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
+
- control = vmreadz(SECONDARY_VM_EXEC_CONTROL);
++ control = vmread(SECONDARY_VM_EXEC_CONTROL);
+ control &= ~(SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE |
+ SECONDARY_EXEC_APIC_REGISTER_VIRT |
+ SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY);
- GUEST_ASSERT_EQ(vmwrite(SECONDARY_VM_EXEC_CONTROL, control), 0);
++ vmwrite(SECONDARY_VM_EXEC_CONTROL, control);
+
- GUEST_ASSERT(!vmresume());
- GUEST_ASSERT_EQ(vmreadz(VM_EXIT_REASON), EXIT_REASON_CPUID);
- GUEST_ASSERT_EQ(vmwrite(GUEST_RIP,
- vmreadz(GUEST_RIP) + vmreadz(VM_EXIT_INSTRUCTION_LEN)), 0);
++ vmresume();
++ GUEST_ASSERT_EQ(vmread(VM_EXIT_REASON), EXIT_REASON_CPUID);
++ vmwrite(GUEST_RIP, vmread(GUEST_RIP) + vmread(VM_EXIT_INSTRUCTION_LEN));
+}
The following changes since commit d4b7fb647204f0c81dfeae2d1a708e4d858e0c94:
Merge branch 'kvm-xen-longmode' into HEAD (2026-09-04 17:35:03 +0200)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-selftests-7.4
for you to fetch changes up to bef953c069806148ae2f10714b39a08726c9a076:
KVM: selftests: Spell out UCALL in nested TSC scaling test's enums (2026-09-30 14:23:47 -0700)
----------------------------------------------------------------
KVM selftests changes and a few KVM x86 fixes for 7.4
- Fix emulation of VMPTRST and VMPTRLD when eVMCS is in-use to match real
Hyper-V's behavior.
- Saturate L2's TSC frequency if stacking L1 and L2 scaling multipliers
exceeds what hardware supports, as attempting to run L2 with an illegal
multiplier will either cause VM-Entry to fail (VMX) or trigger a #GP when
writing MSR_AMD64_TSC_RATIO (SVM). The #GP is thankfully benign in the
grand scheme as even "unsafe" WRMSRs have exception fixup.
- Rework KVM selftest's handling of memory regions so that PPC can force its
page table allocations to be naturally aligned.
- Clean up selftest's VMX instruction helpers, and drop an absurd number of
completely useless return values, e.g. functions that unconditionally
return %true and then have every caller assert success.
- Add selftests support for Zhaoxin CPUs.
- Overhaul the TSC scaling test to add a regression test for the saturation
behavior, and to increase its coverage in general.
- Fix selftests usage various NUMA syscalls to account for an undocumented,
but known since 2007, off-by-one kernel bug. Add helpers to try and avoid
re-introducing the same flaws in the future.
- Automatically run xAPIC IPI migration test (between NUMA nodes) when
possible, as the entire point of the test is verify KVM's handling of page
migration of the APIC backing page.
- Misc cleanups.
----------------------------------------------------------------
Amirmohammad Eftekhar (1):
KVM: x86: Saturate L2's TSC frequency if it exceeds hardware supports
Chaithanya Lagisetty (3):
KVM: selftests: Fix the never-true negative UFFD delay check
KVM: selftests: Fix transposed calloc() arguments in the uffd helper
KVM: selftests: Check calloc() return in vcpu_get_reg_list()
Frank Zhu (8):
KVM: selftests: Add Zhaoxin CPU detection support
KVM: selftests: Use host_cpu_is_intel_compatible for mediated PMU
KVM: selftests: Add TDP detection for Zhaoxin CPUs
KVM: selftests: Allow running invalid guest state test on Zhaoxin CPUs
KVM: selftests: Add Zhaoxin CPU support in x86's "fix" hypercall test
KVM: selftests: Extend Intel MSR_IA32_UCODE_REV quirk to Zhaoxin
KVM: selftests: Add Zhaoxin CPU support to nested exceptions test
KVM: selftests: Check for APIC access virtualization support in said test
Gokul K (6):
KVM: selftests: Fix the bounds of the SEV debug dst buffer check
KVM: selftests: Free the VM when the SEV smoke test's guest completes
KVM: selftests: Free the VM when NX hugepage disabling is denied
KVM: selftests: Delete the declaration of vcpu_set_cpuid_maxphyaddr()
KVM: selftests: Move test_read() into elf.c and delete lib/io.c
KVM: selftests: Delete the unused guest_snprintf()
Hisam Mehboob (1):
KVM: selftests: Replace ulong with unsigned long
Nicholas Piggin (1):
KVM: selftests: Use goto instead of do-while to retry finding unused physical pages
Sean Christopherson (57):
KVM: selftests: Use MEM_REGION_PT memslot instead of '0' for s390 regions/segments
KVM: selftests: Use the common minimum GPA for page tables on LoongArch
KVM: selftests: Use vm_alloc_page_table() to allocate LoongArch page tables
KVM: selftests: Rename "num" param to "nr_pages" for physical page allocators
KVM: selftests: Extend page allocator to support naturally aligned allocations
KVM: selftests: Make the single-page allocator APIs static inline
KVM: selftests: Use the innermost page allocator API in the memslot perf test
KVM: selftests: Use the innermost page allocator API in s390's IRQ routing test
KVM: selftests: Add a wrapper API to allocate multiple page table pages
KVM: selftests: Initialize vm->memslots[] with invalid memslots during creation
KVM: selftests: Add APIs to override memory region types with custom memslots
KVM: selftests: Add TEST_EXTRA memory region type for "special" memslots
KVM: selftests: Use TEST_EXTRA region in arm64's vGIC LPI stress test
KVM: selftests: Use TEST_EXTRA region in x86's smaller MAXPHYADDR test
KVM: selftests: Use TEST_EXTRA region in set memory region test
KVM: selftests: Take the memory region type, not memslot, in page allocators
KVM: selftests: Use TEST_ASSERT(), not assert(), in vm_get_mem_region()
KVM: selftests: Automatically pick min_gpa for allocations based on region type
KVM: selftests: Add arch hook to force page tables to be naturally aligned
KVM: selftests: Don't clobber RFLAGS in happy path of __KVM_ASM_SAFE()
KVM: selftests: Assert success in vmptrst(), kill off vmptrstz()
KVM: selftests: Always assert that vmxon() and prepare_for_vmx_operation() succeed
KVM: selftests: Always assert that vmclear() succeeds
KVM: selftests: Always assert that vmptrld() succeeds
KVM: selftests: Drop useless return code from load_vmcs()
KVM: selftests: Add macros to handle simple VMX instructions
KVM: selftests: Drop dead return code from evmcs_vmptrld() and load_evmcs()
KVM: selftests: Dedup assembly code for VMLAUNCH and VMRESUME
KVM: selftests: Assert success in vmlaunch() and vmresume()
KVM: selftests: Add __vmwrite() and use it when initializing optional fields.
KVM: selftests: Always assert that vmwrite() succeeds
KVM: selftests: Always assert that vmreadz() succeeds
KVM: selftests: Account for kernel's off-by-one bug in NUMA node syscalls
KVM: selftests: Compute node masks on-demand in xAPIC IPI test
KVM: selftests: Add common helper to get mask+number of usable memory NUMA nodes
KVM: selftests: Automatically run xAPIC IPI migration test when possible
KVM: selftests: Skip xAPIC IPI migration test when forced but unsupported
KVM: SVM: Fallback to the default TSC ratio if KVM tries to use a bad multiplier
KVM: x86: Allow userspace to set KVM's max supported guest TSC frequency
KVM: selftests: Use KVM's pRNG to randomize L1's TSC ratio in TSC scaling test
KVM: selftests: Drop redundant VMWRITE of TSC_MULTIPLIER_HIGH
KVM: selftests: Drop unnecessary use of PRIu64 in nested TSC scaling test
KVM: selftests: Randomize L2's scale factor in nested TSC scaling test
KVM: selftests: Rename TSC freq checkers in nested TSC scaling test
KVM: selftests: Extract guts of nested TSC scaling test to helper function
KVM: selftests: Track L2 multiplier, not scale-up factor, in nested TSC test
KVM: selftests: Print out the failing L{0,1,2} level in nested TSC scaling test
KVM: selftests: Allow +/- 1 tolerance if expected TSC frequency is <100
KVM: selftests: Use KVM's reported TSC KHz as L0's frequency (sanity checked)
KVM: selftests: Explicitly pass TSC frequencies to guts of TSC scaling test
KVM: selftests: Sanity check KVM's default TSC freq in nested TSC scaling test
KVM: selftests: Test L1 "up" and L2 "down" in nested TSC scaling test
KVM: selftests: Verify that KVM saturates L2 TSC freq on {under,over}flow
KVM: selftests: Test non-zero TSC offset on SVM in nested TSC scaling test
KVM: selftests: Randomize L2's TSC offset in the nested TSC scaling test
KVM: selftests: Use GUEST_SYNC2() in nested TSC scaling test
KVM: selftests: Spell out UCALL in nested TSC scaling test's enums
Shivank Garg (2):
KVM: selftests: Fix maxnode argument to migrate_pages() in xapic_ipi_test
KVM: selftests: use BITS_PER_TYPE() for NUMA masks
Vitaly Kuznetsov (4):
KVM: nVMX: Make VMPTRLD result in #UD when eVMCS is used
KVM: nVMX: Make VMPTRST return eVMCS GPA when it is used
KVM: selftests: Adapt to the updated VMPTRST behavior when eVMCS is used
KVM: selftests: Check VMPTRLD with active eVMCS
arch/x86/kvm/svm/svm.c | 9 +
arch/x86/kvm/vmx/nested.c | 24 +-
arch/x86/kvm/x86.c | 62 +++++-
tools/testing/selftests/kvm/Makefile.kvm | 1 -
tools/testing/selftests/kvm/arm64/hypercalls.c | 2 +-
.../testing/selftests/kvm/arm64/page_fault_test.c | 18 +-
.../testing/selftests/kvm/arm64/vgic_lpi_stress.c | 21 +-
tools/testing/selftests/kvm/demand_paging_test.c | 3 +-
tools/testing/selftests/kvm/guest_memfd_test.c | 2 +-
tools/testing/selftests/kvm/include/kvm_util.h | 106 +++++++--
tools/testing/selftests/kvm/include/numaif.h | 43 ++++
tools/testing/selftests/kvm/include/test_util.h | 5 -
tools/testing/selftests/kvm/include/x86/evmcs.h | 78 +------
.../testing/selftests/kvm/include/x86/processor.h | 13 +-
tools/testing/selftests/kvm/include/x86/smm.h | 2 +-
tools/testing/selftests/kvm/include/x86/vmx.h | 178 ++++++---------
tools/testing/selftests/kvm/lib/arm64/processor.c | 4 +-
tools/testing/selftests/kvm/lib/elf.c | 48 +++-
tools/testing/selftests/kvm/lib/guest_sprintf.c | 12 -
tools/testing/selftests/kvm/lib/io.c | 157 -------------
tools/testing/selftests/kvm/lib/kvm_util.c | 128 ++++++-----
.../selftests/kvm/lib/loongarch/processor.c | 5 +-
tools/testing/selftests/kvm/lib/riscv/processor.c | 4 +-
tools/testing/selftests/kvm/lib/s390/processor.c | 7 +-
tools/testing/selftests/kvm/lib/userfaultfd_util.c | 6 +-
tools/testing/selftests/kvm/lib/x86/memstress.c | 8 +-
tools/testing/selftests/kvm/lib/x86/processor.c | 23 +-
tools/testing/selftests/kvm/lib/x86/vmx.c | 159 +++++++++-----
tools/testing/selftests/kvm/memslot_perf_test.c | 5 +-
tools/testing/selftests/kvm/s390/cmma_test.c | 19 +-
tools/testing/selftests/kvm/s390/irq_routing.c | 2 +-
.../testing/selftests/kvm/set_memory_region_test.c | 8 +-
tools/testing/selftests/kvm/steal_time.c | 20 +-
tools/testing/selftests/kvm/x86/amx_test.c | 2 +-
tools/testing/selftests/kvm/x86/aperfmperf_test.c | 10 +-
tools/testing/selftests/kvm/x86/cpuid_test.c | 2 +-
.../selftests/kvm/x86/evmcs_smm_controls_test.c | 6 +-
.../testing/selftests/kvm/x86/feature_msrs_test.c | 2 +-
.../testing/selftests/kvm/x86/fix_hypercall_test.c | 2 +-
tools/testing/selftests/kvm/x86/hyperv_clock.c | 2 +-
tools/testing/selftests/kvm/x86/hyperv_evmcs.c | 87 +++++---
tools/testing/selftests/kvm/x86/hyperv_svm_test.c | 2 +-
tools/testing/selftests/kvm/x86/kvm_buslock_test.c | 8 +-
.../selftests/kvm/x86/nested_close_kvm_test.c | 6 +-
.../selftests/kvm/x86/nested_dirty_log_test.c | 8 +-
.../selftests/kvm/x86/nested_emulation_test.c | 23 +-
.../selftests/kvm/x86/nested_exceptions_test.c | 33 +--
.../selftests/kvm/x86/nested_invalid_cr3_test.c | 14 +-
.../selftests/kvm/x86/nested_tdp_fault_test.c | 16 +-
.../selftests/kvm/x86/nested_tsc_adjust_test.c | 10 +-
.../selftests/kvm/x86/nested_tsc_scaling_test.c | 244 +++++++++++++--------
.../testing/selftests/kvm/x86/nx_huge_pages_test.c | 3 +-
.../kvm/x86/save_restore_pf_stress_test.c | 14 +-
tools/testing/selftests/kvm/x86/set_boot_cpu_id.c | 2 +-
tools/testing/selftests/kvm/x86/sev_dbg_test.c | 6 +-
tools/testing/selftests/kvm/x86/sev_smoke_test.c | 3 +-
.../kvm/x86/smaller_maxphyaddr_emulation_test.c | 9 +-
tools/testing/selftests/kvm/x86/smm_test.c | 4 +-
tools/testing/selftests/kvm/x86/state_test.c | 74 +++----
.../selftests/kvm/x86/triple_fault_event_test.c | 8 +-
tools/testing/selftests/kvm/x86/tsc_msrs_test.c | 2 +-
.../selftests/kvm/x86/vmx_apic_access_test.c | 22 +-
.../selftests/kvm/x86/vmx_apicv_updates_test.c | 16 +-
.../x86/vmx_exception_with_invalid_guest_state.c | 2 +-
.../kvm/x86/vmx_invalid_nested_guest_state.c | 12 +-
.../selftests/kvm/x86/vmx_nested_la57_state_test.c | 12 +-
.../selftests/kvm/x86/vmx_preemption_timer_test.c | 28 ++-
tools/testing/selftests/kvm/x86/xapic_ipi_test.c | 78 +++----
68 files changed, 1024 insertions(+), 930 deletions(-)
delete mode 100644 tools/testing/selftests/kvm/lib/io.c
^ permalink raw reply [flat|nested] 10+ messages in thread* [GIT PULL] KVM: x86: SVM changes for 7.4
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
` (5 preceding siblings ...)
2026-10-16 4:44 ` [GIT PULL] KVM: Selftests changes for 7.4 Sean Christopherson
@ 2026-10-16 4:44 ` Sean Christopherson
2026-10-16 4:44 ` [GIT PULL] KVM: x86: VMX+TDX " Sean Christopherson
2026-10-16 9:11 ` [GIT PULL] KVM: x86: Pull requests " Paolo Bonzini
8 siblings, 0 replies; 10+ messages in thread
From: Sean Christopherson @ 2026-10-16 4:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Not much this time around, mainly because PML and Bus Lock virtualization
support went in through the "misc" branch due to making significant changes
to common x86 code.
The following changes since commit d4b7fb647204f0c81dfeae2d1a708e4d858e0c94:
Merge branch 'kvm-xen-longmode' into HEAD (2026-09-04 17:35:03 +0200)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-svm-7.4
for you to fetch changes up to 003892d6e802a1c08ad03e8ea793453465cae7f4:
KVM: SEV: Return INVALID_INPUT on SNP req/resp buffer access failure (2026-09-28 17:55:11 -0700)
----------------------------------------------------------------
KVM SVM changes for 7.4
- Fix a benign-in-practice bug where KVM unintentionally sets a non-zero
error code when delivering exceptions to SEV-ES+ guests.
- Force a new ASID in both VMCBs on pCPU migration to fix a bug where KVM can
run a VMCB with a stale ASID due to the tracking being per-CPU, not per-VMCB.
- Return INVALID_INPUT to the guest instead of exiting to userspace with -EIO
if KVM can't access "guest request" buffer, i.e. try to keep the guest alive
if the guest or userspace goofs.
----------------------------------------------------------------
Chaithanya Lagisetty (1):
x86/svm: Avoid sign extension of SVM_EVTINJ_VALID in 64-bit expressions
Jacky Li (1):
KVM: SEV: Return INVALID_INPUT on SNP req/resp buffer access failure
Yosry Ahmed (1):
KVM: SVM: Trigger new ASID allocation in both VMCBs on pCPU switch
arch/x86/include/asm/svm.h | 4 ++--
arch/x86/kvm/svm/nested.c | 1 +
arch/x86/kvm/svm/sev.c | 37 +++++++++++++++++++++++++++++++------
arch/x86/kvm/svm/svm.c | 19 +++++++++++++++----
4 files changed, 49 insertions(+), 12 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread* [GIT PULL] KVM: x86: VMX+TDX changes for 7.4
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
` (6 preceding siblings ...)
2026-10-16 4:44 ` [GIT PULL] KVM: x86: SVM " Sean Christopherson
@ 2026-10-16 4:44 ` Sean Christopherson
2026-10-16 9:11 ` [GIT PULL] KVM: x86: Pull requests " Paolo Bonzini
8 siblings, 0 replies; 10+ messages in thread
From: Sean Christopherson @ 2026-10-16 4:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Tag says "vmx", but this is almost entirely TDX focused.
The INIT_MEM_REGION fixes will conflict with the "coco" branch due to in-place
conversion allowing a null/0 source address:
diff --cc arch/x86/kvm/vmx/tdx.c
index b816331fcc98,2a3acf493cb5..ee1d412b0ee6
--- arch/x86/kvm/vmx/tdx.c
+++ arch/x86/kvm/vmx/tdx.c
@@@ -3233,12 -3274,14 +3272,15 @@@ static int tdx_vcpu_init_mem_region(str
if (copy_from_user(®ion, u64_to_user_ptr(cmd->data), sizeof(region)))
return -EFAULT;
- if (!PAGE_ALIGNED(region.source_addr) || !region.source_addr ||
+ if (!PAGE_ALIGNED(region.source_addr) ||
+ (!gmem_in_place_conversion && !region.source_addr) ||
- !PAGE_ALIGNED(region.gpa) || !region.nr_pages ||
- region.gpa + (region.nr_pages << PAGE_SHIFT) <= region.gpa ||
+ !PAGE_ALIGNED(region.gpa) || !region.nr_pages)
+ return -EINVAL;
+
+ if (check_shl_overflow(region.nr_pages, PAGE_SHIFT, &nr_bytes) ||
+ check_add_overflow(region.gpa, nr_bytes - 1, &end_gpa) ||
!vt_is_tdx_private_gpa(kvm, region.gpa) ||
- !vt_is_tdx_private_gpa(kvm, region.gpa + (region.nr_pages << PAGE_SHIFT) - 1))
+ !vt_is_tdx_private_gpa(kvm, end_gpa))
return -EINVAL;
ret = 0;
The vmx=>vt renames will conflict with the "misc" branch because of a collision
with the change to track kvm_vcpu_arch.pending_ioapic_eoi as a u8 (four lines
of code in a function that's been touched _once_ since it was added in 2013,
and somehow I manage to create a conflict in a single release cycle, *sigh*).
diff --cc arch/x86/kvm/vmx/vmx.c
index 686e586f3290,cf32aee0aab7..b341af4c6057
--- arch/x86/kvm/vmx/vmx.c
+++ arch/x86/kvm/vmx/vmx.c
@@@ -5898,10 -5881,11 +5892,10 @@@ static int handle_apic_access(struct kv
static int handle_apic_eoi_induced(struct kvm_vcpu *vcpu)
{
- unsigned long exit_qualification = vmx_get_exit_qual(vcpu);
+ unsigned long exit_qualification = vt_get_exit_qual(vcpu);
- int vector = exit_qualification & 0xff;
/* EOI-induced VM exit is trap-like and thus no need to adjust IP */
- kvm_apic_set_eoi_accelerated(vcpu, vector);
+ kvm_apic_set_eoi_accelerated(vcpu, exit_qualification & 0xff);
return 1;
}
The following changes since commit d4b7fb647204f0c81dfeae2d1a708e4d858e0c94:
Merge branch 'kvm-xen-longmode' into HEAD (2026-09-04 17:35:03 +0200)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-vmx-7.4
for you to fetch changes up to 883719f57f5d3898637b130d6db4742471cad618:
KVM: x86: Clear hardware HLT state when userspace makes a vCPU not-halted (2026-09-28 16:20:35 -0700)
----------------------------------------------------------------
KVM VMX changes for 7.4
- Enable Notify VM-Exits (now called Instruction Timeout in the SDM) and Bus
Lock VM-Exits for TDX guests when they're enabled by userspace (KVM forgot
to wire up the TDX Module knobs).
- Move all common (between VMX and TDX) APIs/helpers to common.h/main.c, and
change all namespace prefixes from "vmx" to "vt".
- Fix a thankfully benign bug (due to other areas of KVM being hardened) where
usersepace can bypass INIT_MEM_REGION's address wrap check by providing a
nr_pages that will overflow a u64 when converted to bytes, and fix an also-
benign off-by-one bug in the check (inclusive vs. exclusive).
- Set the vmcs.GUEST_ACTIVITY_STATE back to ACTIVE when userspace sets KVM's
mp_state to anything other than HALTED, e.g. so that a vCPU doesn't get
stuck in HLT if userspace emulates RESET.
----------------------------------------------------------------
Haotian Jiang (1):
KVM: TDX: Reject INIT_MEM_REGION if number of bytes would overflow a u64
Keqiang Duan (1):
KVM: x86: Clear hardware HLT state when userspace makes a vCPU not-halted
Nikolay Borisov (1):
KVM: TDX: Remove always true ifdef
Sean Christopherson (11):
KVM: VMX: Formally define KVM's "0xdead" exit reason used for failed VM-Enter
KVM: VMX: Disallow using to_vmx() in common VT code
KVM: VMX: Move the shared "IRQs off" exit handler(s) to common code
KVM: VMX: Move the shared NMI handler/trampoline to common code
KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt"
KVM: VMX: Rename EPT violation handler prefix from "vmx" to "vt"
KVM: VMX: Use dummy pseudo-overlay struct for to_vt() and vt_to_vcpu()
KVM: VMX: Move common VT getters/converters to common.h
KVM: VMX: Rename common exit info getters prefixes from "vmx" to "vt"
KVM: VMX: Move bus lock handler from main.c => common.h
KVM: TDX: Fix a benign off-by-one bug on the end GPA for INIT_MEM_REGION
Xiaoyao Li (9):
KVM: TDX: Enable Notify VM exit
KVM: TDX: Check if there is valid exit infos based on vp_enter_ret
KVM: TDX: Set bits 31:16 to 0 and use UNDEFINED when synthesizing exit reason
KVM: TDX: Don't assume exit_reason[31:16] is all-0 in tdx_to_vmx_exit_reason()
KVM: TDX: Stuff exit_reason with UNDEFINED on wait_for_sept_zap return
KVM: VMX: Preserve negative return value in vmx_handle_exit() with bus lock detected
KVM: VMX: Make handle_bus_lock_vmexit() a shared helper
KVM: TDX: Enable Bus Lock VM exit
KVM: VMX: Consolidate the exit handler for VMX and TDX
arch/x86/include/asm/kvm-x86-ops.h | 1 +
arch/x86/include/asm/kvm_host.h | 7 ++
arch/x86/include/asm/vmx.h | 8 ++
arch/x86/kvm/vmx/common.h | 90 +++++++++++++++-
arch/x86/kvm/vmx/main.c | 145 +++++++++++++++++++++++---
arch/x86/kvm/vmx/nested.c | 36 +++----
arch/x86/kvm/vmx/posted_intr.c | 24 +++--
arch/x86/kvm/vmx/posted_intr.h | 8 +-
arch/x86/kvm/vmx/tdx.c | 112 +++++++++++++-------
arch/x86/kvm/vmx/vmx.c | 205 ++++++++-----------------------------
arch/x86/kvm/vmx/vmx.h | 37 -------
arch/x86/kvm/vmx/x86_ops.h | 2 +-
arch/x86/kvm/x86.c | 13 +++
13 files changed, 397 insertions(+), 291 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [GIT PULL] KVM: x86: Pull requests for 7.4
2026-10-16 4:44 [GIT PULL] KVM: x86: Pull requests for 7.4 Sean Christopherson
` (7 preceding siblings ...)
2026-10-16 4:44 ` [GIT PULL] KVM: x86: VMX+TDX " Sean Christopherson
@ 2026-10-16 9:11 ` Paolo Bonzini
8 siblings, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2026-10-16 9:11 UTC (permalink / raw)
To: Sean Christopherson; +Cc: kvm, linux-kernel
On Fri, Oct 16, 2026 at 6:44 AM Sean Christopherson <seanjc@google.com> wrote:
>
> This cycle is "fun", only the "mmu" and "svm" requests escaped without a conflict
> or some other notable mess. That said, I don't think there's anything particularly
> thorny to deal with, just a lot of minor stuff. Details in the individual pull
> requests.
>
> My apologies for not getting the guest_memfd in-place conversion changes sent
> along sooner. I really wanted to get you a pull request around 7.3-rc4, but we
> simply could get the code ready in time.
Pulled all, thanks (for now to kvm/queue). Even if it was a bit messy,
part of it was due to more than the usual amount of changes in 7.3.
Paolo
^ permalink raw reply [flat|nested] 10+ messages in thread