From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haitao Shan Subject: Re: [PATCH] x86: add support for newest version of Intel CPUID masking Date: Tue, 24 May 2011 10:44:29 +0800 Message-ID: References: <4DCD2B900200007800041412@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1136375185==" Return-path: In-Reply-To: <4DCD2B900200007800041412@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: "xen-devel@lists.xensource.com" , Jun Nakajima List-Id: xen-devel@lists.xenproject.org --===============1136375185== Content-Type: multipart/alternative; boundary=0016e6d96c3625198704a3fc9129 --0016e6d96c3625198704a3fc9129 Content-Type: text/plain; charset=ISO-8859-1 Hi, Jan, Please hold the patch for a while, as we are internally check the specifications of CPUID masking. Possibly, there will be some updates that changes the details of masking. Thanks! Shan Haitao 2011/5/13 Jan Beulich > This follows appnote 485 rev 037, with a slight deviation in the leaf > 0xd masking: The document states that ECX and EDX outputs get masked, > but with the bit fields of interest being in EAX and EDX (while ECX > holds other information that doesn't make sense to be masked), option > and variable names use 'eax' instead. > > (Jun, would be nice if you could confirm this.) > > Signed-off-by: Jan Beulich > > --- 2011-04-29.orig/xen/arch/x86/cpu/common.c 2011-04-26 > 08:19:36.000000000 +0200 > +++ 2011-04-29/xen/arch/x86/cpu/common.c 2011-05-12 > 18:10:10.000000000 +0200 > @@ -20,10 +20,17 @@ size_param("cachesize", cachesize_overri > > static bool_t __cpuinitdata use_xsave = 1; > 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; > integer_param("cpuid_mask_edx", opt_cpuid_mask_edx); > + > +unsigned int __devinitdata opt_cpuid_mask_xsave_eax = ~0u; > +integer_param("cpuid_mask_ecx", opt_cpuid_mask_xsave_eax); > +unsigned int __devinitdata opt_cpuid_mask_xsave_edx = ~0u; > +integer_param("cpuid_mask_edx", opt_cpuid_mask_xsave_edx); > + > unsigned int __devinitdata opt_cpuid_mask_ext_ecx = ~0u; > integer_param("cpuid_mask_ext_ecx", opt_cpuid_mask_ext_ecx); > unsigned int __devinitdata opt_cpuid_mask_ext_edx = ~0u; > --- 2011-04-29.orig/xen/arch/x86/cpu/cpu.h 2010-06-16 > 12:26:43.000000000 +0200 > +++ 2011-04-29/xen/arch/x86/cpu/cpu.h 2011-05-13 10:51:00.000000000 +0200 > @@ -22,6 +22,7 @@ struct cpu_dev { > extern struct cpu_dev * cpu_devs [X86_VENDOR_NUM]; > > extern unsigned int opt_cpuid_mask_ecx, opt_cpuid_mask_edx; > +extern unsigned int opt_cpuid_mask_xsave_eax, opt_cpuid_mask_xsave_edx; > extern unsigned int opt_cpuid_mask_ext_ecx, opt_cpuid_mask_ext_edx; > > extern int get_model_name(struct cpuinfo_x86 *c); > --- 2011-04-29.orig/xen/arch/x86/cpu/intel.c 2011-03-11 > 10:13:55.000000000 +0100 > +++ 2011-04-29/xen/arch/x86/cpu/intel.c 2011-05-13 10:51:09.000000000 +0200 > @@ -49,9 +49,12 @@ static void __devinit set_cpuidmask(cons > wrmsr(MSR_INTEL_CPUID_FEATURE_MASK, > opt_cpuid_mask_ecx, > opt_cpuid_mask_edx); > - if (!~(opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx)) > + if (~(opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx)) > + extra = "extended "; > + else if (~(opt_cpuid_mask_xsave_eax & > opt_cpuid_mask_xsave_edx)) > + extra = "xsave "; > + else > return; > - extra = "extended "; > break; > /* > * CPU supports this feature if the processor signature meets the > following: > @@ -71,11 +74,25 @@ static void __devinit set_cpuidmask(cons > wrmsr(MSR_INTEL_CPUID80000001_FEATURE_MASK, > opt_cpuid_mask_ext_ecx, > opt_cpuid_mask_ext_edx); > + if (!~(opt_cpuid_mask_xsave_eax & > opt_cpuid_mask_xsave_edx)) > + return; > + extra = "xsave "; > + break; > + case 0x2a: > + wrmsr(MSR_INTEL_CPUID1_FEATURE_MASK_V2, > + opt_cpuid_mask_ecx, > + opt_cpuid_mask_edx); > + wrmsr(MSR_INTEL_CPUIDD0_FEATURE_MASK, > + opt_cpuid_mask_xsave_eax, > + opt_cpuid_mask_xsave_edx); > + wrmsr(MSR_INTEL_CPUID80000001_FEATURE_MASK_V2, > + opt_cpuid_mask_ext_ecx, > + opt_cpuid_mask_ext_edx); > return; > } > > - printk(XENLOG_ERR "Cannot set CPU feature mask on CPU#%d\n", > - smp_processor_id()); > + printk(XENLOG_ERR "Cannot set CPU %sfeature mask on CPU#%d\n", > + extra, smp_processor_id()); > } > > void __devinit early_intel_workaround(struct cpuinfo_x86 *c) > --- 2011-04-29.orig/xen/include/asm-x86/msr-index.h 2011-01-06 > 16:44:36.000000000 +0100 > +++ 2011-04-29/xen/include/asm-x86/msr-index.h 2011-05-12 > 18:17:28.000000000 +0200 > @@ -161,6 +161,10 @@ > #define MSR_INTEL_CPUID1_FEATURE_MASK 0x00000130 > #define MSR_INTEL_CPUID80000001_FEATURE_MASK 0x00000131 > > +#define MSR_INTEL_CPUID1_FEATURE_MASK_V2 0x00000132 > +#define MSR_INTEL_CPUID80000001_FEATURE_MASK_V2 0x00000133 > +#define MSR_INTEL_CPUIDD0_FEATURE_MASK 0x00000134 > + > /* MSRs & bits used for VMX enabling */ > #define MSR_IA32_VMX_BASIC 0x480 > #define MSR_IA32_VMX_PINBASED_CTLS 0x481 > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > > --0016e6d96c3625198704a3fc9129 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi, Jan,
=A0
Please hold the patch for a while, as= we are internally check the specifications of CPUID masking.
Pos= sibly, there will be some updates that changes the details of masking.
Thanks!
=A0
Shan Haitao

