Skip to contentSkip to conversation

x86, x86_64: fix cpu model for family 0x6

PATCH In review Siddha, Suresh B 4 participants 10 messages Sep 30, 2005 – Oct 1, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, x86_64: fix cpu model for family 0x6

Andi, please pickup this patch and push to Andrew/Linus.

thanks,
suresh

--
According to cpuid instruction in IA32 SDM-Vol2, when computing cpu model, we need to consider extended model ID for family 0x6 also.

arch/i386/kernel/cpu/common.c renamed from arch/i386/kernel/cpu/common.c~ +2 -2
@@ -233,10 +233,10 @@ static void __init early_cpu_detect(void
 		cpuid(0x00000001, &tfms, &misc, &junk, &cap0);
 		c->x86 = (tfms >> 8) & 15;
 		c->x86_model = (tfms >> 4) & 15;
-		if (c->x86 == 0xf) {
+		if (c->x86 == 0xf)
 			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 == 0x6 || c->x86 == 0xf)
 			c->x86_model += ((tfms >> 16) & 0xF) << 4;
-		}
 		c->x86_mask = tfms & 15;
 		if (cap0 & (1<<19))
 			c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8;
arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~ +2 -2
@@ -1059,10 +1059,10 @@ void __cpuinit early_identify_cpu(struct
 		c->x86 = (tfms >> 8) & 0xf;
 		c->x86_model = (tfms >> 4) & 0xf;
 		c->x86_mask = tfms & 0xf;
-		if (c->x86 == 0xf) {
+		if (c->x86 == 0xf)
 			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 == 0x6 || c->x86 == 0xf)
 			c->x86_model += ((tfms >> 16) & 0xF) << 4;
-		} 
 		if (c->x86_capability[0] & (1<<19)) 
 			c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
 	} else {
#1 lore raw
Quoted 2 lines · Suresh B

According to cpuid instruction in IA32 SDM-Vol2, when computing cpu model, we need to consider extended model ID for family 0x6 also.

I'm confused. Is there any 64bit capable CPU with family == 6?

-Andi

#2 lore raw
In reply to Siddha, Suresh B
Quoted 14 lines · Suresh B

Andi, please pickup this patch and push to Andrew/Linus.

thanks,
suresh

--
According to cpuid instruction in IA32 SDM-Vol2, when computing cpu model, we need to consider extended model ID for family 0x6 also.

arch/i386/kernel/cpu/common.c static void __init early_cpu_detect(void · line 238

Quoted 7 lines
arch/i386/kernel/cpu/common.c renamed from arch/i386/kernel/cpu/common.c~ +2 -1
@@ -233,10 +233,10 @@ static void __init early_cpu_detect(void
 		cpuid(0x00000001, &tfms, &misc, &junk, &cap0);
 		c->x86 = (tfms >> 8) & 15;
 		c->x86_model = (tfms >> 4) & 15;
-		if (c->x86 == 0xf) {
+		if (c->x86 == 0xf)
 			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 == 0x6 || c->x86 == 0xf)

Are you sure this is correct? You just incremented c->x86 by extended family, so I believe test should be

                if (c->x86 == 0x6 || c->x86 >= 0xf)

or maybe just

                if (c->x86 >= 0x6)

as chips with family 7..14 will either never appear, or they'll follow existing rules (I believe all chips ever built return upper bits of tfms zeroed, so maybe we could get rid of all these 'if' completely).
Petr Vandrovec

#3 lore raw
Quoted 10 lines · Petr Vandrovec

Review

Quoted 4 lines · Suresh B
(quoted diff) +2 -1
-		if (c->x86 == 0xf) {
+		if (c->x86 == 0xf)
 			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 == 0x6 || c->x86 == 0xf)

Are you sure this is correct? You just incremented c->x86 by extended family, so I believe test should be

                 if (c->x86 == 0x6 || c->x86 >= 0xf)

My bad. Your suggestion might work. But let me just follow what SDM Vol-2a says here. New patch appended.

Andi, please apply.

thanks,
suresh

--

According to cpuid instruction in IA32 SDM-Vol2, when computing cpu model, we need to consider extended model ID for family 0x6 also.

arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~ +3 -3
@@ -1059,10 +1059,10 @@ void __cpuinit early_identify_cpu(struct
 		c->x86 = (tfms >> 8) & 0xf;
 		c->x86_model = (tfms >> 4) & 0xf;
 		c->x86_mask = tfms & 0xf;
-		if (c->x86 == 0xf) {
-			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 == 0x6 || c->x86 == 0xf)
 			c->x86_model += ((tfms >> 16) & 0xF) << 4;
-		} 
+		if (c->x86 == 0xf)
+			c->x86 += (tfms >> 20) & 0xff;
 		if (c->x86_capability[0] & (1<<19)) 
 			c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
 	} else {
arch/x86_64/kernel/setup.c renamed from arch/x86_64/kernel/setup.c~ +3 -3
@@ -1059,10 +1059,10 @@ void __cpuinit early_identify_cpu(struct
 		c->x86 = (tfms >> 8) & 0xf;
 		c->x86_model = (tfms >> 4) & 0xf;
 		c->x86_mask = tfms & 0xf;
-		if (c->x86 == 0xf) {
-			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 == 0x6 || c->x86 == 0xf)
 			c->x86_model += ((tfms >> 16) & 0xF) << 4;
-		} 
+		if (c->x86 == 0xf)
+			c->x86 += (tfms >> 20) & 0xff;
 		if (c->x86_capability[0] & (1<<19)) 
 			c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
 	} else {
#4 lore raw
Quoted 10 lines · Suresh B
Quoted 9 lines · Petr Vandrovec

Review

Quoted 4 lines · Suresh B
(quoted diff) +2 -1
-		if (c->x86 == 0xf) {
+		if (c->x86 == 0xf)
 			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 == 0x6 || c->x86 == 0xf)

Are you sure this is correct? You just incremented c->x86 by extended family, so I believe test should be

Quoted 6 lines
Quoted 1 line
                 if (c->x86 == 0x6 || c->x86 >= 0xf)

My bad. Your suggestion might work. But let me just follow what SDM Vol-2a says here. New patch appended.

Andi, please apply.

I applied an earlier mix of your original one and Petr's suggestions. Hope it's ok.

x86-64/i386: Fix CPU model for family 6

From: Suresh Siddha <[email protected]>

According to cpuid instruction in IA32 SDM-Vol2, when computing cpu model, we need to consider extended model ID for family 0x6 also.

AK: Also added fixes/simplifcation from Petr Vandrovec

arch/i386/kernel/cpu/common.c +2 -2
Index: linux/arch/i386/kernel/cpu/common.c
===================================================================
@@ -233,10 +233,10 @@ static void __init early_cpu_detect(void
 		cpuid(0x00000001, &tfms, &misc, &junk, &cap0);
 		c->x86 = (tfms >> 8) & 15;
 		c->x86_model = (tfms >> 4) & 15;
-		if (c->x86 == 0xf) {
+		if (c->x86 == 0xf)
 			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 >= 0x6)
 			c->x86_model += ((tfms >> 16) & 0xF) << 4;
-		}
 		c->x86_mask = tfms & 15;
 		if (cap0 & (1<<19))
 			c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8;
arch/x86_64/kernel/setup.c +2 -2
Index: linux/arch/x86_64/kernel/setup.c
===================================================================
@@ -1059,10 +1059,10 @@ void __cpuinit early_identify_cpu(struct
 		c->x86 = (tfms >> 8) & 0xf;
 		c->x86_model = (tfms >> 4) & 0xf;
 		c->x86_mask = tfms & 0xf;
-		if (c->x86 == 0xf) {
+		if (c->x86 == 0xf)
 			c->x86 += (tfms >> 20) & 0xff;
+		if (c->x86 >= 0xf) 
 			c->x86_model += ((tfms >> 16) & 0xF) << 4;
-		} 
 		if (c->x86_capability[0] & (1<<19)) 
 			c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
 	} else {
#5 lore raw
Quoted 2 lines · Andi Kleen

I applied an earlier mix of your original one and Petr's suggestions. Hope it's ok.

Andi I prefer to follow the SDM guidelines. Who knows if future families comeup with a different rule or use/initialize these extended model/family bits differently. I am just being paranoid.

arch/x86_64/kernel/setup.c void __cpuinit early_identify_cpu(struct · line 1064

Quoted 1 line
arch/x86_64/kernel/setup.c +1 -0
+		if (c->x86 >= 0xf) 

And also you have a typo. It should be 0x6.

Anyhow, I prefer my second patch.

thanks,
suresh

#6 lore raw
Quoted 8 lines · Suresh B
Quoted 1 line · Andi Kleen

I applied an earlier mix of your original one and Petr's suggestions. Hope it's ok.

Andi I prefer to follow the SDM guidelines. Who knows if future families comeup with a different rule or use/initialize these extended model/family bits differently. I am just being paranoid.

And which chance is bigger - that such hypothetical processor will use extended model, and your code will get incorrect answer everywhere, or that such hypothetical processor will not use extended model, and your code will be right?

Quoted 4 lines

arch/x86_64/kernel/setup.c void __cpuinit early_identify_cpu(struct · line 1064

Quoted 1 line
arch/x86_64/kernel/setup.c +1 -0
+		if (c->x86 >= 0xf) 

And also you have a typo. It should be 0x6.

It is intentional. Maybe it could do BUG_ON(c->x86 < 0xf).
Petr

#7 lore raw
Quoted 16 lines · Petr Vandrovec
Quoted 9 lines · Suresh B
Quoted 2 lines · Andi Kleen

I applied an earlier mix of your original one and Petr's suggestions. Hope it's ok.

Andi I prefer to follow the SDM guidelines. Who knows if future families comeup with a different rule or use/initialize these extended model/family bits differently. I am just being paranoid.

And which chance is bigger - that such hypothetical processor will use extended model, and your code will get incorrect answer everywhere, or that such hypothetical processor will not use extended model, and your code will be right?

Quoted 6 lines
Quoted 4 lines

arch/x86_64/kernel/setup.c void __cpuinit early_identify_cpu(struct · line 1064

Quoted 1 line
arch/x86_64/kernel/setup.c +1 -0
+		if (c->x86 >= 0xf) 

And also you have a typo. It should be 0x6.

It is intentional. Maybe it could do BUG_ON(c->x86 < 0xf).

<complete speculation> Pentium M is family 6, so maybe this is an indication we'll see em64t capable P-M's soon ? :)

Dave

#8 lore raw
In reply to Siddha, Suresh B
Quoted 1 line · Suresh B

And also you have a typo. It should be 0x6.

Fixed.

Quoted 1 line

Anyhow, I prefer my second patch.

It doesn't even apply - you patched x86_64/kernel/setup.c twice.

-Andi

#9 lore raw
Quoted 5 lines · Andi Kleen
Quoted 1 line · Suresh B

And also you have a typo. It should be 0x6.

Fixed.

Thanks. Lets go ahead with Petrs suggestion then.