Intel CPUID2 (data in ecx after cpuid) patch

Thomas E. Spanjaard tgen at netphreax.net
Thu Dec 7 06:39:23 PST 2006


Attached patch adds detection, storage and printing of additional flags 
reported by cpuid in the ecx register on newer Intel CPUs. One problem I 
have, is that cpu_feature (and the new cpu_feature2) are declared in 
sys/systm.h, when they're actually machine dependent. Shouldn't they 
rather be in e.g. machine/cpufunc.h?

The printing stuff was obtained from FreeBSD, as for the CPUID2 constants.

Cheers,
--
        Thomas E. Spanjaard
        tgen at netphreax.net
Index: cpu/i386/include/specialreg.h
===================================================================
RCS file: /home/dcvs/src/sys/cpu/i386/include/specialreg.h,v
retrieving revision 1.6
diff -u -r1.6 specialreg.h
--- cpu/i386/include/specialreg.h	7 Nov 2006 06:43:22 -0000	1.6
+++ cpu/i386/include/specialreg.h	7 Dec 2006 14:24:19 -0000
@@ -112,6 +112,14 @@
 #define	CPUID_B30	0x40000000
 #define	CPUID_PBE	0x80000000
 
+#define	CPUID2_SSE3	0x00000001
+#define	CPUID2_MON	0x00000008
+#define	CPUID2_DS_CPL	0x00000010
+#define	CPUID2_EST	0x00000080
+#define	CPUID2_TM2	0x00000100
+#define	CPUID2_CNTXID	0x00000400
+#define	CPUID2_CX16	0x00002000
+
 /*
  * CPUID instruction 1 ebx info
  */
Index: machine/pc32/i386/est.c
===================================================================
RCS file: /home/dcvs/src/sys/machine/pc32/i386/est.c,v
retrieving revision 1.2
diff -u -r1.2 est.c
--- machine/pc32/i386/est.c	30 Jun 2006 07:34:59 -0000	1.2
+++ machine/pc32/i386/est.c	7 Dec 2006 14:18:01 -0000
@@ -578,6 +578,7 @@
 	int			err;
 	size_t			i;
 
+/* XXX TGEN this is dead code now, retained for reference */
 #ifndef CPUID2_EST
 	int			regs[4];
 
Index: machine/pc32/i386/identcpu.c
===================================================================
RCS file: /home/dcvs/src/sys/machine/pc32/i386/identcpu.c,v
retrieving revision 1.14
diff -u -r1.14 identcpu.c
--- machine/pc32/i386/identcpu.c	7 Dec 2006 13:33:04 -0000	1.14
+++ machine/pc32/i386/identcpu.c	7 Dec 2006 14:27:06 -0000
@@ -688,6 +688,44 @@
 			"\040PBE"	/* Pending Break Enable */
 			);
 
+			if (cpu_feature2 != 0) {
+				printf("\n  Features2=0x%b", cpu_feature2,
+				"\020"
+				"\001SSE3"	/* SSE3 */
+				"\002<b1>"
+				"\003RSVD2"	/* "Reserved" bit 2 */
+				"\004MON"	/* MONITOR/MWAIT Instructions */
+				"\005DS_CPL"	/* CPL Qualified Debug Store */
+				"\006VMX"	/* Virtual Machine Extensions */
+				"\007<b6>"
+				"\010EST"	/* Enhanced SpeedStep */
+				"\011TM2"	/* Thermal Monitor 2 */
+				"\012<b9>"
+				"\013CNTX-ID"	/* L1 context ID available */
+				"\014<b11>"
+				"\015<b12>"
+				"\016CX16"	/* CMPXCHG16B Instruction */
+				"\017XTPR"	/* Send Task Priority Messages*/
+				"\020<b15>"
+				"\021<b16>"
+				"\022<b17>"
+				"\023<b18>"
+				"\024<b19>"
+				"\025<b20>"
+				"\026<b21>"
+				"\027<b22>"
+				"\030<b23>"
+				"\031<b24>"
+				"\032<b25>"
+				"\033<b26>"
+				"\034<b27>"
+				"\035<b28>"
+				"\036<b29>"
+				"\037<b30>"
+				"\040<b31>"
+				);
+			}
+
 			/*
 			 * If this CPU supports hyperthreading then mention
 			 * the number of logical CPU's it contains.
Index: machine/pc32/i386/locore.s
===================================================================
RCS file: /home/dcvs/src/sys/machine/pc32/i386/locore.s,v
retrieving revision 1.11
diff -u -r1.11 locore.s
--- machine/pc32/i386/locore.s	7 Nov 2005 20:05:51 -0000	1.11
+++ machine/pc32/i386/locore.s	7 Dec 2006 14:13:29 -0000
@@ -103,12 +103,13 @@
 	.globl	boothowto,bootdev
 
 	.globl	cpu,cpu_vendor,cpu_id,bootinfo
-	.globl	cpu_high, cpu_feature, cpu_procinfo
+	.globl	cpu_high, cpu_feature, cpu_feature2, cpu_procinfo
 
 cpu:		.long	0			/* are we 386, 386sx, or 486 */
 cpu_id:		.long	0			/* stepping ID */
 cpu_high:	.long	0			/* highest arg to CPUID */
 cpu_feature:	.long	0			/* features */
+cpu_feature2:	.long	0			/* additional features */
 cpu_procinfo:	.long	0			/* brand index / HTT info */
 cpu_vendor:	.space	20			/* CPU origin code */
 bootinfo:	.space	BOOTINFO_SIZE		/* bootinfo buffer space */
@@ -623,6 +624,7 @@
 	movl	%eax,R(cpu_id)			# store cpu_id
 	movl	%ebx,R(cpu_procinfo)		# store cpu_procinfo
 	movl	%edx,R(cpu_feature)		# store cpu_feature
+	movl	%ecx,R(cpu_feature2)		# store cpu_feature2
 	rorl	$8,%eax				# extract family type
 	andl	$15,%eax
 	cmpl	$5,%eax
Index: sys/systm.h
===================================================================
RCS file: /home/dcvs/src/sys/sys/systm.h,v
retrieving revision 1.48
diff -u -r1.48 systm.h
--- sys/systm.h	5 Dec 2006 23:14:55 -0000	1.48
+++ sys/systm.h	7 Dec 2006 14:23:20 -0000
@@ -90,7 +90,10 @@
 extern int ncpus2_mask;		/* ncpus2 - 1 */
 extern int clocks_running;	/* timing/timeout subsystem is operational */
 
+/* XXX TGEN these don't belong here, they're MD on i386/amd64 */
 extern u_int cpu_feature;	/* CPUID_* features */
+extern u_int cpu_feature2;	/* CPUID2_* features */
+
 extern int nfs_diskless_valid;	/* NFS diskless params were obtained */
 extern vm_paddr_t Maxmem;	/* Highest physical memory address in system */
 
Attachment:
signature.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00005.pgp
Type: application/octet-stream
Size: 186 bytes
Desc: "Description: OpenPGP digital signature"
URL: <http://lists.dragonflybsd.org/pipermail/submit/attachments/20061207/ff01cb65/attachment-0018.obj>


More information about the Submit mailing list