KVM: x86 pull requests for 6.11
Sean Christopherson
maintainerThere's a trivial conflict between "misc" and "vmx" in kvm-x86-ops.h, they both delete ops that happen to be _right_ next to each other. Otherwise, should apply cleanly.
Sean Christopherson
maintainer[GIT PULL] KVM: x86: Single Xen fix for 6.10 or 6.11
A one-off fix for KVM Xen. This pull request is built on kvm/master, and tagged somewhat ambiguously in case you deem it worthy of 6.10.
The following changes since commit dee67a94d4c6cbd05b8f6e1181498e94caa33334:
Merge tag 'kvm-x86-fixes-6.10-rcN' of https://github.com/kvm-x86/linux into HEAD (2024-06-21 08:03:55 -0400)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-fixes-6.10-11
for you to fetch changes up to ebbdf37ce9abb597015fa85df6630ebfa7d0a97f:
KVM: Validate hva in kvm_gpc_activate_hva() to fix __kvm_gpc_refresh() WARN (2024-06-28 08:31:46 -0700)
----------------------------------------------------------------
KVM Xen:
Fix a bug where KVM fails to check the validity of an incoming userspace virtual address and tries to activate a gfn_to_pfn_cache with a kernel address.
----------------------------------------------------------------
Pei Li (1):
KVM: Validate hva in kvm_gpc_activate_hva() to fix __kvm_gpc_refresh() WARN
arch/x86/kvm/xen.c | 2 +- virt/kvm/pfncache.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
Sean Christopherson
maintainer[GIT PULL] KVM: Generic changes for 6.11
In reply to Sean ChristophersonMight be worth peeking at the vcpu->wants_to_run vs. preemption change, to make sure that it aligns with QEMU's views on live migration and steal time. Ditto for the vCPU ID change from Mathias (though if QEMU runs afoul of that one...).
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-generic-6.11
for you to fetch changes up to 25bc6af60f6121071ab4aa924a24cf6011125614:
KVM: Add missing MODULE_DESCRIPTION() (2024-06-28 08:51:41 -0700)
----------------------------------------------------------------
KVM generic changes for 6.11
- Enable halt poll shrinking by default, as Intel found it to be a clear win.
- Setup empty IRQ routing when creating a VM to avoid having to synchronize SRCU when creating a split IRQCHIP on x86.
- Rework the sched_in/out() paths to replace kvm_arch_sched_in() with a flag that arch code can use for hooking both sched_in() and sched_out().
- Take the vCPU @id as an "unsigned long" instead of "u32" to avoid truncating a bogus value from userspace, e.g. to help userspace detect bugs.
- Mark a vCPU as preempted if and only if it's scheduled out while in the KVM_RUN loop, e.g. to avoid marking it preempted and thus writing guest memory when retrieving guest state during live migration blackout.
- A few minor cleanups
----------------------------------------------------------------
Borislav Petkov (1):
KVM: Unexport kvm_debugfs_dir
Dan Carpenter (1):
KVM: Fix a goof where kvm_create_vm() returns 0 instead of -ENOMEM
David Matlack (3):
KVM: Introduce vcpu->wants_to_run
KVM: Ensure new code that references immediate_exit gets extra scrutiny
KVM: Mark a vCPU as preempted/ready iff it's scheduled out while running
Jeff Johnson (1):
KVM: Add missing MODULE_DESCRIPTION()
Julian Stecklina (1):
KVM: fix documentation rendering for KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM
Mathias Krause (4):
KVM: Reject overly excessive IDs in KVM_CREATE_VCPU
KVM: x86: Limit check IDs for KVM_SET_BOOT_CPU_ID
KVM: selftests: Test max vCPU IDs corner cases
KVM: selftests: Test vCPU boot IDs above 2^32 and MAX_VCPU_ID
Parshuram Sangle (2):
KVM: Enable halt polling shrink parameter by default
KVM: Update halt polling documentation to note that KVM has 4 module params
Sean Christopherson (8):
Revert "KVM: async_pf: avoid recursive flushing of work items"
KVM: Add a flag to track if a loaded vCPU is scheduled out
KVM: VMX: Move PLE grow/shrink helpers above vmx_vcpu_load()
KVM: x86: Fold kvm_arch_sched_in() into kvm_arch_vcpu_load()
KVM: Delete the now unused kvm_arch_sched_in()
KVM: x86: Unconditionally set l1tf_flush_l1d during vCPU load
KVM: x86: Drop now-superflous setting of l1tf_flush_l1d in vcpu_run()
KVM: x86: Prevent excluding the BSP on setting max_vcpu_ids
Yi Wang (3):
KVM: Setup empty IRQ routing when creating a VM
KVM: x86: Don't re-setup empty IRQ routing when KVM_CAP_SPLIT_IRQCHIP
KVM: s390: Don't re-setup dummy routing when KVM_CREATE_IRQCHIP
Documentation/virt/kvm/api.rst | 8 +-- Documentation/virt/kvm/halt-polling.rst | 12 ++-- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/arm.c | 2 +- arch/loongarch/include/asm/kvm_host.h | 1 - arch/loongarch/kvm/vcpu.c | 2 +- arch/mips/include/asm/kvm_host.h | 1 - arch/mips/kvm/mips.c | 2 +- arch/powerpc/include/asm/kvm_host.h | 1 - arch/powerpc/kvm/powerpc.c | 2 +- arch/riscv/include/asm/kvm_host.h | 1 - arch/riscv/kvm/vcpu.c | 2 +- arch/s390/include/asm/kvm_host.h | 1 - arch/s390/kvm/kvm-s390.c | 11 +-- arch/x86/include/asm/kvm-x86-ops.h | 1 - arch/x86/include/asm/kvm_host.h | 2 - arch/x86/kvm/irq.h | 1 - arch/x86/kvm/irq_comm.c | 7 -- arch/x86/kvm/pmu.c | 6 +- arch/x86/kvm/svm/svm.c | 11 +-- arch/x86/kvm/vmx/main.c | 2 - arch/x86/kvm/vmx/vmx.c | 80 +++++++++++----------- arch/x86/kvm/vmx/x86_ops.h | 1 - arch/x86/kvm/x86.c | 36 +++++----- include/linux/kvm_host.h | 12 ++-- include/uapi/linux/kvm.h | 15 +++- .../selftests/kvm/x86_64/max_vcpuid_cap_test.c | 22 +++++- .../testing/selftests/kvm/x86_64/set_boot_cpu_id.c | 16 +++++ virt/kvm/async_pf.c | 13 +--- virt/kvm/irqchip.c | 24 +++++++ virt/kvm/kvm_main.c | 46 +++++++++---- 31 files changed, 196 insertions(+), 146 deletions(-)
Sean Christopherson
maintainer[GIT PULL] KVM: x86: Misc changes for 6.11
In reply to Sean ChristophersonThe most notable change is the addition of the capability to allow changing KVM's emulated APIC bus frequency for TDX. Most everything else is cleanups.
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-misc-6.11
for you to fetch changes up to 82222ee7e84cb03158935e053c4c4960ac1debbd:
KVM: selftests: Add test for configure of x86 APIC bus frequency (2024-06-28 15:21:43 -0700)
----------------------------------------------------------------
KVM x86 misc changes for 6.11
- Add a global struct to consolidate tracking of host values, e.g. EFER, and move "shadow_phys_bits" into the structure as "maxphyaddr".
- Add KVM_CAP_X86_APIC_BUS_CYCLES_NS to allow configuring the effective APIC bus frequency, because TDX.
- Print the name of the APICv/AVIC inhibits in the relevant tracepoint.
- Clean up KVM's handling of vendor specific emulation to consistently act on "compatible with Intel/AMD", versus checking for a specific vendor.
- Misc cleanups
----------------------------------------------------------------
Alejandro Jimenez (2):
KVM: x86: Print names of apicv inhibit reasons in traces
KVM: x86: Keep consistent naming for APICv/AVIC inhibit reasons
Binbin Wu (1):
KVM: VMX: Remove unused declaration of vmx_request_immediate_exit()
Carlos López (1):
KVM: x86: Improve documentation for KVM_CAP_X86_BUS_LOCK_EXIT
Hou Wenlong (1):
KVM: x86: Drop unused check_apicv_inhibit_reasons() callback definition
Isaku Yamahata (4):
KVM: x86: hyper-v: Calculate APIC bus frequency for Hyper-V
KVM: x86: Make nanoseconds per APIC bus cycle a VM variable
KVM: x86: Add a capability to configure bus frequency for APIC timer
KVM: selftests: Add test for configure of x86 APIC bus frequency
Jeff Johnson (1):
KVM: x86: Add missing MODULE_DESCRIPTION() macros
Peng Hao (1):
KVM: X86: Remove unnecessary GFP_KERNEL_ACCOUNT for temporary variables
Reinette Chatre (1):
KVM: selftests: Add guest udelay() utility for x86
Sean Christopherson (12):
KVM: x86: Add a struct to consolidate host values, e.g. EFER, XCR0, etc...
KVM: SVM: Use KVM's snapshot of the host's XCR0 for SEV-ES host state
KVM: x86/mmu: Snapshot shadow_phys_bits when kvm.ko is loaded
KVM: x86: Move shadow_phys_bits into "kvm_host", as "maxphyaddr"
KVM: x86/pmu: Squash period for checkpointed events based on host HLE/RTM
KVM: x86: Apply Intel's TSC_AUX reserved-bit behavior to Intel compat vCPUs
KVM: x86: Inhibit code #DBs in MOV-SS shadow for all Intel compat vCPUs
KVM: x86: Use "is Intel compatible" helper to emulate SYSCALL in !64-bit
KVM: SVM: Emulate SYSENTER RIP/RSP behavior for all Intel compat vCPUs
KVM: x86: Allow SYSENTER in Compatibility Mode for all Intel compat vCPUs
KVM: x86: Open code vendor_intel() in string_registers_quirk()
KVM: x86: Bury guest_cpuid_is_amd_or_hygon() in cpuid.c
Thomas Prescher (1):
KVM: x86: Add KVM_RUN_X86_GUEST_MODE kvm_run flag
Documentation/virt/kvm/api.rst | 78 ++++++--- arch/x86/include/asm/kvm_host.h | 24 ++- arch/x86/include/uapi/asm/kvm.h | 1 + arch/x86/kvm/cpuid.c | 12 ++ arch/x86/kvm/cpuid.h | 18 -- arch/x86/kvm/emulate.c | 71 +++----- arch/x86/kvm/hyperv.c | 3 +- arch/x86/kvm/kvm_emulate.h | 1 + arch/x86/kvm/lapic.c | 6 +- arch/x86/kvm/lapic.h | 3 +- arch/x86/kvm/mmu.h | 27 +-- arch/x86/kvm/mmu/mmu.c | 2 +- arch/x86/kvm/mmu/spte.c | 26 ++- arch/x86/kvm/pmu.c | 2 +- arch/x86/kvm/svm/sev.c | 4 +- arch/x86/kvm/svm/svm.c | 15 +- arch/x86/kvm/svm/svm.h | 2 +- arch/x86/kvm/trace.h | 9 +- arch/x86/kvm/vmx/main.c | 2 +- arch/x86/kvm/vmx/nested.c | 8 +- arch/x86/kvm/vmx/vmx.c | 29 ++- arch/x86/kvm/vmx/vmx.h | 2 +- arch/x86/kvm/vmx/x86_ops.h | 2 - arch/x86/kvm/x86.c | 112 +++++++----- arch/x86/kvm/x86.h | 19 +- include/uapi/linux/kvm.h | 2 + tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/include/x86_64/apic.h | 8 + .../selftests/kvm/include/x86_64/processor.h | 18 ++ tools/testing/selftests/kvm/lib/x86_64/processor.c | 11 ++ .../selftests/kvm/x86_64/apic_bus_clock_test.c | 194 +++++++++++++++++++++ 31 files changed, 503 insertions(+), 209 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c
Sean Christopherson
maintainer[GIT PULL] KVM: x86: MMU changes for 6.11
In reply to Sean ChristophersonI got nothing for this one.
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-mmu-6.11
for you to fetch changes up to 0089c055b56024edf90e85dc852440b713ce8cb5:
KVM: x86/mmu: Avoid reacquiring RCU if TDP MMU fails to allocate an SP (2024-06-14 09:25:03 -0700)
----------------------------------------------------------------
KVM x86 MMU changes for 6.11
- Don't allocate kvm_mmu_page.shadowed_translation for shadow pages that can't hole leafs SPTEs.
- Unconditionally drop mmu_lock when allocating TDP MMU page tables for eager page splitting to avoid stalling vCPUs when splitting huge pages.
- Misc cleanups
----------------------------------------------------------------
David Matlack (4):
KVM: x86/mmu: Always drop mmu_lock to allocate TDP MMU SPs for eager splitting
KVM: x86/mmu: Hard code GFP flags for TDP MMU eager split allocations
KVM: x86/mmu: Unnest TDP MMU helpers that allocate SPs for eager splitting
KVM: x86/mmu: Avoid reacquiring RCU if TDP MMU fails to allocate an SP
Hou Wenlong (1):
KVM: x86/mmu: Only allocate shadowed translation cache for sp->role.level <= KVM_MAX_HUGEPAGE_LEVEL
Liang Chen (1):
KVM: x86: invalid_list not used anymore in mmu_shrink_scan
Sean Christopherson (1):
KVM: x86/mmu: Rephrase comment about synthetic PFERR flags in #PF handler
arch/x86/kvm/mmu/mmu.c | 17 ++++----- arch/x86/kvm/mmu/paging_tmpl.h | 3 +- arch/x86/kvm/mmu/tdp_mmu.c | 78 +++++++++++++----------------------------- 3 files changed, 35 insertions(+), 63 deletions(-)
Sean Christopherson
maintainer[GIT PULL] KVM: x86: Remove MTRR virtualization
In reply to Sean ChristophersonYank out KVM's MTRR virtualization, which is Intel-only and limited to very specific setups, i.e. can't possibly be useful for any real world, modern guest.
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-mtrrs-6.11
for you to fetch changes up to 377b2f359d1f71c75f8cc352b5c81f2210312d83:
KVM: VMX: Always honor guest PAT on CPUs that support self-snoop (2024-06-07 07:18:03 -0700)
----------------------------------------------------------------
KVM x86 MTRR virtualization removal
Remove support for virtualizing MTRRs on Intel CPUs, along with a nasty CR0.CD hack, and instead always honor guest PAT on CPUs that support self-snoop.
----------------------------------------------------------------
Sean Christopherson (3):
KVM: x86: Remove VMX support for virtualizing guest MTRR memtypes
KVM: VMX: Drop support for forcing UC memory when guest CR0.CD=1
KVM: VMX: Always honor guest PAT on CPUs that support self-snoop
Yan Zhao (2):
srcu: Add an API for a memory barrier after SRCU read lock
KVM: x86: Ensure a full memory barrier is emitted in the VM-Exit path
Documentation/virt/kvm/api.rst | 6 +- Documentation/virt/kvm/x86/errata.rst | 18 + arch/x86/include/asm/kvm_host.h | 15 +- arch/x86/kvm/mmu.h | 7 +- arch/x86/kvm/mmu/mmu.c | 35 +- arch/x86/kvm/mtrr.c | 644 ++-------------------------------- arch/x86/kvm/vmx/vmx.c | 40 +-- arch/x86/kvm/x86.c | 24 +- arch/x86/kvm/x86.h | 4 - include/linux/srcu.h | 14 + 10 files changed, 105 insertions(+), 702 deletions(-)
Sean Christopherson
maintainer[GIT PULL] KVM: x86: PMU changes for 6.11
In reply to Sean ChristophersonA small collection of PMU cleanups.
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-pmu-6.11
for you to fetch changes up to f287bef6ddc208cae49c8d3833aeecda47872608:
KVM: x86/pmu: Introduce distinct macros for GP/fixed counter max number (2024-06-28 09:12:16 -0700)
----------------------------------------------------------------
KVM x86/pmu changes for 6.11
- Don't advertise IA32_PERF_GLOBAL_OVF_CTRL as an MSR-to-be-saved, as it reads '0' and writes from userspace are ignored.
- Update to the newfangled Intel CPU FMS infrastructure.
- Use macros instead of open-coded literals to clean up KVM's manipulation of FIXED_CTR_CTRL MSRs.
----------------------------------------------------------------
Dapeng Mi (3):
KVM: x86/pmu: Change ambiguous _mask suffix to _rsvd in kvm_pmu
KVM: x86/pmu: Manipulate FIXED_CTR_CTRL MSR with macros
KVM: x86/pmu: Introduce distinct macros for GP/fixed counter max number
Jim Mattson (1):
KVM: x86: Remove IA32_PERF_GLOBAL_OVF_CTRL from KVM_GET_MSR_INDEX_LIST
Sean Christopherson (1):
KVM: x86/pmu: Add a helper to enable bits in FIXED_CTR_CTRL
Tony Luck (2):
KVM: x86/pmu: Switch to new Intel CPU model defines
KVM: VMX: Switch to new Intel CPU model infrastructure
arch/x86/include/asm/kvm_host.h | 30 +++++++++++++----------- arch/x86/kvm/pmu.c | 36 ++++++++++++++-------------- arch/x86/kvm/pmu.h | 10 ++++---- arch/x86/kvm/svm/pmu.c | 11 ++++----- arch/x86/kvm/vmx/pmu_intel.c | 52 +++++++++++++++++++++++------------------ arch/x86/kvm/vmx/vmx.c | 20 +++++++--------- arch/x86/kvm/x86.c | 17 ++++++++------ 7 files changed, 94 insertions(+), 82 deletions(-)
Sean Christopherson
maintainer[GIT PULL] KVM: Selftests changes for 6.11
In reply to Sean ChristophersonA handful of random selftests changes. Props to Maxim for figuring out a way to fix the PMU counters test.
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-selftests-6.11
for you to fetch changes up to 4669de42aa6c78669975d58c92433cdedeb7c2c3:
KVM: selftests: Increase robustness of LLC cache misses in PMU counters test (2024-06-28 08:44:03 -0700)
----------------------------------------------------------------
KVM selftests for 6.11
- Remove dead code in the memslot modification stress test.
- Treat "branch instructions retired" as supported on all AMD Family 17h+ CPUs.
- Print the guest pseudo-RNG seed only when it changes, to avoid spamming the log for tests that create lots of VMs.
- Make the PMU counters test less flaky when counting LLC cache misses by doing CLFLUSH{OPT} in every loop iteration.
----------------------------------------------------------------
Dr. David Alan Gilbert (1):
KVM: selftests: remove unused struct 'memslot_antagonist_args'
Manali Shukla (1):
KVM: selftests: Treat AMD Family 17h+ as supporting branch insns retired
Maxim Levitsky (1):
KVM: selftests: Increase robustness of LLC cache misses in PMU counters test
Sean Christopherson (2):
KVM: selftests: Print the seed for the guest pRNG iff it has changed
KVM: selftests: Rework macros in PMU counters test to prep for multi-insn loop
tools/testing/selftests/kvm/lib/kvm_util.c | 9 ++++- .../kvm/memslot_modification_stress_test.c | 6 --- .../selftests/kvm/x86_64/pmu_counters_test.c | 44 ++++++++++++++-------- .../selftests/kvm/x86_64/pmu_event_filter_test.c | 35 +++-------------- 4 files changed, 41 insertions(+), 53 deletions(-)
Sean Christopherson
maintainer[GIT PULL (sort of)] KVM: x86: Static call changes for 6.11
In reply to Sean ChristophersonHere's a massage pull request for the static_call() changes, just in case you want to go this route instead of applying patches directly after merging everything else for 6.11 (it was easy to generate this). If you want to go the patches route, I'll post 'em next week.
The following changes since commit c1c8a908a5f4c372f8a8dca0501b56ffc8d260fe:
Merge branch 'vmx' (2024-06-28 22:22:53 +0000)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-static_calls-6.11
for you to fetch changes up to b528de209c858f61953023b405a4abbf9a9933da:
KVM: x86/pmu: Add kvm_pmu_call() to simplify static calls of kvm_pmu_ops (2024-06-28 15:23:49 -0700)
----------------------------------------------------------------
KVM x86 static_call() cleanup for 6.11
Add kvm_x86_call() and kvm_pmu_call() wrappers for KVM's static_call() usage to improve readability and make it easier to connect the calls to the vendor implementations.
----------------------------------------------------------------
Wei Wang (3):
KVM: x86: Replace static_call_cond() with static_call()
KVM: x86: Introduce kvm_x86_call() to simplify static calls of kvm_x86_ops
KVM: x86/pmu: Add kvm_pmu_call() to simplify static calls of kvm_pmu_ops
arch/x86/include/asm/kvm_host.h | 11 +++-- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/hyperv.c | 6 +-- arch/x86/kvm/irq.c | 2 +- arch/x86/kvm/kvm_cache_regs.h | 10 ++--- arch/x86/kvm/lapic.c | 42 +++++++++--------- arch/x86/kvm/lapic.h | 2 +- arch/x86/kvm/mmu.h | 6 +-- arch/x86/kvm/mmu/mmu.c | 6 +-- arch/x86/kvm/mmu/spte.c | 4 +- arch/x86/kvm/pmu.c | 29 ++++++------ arch/x86/kvm/smm.c | 44 +++++++++--------- arch/x86/kvm/trace.h | 15 ++++--- arch/x86/kvm/x86.c | 324 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------- arch/x86/kvm/x86.h | 2 +- arch/x86/kvm/xen.c | 4 +- 16 files changed, 261 insertions(+), 248 deletions(-)
Paolo Bonzini
maintainerRe: [GIT PULL (sort of)] KVM: x86: Static call changes for 6.11
Quoted 9 lines · Sean Christopherson
Here's a massage pull request for the
static_call()changes, just in case you want to go this route instead of applying patches directly after merging everything else for 6.11 (it was easy to generate this). If you want to go the patches route, I'll post 'em next week.The following changes since commit
c1c8a908a5f4c372f8a8dca0501b56ffc8d260fe:Merge branch 'vmx' (2024-06-28 22:22:53 +0000)
Quoted 7 lines
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-static_calls-6.11for you to fetch changes up to
b528de209c858f61953023b405a4abbf9a9933da:KVM: x86/pmu: Add kvm_pmu_call() to simplify static calls of kvm_pmu_ops (2024-06-28 15:23:49 -0700)
Thanks, indeed there was no straggler static_call() after applying this. However, there might be a problem: static_call_cond() is equal to static_call() only if CONFIG_HAVE_STATIC_CALL_INLINE, and arch/x86 has this:
select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL
select HAVE_OBJTOOL if X86_64
And indeed if I apply
arch/x86/kvm/Kconfig +2 -0
@@ -21,6 +21,8 @@ config KVM tristate "Kernel-based Virtual Machine (KVM) support" depends on HIGH_RES_TIMERS depends on X86_LOCAL_APIC + # KVM relies on static_call_cond() being the same as static_call() + depends on HAVE_STATIC_CALL_INLINE select KVM_COMMON select KVM_GENERIC_MMU_NOTIFIER select HAVE_KVM_IRQCHIP
KVM disappears from 32-bit kernels. :) So I haven't checked but I suspect this breaks 32-bit?
Paolo
Sean Christopherson
maintainerRe: [GIT PULL (sort of)] KVM: x86: Static call changes for 6.11
Quoted 14 lines · Paolo Bonzini
Quoted 13 lines · Sean Christopherson
Here's a massage pull request for the
static_call()changes, just in case you want to go this route instead of applying patches directly after merging everything else for 6.11 (it was easy to generate this). If you want to go the patches route, I'll post 'em next week.The following changes since commit
c1c8a908a5f4c372f8a8dca0501b56ffc8d260fe:Merge branch 'vmx' (2024-06-28 22:22:53 +0000)are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-static_calls-6.11
Quoted 7 lines
Quoted 3 lines
for you to fetch changes up to
b528de209c858f61953023b405a4abbf9a9933da:KVM: x86/pmu: Add kvm_pmu_call() to simplify static calls of kvm_pmu_ops (2024-06-28 15:23:49 -0700)Thanks, indeed there was no straggler
static_call()after applying this. However, there might be a problem:static_call_cond()is equal tostatic_call()only ifCONFIG_HAVE_STATIC_CALL_INLINE,
No, I think you misread the #if-#elif-#else. It's only the !HAVE_STATIC_CALL case that requires use of static_call_cond(). From include/linux/static_call.h:
#ifdef CONFIG_HAVE_STATIC_CALL_INLINE #define static_call_cond(name) (void)__static_call(name) #elif defined(CONFIG_HAVE_STATIC_CALL) #define static_call_cond(name) (void)__static_call(name) #else #define static_call_cond(name) (void)__static_call_cond(name) #endif
And per Josh, from an old RFC[*] to yank out static_call_cond():
: Static calling a NULL pointer is a NOP, unless you're one of those poor : souls running on an arch (or backported x86 monstrosity) with : CONFIG_HAVE_STATIC_CALL=n, then it's a panic.
I double checked that 32-bit KVM works on Intel (which is guaranteed to have a NULL guest_memory_reclaimed()). I also verified that the generated code is identical for both static_call() and static_call_cond(), i.e. the READ_ONCE() of the func at runtime that's present in __static_call_cond() isn't showing up.
Dump of assembler code for function kvm_arch_guest_memory_reclaimed:
0xc1042094 <+0>: call 0xc10ce650 <__fentry__> 0xc1042099 <+5>: push %ebp 0xc104209a <+6>: mov %esp,%ebp 0xc104209c <+8>: call 0xc1932d8c <__SCT__kvm_x86_guest_memory_reclaimed>
0xc10420a1 <+13>: pop %ebp
0xc10420a2 <+14>: ret
End of assembler dump.
Dump of assembler code for function __SCT__kvm_x86_guest_memory_reclaimed:
0xc1932d8c <+0>: ret
0xc1932d8d <+1>: int3
0xc1932d8e <+2>: nop
0xc1932d8f <+3>: nop
0xc1932d90 <+4>: nop
0xc1932d91 <+5>: ud1 %esp,%ecx
End of assembler dump.
Paolo Bonzini
maintainerRe: [GIT PULL (sort of)] KVM: x86: Static call changes for 6.11
Quoted 2 lines · Sean Christopherson
No, I think you misread the #if-#elif-#else. It's only the !HAVE_STATIC_CALL case that requires use of
static_call_cond().
Oh, of course - the "select HAVE_STATIC_CALL" is right above the "select
HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL" line. I was definitely
overthinking it.
Paolo
Sean Christopherson
maintainer[GIT PULL] KVM: x86: SVM changes for 6.11
In reply to Sean ChristophersonAnother small pull request. Embarrasingly, I'm pretty sure Google has been carrying a patch to make the per-CPU allocation NUMA-aware for many years :-(
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-svm-6.11
for you to fetch changes up to 704ec48fc2fbd4e41ec982662ad5bf1eee33eeb2:
KVM: SVM: Use sev_es_host_save_area() helper when initializing tsc_aux (2024-06-28 08:53:00 -0700)
----------------------------------------------------------------
KVM SVM changes for 6.11
- Make per-CPU save_area allocations NUMA-aware.
- Force sev_es_host_save_area() to be inlined to avoid calling into an instrumentable function from noinstr code.
----------------------------------------------------------------
Li RongQing (3):
KVM: SVM: remove useless input parameter in snp_safe_alloc_page
KVM: SVM: not account memory allocation for per-CPU svm_data
KVM: SVM: Consider NUMA affinity when allocating per-CPU save_area
Sean Christopherson (2):
KVM: SVM: Force sev_es_host_save_area() to be inlined (for noinstr usage)
KVM: SVM: Use sev_es_host_save_area() helper when initializing tsc_aux
arch/x86/kvm/svm/nested.c | 2 +- arch/x86/kvm/svm/sev.c | 6 +++--- arch/x86/kvm/svm/svm.c | 23 ++++++++++------------- arch/x86/kvm/svm/svm.h | 18 +++++++++++++++--- 4 files changed, 29 insertions(+), 20 deletions(-)
Sean Christopherson
maintainer[GIT PULL] KVM: x86: VMX changes for 6.11
In reply to Sean ChristophersonThe highlight is a largish series to fix nested posted interrupt detection. The series hasn't gotten any reviews, so if you have time to take a closer look, it would be appreciated.
The following changes since commit 02b0d3b9d4dd1ef76b3e8c63175f1ae9ff392313:
Merge branch 'kvm-6.10-fixes' into HEAD (2024-06-20 17:31:50 -0400)
are available in the Git repository at:
https://github.com/kvm-x86/linux.git tags/kvm-x86-vmx-6.11
for you to fetch changes up to 45405155d876c326da89162b8173b8cc9ab7ed75:
KVM: x86: WARN if a vCPU gets a valid wakeup that KVM can't yet inject (2024-06-28 08:59:07 -0700)
----------------------------------------------------------------
KVM VMX changes for 6.11
- Remove an unnecessary EPT TLB flush when enabling hardware.
- Fix a series of bugs that cause KVM to fail to detect nested pending posted interrupts as valid wake eents for a vCPU executing HLT in L2 (with HLT-exiting disable by L1).
- Misc cleanups
----------------------------------------------------------------
Kai Huang (1):
KVM: VMX: Switch __vmx_exit() and kvm_x86_vendor_exit() in vmx_exit()
Sean Christopherson (8):
KVM: nVMX: Update VMCS12_REVISION comment to state it should never change
KVM: VMX: Remove unnecessary INVEPT[GLOBAL] from hardware enable path
KVM: nVMX: Add a helper to get highest pending from Posted Interrupt vector
KVM: nVMX: Request immediate exit iff pending nested event needs injection
KVM: VMX: Split out the non-virtualization part of vmx_interrupt_blocked()
KVM: nVMX: Check for pending posted interrupts when looking for nested events
KVM: nVMX: Fold requested virtual interrupt check into has_nested_events()
KVM: x86: WARN if a vCPU gets a valid wakeup that KVM can't yet inject
arch/x86/include/asm/kvm-x86-ops.h | 1 - arch/x86/include/asm/kvm_host.h | 3 +-- arch/x86/kvm/vmx/main.c | 1 - arch/x86/kvm/vmx/nested.c | 47 ++++++++++++++++++++++++++++++++++---- arch/x86/kvm/vmx/posted_intr.h | 10 ++++++++ arch/x86/kvm/vmx/vmcs12.h | 14 +++++++----- arch/x86/kvm/vmx/vmx.c | 38 ++++++++---------------------- arch/x86/kvm/vmx/vmx.h | 1 + arch/x86/kvm/vmx/x86_ops.h | 1 - arch/x86/kvm/x86.c | 19 ++++++--------- 10 files changed, 79 insertions(+), 56 deletions(-)