From 49cda8ebad91c3ca9ce808d599cb3562cb52aafa Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" <hpa@zytor.com> Date: Sun, 15 Sep 2002 21:27:07 -0700 Subject: [PATCH] [PATCH] CPU detection fixes... I noticed a kluge had been put into 2.5.35, to cover up *one* of the errors caused by a particular bug that was introduced when Patrick Mochel split up arch/i386/kernel/setup.c: he incorrectly thought the AMD-defined CPUID levels were AMD-specific; they're not -- every other x86 vendors *including* Intel uses them as well. This also adds the "i686" hack for TM5xxx that was added in 2.4 recently. --- arch/i386/kernel/cpu/amd.c | 20 +------------------- arch/i386/kernel/cpu/common.c | 11 ++++++++++- arch/i386/kernel/cpu/intel.c | 1 - arch/i386/kernel/cpu/transmeta.c | 5 +++++ 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c index 9c7f94037fda..00b09cc403a2 100644 --- a/arch/i386/kernel/cpu/amd.c +++ b/arch/i386/kernel/cpu/amd.c @@ -157,24 +157,6 @@ static void __init init_amd(struct cpuinfo_x86 *c) // return r; } -static void amd_identify(struct cpuinfo_x86 * c) -{ - u32 xlvl; - - if (have_cpuid_p()) { - generic_identify(c); - - /* AMD-defined flags: level 0x80000001 */ - xlvl = cpuid_eax(0x80000000); - if ( (xlvl & 0xffff0000) == 0x80000000 ) { - if ( xlvl >= 0x80000001 ) - c->x86_capability[1] = cpuid_edx(0x80000001); - if ( xlvl >= 0x80000004 ) - get_model_name(c); /* Default name */ - } - } -} - static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size) { /* AMD errata T13 (order #21922) */ @@ -204,7 +186,7 @@ static struct cpu_dev amd_cpu_dev __initdata = { }, }, .c_init = init_amd, - .c_identify = amd_identify, + .c_identify = generic_identify, .c_size_cache = amd_size_cache, }; diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c index 88041a31ce5d..2af5a1fa3e72 100644 --- a/arch/i386/kernel/cpu/common.c +++ b/arch/i386/kernel/cpu/common.c @@ -204,7 +204,7 @@ int __init have_cpuid_p(void) void __init generic_identify(struct cpuinfo_x86 * c) { - u32 tfms; + u32 tfms, xlvl; int junk; if (have_cpuid_p()) { @@ -230,6 +230,15 @@ void __init generic_identify(struct cpuinfo_x86 * c) /* Have CPUID level 0 only - unheard of */ c->x86 = 4; } + + /* AMD-defined flags: level 0x80000001 */ + xlvl = cpuid_eax(0x80000000); + if ( (xlvl & 0xffff0000) == 0x80000000 ) { + if ( xlvl >= 0x80000001 ) + c->x86_capability[1] = cpuid_edx(0x80000001); + if ( xlvl >= 0x80000004 ) + get_model_name(c); /* Default name */ + } } } diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c index 6aa1e33becaf..ff98d996d336 100644 --- a/arch/i386/kernel/cpu/intel.c +++ b/arch/i386/kernel/cpu/intel.c @@ -156,7 +156,6 @@ static void __init init_intel(struct cpuinfo_x86 *c) } #endif - get_model_name(c); if (c->cpuid_level > 1) { /* supports eax=2 call */ diff --git a/arch/i386/kernel/cpu/transmeta.c b/arch/i386/kernel/cpu/transmeta.c index 2314da6f8421..4bb3c5633b1f 100644 --- a/arch/i386/kernel/cpu/transmeta.c +++ b/arch/i386/kernel/cpu/transmeta.c @@ -64,6 +64,11 @@ static void __init init_transmeta(struct cpuinfo_x86 *c) wrmsr(0x80860004, ~0, uk); c->x86_capability[0] = cpuid_edx(0x00000001); wrmsr(0x80860004, cap_mask, uk); + + /* If we can run i686 user-space code, call us an i686 */ +#define USER686 (X86_FEATURE_TSC|X86_FEATURE_CX8|X86_FEATURE_CMOV) + if ( c->x86 == 5 && (c->x86_capability[0] & USER686) == USER686 ) + c->x86 = 6; } static void transmeta_identify(struct cpuinfo_x86 * c) -- 2.30.9