Module Name:    src
Committed By:   maxv
Date:           Sun Dec 13 15:02:20 UTC 2015

Modified Files:
        src/sys/arch/x86/include: cpu.h cpuvar.h
        src/sys/arch/x86/x86: cpu.c identcpu.c

Log Message:
Retrieve cpuid7 (Structured Extended Features) into ci_feat_val.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x86/include/cpuvar.h
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/x86/x86/identcpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.66 src/sys/arch/x86/include/cpu.h:1.67
--- src/sys/arch/x86/include/cpu.h:1.66	Sun Feb 23 22:38:40 2014
+++ src/sys/arch/x86/include/cpu.h	Sun Dec 13 15:02:19 2015
@@ -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 @@ struct cpu_info {
 	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 */

Index: src/sys/arch/x86/include/cpuvar.h
diff -u src/sys/arch/x86/include/cpuvar.h:1.46 src/sys/arch/x86/include/cpuvar.h:1.47
--- src/sys/arch/x86/include/cpuvar.h:1.46	Fri Apr 20 22:23:24 2012
+++ src/sys/arch/x86/include/cpuvar.h	Sun Dec 13 15:02:19 2015
@@ -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 @@ void	pat_init(struct cpu_info *);
 extern int cpu_vendor;
 extern bool x86_mp_online;
 
-extern uint32_t cpu_feature[5];
+extern uint32_t cpu_feature[7];
 
 #endif /* _KERNEL */
 

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.116 src/sys/arch/x86/x86/cpu.c:1.117
--- src/sys/arch/x86/x86/cpu.c:1.116	Thu Sep 17 23:48:01 2015
+++ src/sys/arch/x86/x86/cpu.c	Sun Dec 13 15:02:19 2015
@@ -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	tss_init(struct i386tss *, v
 
 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 @@ cpu_boot_secondary(struct cpu_info *ci)
 }
 
 /*
- * 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.

Index: src/sys/arch/x86/x86/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.48 src/sys/arch/x86/x86/identcpu.c:1.49
--- src/sys/arch/x86/x86/identcpu.c:1.48	Mon Dec  8 15:22:47 2014
+++ src/sys/arch/x86/x86/identcpu.c	Sun Dec 13 15:02:19 2015
@@ -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 @@ cpu_probe(struct cpu_info *ci)
 		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);

Reply via email to