diff options
author | netchild <netchild@FreeBSD.org> | 2006-01-04 12:57:02 +0000 |
---|---|---|
committer | netchild <netchild@FreeBSD.org> | 2006-01-04 12:57:02 +0000 |
commit | e426666183b577af4f703c82c374703a3b0ce946 (patch) | |
tree | 722f8ce49b2e759c2b390af773686c386652d017 | |
parent | 45180066f93caa4e3c964ce71f02f9db7f7415fa (diff) | |
download | FreeBSD-src-e426666183b577af4f703c82c374703a3b0ce946.zip FreeBSD-src-e426666183b577af4f703c82c374703a3b0ce946.tar.gz |
- Make sure the cpu_exthigh variable is initialized (page coloring case). [1]
- Remove a conditional in the AMD cache detection, it's always false. [2]
- Don't try to detect a cache if only compiled for i386.
Analyzed by: Antoine Brodin <antoine.brodin@laposte.net> [1]
Submitted by: Antoine Brodin <antoine.brodin@laposte.net> [2]
-rw-r--r-- | sys/i386/i386/identcpu.c | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/sys/i386/i386/identcpu.c b/sys/i386/i386/identcpu.c index 9c8da1e..944dba9 100644 --- a/sys/i386/i386/identcpu.c +++ b/sys/i386/i386/identcpu.c @@ -74,6 +74,9 @@ void enable_K6_2_wt_alloc(void); void panicifcpuunsupported(void); static void identifycyrix(void); +#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) +static void init_exthigh(void); +#endif void setPQL2(int *const size, int *const ways); static void setPQL2_AMD(int *const size, int *const ways); static void setPQL2_INTEL(int *const size, int *const ways); @@ -144,6 +147,30 @@ static struct { int has_f00f_bug = 0; /* Initialized so that it can be patched. */ #endif +#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) +static void +init_exthigh(void) +{ + static int done = 0; + u_int regs[4]; + + if (done == 0) { + if (cpu_high > 0 && + (strcmp(cpu_vendor, "GenuineIntel") == 0 || + strcmp(cpu_vendor, "AuthenticAMD") == 0 || + strcmp(cpu_vendor, "GenuineTMx86") == 0 || + strcmp(cpu_vendor, "TransmetaCPU") == 0 || + strcmp(cpu_vendor, "Geode by NSC") == 0)) { + do_cpuid(0x80000000, regs); + if (regs[0] >= 0x80000000) + cpu_exthigh = regs[0]; + } + + done = 1; + } +} +#endif + void printcpuinfo(void) { @@ -158,23 +185,13 @@ printcpuinfo(void) #if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) /* Check for extended CPUID information and a processor name. */ - if (cpu_high > 0 && - (strcmp(cpu_vendor, "GenuineIntel") == 0 || - strcmp(cpu_vendor, "AuthenticAMD") == 0 || - strcmp(cpu_vendor, "GenuineTMx86") == 0 || - strcmp(cpu_vendor, "TransmetaCPU") == 0 || - strcmp(cpu_vendor, "Geode by NSC") == 0)) { - do_cpuid(0x80000000, regs); - if (regs[0] >= 0x80000000) { - cpu_exthigh = regs[0]; - if (cpu_exthigh >= 0x80000004) { - brand = cpu_brand; - for (i = 0x80000002; i < 0x80000005; i++) { - do_cpuid(i, regs); - memcpy(brand, regs, sizeof(regs)); - brand += sizeof(regs); - } - } + init_exthigh(); + if (cpu_exthigh >= 0x80000004) { + brand = cpu_brand; + for (i = 0x80000002; i < 0x80000005; i++) { + do_cpuid(i, regs); + memcpy(brand, regs, sizeof(regs)); + brand += sizeof(regs); } } @@ -1431,8 +1448,6 @@ setPQL2_AMD(int *const size, int *const ways) { do_cpuid(0x80000006, regs); *size = regs[2] >> 16; *ways = (regs[2] >> 12) & 0x0f; - if(*ways == 255) /* fully associative */ - *ways = 1; } } @@ -1677,10 +1692,15 @@ get_INTEL_TLB(u_int data, int *const size, int *const ways) void setPQL2(int *const size, int *const ways) { +#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) + /* make sure the cpu_exthigh variable is initialized */ + init_exthigh(); + if (strcmp(cpu_vendor, "AuthenticAMD") == 0) setPQL2_AMD(size, ways); else if (strcmp(cpu_vendor, "GenuineIntel") == 0) setPQL2_INTEL(size, ways); +#endif } static void |