2011/5/13 Jan Beulich <JBeulich@novell.com>
This follows appnote 485 rev 037, with a slight deviation in the leaf
0xd masking: The document states that ECX and EDX outputs get masked,
but with the bit fields of interest being in EAX and EDX (while ECX
holds other information that doesn't make sense to be masked), option and variable names use 'eax' instead.

(Jun, would be nice if you could confirm this.)

Signed-off-by: Jan Beulich <jbeul= ich@novell.com>

--- 2011-04-29.orig/xen/arch/x86/cpu/common.c =A0 2011-04-26 08:19:36.00000= 0000 +0200
+++ 2011-04-29/xen/arch/x86/cpu/common.c =A0 =A0 =A0 =A02011-05-12 18:10:10= .000000000 +0200
@@ -20,10 +20,17 @@ size_param("cachesize", cachesize_overri

=A0static bool_t __cpuinitdata use_xsave =3D 1;
=A0boolean_param("xsave", use_xsave);
+
=A0unsigned int __devinitdata opt_cpuid_mask_ecx =3D ~0u;
=A0integer_param("cpuid_mask_ecx", opt_cpuid_mask_ecx);
=A0unsigned int __devinitdata opt_cpuid_mask_edx =3D ~0u;
=A0integer_param("cpuid_mask_edx", opt_cpuid_mask_edx);
+
+unsigned int __devinitdata opt_cpuid_mask_xsave_eax =3D ~0u;
+integer_param("cpuid_mask_ecx", opt_cpuid_mask_xsave_eax);
+unsigned int __devinitdata opt_cpuid_mask_xsave_edx =3D ~0u;
+integer_param("cpuid_mask_edx", opt_cpuid_mask_xsave_edx);
+
=A0unsigned int __devinitdata opt_cpuid_mask_ext_ecx =3D ~0u;
=A0integer_param("cpuid_mask_ext_ecx", opt_cpuid_mask_ext_ecx); =A0unsigned int __devinitdata opt_cpuid_mask_ext_edx =3D ~0u;
--- 2011-04-29.orig/xen/arch/x86/cpu/cpu.h =A0 =A0 =A02010-06-16 12:26:43.0= 00000000 +0200
+++ 2011-04-29/xen/arch/x86/cpu/cpu.h =A0 2011-05-13 10:51:00.000000000 +02= 00
@@ -22,6 +22,7 @@ struct cpu_dev {
=A0extern struct cpu_dev * cpu_devs [X86_VENDOR_NUM];

=A0extern unsigned int opt_cpuid_mask_ecx, opt_cpuid_mask_edx;
+extern unsigned int opt_cpuid_mask_xsave_eax, opt_cpuid_mask_xsave_edx; =A0extern unsigned int opt_cpuid_mask_ext_ecx, opt_cpuid_mask_ext_edx;

=A0extern int get_model_name(struct cpuinfo_x86 *c);
--- 2011-04-29.orig/xen/arch/x86/cpu/intel.c =A0 =A02011-03-11 10:13:55.000= 000000 +0100
+++ 2011-04-29/xen/arch/x86/cpu/intel.c 2011-05-13 10:51:09.000000000 +0200=
@@ -49,9 +49,12 @@ static void __devinit set_cpuidmask(cons
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wrmsr(MSR_INTEL_CPUID_FEATURE_MASK,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0opt_cpuid_mask_ecx,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0opt_cpuid_mask_edx);
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!~(opt_cpuid_mask_ext_ecx & opt_cpuid= _mask_ext_edx))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (~(opt_cpuid_mask_ext_ecx & opt_cpuid_= mask_ext_edx))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 extra =3D "extended &quo= t;;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 else if (~(opt_cpuid_mask_xsave_eax & opt= _cpuid_mask_xsave_edx))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 extra =3D "xsave ";=
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 else
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return;
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 extra =3D "extended ";
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
=A0/*
=A0* CPU supports this feature if the processor signature meets the follow= ing:
@@ -71,11 +74,25 @@ static void __devinit set_cpuidmask(cons
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wrmsr(MSR_INTEL_CPUID80000001_FEATURE_MASK,=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0opt_cpuid_mask_ext_ecx,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0opt_cpuid_mask_ext_edx);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!~(opt_cpuid_mask_xsave_eax & opt_cpu= id_mask_xsave_edx))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 extra =3D "xsave ";
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
+ =A0 =A0 =A0 case 0x2a:
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 wrmsr(MSR_INTEL_CPUID1_FEATURE_MASK_V2,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 opt_cpuid_mask_ecx,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 opt_cpuid_mask_edx);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 wrmsr(MSR_INTEL_CPUIDD0_FEATURE_MASK,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 opt_cpuid_mask_xsave_eax,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 opt_cpuid_mask_xsave_edx);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 wrmsr(MSR_INTEL_CPUID80000001_FEATURE_MASK_V2= ,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 opt_cpuid_mask_ext_ecx,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 opt_cpuid_mask_ext_edx);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return;
=A0 =A0 =A0 =A0}

- =A0 =A0 =A0 printk(XENLOG_ERR "Cannot set CPU feature mask on CPU#%d= \n",
- =A0 =A0 =A0 =A0 =A0 =A0 =A0smp_processor_id());
+ =A0 =A0 =A0 printk(XENLOG_ERR "Cannot set CPU %sfeature mask on CPU#= %d\n",
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0extra, smp_processor_id());
=A0}

=A0void __devinit early_intel_workaround(struct cpuinfo_x86 *c)
--- 2011-04-29.orig/xen/include/asm-x86/msr-index.h =A0 =A0 2011-01-06 16:4= 4:36.000000000 +0100
+++ 2011-04-29/xen/include/asm-x86/msr-index.h =A02011-05-12 18:17:28.00000= 0000 +0200
@@ -161,6 +161,10 @@
=A0#define MSR_INTEL_CPUID1_FEATURE_MASK =A00x00000130
=A0#define MSR_INTEL_CPUID80000001_FEATURE_MASK 0x00000131

+#define MSR_INTEL_CPUID1_FEATURE_MASK_V2 =A0 =A0 =A0 =A00x00000132
+#define MSR_INTEL_CPUID80000001_FEATURE_MASK_V2 0x00000133
+#define MSR_INTEL_CPUIDD0_FEATURE_MASK =A0 =A0 =A0 =A0 =A00x00000134
+
=A0/* MSRs & bits used for VMX enabling */
=A0#define MSR_IA32_VMX_BASIC =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00x= 480
=A0#define MSR_IA32_VMX_PINBASED_CTLS =A0 =A0 =A0 =A0 =A0 =A0 =A00x481



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.= com
http://l= ists.xensource.com/xen-devel


--0016e6d96c3625198704a3fc9129-- --===============1136375185== 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 --===============1136375185==--