KVM: SVM: Do not report xsave in supported cpuid
authorJoerg Roedel <joerg.roedel@amd.com>
Tue, 7 Dec 2010 16:15:05 +0000 (17:15 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 7 Jan 2011 21:58:46 +0000 (13:58 -0800)
commit 24d1b15f72abe3465e871d11cfc9dc34d1aab8b2 upstream.

To support xsave properly for the guest the SVM module need
software support for it. As long as this is not present do
not report the xsave as supported feature in cpuid.
As a side-effect this patch moves the bit() helper function
into the x86.h file so that it can be used in svm.c too.

KVM-Stable-Tag.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c
arch/x86/kvm/x86.h

index 89055e00213713bcd5b7cd019c101f6b5b54a042..e7c3f3bd08fc8730c3c22721b4c430f5c7ea4fbd 100644 (file)
@@ -3383,6 +3383,10 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu)
 static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
 {
        switch (func) {
+       case 0x00000001:
+               /* Mask out xsave bit as long as it is not supported by SVM */
+               entry->ecx &= ~(bit(X86_FEATURE_XSAVE));
+               break;
        case 0x80000001:
                if (nested)
                        entry->ecx |= (1 << 2); /* Set SVM bit */
index f23f725dfd8c9be11bc18a528b247ea3855cf401..b3986fec7e681e79a74e96132ef49d539d5ba71d 100644 (file)
@@ -4248,11 +4248,6 @@ static int vmx_get_lpage_level(void)
                return PT_PDPE_LEVEL;
 }
 
-static inline u32 bit(int bitno)
-{
-       return 1 << (bitno & 31);
-}
-
 static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
 {
        struct kvm_cpuid_entry2 *best;
index 3f2d2b3b4d852eaa5683431952035901879bdd67..fd9911b9e38bc464cf1b4a51726bd7b9b243a4da 100644 (file)
@@ -153,11 +153,6 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
 
 u64 __read_mostly host_xcr0;
 
-static inline u32 bit(int bitno)
-{
-       return 1 << (bitno & 31);
-}
-
 static void kvm_on_user_return(struct user_return_notifier *urn)
 {
        unsigned slot;
index b7a404722d2b791efa2a9ae12d636ec2e5fd0a83..0bf32745349943615ee410861cbca90e6587e8c6 100644 (file)
@@ -65,6 +65,11 @@ static inline int is_paging(struct kvm_vcpu *vcpu)
        return kvm_read_cr0_bits(vcpu, X86_CR0_PG);
 }
 
+static inline u32 bit(int bitno)
+{
+       return 1 << (bitno & 31);
+}
+
 void kvm_before_handle_nmi(struct kvm_vcpu *vcpu);
 void kvm_after_handle_nmi(struct kvm_vcpu *vcpu);