Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86 Retrieve cpuid7 (Structured Extended Features) ...



details:   https://anonhg.NetBSD.org/src/rev/ebcf92a3ecac
branches:  trunk
changeset: 812368:ebcf92a3ecac
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Dec 13 15:02:19 2015 +0000

description:
Retrieve cpuid7 (Structured Extended Features) into ci_feat_val.

diffstat:

 sys/arch/x86/include/cpu.h    |   6 ++++--
 sys/arch/x86/include/cpuvar.h |   4 ++--
 sys/arch/x86/x86/cpu.c        |  22 ++++++++++++----------
 sys/arch/x86/x86/identcpu.c   |  13 +++++++++++--
 4 files changed, 29 insertions(+), 16 deletions(-)

diffs (127 lines):

diff -r 73653f3eeaf4 -r ebcf92a3ecac sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Sun Dec 13 14:54:17 2015 +0000
+++ b/sys/arch/x86/include/cpu.h        Sun Dec 13 15:02:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.66 2014/02/23 22:38:40 dsl Exp $     */
+/*     $NetBSD: cpu.h,v 1.67 2015/12/13 15:02:19 maxv Exp $    */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -157,12 +157,14 @@
        uint32_t        ci_max_ext_cpuid; /* cpuid.80000000:%eax */
        volatile uint32_t       ci_lapic_counter;
 
-       uint32_t        ci_feat_val[5]; /* X86 CPUID feature bits */
+       uint32_t        ci_feat_val[7]; /* X86 CPUID feature bits */
                        /* [0] basic features cpuid.1:%edx
                         * [1] basic features cpuid.1:%ecx (CPUID2_xxx bits)
                         * [2] extended features cpuid:80000001:%edx
                         * [3] extended features cpuid:80000001:%ecx
                         * [4] VIA padlock features
+                        * [5] structured extended features cpuid.7:%ebx
+                        * [6] structured extended features cpuid.7:%ecx
                         */
        
        const struct cpu_functions *ci_func;  /* start/stop functions */
diff -r 73653f3eeaf4 -r ebcf92a3ecac sys/arch/x86/include/cpuvar.h
--- a/sys/arch/x86/include/cpuvar.h     Sun Dec 13 14:54:17 2015 +0000
+++ b/sys/arch/x86/include/cpuvar.h     Sun Dec 13 15:02:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuvar.h,v 1.46 2012/04/20 22:23:24 rmind Exp $ */
+/*     $NetBSD: cpuvar.h,v 1.47 2015/12/13 15:02:19 maxv Exp $ */
 
 /*-
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
 extern int cpu_vendor;
 extern bool x86_mp_online;
 
-extern uint32_t cpu_feature[5];
+extern uint32_t cpu_feature[7];
 
 #endif /* _KERNEL */
 
diff -r 73653f3eeaf4 -r ebcf92a3ecac sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Sun Dec 13 14:54:17 2015 +0000
+++ b/sys/arch/x86/x86/cpu.c    Sun Dec 13 15:02:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.116 2015/09/17 23:48:01 nat Exp $    */
+/*     $NetBSD: cpu.c,v 1.117 2015/12/13 15:02:19 maxv Exp $   */
 
 /*-
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.116 2015/09/17 23:48:01 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.117 2015/12/13 15:02:19 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -177,13 +177,15 @@
 
 static void    cpu_init_idle_lwp(struct cpu_info *);
 
-uint32_t cpu_feature[5]; /* X86 CPUID feature bits
-                         *     [0] basic features %edx
-                         *     [1] basic features %ecx
-                         *     [2] extended features %edx
-                         *     [3] extended features %ecx
-                         *     [4] VIA padlock features
-                         */
+uint32_t cpu_feature[7]; /* X86 CPUID feature bits */
+                       /* [0] basic features cpuid.1:%edx
+                        * [1] basic features cpuid.1:%ecx (CPUID2_xxx bits)
+                        * [2] extended features cpuid:80000001:%edx
+                        * [3] extended features cpuid:80000001:%ecx
+                        * [4] VIA padlock features
+                        * [5] structured extended features cpuid.7:%ebx
+                        * [6] structured extended features cpuid.7:%ecx
+                        */
 
 extern char x86_64_doubleflt_stack[];
 
@@ -783,7 +785,7 @@
 }
 
 /*
- * The CPU ends up here when its ready to run
+ * The CPU ends up here when it's ready to run.
  * This is called from code in mptramp.s; at this point, we are running
  * in the idle pcb/idle stack of the new CPU.  When this function returns,
  * this processor will enter the idle loop and start looking for work.
diff -r 73653f3eeaf4 -r ebcf92a3ecac sys/arch/x86/x86/identcpu.c
--- a/sys/arch/x86/x86/identcpu.c       Sun Dec 13 14:54:17 2015 +0000
+++ b/sys/arch/x86/x86/identcpu.c       Sun Dec 13 15:02:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: identcpu.c,v 1.48 2014/12/08 15:22:47 msaitoh Exp $    */
+/*     $NetBSD: identcpu.c,v 1.49 2015/12/13 15:02:19 maxv Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.48 2014/12/08 15:22:47 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.49 2015/12/13 15:02:19 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -858,6 +858,15 @@
                memcpy(cpu_brand_string, ((char *) brand) + i, 48 - i);
        }
 
+       /*
+        * Get the structured extended features.
+        */
+       if (cpuid_level >= 7) {
+               x86_cpuid(7, descs);
+               ci->ci_feat_val[5] = descs[1]; /* %ebx */
+               ci->ci_feat_val[6] = descs[2]; /* %ecx */
+       }
+
        cpu_probe_intel(ci);
        cpu_probe_k5(ci);
        cpu_probe_k678(ci);



Home | Main Index | Thread Index | Old Index