Skip to contentSkip to conversation

xsave: move xsave initialization code to a common place

PATCH New Wei Huang 1 participant 1 message Oct 24, 2011

lore
Share & tools
lore

Wei Huang

author
#0 lore raw

PATCH 1/1 xsave: move xsave initialization code to a common place

Please apply this patch to xen-4.0 tree.

This patch moves xsave option setting and initilization to CPU common file. Without this Xen would crash on __context_switch() on xsave-capable AMD CPUs. The crash was due to cpu_has_xsave reports true in domain.c while xsave space wasn't initialized. This patch is adopted from xen upstream.

# HG changeset patch
# User Wei Huang <[email protected]>
# Date 1319469115 18000
# Branch patches
# Node ID c863dbcd714987ca8f1ab93ffbf61ea64b394f23 # Parent 71b96c0b083f3de46f566a406e0aee16a427950f
xsave: Move xsave initialization code to a common place

This patch moves xsave option setting and initilization to CPU common file. Without this Xen would crash on __context_switch() on xsave-capable AMD CPUs. The crash was due to cpu_has_xsave reports true in domain.c while xsave space wasn't initialized. This patch is adopted from xen upstream.

xen/arch/x86/cpu/common.c +10 -0
diff -r 71b96c0b083f -r c863dbcd7149 xen/arch/x86/cpu/common.c
@@ -22,6 +22,9 @@
 static int disable_x86_fxsr __cpuinitdata;
 static int disable_x86_serial_nr __cpuinitdata;
 
+static int use_xsave;
+boolean_param("xsave", use_xsave);
+
 struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
 
 /*
@@ -391,6 +394,13 @@
 	if (this_cpu->c_init)
 		this_cpu->c_init(c);
 
+        /* Initialize xsave/xrstor features */
+	if ( !use_xsave )
+		clear_bit(X86_FEATURE_XSAVE, boot_cpu_data.x86_capability);
+
+	if ( cpu_has_xsave )
+		xsave_init();
+
 	/* Disable the PN if appropriate */
 	squash_the_stupid_serial_number(c);
 
xen/arch/x86/cpu/intel.c +0 -9
diff -r 71b96c0b083f -r c863dbcd7149 xen/arch/x86/cpu/intel.c
@@ -30,9 +30,6 @@
 integer_param("cpuid_mask_ecx", opt_cpuid_mask_ecx);
 integer_param("cpuid_mask_edx", opt_cpuid_mask_edx);
 
-static int use_xsave;
-boolean_param("xsave", use_xsave);
-
 #ifdef CONFIG_X86_INTEL_USERCOPY
 /*
  * Alignment at which movsl is preferred for bulk memory copies.
@@ -219,12 +216,6 @@
 		set_bit(X86_FEATURE_ARAT, c->x86_capability);
 
 	start_vmx();
-
-	if ( !use_xsave )
-		clear_bit(X86_FEATURE_XSAVE, boot_cpu_data.x86_capability);
-
-	if ( cpu_has_xsave )
-		xsave_init();
 }
 
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel