--- sys/amd64/amd64/identcpu.c 29 Apr 2009 06:54:40 -0000 1.172 +++ sys/amd64/amd64/identcpu.c 1 May 2009 20:00:59 -0000 @@ -472,6 +472,24 @@ cpu_feature = regs[3]; cpu_feature2 = regs[2]; + /* + * Clear "Limit CPUID Maxval" bit and get the highest + * basic CPUID function again if it is set from BIOS. + * It is necessary for probing correct CPU topology later. + * XXX This is only done on BSP. + */ + if (cpu_vendor_id == CPU_VENDOR_INTEL && + cpu_high > 0 && cpu_high < 4 && + (cpu_feature & CPUID_HTT) != 0) { + uint64_t msr; + msr = rdmsr(MSR_IA32_MISC_ENABLE); + if ((msr & 0x400000ULL) != 0) { + wrmsr(MSR_IA32_MISC_ENABLE, msr & ~0x400000ULL); + do_cpuid(0, regs); + cpu_high = regs[0]; + } + } + if (cpu_vendor_id == CPU_VENDOR_INTEL || cpu_vendor_id == CPU_VENDOR_AMD || cpu_vendor_id == CPU_VENDOR_CENTAUR) { --- sys/i386/i386/identcpu.c 29 Apr 2009 06:54:40 -0000 1.201 +++ sys/i386/i386/identcpu.c 1 May 2009 20:00:59 -0000 @@ -323,15 +323,6 @@ strcat(cpu_model, "Pentium 4"); cpu = CPU_P4; model = (cpu_id & 0x0f0) >> 4; - if (model == 3 || model == 4 || model == 6) { - uint64_t tmp; - - tmp = rdmsr(MSR_IA32_MISC_ENABLE); - wrmsr(MSR_IA32_MISC_ENABLE, - tmp & ~(1LL << 22)); - do_cpuid(0, regs); - cpu_high = regs[0]; - } break; default: strcat(cpu_model, "unknown"); @@ -1110,6 +1101,24 @@ cpu_vendor_id = find_cpu_vendor_id(); + /* + * Clear "Limit CPUID Maxval" bit and get the highest + * basic CPUID function again if it is set from BIOS. + * It is necessary for probing correct CPU topology later. + * XXX This is only done on BSP. + */ + if (cpu_vendor_id == CPU_VENDOR_INTEL && + cpu_high > 0 && cpu_high < 4 && + (cpu_feature & CPUID_HTT) != 0) { + uint64_t msr; + msr = rdmsr(MSR_IA32_MISC_ENABLE); + if ((msr & 0x400000ULL) != 0) { + wrmsr(MSR_IA32_MISC_ENABLE, msr & ~0x400000ULL); + do_cpuid(0, regs); + cpu_high = regs[0]; + } + } + /* Detect AMD features (PTE no-execute bit, 3dnow, 64 bit mode etc) */ if (cpu_vendor_id == CPU_VENDOR_INTEL || cpu_vendor_id == CPU_VENDOR_AMD) {