WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] x86: check CPUID level before enabling xsave

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] x86: check CPUID level before enabling xsave
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Fri, 24 Sep 2010 13:00:01 +0100
Delivery-date: Fri, 24 Sep 2010 05:00:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
While not as relevant after c/s 21894, is still seems safer to check
the CPUID level here, just like Linux does. The is particularly
relevant for the 4.0 tree (which doesn't have said c/s), but also
possibly for nested environments where writing MSR_IA32_MISC_ENABLE
may not actually take effect (Xen itself ignores such writes).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 2010-09-20.orig/xen/arch/x86/i387.c 2009-10-01 10:53:02.000000000 +0200
+++ 2010-09-20/xen/arch/x86/i387.c      2010-09-24 13:30:25.000000000 +0200
@@ -132,6 +132,8 @@ void restore_fpu(struct vcpu *v)
     }
 }
 
+#define XSTATE_CPUID 0xd
+
 /*
  * Maximum size (in byte) of the XSAVE/XRSTOR save area required by all
  * the supported and enabled features on the processor, including the
@@ -148,7 +150,12 @@ void xsave_init(void)
     int cpu = smp_processor_id();
     u32 min_size;
 
-    cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx);
+    if ( boot_cpu_data.cpuid_level < XSTATE_CPUID ) {
+        printk(XENLOG_ERR "XSTATE_CPUID missing\n");
+        return;
+    }
+
+    cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx);
 
     printk("%s: cpu%d: cntxt_max_size: 0x%x and states: %08x:%08x\n",
         __func__, cpu, ecx, edx, eax);
@@ -169,7 +176,7 @@ void xsave_init(void)
      */
     set_in_cr4(X86_CR4_OSXSAVE);
     set_xcr0(eax & XCNTXT_MASK);
-    cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx);
+    cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx);
     clear_in_cr4(X86_CR4_OSXSAVE);
 
     if ( cpu == 0 )



Attachment: x86-xsave-cpuid.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] x86: check CPUID level before enabling xsave, Jan Beulich <=