Skip to contentSkip to conversation

x86, cpu, amd: Use 8-bit extractor for NodeId field

PATCH In review Aravind Gopalakrishnan 2 participants 3 messages Jan 19, 2015 – Jan 20, 2015 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, cpu, amd: Use 8-bit extractor for NodeId field

The NodeId field in cpuid_ecx(0x8000001e) is a 8 bit field. Although current extractor works fine, it will break if/when the most significant 5 bits ever get used.

So, lets honor the field as architected in the BKDG

Reference: BKDG for AMD Fam15h Models 00h-0fh,
CPUID Fn8000_001E_ECX Node Identifiers

---
 arch/x86/kernel/cpu/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +1 -1
index a220239..9942b83 100644
@@ -300,7 +300,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
 
 		cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
 		nodes = ((ecx >> 8) & 7) + 1;
-		node_id = ecx & 7;
+		node_id = ecx & 0xff;
 
 		/* get compute unit information */
 		smp_num_siblings = ((ebx >> 8) & 3) + 1;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 19 lines · Aravind Gopalakrishnan

The NodeId field in cpuid_ecx(0x8000001e) is a 8 bit field. Although current extractor works fine, it will break if/when the most significant 5 bits ever get used.

So, lets honor the field as architected in the BKDG

Reference: BKDG for AMD Fam15h Models 00h-0fh,
CPUID Fn8000_001E_ECX Node Identifiers

---
 arch/x86/kernel/cpu/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +0 -0
index a220239..9942b83 100644

arch/x86/kernel/cpu/amd.c static void amd_get_topology(struct cpuinfo_x86 *c) · line 303

Quoted 5 lines
arch/x86/kernel/cpu/amd.c +1 -1
@@ -300,7 +300,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
 
 		cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
 		nodes = ((ecx >> 8) & 7) + 1;
-		node_id = ecx & 7;
+		node_id = ecx & 0xff;

That's {00000b,D18F0x60[NodeId]} and NodeId is 3 bits for enumerating 8 nodes so checking the 3 bits is actually correct as it says that the other 5 are 0b.

Regardless, is this something hypothetical you've noticed from code inspection or are we really going to have more than 8 nodes? If the former, then patch is unnecessary churn.

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#2 lore raw
Quoted 21 lines · Borislav Petkov
Quoted 20 lines · Aravind Gopalakrishnan

The NodeId field in cpuid_ecx(0x8000001e) is a 8 bit field. Although current extractor works fine, it will break if/when the most significant 5 bits ever get used.

So, lets honor the field as architected in the BKDG

Reference: BKDG for AMD Fam15h Models 00h-0fh,
CPUID Fn8000_001E_ECX Node Identifiers

---
  arch/x86/kernel/cpu/amd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +0 -0
index a220239..9942b83 100644
@@ -300,7 +300,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
 
Quoted 7 lines

arch/x86/kernel/cpu/amd.c static void amd_get_topology(struct cpuinfo_x86 *c) · line 303

Quoted 4 lines
arch/x86/kernel/cpu/amd.c +1 -1
  		cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
  		nodes = ((ecx >> 8) & 7) + 1;
-		node_id = ecx & 7;
+		node_id = ecx & 0xff;

That's {00000b,D18F0x60[NodeId]} and NodeId is 3 bits for enumerating 8 nodes so checking the 3 bits is actually correct as it says that the other 5 are 0b.

Right. Just a concern that if the definition of those 5 bits changes then it would be a problem.

Quoted 4 lines

Regardless, is this something hypothetical you've noticed from code inspection or are we really going to have more than 8 nodes? If the former, then patch is unnecessary churn.

Just something from code inspection. So not an immediate issue.

Thanks,
-Aravind.