From owner-svn-src-all@FreeBSD.ORG Tue Jul 14 18:40:31 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D50D106564A; Tue, 14 Jul 2009 18:40:31 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 79DEB8FC1D; Tue, 14 Jul 2009 18:40:31 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n6EIeVrh067800; Tue, 14 Jul 2009 18:40:31 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6EIeV4i067797; Tue, 14 Jul 2009 18:40:31 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <200907141840.n6EIeV4i067797@svn.freebsd.org> From: Jung-uk Kim Date: Tue, 14 Jul 2009 18:40:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195687 - in stable/7/sys: . amd64/amd64 contrib/pf i386/i386 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2009 18:40:32 -0000 Author: jkim Date: Tue Jul 14 18:40:31 2009 New Revision: 195687 URL: http://svn.freebsd.org/changeset/base/195687 Log: MFC: r191788 Unlock the largest standard CPUID on Intel CPUs for both amd64 and i386. On i386, we extend it to cover Core, Core 2, and Core i7 processors, not just Pentium 4 family, and move it to better place. On amd64, all supported Intel CPUs should have this MSR. Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/amd64/identcpu.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/i386/i386/identcpu.c Modified: stable/7/sys/amd64/amd64/identcpu.c ============================================================================== --- stable/7/sys/amd64/amd64/identcpu.c Tue Jul 14 17:37:59 2009 (r195686) +++ stable/7/sys/amd64/amd64/identcpu.c Tue Jul 14 18:40:31 2009 (r195687) @@ -489,6 +489,22 @@ identify_cpu(void) cpu_feature = regs[3]; cpu_feature2 = regs[2]; + /* + * Clear "Limit CPUID Maxval" bit and get the largest standard CPUID + * function number again if it is set from BIOS. It is necessary + * for probing correct CPU topology later. + * XXX This is only done on the BSP package. + */ + if (cpu_vendor_id == CPU_VENDOR_INTEL && cpu_high > 0 && cpu_high < 4) { + 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) { Modified: stable/7/sys/i386/i386/identcpu.c ============================================================================== --- stable/7/sys/i386/i386/identcpu.c Tue Jul 14 17:37:59 2009 (r195686) +++ stable/7/sys/i386/i386/identcpu.c Tue Jul 14 18:40:31 2009 (r195687) @@ -209,7 +209,6 @@ printcpuinfo(void) if (cpu_vendor_id == CPU_VENDOR_INTEL) { if ((cpu_id & 0xf00) > 0x300) { u_int brand_index; - u_int model; cpu_model[0] = '\0'; @@ -322,16 +321,6 @@ printcpuinfo(void) case 0xf00: 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"); @@ -1127,6 +1116,24 @@ finishidentcpu(void) cpu_vendor_id = find_cpu_vendor_id(); + /* + * Clear "Limit CPUID Maxval" bit and get the largest standard CPUID + * function number again if it is set from BIOS. It is necessary + * for probing correct CPU topology later. + * XXX This is only done on the BSP package. + */ + if (cpu_vendor_id == CPU_VENDOR_INTEL && cpu_high > 0 && cpu_high < 4 && + ((I386_CPU_FAMILY(cpu_id) == 0xf && I386_CPU_MODEL(cpu_id) >= 0x3) || + (I386_CPU_FAMILY(cpu_id) == 0x6 && I386_CPU_MODEL(cpu_id) >= 0xe))) { + 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) {