KVM: CPUID: Fix IA32_XSS support in CPUID(0xd,i) enumeration
PATCH 1/1 KVM: CPUID: Fix IA32_XSS support in CPUID(0xd,i) enumeration
The control bits in IA32_XSS MSR are being used for new features, but current CPUID(0xd,i) enumeration code doesn't support them, so fix existing code first.
The supervisor states in IA32_XSS haven't been used in public KVM code, so set KVM_SUPPORTED_XSS to 0 now, anyone who's developing IA32_XSS related feature may expand the macro to add the CPUID support, otherwise, CPUID(0xd,i>1) always reports 0 of the subleaf to guest.
Extracted old code into a new filter and keep it same flavor as others.
This patch passed selftest on a few Intel platforms.
Suggested-by Sean Christopherson <[email protected]>
Signed-off-by Yang Weijiang <[email protected]>
--- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/cpuid.c | 94 +++++++++++++++++++++------------ arch/x86/kvm/svm.c | 7 +++ arch/x86/kvm/vmx/vmx.c | 6 +++ arch/x86/kvm/x86.h | 7 +++ 5 files changed, 82 insertions(+), 33 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -0
@@ -1209,6 +1209,7 @@ struct kvm_x86_ops {uint16_t (*nested_get_evmcs_version)(struct kvm_vcpu *vcpu);bool (*need_emulation_on_page_fault)(struct kvm_vcpu *vcpu); +u64 (*supported_xss)(void); };struct kvm_arch_async_pf {
arch/x86/kvm/cpuid.c +61 -33
128 lines not on this page · raw message
arch/x86/kvm/svm.c +7 -0
@@ -7193,6 +7193,11 @@ static bool svm_need_emulation_on_page_fault(struct kvm_vcpu *vcpu)return false; } +static u64 svm_supported_xss (void ) +{ +return 0 ; +} +static struct kvm_x86_ops svm_x86_ops__ro_after_init = { .cpu_has_kvm_support = has_svm, .disabled_by_bios = is_disabled,
@@ -7329,6 +7334,8 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = { .nested_get_evmcs_version = NULL, .need_emulation_on_page_fault = svm_need_emulation_on_page_fault, + + .supported_xss = svm_supported_xss, };static int __init svm_init (void )
arch/x86/kvm/vmx/vmx.c +6 -0
@@ -1651,6 +1651,11 @@ static inline bool vmx_feature_control_msr_valid(struct kvm_vcpu *vcpu,return !(val & ~valid_bits); } +static inline u64 vmx_supported_xss (void ) +{ +return host_xss; +} +static int vmx_get_msr_feature (struct kvm_msr_entry *msr) {switch (msr->index) {
@@ -7799,6 +7804,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { .nested_enable_evmcs = NULL, .nested_get_evmcs_version = NULL, .need_emulation_on_page_fault = vmx_need_emulation_on_page_fault, + .supported_xss = vmx_supported_xss, };static void vmx_cleanup_l1d_flush (void )
arch/x86/kvm/x86.h +7 -0
@@ -293,6 +293,13 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2, | XFEATURE_MASK_YMM | XFEATURE_MASK_BNDREGS \ | XFEATURE_MASK_BNDCSR | XFEATURE_MASK_AVX512 \ | XFEATURE_MASK_PKRU) + +/* +* Right now, no XSS states are used on x86 platform, +* expand the macro for new features. +*/ +#define KVM_SUPPORTED_XSS (0) +extern u64 host_xcr0;extern u64 kvm_supported_xcr0 (void );
Signature · 1 line
2.17.2