Skip to contentSkip to conversation

x86/amd: re-enable CPU topology extensions in case BIOS has disabled it

PATCH In review Jan Beulich 2 participants 3 messages May 30, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/amd: re-enable CPU topology extensions in case BIOS has disabled it

BIOS will switch off the corresponding feature flag on family 15h models 10h-1fh non-desktop CPUs.

The topology extension CPUID leafs are required to detect which cores belong to the same compute unit. (thread siblings mask is set accordingly and also correct information about L1i and L2 cache sharing depends on this).

W/o this patch we wouldn't see which cores belong to the same compute unit and also cache sharing information for L1i and L2 would be incorrect on such systems.

xen/arch/x86/cpu/amd.c +15 -0
@@ -471,6 +471,21 @@ static void __devinit init_amd(struct cp
 		}
 	}
 
+	/* re-enable TopologyExtensions if switched off by BIOS */
+	if ((c->x86 == 0x15) &&
+	    (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
+	    !cpu_has(c, X86_FEATURE_TOPOEXT) &&
+	    !rdmsr_safe(MSR_K8_EXT_FEATURE_MASK, value)) {
+		value |= 1ULL << 54;
+		wrmsr_safe(MSR_K8_EXT_FEATURE_MASK, value);
+		rdmsrl(MSR_K8_EXT_FEATURE_MASK, value);
+		if (value & (1ULL << 54)) {
+			set_bit(X86_FEATURE_TOPOEXT, c->x86_capability);
+			printk(KERN_INFO "CPU: Re-enabling disabled "
+			       "Topology Extensions Support\n");
+		}
+	}
+
         amd_get_topology(c);
 
 	/* Pointless to use MWAIT on Family10 as it does not deep sleep. */

x86/amd: re-enable CPU topology extensions in case BIOS has disabled it

BIOS will switch off the corresponding feature flag on family 15h models 10h-1fh non-desktop CPUs.

The topology extension CPUID leafs are required to detect which cores belong to the same compute unit. (thread siblings mask is set accordingly and also correct information about L1i and L2 cache sharing depends on this).

W/o this patch we wouldn't see which cores belong to the same compute unit and also cache sharing information for L1i and L2 would be incorrect on such systems.

xen/arch/x86/cpu/amd.c +15 -0
@@ -471,6 +471,21 @@ static void __devinit init_amd(struct cp
 		}
 	}
 
+	/* re-enable TopologyExtensions if switched off by BIOS */
+	if ((c->x86 == 0x15) &&
+	    (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
+	    !cpu_has(c, X86_FEATURE_TOPOEXT) &&
+	    !rdmsr_safe(MSR_K8_EXT_FEATURE_MASK, value)) {
+		value |= 1ULL << 54;
+		wrmsr_safe(MSR_K8_EXT_FEATURE_MASK, value);
+		rdmsrl(MSR_K8_EXT_FEATURE_MASK, value);
+		if (value & (1ULL << 54)) {
+			set_bit(X86_FEATURE_TOPOEXT, c->x86_capability);
+			printk(KERN_INFO "CPU: Re-enabling disabled "
+			       "Topology Extensions Support\n");
+		}
+	}
+
         amd_get_topology(c);
 
 	/* Pointless to use MWAIT on Family10 as it does not deep sleep. */

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

Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Jan Beulich

BIOS will switch off the corresponding feature flag on family 15h models 10h-1fh non-desktop CPUs.

Why would it do that? It seems silly.

Quoted 11 lines

The topology extension CPUID leafs are required to detect which cores belong to the same compute unit. (thread siblings mask is set accordingly and also correct information about L1i and L2 cache sharing depends on this).

W/o this patch we wouldn't see which cores belong to the same compute unit and also cache sharing information for L1i and L2 would be incorrect on such systems.

Assuming there's no good reason for the BIOS having disabled the feature...

Quoted 31 lines
xen/arch/x86/cpu/amd.c +15 -0
@@ -471,6 +471,21 @@ static void __devinit init_amd(struct cp
 }
 }
 
+ /* re-enable TopologyExtensions if switched off by BIOS */
+ if ((c->x86 == 0x15) &&
+     (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
+     !cpu_has(c, X86_FEATURE_TOPOEXT) &&
+     !rdmsr_safe(MSR_K8_EXT_FEATURE_MASK, value)) {
+  value |= 1ULL << 54;
+  wrmsr_safe(MSR_K8_EXT_FEATURE_MASK, value);
+  rdmsrl(MSR_K8_EXT_FEATURE_MASK, value);
+  if (value & (1ULL << 54)) {
+   set_bit(X86_FEATURE_TOPOEXT, c->x86_capability);
+   printk(KERN_INFO "CPU: Re-enabling disabled "
+          "Topology Extensions Support\n");
+  }
+ }
+
         amd_get_topology(c);
 
 /* Pointless to use MWAIT on Family10 as it does not deep sleep. */

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

#2 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 2 lines · Jan Beulich

BIOS will switch off the corresponding feature flag on family 15h models 10h-1fh non-desktop CPUs.

Why would it do that? It seems silly.

Indeed. But the change comes from Linux 3.4. Andreas, Andre?

Jan