From: Wei Huang Subject: [PATCH 1/3] HVM: Support XSAVE/XRSTOR and AVX for AMD CPUs Date: Fri, 3 Dec 2010 09:43:34 -0600 Message-ID: <1291391014.1867.26.camel@weilaptop> Reply-To: wei.huang2@amd.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-Kb6f/2XaWmoaok4UNlA8" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: keir@xen.org List-Id: xen-devel@lists.xenproject.org --=-Kb6f/2XaWmoaok4UNlA8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Move xsave initialization code to a common place This patch moves xsave/xrstor code to CPU common file. First of all, it prepares xsave/xrstor support for AMD CPUs. Secondly, Xen would crash on __context_switch() without this patch on xsave-capable AMD CPUs. The crash was due to cpu_has_xsave reports true in domain.c while xsave space wasn't initialized. Signed-off-by: Wei Huang --=-Kb6f/2XaWmoaok4UNlA8 Content-Disposition: attachment; filename="amd_xsave_support_patch_1.txt" Content-Type: text/plain; name="amd_xsave_support_patch_1.txt"; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-Description: amd_xsave_support_patch_1.txt diff -r e5f7bffe62c4 -r 47c05f13d036 xen/arch/x86/cpu/common.c --- a/xen/arch/x86/cpu/common.c Mon Nov 29 14:29:26 2010 -0600 +++ b/xen/arch/x86/cpu/common.c Tue Nov 30 13:49:59 2010 -0600 @@ -22,6 +22,8 @@ static int disable_x86_fxsr __cpuinitdata; static int disable_x86_serial_nr __cpuinitdata; +static int use_xsave; +boolean_param("xsave", use_xsave); unsigned int __devinitdata opt_cpuid_mask_ecx = ~0u; integer_param("cpuid_mask_ecx", opt_cpuid_mask_ecx); unsigned int __devinitdata opt_cpuid_mask_edx = ~0u; @@ -404,6 +406,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); diff -r e5f7bffe62c4 -r 47c05f13d036 xen/arch/x86/cpu/intel.c --- a/xen/arch/x86/cpu/intel.c Mon Nov 29 14:29:26 2010 -0600 +++ b/xen/arch/x86/cpu/intel.c Tue Nov 30 13:49:59 2010 -0600 @@ -20,9 +20,6 @@ extern int trap_init_f00f_bug(void); -static int use_xsave; -boolean_param("xsave", use_xsave); - #ifdef CONFIG_X86_INTEL_USERCOPY /* * Alignment at which movsl is preferred for bulk memory copies. @@ -259,12 +256,6 @@ if ((c->cpuid_level >= 0x00000006) && (cpuid_eax(0x00000006) & (1u<<2))) set_bit(X86_FEATURE_ARAT, c->x86_capability); - - if ( !use_xsave ) - clear_bit(X86_FEATURE_XSAVE, boot_cpu_data.x86_capability); - - if ( cpu_has_xsave ) - xsave_init(); } --=-Kb6f/2XaWmoaok4UNlA8 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-Kb6f/2XaWmoaok4UNlA8--