Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src - AMD also reports CPUID 7's highest subleaf. Print it.



details:   https://anonhg.NetBSD.org/src/rev/b6b48913f2ac
branches:  trunk
changeset: 837155:b6b48913f2ac
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Nov 21 10:34:53 2018 +0000

description:
- AMD also reports CPUID 7's highest subleaf. Print it.
- Use macro.

diffstat:

 sys/arch/x86/x86/cpu_topology.c |   7 ++++---
 usr.sbin/cpuctl/arch/i386.c     |  22 ++++++++++++++--------
 2 files changed, 18 insertions(+), 11 deletions(-)

diffs (96 lines):

diff -r 2aa0f53601bb -r b6b48913f2ac sys/arch/x86/x86/cpu_topology.c
--- a/sys/arch/x86/x86/cpu_topology.c   Wed Nov 21 10:25:17 2018 +0000
+++ b/sys/arch/x86/x86/cpu_topology.c   Wed Nov 21 10:34:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_topology.c,v 1.13 2018/01/28 16:32:43 mlelstv Exp $        */
+/*     $NetBSD: cpu_topology.c,v 1.14 2018/11/21 10:34:53 msaitoh Exp $        */
 
 /*-
  * Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>,
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.13 2018/01/28 16:32:43 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.14 2018/11/21 10:34:53 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/bitops.h>
@@ -92,7 +92,8 @@
                if (ci->ci_max_cpuid >= 4) {
                        /* Maximum number of Cores per package (eax[31:26]). */
                        x86_cpuid2(4, 0, descs);
-                       core_max = (descs[0] >> 26) + 1;
+                       core_max = __SHIFTOUT(descs[0], CPUID_DCP_CORE_P_PKG)
+                           + 1;
                } else {
                        core_max = 1;
                }
diff -r 2aa0f53601bb -r b6b48913f2ac usr.sbin/cpuctl/arch/i386.c
--- a/usr.sbin/cpuctl/arch/i386.c       Wed Nov 21 10:25:17 2018 +0000
+++ b/usr.sbin/cpuctl/arch/i386.c       Wed Nov 21 10:34:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386.c,v 1.86 2018/11/21 06:10:25 msaitoh Exp $        */
+/*     $NetBSD: i386.c,v 1.87 2018/11/21 10:34:53 msaitoh Exp $        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.86 2018/11/21 06:10:25 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.87 2018/11/21 10:34:53 msaitoh Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -1813,7 +1813,7 @@
        }
        if (ci->ci_cpuid_level >= 4) {
                x86_cpuid2(4, 0, descs);
-               core_max = (descs[0] >> 26) + 1;
+               core_max = __SHIFTOUT(descs[0], CPUID_DCP_CORE_P_PKG) + 1;
        }
        assert(lp_max >= core_max);
        smt_max = lp_max / core_max;
@@ -2098,6 +2098,14 @@
                print_bits(cpuname, "DSPM-eax", CPUID_DSPM_FLAGS, descs[0]);
                print_bits(cpuname, "DSPM-ecx", CPUID_DSPM_FLAGS1, descs[2]);
        }
+       if ((ci->ci_cpuid_level >= 7)
+           && ((cpu_vendor == CPUVENDOR_INTEL)
+               || (cpu_vendor == CPUVENDOR_AMD))) {
+               x86_cpuid(7, descs);
+               aprint_verbose("%s: SEF highest subleaf %08x\n",
+                   cpuname, descs[0]);
+       }
+
        if (cpu_vendor == CPUVENDOR_AMD) {
                x86_cpuid(0x80000000, descs);
                if (descs[0] >= 0x80000007)
@@ -2117,13 +2125,11 @@
                int32_t bi_index;
 
                for (bi_index = 1; bi_index <= ci->ci_cpuid_level; bi_index++) {
+#if 0
                        x86_cpuid(bi_index, descs);
                        switch (bi_index) {
-                       case 7:
-                               aprint_verbose("%s: SEF highest subleaf %08x\n",
-                                   cpuname, descs[0]);
+                       case 0x0b:
                                break;
-#if 0
                        default:
                                aprint_verbose("%s: basic %08x-eax %08x\n",
                                    cpuname, bi_index, descs[0]);
@@ -2134,8 +2140,8 @@
                                aprint_verbose("%s: basic %08x-edx %08x\n",
                                    cpuname, bi_index, descs[3]);
                                break;
+                       }
 #endif
-                       }
                }
        }
 



Home | Main Index | Thread Index | Old Index