* [GIT PULL] KVM: Generic changes for 6.13
2024-11-12 19:33 [GIT PULL] KVM: x86 changes for 6.13 Sean Christopherson
@ 2024-11-12 19:33 ` Sean Christopherson
2024-11-12 19:33 ` [GIT PULL] KVM: x86: Misc " Sean Christopherson
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Sean Christopherson @ 2024-11-12 19:33 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Please pull two changes that coincidentally happen to be related to vcpu->pid.
The following changes since commit 5cb1659f412041e4780f2e8ee49b2e03728a2ba6:
Merge branch 'kvm-no-struct-page' into HEAD (2024-10-25 13:38:16 -0400)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-generic-6.13
for you to fetch changes up to 3e7f43188ee227bcf0f07f60a00f1fd1aca10e6a:
KVM: Protect vCPU's "last run PID" with rwlock, not RCU (2024-10-30 14:41:22 -0700)
----------------------------------------------------------------
KVM generic changes for 6.13
- Rework kvm_vcpu_on_spin() to use a single for-loop instead of making two
partial poasses over "all" vCPUs. Opportunistically expand the comment
to better explain the motivation and logic.
- Protect vcpu->pid accesses outside of vcpu->mutex with a rwlock instead
of RCU, so that running a vCPU on a different task doesn't encounter
long stalls due to having to wait for all CPUs become quiescent.
----------------------------------------------------------------
Sean Christopherson (3):
KVM: Rework core loop of kvm_vcpu_on_spin() to use a single for-loop
KVM: Return '0' directly when there's no task to yield to
KVM: Protect vCPU's "last run PID" with rwlock, not RCU
arch/arm64/include/asm/kvm_host.h | 2 +-
include/linux/kvm_host.h | 3 +-
virt/kvm/kvm_main.c | 143 ++++++++++++++++++++++----------------
3 files changed, 86 insertions(+), 62 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread* [GIT PULL] KVM: x86: Misc changes for 6.13
2024-11-12 19:33 [GIT PULL] KVM: x86 changes for 6.13 Sean Christopherson
2024-11-12 19:33 ` [GIT PULL] KVM: Generic " Sean Christopherson
@ 2024-11-12 19:33 ` Sean Christopherson
2024-11-13 11:52 ` Paolo Bonzini
2024-11-12 19:33 ` [GIT PULL] KVM: x86: MMU " Sean Christopherson
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Sean Christopherson @ 2024-11-12 19:33 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Please pull a variety of misc x86 changes. The highlight is Maxim's
overhaul of the non-canonical logic to (try to) better follow hardware
behavior when LA57 is supported.
The STUFF_FEATURE_MSRS quirk might also be worth a second glance?
The following changes since commit 81983758430957d9a5cb3333fe324fd70cf63e7e:
Linux 6.12-rc5 (2024-10-27 12:52:02 -1000)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-misc-6.13
for you to fetch changes up to a75b7bb46a83a2990f6b498251798930a19808d9:
KVM: x86: Short-circuit all of kvm_apic_set_base() if MSR value is unchanged (2024-11-04 20:57:55 -0800)
----------------------------------------------------------------
KVM x86 misc changes for 6.13
- Clean up and optimize KVM's handling of writes to MSR_IA32_APICBASE.
- Quirk KVM's misguided behavior of initialized certain feature MSRs to
their maximum supported feature set, which can result in KVM creating
invalid vCPU state. E.g. initializing PERF_CAPABILITIES to a non-zero
value results in the vCPU having invalid state if userspace hides PDCM
from the guest, which can lead to save/restore failures.
- Fix KVM's handling of non-canonical checks for vCPUs that support LA57
to better follow the "architecture", in quotes because the actual
behavior is poorly documented. E.g. most MSR writes and descriptor
table loads ignore CR4.LA57 and operate purely on whether the CPU
supports LA57.
- Bypass the register cache when querying CPL from kvm_sched_out(), as
filling the cache from IRQ context is generally unsafe, and harden the
cache accessors to try to prevent similar issues from occuring in the
future.
- Advertise AMD_IBPB_RET to userspace, and fix a related bug where KVM
over-advertises SPEC_CTRL when trying to support cross-vendor VMs.
- Minor cleanups
----------------------------------------------------------------
Jim Mattson (2):
KVM: x86: Advertise AMD_IBPB_RET to userspace
KVM: x86: AMD's IBPB is not equivalent to Intel's IBPB
Kai Huang (2):
KVM: x86: Fix a comment inside kvm_vcpu_update_apicv()
KVM: x86: Fix a comment inside __kvm_set_or_clear_apicv_inhibit()
Maxim Levitsky (5):
KVM: x86: drop x86.h include from cpuid.h
KVM: x86: Route non-canonical checks in emulator through emulate_ops
KVM: x86: Add X86EMUL_F_MSR and X86EMUL_F_DT_LOAD to aid canonical checks
KVM: x86: model canonical checks more precisely
KVM: nVMX: fix canonical check of vmcs12 HOST_RIP
Sean Christopherson (23):
KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request()
KVM: x86: Bypass register cache when querying CPL from kvm_sched_out()
KVM: x86: Add lockdep-guarded asserts on register cache usage
KVM: x86: Use '0' for guest RIP if PMI encounters protected guest state
KVM: x86: Document an erratum in KVM_SET_VCPU_EVENTS on Intel CPUs
KVM: x86: Co-locate initialization of feature MSRs in kvm_arch_vcpu_create()
KVM: x86: Disallow changing MSR_PLATFORM_INFO after vCPU has run
KVM: x86: Quirk initialization of feature MSRs to KVM's max configuration
KVM: x86: Reject userspace attempts to access PERF_CAPABILITIES w/o PDCM
KVM: VMX: Remove restriction that PMU version > 0 for PERF_CAPABILITIES
KVM: x86: Reject userspace attempts to access ARCH_CAPABILITIES w/o support
KVM: x86: Remove ordering check b/w MSR_PLATFORM_INFO and MISC_FEATURES_ENABLES
KVM: selftests: Verify get/set PERF_CAPABILITIES w/o guest PDMC behavior
KVM: selftests: Add a testcase for disabling feature MSRs init quirk
KVM: x86: Short-circuit all kvm_lapic_set_base() if MSR value isn't changing
KVM: x86: Drop superfluous kvm_lapic_set_base() call when setting APIC state
KVM: x86: Get vcpu->arch.apic_base directly and drop kvm_get_apic_base()
KVM: x86: Inline kvm_get_apic_mode() in lapic.h
KVM: x86: Move kvm_set_apic_base() implementation to lapic.c (from x86.c)
KVM: x86: Rename APIC base setters to better capture their relationship
KVM: x86: Make kvm_recalculate_apic_map() local to lapic.c
KVM: x86: Unpack msr_data structure prior to calling kvm_apic_set_base()
KVM: x86: Short-circuit all of kvm_apic_set_base() if MSR value is unchanged
Documentation/virt/kvm/api.rst | 22 ++++
Documentation/virt/kvm/x86/errata.rst | 12 +++
arch/x86/include/asm/kvm-x86-ops.h | 1 +
arch/x86/include/asm/kvm_host.h | 4 +-
arch/x86/include/uapi/asm/kvm.h | 1 +
arch/x86/kvm/cpuid.c | 12 ++-
arch/x86/kvm/cpuid.h | 1 -
arch/x86/kvm/emulate.c | 15 +--
arch/x86/kvm/kvm_cache_regs.h | 17 +++
arch/x86/kvm/kvm_emulate.h | 5 +
arch/x86/kvm/lapic.c | 39 ++++++-
arch/x86/kvm/lapic.h | 11 +-
arch/x86/kvm/mmu.h | 1 +
arch/x86/kvm/mmu/mmu.c | 2 +-
arch/x86/kvm/mtrr.c | 1 +
arch/x86/kvm/svm/svm.c | 5 +-
arch/x86/kvm/vmx/hyperv.c | 1 +
arch/x86/kvm/vmx/main.c | 1 +
arch/x86/kvm/vmx/nested.c | 35 +++---
arch/x86/kvm/vmx/pmu_intel.c | 2 +-
arch/x86/kvm/vmx/sgx.c | 5 +-
arch/x86/kvm/vmx/vmx.c | 38 ++++---
arch/x86/kvm/vmx/vmx.h | 1 +
arch/x86/kvm/x86.c | 120 ++++++++++-----------
arch/x86/kvm/x86.h | 48 ++++++++-
tools/testing/selftests/kvm/Makefile | 2 +-
.../selftests/kvm/x86_64/feature_msrs_test.c | 113 +++++++++++++++++++
.../selftests/kvm/x86_64/get_msr_index_features.c | 35 ------
.../selftests/kvm/x86_64/platform_info_test.c | 2 -
.../selftests/kvm/x86_64/vmx_pmu_caps_test.c | 23 ++++
30 files changed, 419 insertions(+), 156 deletions(-)
create mode 100644 tools/testing/selftests/kvm/x86_64/feature_msrs_test.c
delete mode 100644 tools/testing/selftests/kvm/x86_64/get_msr_index_features.c
^ permalink raw reply [flat|nested] 8+ messages in thread* [GIT PULL] KVM: x86: MMU changes for 6.13
2024-11-12 19:33 [GIT PULL] KVM: x86 changes for 6.13 Sean Christopherson
2024-11-12 19:33 ` [GIT PULL] KVM: Generic " Sean Christopherson
2024-11-12 19:33 ` [GIT PULL] KVM: x86: Misc " Sean Christopherson
@ 2024-11-12 19:33 ` Sean Christopherson
2024-11-12 19:33 ` [GIT PULL] KVM: Selftests " Sean Christopherson
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Sean Christopherson @ 2024-11-12 19:33 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Aside from the A/D overhaul that you've already seen, the two highlights
are support for recovering TDP MMU huge pages in-place, and removal of KVM's
MMU shrinker (which IMO is long overdue).
The following changes since commit 5cb1659f412041e4780f2e8ee49b2e03728a2ba6:
Merge branch 'kvm-no-struct-page' into HEAD (2024-10-25 13:38:16 -0400)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-mmu-6.13
for you to fetch changes up to 4cf20d42543cff8778f70b0c29def984098641a5:
KVM: x86/mmu: Drop per-VM zapped_obsolete_pages list (2024-11-04 19:22:53 -0800)
----------------------------------------------------------------
KVM x86 MMU changes for 6.13
- Cleanup KVM's handling of Accessed and Dirty bits to dedup code, improve
documentation, harden against unexpected changes, and to simplify
A/D-disabled MMUs by using the hardware-defined A/D bits to track if a
PFN is Accessed and/or Dirty.
- Elide TLB flushes when aging SPTEs, as has been done in x86's primary
MMU for over 10 years.
- Batch TLB flushes when zapping collapsible TDP MMU SPTEs, i.e. when
dirty logging is toggled off, which reduces the time it takes to disable
dirty logging by ~3x.
- Recover huge pages in-place in the TDP MMU instead of zapping the SP
and waiting until the page is re-accessed to create a huge mapping.
Proactively installing huge pages can reduce vCPU jitter in extreme
scenarios.
- Remove support for (poorly) reclaiming page tables in shadow MMUs via
the primary MMU's shrinker interface.
----------------------------------------------------------------
David Matlack (5):
KVM: x86/mmu: Drop @max_level from kvm_mmu_max_mapping_level()
KVM: x86/mmu: Batch TLB flushes when zapping collapsible TDP MMU SPTEs
KVM: x86/mmu: Recover TDP MMU huge page mappings in-place instead of zapping
KVM: x86/mmu: Rename make_huge_page_split_spte() to make_small_spte()
KVM: x86/mmu: WARN if huge page recovery triggered during dirty logging
Sean Christopherson (21):
KVM: x86/mmu: Flush remote TLBs iff MMU-writable flag is cleared from RO SPTE
KVM: x86/mmu: Always set SPTE's dirty bit if it's created as writable
KVM: x86/mmu: Fold all of make_spte()'s writable handling into one if-else
KVM: x86/mmu: Don't force flush if SPTE update clears Accessed bit
KVM: x86/mmu: Don't flush TLBs when clearing Dirty bit in shadow MMU
KVM: x86/mmu: Drop ignored return value from kvm_tdp_mmu_clear_dirty_slot()
KVM: x86/mmu: Fold mmu_spte_update_no_track() into mmu_spte_update()
KVM: x86/mmu: WARN and flush if resolving a TDP MMU fault clears MMU-writable
KVM: x86/mmu: Add a dedicated flag to track if A/D bits are globally enabled
KVM: x86/mmu: Set shadow_accessed_mask for EPT even if A/D bits disabled
KVM: x86/mmu: Set shadow_dirty_mask for EPT even if A/D bits disabled
KVM: x86/mmu: Use Accessed bit even when _hardware_ A/D bits are disabled
KVM: x86/mmu: Process only valid TDP MMU roots when aging a gfn range
KVM: x86/mmu: Stop processing TDP MMU roots for test_age if young SPTE found
KVM: x86/mmu: Dedup logic for detecting TLB flushes on leaf SPTE changes
KVM: x86/mmu: Set Dirty bit for new SPTEs, even if _hardware_ A/D bits are disabled
KVM: Allow arch code to elide TLB flushes when aging a young page
KVM: x86: Don't emit TLB flushes when aging SPTEs for mmu_notifiers
KVM: x86/mmu: Check yielded_gfn for forward progress iff resched is needed
KVM: x86/mmu: Demote the WARN on yielded in xxx_cond_resched() to KVM_MMU_WARN_ON
KVM: x86/mmu: Refactor TDP MMU iter need resched check
Vipin Sharma (2):
KVM: x86/mmu: Remove KVM's MMU shrinker
KVM: x86/mmu: Drop per-VM zapped_obsolete_pages list
arch/x86/include/asm/kvm_host.h | 5 +-
arch/x86/kvm/Kconfig | 1 +
arch/x86/kvm/mmu/mmu.c | 201 ++++++-------------------------
arch/x86/kvm/mmu/mmu_internal.h | 3 +-
arch/x86/kvm/mmu/spte.c | 99 +++++++++-------
arch/x86/kvm/mmu/spte.h | 76 ++++++------
arch/x86/kvm/mmu/tdp_mmu.c | 257 +++++++++++++++++++---------------------
arch/x86/kvm/mmu/tdp_mmu.h | 6 +-
arch/x86/kvm/x86.c | 18 ++-
virt/kvm/Kconfig | 4 +
virt/kvm/kvm_main.c | 20 +---
11 files changed, 280 insertions(+), 410 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread* [GIT PULL] KVM: Selftests changes for 6.13
2024-11-12 19:33 [GIT PULL] KVM: x86 changes for 6.13 Sean Christopherson
` (2 preceding siblings ...)
2024-11-12 19:33 ` [GIT PULL] KVM: x86: MMU " Sean Christopherson
@ 2024-11-12 19:33 ` Sean Christopherson
2024-11-12 19:33 ` [GIT PULL] KVM: VMX change " Sean Christopherson
2024-11-13 12:23 ` [GIT PULL] KVM: x86 changes " Paolo Bonzini
5 siblings, 0 replies; 8+ messages in thread
From: Sean Christopherson @ 2024-11-12 19:33 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
Essentially AVX support, plus a few minor cleanups.
Far more noteworth is what's not in this pull request. For 6.14, I want
to I want to land series with KVM-selftests-tree-wide impact: one that
changes^fixes the prototype for vcpu_get_reg(), and another that uses the
kernel's canonical $(ARCH) directory scheme instead of KVM selftests'
homebrewed $(ARCH_DIR). My plan is to refresh both series after all arch
pull requests for 6.13 have landed, and then pester you incessantly to
apply them :-)
https://lore.kernel.org/all/20241009154953.1073471-1-seanjc@google.com
https://lore.kernel.org/all/20240826190116.145945-1-seanjc@google.com
The following changes since commit 81983758430957d9a5cb3333fe324fd70cf63e7e:
Linux 6.12-rc5 (2024-10-27 12:52:02 -1000)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-selftests-6.13
for you to fetch changes up to 89f8869835e4da836bc60ab20568b7864706f94b:
KVM: selftests: Ensure KVM supports AVX for SEV-ES VMSA FPU test (2024-11-01 09:26:37 -0700)
----------------------------------------------------------------
KVM selftests changes for 6.13
- Enable XFAM-based features by default for all selftests VMs, which will
allow removing the "no AVX" restriction.
----------------------------------------------------------------
Ba Jing (1):
KVM: selftests: Remove unused macro in the hardware disable test
Jiapeng Chong (1):
KVM: selftests: Use ARRAY_SIZE for array length
Sean Christopherson (10):
KVM: selftests: Precisely mask off dynamic fields in CPUID test
KVM: selftests: Mask off OSPKE and OSXSAVE when comparing CPUID entries
KVM: selftests: Rework OSXSAVE CR4=>CPUID test to play nice with AVX insns
KVM: selftests: Configure XCR0 to max supported value by default
KVM: selftests: Verify XCR0 can be "downgraded" and "upgraded"
KVM: selftests: Drop manual CR4.OSXSAVE enabling from CR4/CPUID sync test
KVM: selftests: Drop manual XCR0 configuration from AMX test
KVM: selftests: Drop manual XCR0 configuration from state test
KVM: selftests: Drop manual XCR0 configuration from SEV smoke test
KVM: selftests: Ensure KVM supports AVX for SEV-ES VMSA FPU test
.../testing/selftests/kvm/hardware_disable_test.c | 1 -
.../selftests/kvm/include/x86_64/processor.h | 5 ++
tools/testing/selftests/kvm/lib/x86_64/processor.c | 24 ++++++++
tools/testing/selftests/kvm/x86_64/amx_test.c | 23 ++------
tools/testing/selftests/kvm/x86_64/cpuid_test.c | 67 ++++++++++++++--------
.../selftests/kvm/x86_64/cr4_cpuid_sync_test.c | 53 +++++++++++------
tools/testing/selftests/kvm/x86_64/debug_regs.c | 2 +-
.../testing/selftests/kvm/x86_64/sev_smoke_test.c | 19 ++----
tools/testing/selftests/kvm/x86_64/state_test.c | 5 --
.../testing/selftests/kvm/x86_64/xcr0_cpuid_test.c | 11 +++-
10 files changed, 123 insertions(+), 87 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread* [GIT PULL] KVM: VMX change for 6.13
2024-11-12 19:33 [GIT PULL] KVM: x86 changes for 6.13 Sean Christopherson
` (3 preceding siblings ...)
2024-11-12 19:33 ` [GIT PULL] KVM: Selftests " Sean Christopherson
@ 2024-11-12 19:33 ` Sean Christopherson
2024-11-13 12:23 ` [GIT PULL] KVM: x86 changes " Paolo Bonzini
5 siblings, 0 replies; 8+ messages in thread
From: Sean Christopherson @ 2024-11-12 19:33 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Sean Christopherson
One lonely, comically small VMX change for 6.13.
The following changes since commit 5cb1659f412041e4780f2e8ee49b2e03728a2ba6:
Merge branch 'kvm-no-struct-page' into HEAD (2024-10-25 13:38:16 -0400)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-vmx-6.13
for you to fetch changes up to bc17fccb37c8c100e3390e429e952330fd7cab1e:
KVM: VMX: Remove the unused variable "gpa" in __invept() (2024-10-30 12:28:37 -0700)
----------------------------------------------------------------
KVM VMX change for 6.13
- Remove __invept()'s unused @gpa param, which was left behind when KVM
dropped code for invalidating a specific GPA (Intel never officially
documented support for single-address INVEPT; presumably pre-production
CPUs supported it at some point).
----------------------------------------------------------------
Yan Zhao (1):
KVM: VMX: Remove the unused variable "gpa" in __invept()
arch/x86/kvm/vmx/vmx.c | 5 ++---
arch/x86/kvm/vmx/vmx_ops.h | 16 ++++++++--------
2 files changed, 10 insertions(+), 11 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [GIT PULL] KVM: x86 changes for 6.13
2024-11-12 19:33 [GIT PULL] KVM: x86 changes for 6.13 Sean Christopherson
` (4 preceding siblings ...)
2024-11-12 19:33 ` [GIT PULL] KVM: VMX change " Sean Christopherson
@ 2024-11-13 12:23 ` Paolo Bonzini
5 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2024-11-13 12:23 UTC (permalink / raw)
To: Sean Christopherson; +Cc: kvm, linux-kernel
Thanks, pulled.
Paolo
On Tue, Nov 12, 2024 at 8:33 PM Sean Christopherson <seanjc@google.com> wrote:
>
> AFAIK, there are no conflicts or dependencies with other architectures or
> trees.
>
^ permalink raw reply [flat|nested] 8+ messages in thread