kvm: x86: mask out XSAVES
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 21 Nov 2014 17:13:26 +0000 (18:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Jan 2015 14:59:49 +0000 (06:59 -0800)
commit b65d6e17fe2239c9b2051727903955d922083fbf upstream.

This feature is not supported inside KVM guests yet, because we do not emulate
MSR_IA32_XSS.  Mask it out.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/cpuid.c

index 976e3a57f9eaa0bc178e4a65b45531507f0416b4..88f92014ba6be27cd4d0cea4593b42af0a5a0bc7 100644 (file)
@@ -319,6 +319,10 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
                F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) |
                F(ADX) | F(SMAP);
 
+       /* cpuid 0xD.1.eax */
+       const u32 kvm_supported_word10_x86_features =
+               F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1);
+
        /* all calls to cpuid_count() should be made on the same cpu */
        get_cpu();
 
@@ -455,13 +459,18 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
                entry->eax &= supported;
                entry->edx &= supported >> 32;
                entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
+               if (!supported)
+                       break;
+
                for (idx = 1, i = 1; idx < 64; ++idx) {
                        u64 mask = ((u64)1 << idx);
                        if (*nent >= maxnent)
                                goto out;
 
                        do_cpuid_1_ent(&entry[i], function, idx);
-                       if (entry[i].eax == 0 || !(supported & mask))
+                       if (idx == 1)
+                               entry[i].eax &= kvm_supported_word10_x86_features;
+                       else if (entry[i].eax == 0 || !(supported & mask))
                                continue;
                        entry[i].flags |=
                               KVM_CPUID_FLAG_SIGNIFCANT_INDEX;