KVM: x86: Purge kvm_x86_ops->*_supported()
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest26 patches 14 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/26 | KVM: x86: Remove superfluous brackets from case statementarch/ | +2 | 2 replies | |
| 2/26 | KVM: x86: Take an unsigned 32-bit int for has_emulated_msr()'s indexarch/ arch/ arch/ | +3 | 1 reply | |
| 3/26 | KVM: x86: Snapshot MSR index in a local variable when processing listsarch/ | +13 | 1 reply | |
| 4/26 | KVM: x86: Add a kvm_x86_ops hook to query virtualized MSR supportarch/ arch/ arch/ +1 more | +15 | 7 replies | |
| 5/26 | KVM: x86: Move MSR_TSC_AUX existence checks into vendor codearch/ arch/ arch/ | +14 | 1 reply | |
| 6/26 | KVM: x86: Move MSR_IA32_BNDCFGS existence checks into vendor codearch/ arch/ arch/ | +4 | 1 reply | |
| 7/26 | KVM: VMX: Add helpers to query Intel PT modearch/ arch/ arch/ +1 more | +34 | 0 replies | |
| 8/26 | KVM: x86: Move RTIT (Intel PT) MSR existence checks into vendor codearch/ arch/ arch/ | +22 | 0 replies | |
| 9/26 | KVM: x86: Calculate the supported xcr0 mask at load timearch/ arch/ arch/ +2 more | +20 | 0 replies | |
| 10/26 | KVM: x86: Use supported_xcr0 to detect MPX supportarch/ arch/ arch/ +2 more | +4 | 0 replies | |
| 11/26 | KVM: x86: Make kvm_mpx_supported() an inline functionarch/ arch/ arch/ | +5 | 0 replies | |
| 12/26 | KVM: x86: Drop explicit @func param from ->set_supported_cpuid()arch/ arch/ arch/ +1 more | +6 | 0 replies | |
| 13/26 | KVM: x86: Use u32 for holding CPUID register value in helpersarch/ | +3 | 0 replies | |
| 14/26 | KVM: x86: Introduce cpuid_entry_{get,has}() accessorsarch/ arch/ | +42 | 0 replies | |
| 15/26 | KVM: x86: Introduce cpuid_entry_{change,set,clear}() mutatorsarch/ arch/ arch/ | +62 | 0 replies | |
| 16/26 | KVM: x86: Add Kconfig-controlled auditing of reverse CPUID lookupsarch/ arch/ | +15 | 0 replies | |
| 17/26 | KVM: x86: Handle MPX CPUID adjustment in vendor codearch/ arch/ arch/ | +16 | 0 replies | |
| 18/26 | KVM: x86: Handle INVPCID CPUID adjustment in vendor codearch/ arch/ arch/ +1 more | +5 | 0 replies | |
| 19/26 | KVM: x86: Handle UMIP emulation CPUID adjustment in VMX codearch/ arch/ | +3 | 0 replies | |
| 20/26 | KVM: x86: Handle PKU CPUID adjustment in SVM codearch/ arch/ arch/ +2 more | +2 | 0 replies | |
| 21/26 | KVM: x86: Handle RDTSCP CPUID adjustment in VMX codearch/ arch/ arch/ +1 more | +5 | 0 replies | |
| 22/26 | KVM: x86: Handle XSAVES CPUID adjustment in VMX codearch/ arch/ arch/ +1 more | +15 | 0 replies | |
| 23/26 | KVM: x86: Handle Intel PT CPUID adjustment in vendor codearch/ arch/ arch/ | +4 | 0 replies | |
| 24/26 | KVM: x86: Clear output regs for CPUID 0x14 if PT isn't exposed to guestarch/ | +3 | 0 replies | |
| 25/26 | KVM: x86: Handle main Intel PT CPUID leaf in vendor codearch/ arch/ arch/ | +23 | 1 reply | |
| 26/26 | KVM: VMX: Directly query Intel PT mode when refreshing PMUsarch/ arch/ arch/ +2 more | +4 | 0 replies |
Reviews trailers per patch
6 of 26 patches have a Reviewed-by or Acked-by.
| Patch | Vitaly Kuznetsov |
|---|---|
| 1/26 | R-b |
| 2/26 | R-b |
| 3/26 | R-b |
| 4/26 | R-b |
| 5/26 | R-b |
| 6/26 | R-b |
| 7/26 | |
| 8/26 | |
| 9/26 | |
| 10/26 | |
| 11/26 | |
| 12/26 | |
| 13/26 | |
| 14/26 | |
| 15/26 | |
| 16/26 | |
| 17/26 | |
| 18/26 | |
| 19/26 | |
| 20/26 | |
| 21/26 | |
| 22/26 | |
| 23/26 | |
| 24/26 | |
| 25/26 | |
| 26/26 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 00/26] KVM: x86: Purge kvm_x86_ops->*_supported()
Our benevolent dictator decreed that "all *_supported() should be removed, and the code moved from __do_cpuid_func() to set_supported_cpuid"[*].
To make that happen, move CPUID and MSR checks from x86 into SVM/VMX via the existing ->set_supported_cpuid() and a ->new has_virtualized_msr() ops respectively.
As usual, there's a fair amount of cleanup in between the mechanical changes. Most notable is the introduction of cpuid entry accessors and mutators to replace all of the code to manipulate individual feature bits in cpuid entries, which is error prone and annoying. MPX (*sigh*) also gets a healthly dose of cleanup.
I don't love every patch in this series. Specifically, adding an extra call to ->set_supported_cpuid() to handle XSAVES is ugly. But, I do like that it purges all ->*_supported() hooks. And practically speaking, odds are good that CPUID 0xD.1 will get more feature bits, i.e. keeping ->xsaves_supported() would likely lead to another ->*_supported() hook.
Paolo also expressed a dislike for clearing bits in set_supported_cpuid(). I don't have a strong opinion regarding clearing bits, but the alternative approach, i.e. leave the bits clear and then set them in vendor code, gets quite kludgy because the vendor code (mostly VMX) would need to manually recheck boot_cpu_data to ensure it wasn't advertising a feature that the user/kernel expressly disabled. IMO, forcing manual checks is more likely to introduce errors and provides less insight into why VMX needs to adjust the advertised CPUID values (VMCS != CPUID).
Tested on Intel by verifying the output of KVM_GET_SUPPORTED_CPUID is identical before and after (on almost every patch) on a Haswell and Coffee Lake. The big untested pieces are PKU and PT on Intel, and everything AMD.
[*] https://lkml.kernel.org/r/[email protected]
Sean Christopherson (26):
KVM: x86: Remove superfluous brackets from case statement
KVM: x86: Take an unsigned 32-bit int for has_emulated_msr()'s index
KVM: x86: Snapshot MSR index in a local variable when processing lists
KVM: x86: Add a kvm_x86_ops hook to query virtualized MSR support
KVM: x86: Move MSR_TSC_AUX existence checks into vendor code
KVM: x86: Move MSR_IA32_BNDCFGS existence checks into vendor code
KVM: VMX: Add helpers to query Intel PT mode
KVM: x86: Move RTIT (Intel PT) MSR existence checks into vendor code
KVM: x86: Calculate the supported xcr0 mask at load time
KVM: x86: Use supported_xcr0 to detect MPX support
KVM: x86: Make kvm_mpx_supported() an inline function
KVM: x86: Drop explicit @func param from ->set_supported_cpuid()
KVM: x86: Use u32 for holding CPUID register value in helpers
KVM: x86: Introduce cpuid_entry_{get,has}() accessors
KVM: x86: Introduce cpuid_entry_{change,set,clear}() mutators
KVM: x86: Add Kconfig-controlled auditing of reverse CPUID lookups
KVM: x86: Handle MPX CPUID adjustment in vendor code
KVM: x86: Handle INVPCID CPUID adjustment in vendor code
KVM: x86: Handle UMIP emulation CPUID adjustment in VMX code
KVM: x86: Handle PKU CPUID adjustment in SVM code
KVM: x86: Handle RDTSCP CPUID adjustment in VMX code
KVM: x86: Handle XSAVES CPUID adjustment in VMX code
KVM: x86: Handle Intel PT CPUID adjustment in vendor code
KVM: x86: Clear output regs for CPUID 0x14 if PT isn't exposed to
guest
KVM: x86: Handle main Intel PT CPUID leaf in vendor code
KVM: VMX: Directly query Intel PT mode when refreshing PMUs
arch/x86/include/asm/kvm_host.h | 12 +-- arch/x86/kvm/Kconfig | 10 +++ arch/x86/kvm/cpuid.c | 147 +++++++++++++------------------- arch/x86/kvm/cpuid.h | 85 +++++++++++++++--- arch/x86/kvm/svm.c | 88 ++++++++++--------- arch/x86/kvm/vmx/capabilities.h | 25 ++++-- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/vmx/pmu_intel.c | 2 +- arch/x86/kvm/vmx/vmx.c | 119 ++++++++++++++++++-------- arch/x86/kvm/vmx/vmx.h | 4 +- arch/x86/kvm/x86.c | 76 +++++++---------- arch/x86/kvm/x86.h | 10 +-- 12 files changed, 331 insertions(+), 249 deletions(-)
Signature · 1 line
2.24.1