Skip to contentSkip to conversation

x86: fix pv cpuid masking

PATCH In review Jan Beulich 2 participants 3 messages Jun 15, 2010 – Jun 16, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: fix pv cpuid masking

Invert initial values of the variables parsed into from the command line, so that completely clearing out one or more of the four bit fields is possible.

Further, consolidate the command line parameter specifications into a single place.

Finally, as per "Intel Virtualization Technology FlexMigration Application Note" (http://www.intel.com/Assets/PDF/manual/323850.pdf),
also handle family 6 model 0x1f.

What remains open is the question whether pv_cpuid() shouldn't also consume these masks.

xen/arch/x86/cpu/amd.c +7 -15
@@ -31,14 +31,6 @@
 static char opt_famrev[14];
 string_param("cpuid_mask_cpu", opt_famrev);
 
-/* Finer-grained CPUID feature control. */
-static unsigned int opt_cpuid_mask_ecx, opt_cpuid_mask_edx;
-integer_param("cpuid_mask_ecx", opt_cpuid_mask_ecx);
-integer_param("cpuid_mask_edx", opt_cpuid_mask_edx);
-static unsigned int opt_cpuid_mask_ext_ecx, opt_cpuid_mask_ext_edx;
-integer_param("cpuid_mask_ext_ecx", opt_cpuid_mask_ext_ecx);
-integer_param("cpuid_mask_ext_edx", opt_cpuid_mask_ext_edx);
-
 static inline void wrmsr_amd(unsigned int index, unsigned int lo, 
 		unsigned int hi)
 {
@@ -59,7 +51,7 @@ static inline void wrmsr_amd(unsigned in
  *
  * The processor revision string parameter has precedene.
  */
-static void __devinit set_cpuidmask(struct cpuinfo_x86 *c)
+static void __devinit set_cpuidmask(const struct cpuinfo_x86 *c)
 {
 	static unsigned int feat_ecx, feat_edx;
 	static unsigned int extfeat_ecx, extfeat_edx;
@@ -74,12 +66,12 @@ static void __devinit set_cpuidmask(stru
 	ASSERT((status == not_parsed) && (smp_processor_id() == 0));
 	status = no_mask;
 
-	if (opt_cpuid_mask_ecx | opt_cpuid_mask_edx |
-	    opt_cpuid_mask_ext_ecx | opt_cpuid_mask_ext_edx) {
-		feat_ecx = opt_cpuid_mask_ecx ? : ~0U;
-		feat_edx = opt_cpuid_mask_edx ? : ~0U;
-		extfeat_ecx = opt_cpuid_mask_ext_ecx ? : ~0U;
-		extfeat_edx = opt_cpuid_mask_ext_edx ? : ~0U;
+	if (~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
+	      opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx)) {
+		feat_ecx = opt_cpuid_mask_ecx;
+		feat_edx = opt_cpuid_mask_edx;
+		extfeat_ecx = opt_cpuid_mask_ext_ecx;
+		extfeat_edx = opt_cpuid_mask_ext_edx;
 	} else if (*opt_famrev == '\0') {
 		return;
 	} else if (!strcmp(opt_famrev, "fam_0f_rev_c")) {
xen/arch/x86/cpu/common.c +9 -0
@@ -22,6 +22,15 @@ static int cachesize_override __cpuinitd
 static int disable_x86_fxsr __cpuinitdata;
 static int disable_x86_serial_nr __cpuinitdata;
 
+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_ext_ecx = ~0u;
+integer_param("cpuid_mask_ext_ecx", opt_cpuid_mask_ext_ecx);
+unsigned int __devinitdata opt_cpuid_mask_ext_edx = ~0u;
+integer_param("cpuid_mask_ext_edx", opt_cpuid_mask_ext_edx);
+
 struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
 
 /*
xen/arch/x86/cpu/cpu.h +3 -0
@@ -21,6 +21,9 @@ 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_ext_ecx, opt_cpuid_mask_ext_edx;
+
 extern int get_model_name(struct cpuinfo_x86 *c);
 extern void display_cacheinfo(struct cpuinfo_x86 *c);
 
xen/arch/x86/cpu/intel.c +39 -41

104 lines not on this page · raw message

xen/include/asm-x86/msr-index.h +4 -4
@@ -156,10 +156,10 @@
 #define MSR_P6_EVNTSEL0			0x00000186
 #define MSR_P6_EVNTSEL1			0x00000187
 
-/* MSR for cpuid feature mask */
-#define MSR_IA32_CPUID_FEATURE_MASK1	0x00000478
-#define MSR_IA32_CPUID1_FEATURE_MASK    0x00000130
-#define MSR_IA32_CPUID80000001_FEATURE_MASK 0x00000131
+/* MSRs for Intel cpuid feature mask */
+#define MSR_INTEL_CPUID_FEATURE_MASK	0x00000478
+#define MSR_INTEL_CPUID1_FEATURE_MASK	0x00000130
+#define MSR_INTEL_CPUID80000001_FEATURE_MASK 0x00000131
 
 /* MSRs & bits used for VMX enabling */
 #define MSR_IA32_VMX_BASIC                      0x480

Invert initial values of the variables parsed into from the command line, so that completely clearing out one or more of the four bit fields is possible.

Further, consolidate the command line parameter specifications into a single place.

Finally, as per "Intel Virtualization Technology FlexMigration Application Note" (http://www.intel.com/Assets/PDF/manual/323850.pdf),
also handle family 6 model 0x1f.

What remains open is the question whether pv_cpuid() shouldn't also consume these masks.

xen/arch/x86/cpu/amd.c +7 -15
@@ -31,14 +31,6 @@
 static char opt_famrev[14];
 string_param("cpuid_mask_cpu", opt_famrev);
 
-/* Finer-grained CPUID feature control. */
-static unsigned int opt_cpuid_mask_ecx, opt_cpuid_mask_edx;
-integer_param("cpuid_mask_ecx", opt_cpuid_mask_ecx);
-integer_param("cpuid_mask_edx", opt_cpuid_mask_edx);
-static unsigned int opt_cpuid_mask_ext_ecx, opt_cpuid_mask_ext_edx;
-integer_param("cpuid_mask_ext_ecx", opt_cpuid_mask_ext_ecx);
-integer_param("cpuid_mask_ext_edx", opt_cpuid_mask_ext_edx);
-
 static inline void wrmsr_amd(unsigned int index, unsigned int lo, 
 		unsigned int hi)
 {
@@ -59,7 +51,7 @@ static inline void wrmsr_amd(unsigned in
  *
  * The processor revision string parameter has precedene.
  */
-static void __devinit set_cpuidmask(struct cpuinfo_x86 *c)
+static void __devinit set_cpuidmask(const struct cpuinfo_x86 *c)
 {
 	static unsigned int feat_ecx, feat_edx;
 	static unsigned int extfeat_ecx, extfeat_edx;
@@ -74,12 +66,12 @@ static void __devinit set_cpuidmask(stru
 	ASSERT((status == not_parsed) && (smp_processor_id() == 0));
 	status = no_mask;
 
-	if (opt_cpuid_mask_ecx | opt_cpuid_mask_edx |
-	    opt_cpuid_mask_ext_ecx | opt_cpuid_mask_ext_edx) {
-		feat_ecx = opt_cpuid_mask_ecx ? : ~0U;
-		feat_edx = opt_cpuid_mask_edx ? : ~0U;
-		extfeat_ecx = opt_cpuid_mask_ext_ecx ? : ~0U;
-		extfeat_edx = opt_cpuid_mask_ext_edx ? : ~0U;
+	if (~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
+	      opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx)) {
+		feat_ecx = opt_cpuid_mask_ecx;
+		feat_edx = opt_cpuid_mask_edx;
+		extfeat_ecx = opt_cpuid_mask_ext_ecx;
+		extfeat_edx = opt_cpuid_mask_ext_edx;
 	} else if (*opt_famrev == '\0') {
 		return;
 	} else if (!strcmp(opt_famrev, "fam_0f_rev_c")) {
xen/arch/x86/cpu/common.c +9 -0
@@ -22,6 +22,15 @@ static int cachesize_override __cpuinitd
 static int disable_x86_fxsr __cpuinitdata;
 static int disable_x86_serial_nr __cpuinitdata;
 
+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_ext_ecx = ~0u;
+integer_param("cpuid_mask_ext_ecx", opt_cpuid_mask_ext_ecx);
+unsigned int __devinitdata opt_cpuid_mask_ext_edx = ~0u;
+integer_param("cpuid_mask_ext_edx", opt_cpuid_mask_ext_edx);
+
 struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
 
 /*
xen/arch/x86/cpu/cpu.h +3 -0
@@ -21,6 +21,9 @@ 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_ext_ecx, opt_cpuid_mask_ext_edx;
+
 extern int get_model_name(struct cpuinfo_x86 *c);
 extern void display_cacheinfo(struct cpuinfo_x86 *c);
 
xen/arch/x86/cpu/intel.c +39 -41

104 lines not on this page · raw message

xen/include/asm-x86/msr-index.h +4 -4
@@ -156,10 +156,10 @@
 #define MSR_P6_EVNTSEL0			0x00000186
 #define MSR_P6_EVNTSEL1			0x00000187
 
-/* MSR for cpuid feature mask */
-#define MSR_IA32_CPUID_FEATURE_MASK1	0x00000478
-#define MSR_IA32_CPUID1_FEATURE_MASK    0x00000130
-#define MSR_IA32_CPUID80000001_FEATURE_MASK 0x00000131
+/* MSRs for Intel cpuid feature mask */
+#define MSR_INTEL_CPUID_FEATURE_MASK	0x00000478
+#define MSR_INTEL_CPUID1_FEATURE_MASK	0x00000130
+#define MSR_INTEL_CPUID80000001_FEATURE_MASK 0x00000131
 
 /* MSRs & bits used for VMX enabling */
 #define MSR_IA32_VMX_BASIC                      0x480

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

#1 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

Invert initial values of the variables parsed into from the command line, so that completely clearing out one or more of the four bit fields is possible.

Further, consolidate the command line parameter specifications into a single place.

Quoted 6 lines

Finally, as per "Intel Virtualization Technology FlexMigration Application Note" (http://www.intel.com/Assets/PDF/manual/323850.pdf),
also handle family 6 model 0x1f.

What remains open is the question whether pv_cpuid() shouldn't also consume these masks.

What is your opinion on this, Keir?

Jan

#2 lore raw
Quoted 4 lines · Jan Beulich
Quoted 2 lines

What remains open is the question whether pv_cpuid() shouldn't also consume these masks.

What is your opinion on this, Keir?

Libxc/xc_cpuid_x86.c already applies the policy expressed in a domain's config file, plus its own internal policy, on top of physical host CPUID. Since host CPUID is already affected by the above-mentioned masks, I don't think anything further needs to be done.

-- Keir