Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] CPUID bug and inconsistency fix

The recent support for K8 multicore was misported from x86-64 to i386, due
to an unnecessary inconsistency between the CPUID code. Sure, there is are
no x86-64 VIA chips yet, but it should happen eventually.

This patch fixes the i386 bug as well as makes x86-64 match i386 in the
handing of the CPUID array.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

H. Peter Anvin and committed by
Linus Torvalds
5b7abc6f a6954ba2

+20 -8
+8 -2
arch/x86_64/kernel/setup.c
··· 977 977 if ((xlvl & 0xffff0000) == 0x80000000) { 978 978 if (xlvl >= 0x80000001) { 979 979 c->x86_capability[1] = cpuid_edx(0x80000001); 980 - c->x86_capability[5] = cpuid_ecx(0x80000001); 980 + c->x86_capability[6] = cpuid_ecx(0x80000001); 981 981 } 982 982 if (xlvl >= 0x80000004) 983 983 get_model_name(c); /* Default name */ ··· 1100 1100 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1101 1101 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1102 1102 1103 + /* VIA/Cyrix/Centaur-defined */ 1104 + NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en", 1105 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1106 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1107 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1108 + 1103 1109 /* AMD-defined (#2) */ 1104 1110 "lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL, 1105 1111 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1106 1112 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1107 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL 1113 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1108 1114 }; 1109 1115 static char *x86_power_flags[] = { 1110 1116 "ts", /* temperature sensor */
+2 -2
include/asm-i386/cpufeature.h
··· 87 87 #define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */ 88 88 89 89 /* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */ 90 - #define X86_FEATURE_LAHF_LM (5*32+ 0) /* LAHF/SAHF in long mode */ 91 - #define X86_FEATURE_CMP_LEGACY (5*32+ 1) /* If yes HyperThreading not valid */ 90 + #define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */ 91 + #define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */ 92 92 93 93 #define cpu_has(c, bit) test_bit(bit, (c)->x86_capability) 94 94 #define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
+10 -4
include/asm-x86_64/cpufeature.h
··· 7 7 #ifndef __ASM_X8664_CPUFEATURE_H 8 8 #define __ASM_X8664_CPUFEATURE_H 9 9 10 - #define NCAPINTS 6 10 + #define NCAPINTS 7 /* N 32-bit words worth of info */ 11 11 12 12 /* Intel-defined CPU features, CPUID level 0x00000001, word 0 */ 13 13 #define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */ ··· 74 74 #define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B */ 75 75 #define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */ 76 76 77 - /* More extended AMD flags: CPUID level 0x80000001, ecx, word 5 */ 78 - #define X86_FEATURE_LAHF_LM (5*32+ 0) /* LAHF/SAHF in long mode */ 79 - #define X86_FEATURE_CMP_LEGACY (5*32+ 1) /* If yes HyperThreading not valid */ 77 + /* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */ 78 + #define X86_FEATURE_XSTORE (5*32+ 2) /* on-CPU RNG present (xstore insn) */ 79 + #define X86_FEATURE_XSTORE_EN (5*32+ 3) /* on-CPU RNG enabled */ 80 + #define X86_FEATURE_XCRYPT (5*32+ 6) /* on-CPU crypto (xcrypt insn) */ 81 + #define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */ 82 + 83 + /* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */ 84 + #define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */ 85 + #define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */ 80 86 81 87 #define cpu_has(c, bit) test_bit(bit, (c)->x86_capability) 82 88 #define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)