summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/cpuid.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-03-05 16:11:56 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2020-03-16 17:58:45 +0100
commit408e9a318f57ba8be82ba01e98cc271b97392187 (patch)
tree1730689c6284511cbbe6e5f8545eb3f46114b5c6 /arch/x86/kvm/cpuid.c
parent257038745cae1fdaa3948013a22eba3b1d610174 (diff)
KVM: CPUID: add support for supervisor states
Current CPUID 0xd enumeration code does not support supervisor states, because KVM only supports setting IA32_XSS to zero. Change it instead to use a new variable supported_xss, to be set from the hardware_setup callback which is in charge of CPU capabilities. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/cpuid.c')
-rw-r--r--arch/x86/kvm/cpuid.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index cc8b24b4d8f3..78d461be2102 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -642,15 +642,22 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
cpuid_entry_override(entry, CPUID_D_1_EAX);
if (entry->eax & (F(XSAVES)|F(XSAVEC)))
- entry->ebx = xstate_required_size(supported_xcr0, true);
- else
+ entry->ebx = xstate_required_size(supported_xcr0 | supported_xss,
+ true);
+ else {
+ WARN_ON_ONCE(supported_xss != 0);
entry->ebx = 0;
- /* Saving XSS controlled state via XSAVES isn't supported. */
- entry->ecx = 0;
- entry->edx = 0;
+ }
+ entry->ecx &= supported_xss;
+ entry->edx &= supported_xss >> 32;
for (i = 2; i < 64; ++i) {
- if (!(supported_xcr0 & BIT_ULL(i)))
+ bool s_state;
+ if (supported_xcr0 & BIT_ULL(i))
+ s_state = false;
+ else if (supported_xss & BIT_ULL(i))
+ s_state = true;
+ else
continue;
entry = do_host_cpuid(array, function, i);
@@ -659,17 +666,16 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
/*
* The supported check above should have filtered out
- * invalid sub-leafs as well as sub-leafs managed by
- * IA32_XSS MSR. Only XCR0-managed sub-leafs should
+ * invalid sub-leafs. Only valid sub-leafs should
* reach this point, and they should have a non-zero
- * save state size.
+ * save state size. Furthermore, check whether the
+ * processor agrees with supported_xcr0/supported_xss
+ * on whether this is an XCR0- or IA32_XSS-managed area.
*/
- if (WARN_ON_ONCE(!entry->eax || (entry->ecx & 1))) {
+ if (WARN_ON_ONCE(!entry->eax || (entry->ecx & 0x1) != s_state)) {
--array->nent;
continue;
}
-
- entry->ecx = 0;
entry->edx = 0;
}
break;