xref: /titanic_44/usr/src/uts/intel/sys/x86_archext.h (revision d573a5661b3f90d56bd90e44b1d931805839ec80)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5ee88d2b9Skchow  * Common Development and Distribution License (the "License").
6ee88d2b9Skchow  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227417cfdeSKuriakose Kuruvilla  * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
23cfe84b82SMatt Amdur  * Copyright (c) 2011 by Delphix. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
25cef70d2cSBill Holler /*
2641afdfa7SKrishnendu Sadhukhan - Sun Microsystems  * Copyright (c) 2010, Intel Corporation.
27cef70d2cSBill Holler  * All rights reserved.
28cef70d2cSBill Holler  */
29faa20166SBryan Cantrill /*
304e348e74SJohn Levon  * Copyright 2018 Joyent, Inc.
3179321794SJens Elkner  * Copyright 2012 Jens Elkner <jel+illumos@cs.uni-magdeburg.de>
3279321794SJens Elkner  * Copyright 2012 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
336eedf6a5SJosef 'Jeff' Sipek  * Copyright 2014 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
34a48de2a1SYuri Pankov  * Copyright 2018 Nexenta Systems, Inc.
35faa20166SBryan Cantrill  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifndef _SYS_X86_ARCHEXT_H
387c478bd9Sstevel@tonic-gate #define	_SYS_X86_ARCHEXT_H
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #if !defined(_ASM)
417c478bd9Sstevel@tonic-gate #include <sys/regset.h>
427c478bd9Sstevel@tonic-gate #include <sys/processor.h>
437c478bd9Sstevel@tonic-gate #include <vm/seg_enum.h>
447c478bd9Sstevel@tonic-gate #include <vm/page.h>
457c478bd9Sstevel@tonic-gate #endif	/* _ASM */
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
487c478bd9Sstevel@tonic-gate extern "C" {
497c478bd9Sstevel@tonic-gate #endif
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * cpuid instruction feature flags in %edx (standard function 1)
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_FPU	0x00000001	/* x87 fpu present */
567c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_VME	0x00000002	/* virtual-8086 extension */
577c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_DE	0x00000004	/* debugging extensions */
587c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_PSE	0x00000008	/* page size extension */
597c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_TSC	0x00000010	/* time stamp counter */
607c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_MSR	0x00000020	/* rdmsr and wrmsr */
617c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_PAE	0x00000040	/* physical addr extension */
627c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_MCE	0x00000080	/* machine check exception */
637c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_CX8	0x00000100	/* cmpxchg8b instruction */
647c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_APIC	0x00000200	/* local APIC */
657c478bd9Sstevel@tonic-gate 						/* 0x400 - reserved */
667c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_SEP	0x00000800	/* sysenter and sysexit */
677c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_MTRR	0x00001000	/* memory type range reg */
687c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_PGE	0x00002000	/* page global enable */
697c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_MCA	0x00004000	/* machine check arch */
707c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_CMOV	0x00008000	/* conditional move insns */
717c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_PAT	0x00010000	/* page attribute table */
727c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_PSE36	0x00020000	/* 36-bit pagesize extension */
737c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_PSN	0x00040000	/* processor serial number */
747c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_CLFSH	0x00080000	/* clflush instruction */
757c478bd9Sstevel@tonic-gate 						/* 0x100000 - reserved */
767c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_DS	0x00200000	/* debug store exists */
777c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_ACPI	0x00400000	/* monitoring + clock ctrl */
787c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_MMX	0x00800000	/* MMX instructions */
797c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_FXSR	0x01000000	/* fxsave and fxrstor */
807c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_SSE	0x02000000	/* streaming SIMD extensions */
817c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_SSE2	0x04000000	/* SSE extensions */
827c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_SS	0x08000000	/* self-snoop */
837c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_HTT	0x10000000	/* Hyper Thread Technology */
847c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_TM	0x20000000	/* thermal monitoring */
85ae115bc7Smrj #define	CPUID_INTC_EDX_IA64	0x40000000	/* Itanium emulating IA32 */
867c478bd9Sstevel@tonic-gate #define	CPUID_INTC_EDX_PBE	0x80000000	/* Pending Break Enable */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate #define	FMT_CPUID_INTC_EDX					\
897c478bd9Sstevel@tonic-gate 	"\20"							\
90ae115bc7Smrj 	"\40pbe\37ia64\36tm\35htt\34ss\33sse2\32sse\31fxsr"	\
917c478bd9Sstevel@tonic-gate 	"\30mmx\27acpi\26ds\24clfsh\23psn\22pse36\21pat"	\
927c478bd9Sstevel@tonic-gate 	"\20cmov\17mca\16pge\15mtrr\14sep\12apic\11cx8"		\
937c478bd9Sstevel@tonic-gate 	"\10mce\7pae\6msr\5tsc\4pse\3de\2vme\1fpu"
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * cpuid instruction feature flags in %ecx (standard function 1)
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate #define	CPUID_INTC_ECX_SSE3	0x00000001	/* Yet more SSE extensions */
100a50a8b93SKuriakose Kuruvilla #define	CPUID_INTC_ECX_PCLMULQDQ 0x00000002 	/* PCLMULQDQ insn */
1014e348e74SJohn Levon #define	CPUID_INTC_ECX_DTES64	0x00000004	/* 64-bit DS area */
1027c478bd9Sstevel@tonic-gate #define	CPUID_INTC_ECX_MON	0x00000008	/* MONITOR/MWAIT */
1037c478bd9Sstevel@tonic-gate #define	CPUID_INTC_ECX_DSCPL	0x00000010	/* CPL-qualified debug store */
104ae115bc7Smrj #define	CPUID_INTC_ECX_VMX	0x00000020	/* Hardware VM extensions */
105ae115bc7Smrj #define	CPUID_INTC_ECX_SMX	0x00000040	/* Secure mode extensions */
1067c478bd9Sstevel@tonic-gate #define	CPUID_INTC_ECX_EST	0x00000080	/* enhanced SpeedStep */
1077c478bd9Sstevel@tonic-gate #define	CPUID_INTC_ECX_TM2	0x00000100	/* thermal monitoring */
108ae115bc7Smrj #define	CPUID_INTC_ECX_SSSE3	0x00000200	/* Supplemental SSE3 insns */
1097c478bd9Sstevel@tonic-gate #define	CPUID_INTC_ECX_CID	0x00000400	/* L1 context ID */
1107c478bd9Sstevel@tonic-gate 						/* 0x00000800 - reserved */
111245ac945SRobert Mustacchi #define	CPUID_INTC_ECX_FMA	0x00001000	/* Fused Multiply Add */
112ae115bc7Smrj #define	CPUID_INTC_ECX_CX16	0x00002000	/* cmpxchg16 */
113ae115bc7Smrj #define	CPUID_INTC_ECX_ETPRD	0x00004000	/* extended task pri messages */
1144e348e74SJohn Levon #define	CPUID_INTC_ECX_PDCM	0x00008000	/* Perf/Debug Capability MSR */
115ae115bc7Smrj 						/* 0x00010000 - reserved */
1164e348e74SJohn Levon #define	CPUID_INTC_ECX_PCID	0x00020000	/* process-context ids */
117ae115bc7Smrj #define	CPUID_INTC_ECX_DCA	0x00040000	/* direct cache access */
118d0f8ff6eSkk208521 #define	CPUID_INTC_ECX_SSE4_1	0x00080000	/* SSE4.1 insns */
119d0f8ff6eSkk208521 #define	CPUID_INTC_ECX_SSE4_2	0x00100000	/* SSE4.2 insns */
1206eedf6a5SJosef 'Jeff' Sipek #define	CPUID_INTC_ECX_X2APIC	0x00200000	/* x2APIC */
1215087e485SKrishnendu Sadhukhan - Sun Microsystems #define	CPUID_INTC_ECX_MOVBE	0x00400000	/* MOVBE insn */
122f8801251Skk208521 #define	CPUID_INTC_ECX_POPCNT	0x00800000	/* POPCNT insn */
1234e348e74SJohn Levon #define	CPUID_INTC_ECX_TSCDL	0x01000000	/* Deadline TSC */
124a50a8b93SKuriakose Kuruvilla #define	CPUID_INTC_ECX_AES	0x02000000	/* AES insns */
1257af88ac7SKuriakose Kuruvilla #define	CPUID_INTC_ECX_XSAVE	0x04000000	/* XSAVE/XRESTOR insns */
1267af88ac7SKuriakose Kuruvilla #define	CPUID_INTC_ECX_OSXSAVE	0x08000000	/* OS supports XSAVE insns */
1277af88ac7SKuriakose Kuruvilla #define	CPUID_INTC_ECX_AVX	0x10000000	/* AVX supported */
128ebb8ac07SRobert Mustacchi #define	CPUID_INTC_ECX_F16C	0x20000000	/* F16C supported */
129ebb8ac07SRobert Mustacchi #define	CPUID_INTC_ECX_RDRAND	0x40000000	/* RDRAND supported */
13079ec9da8SYuri Pankov #define	CPUID_INTC_ECX_HV	0x80000000	/* Hypervisor */
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate #define	FMT_CPUID_INTC_ECX					\
1337c478bd9Sstevel@tonic-gate 	"\20"							\
134ebb8ac07SRobert Mustacchi 	"\37rdrand\36f16c\35avx\34osxsav\33xsave"		\
135a50a8b93SKuriakose Kuruvilla 	"\32aes"						\
1366eedf6a5SJosef 'Jeff' Sipek 	"\30popcnt\27movbe\26x2apic\25sse4.2\24sse4.1\23dca"	\
137ae115bc7Smrj 	"\20\17etprd\16cx16\13cid\12ssse3\11tm2"		\
138a50a8b93SKuriakose Kuruvilla 	"\10est\7smx\6vmx\5dscpl\4mon\2pclmulqdq\1sse3"
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  * cpuid instruction feature flags in %edx (extended function 0x80000001)
1427c478bd9Sstevel@tonic-gate  */
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_FPU	0x00000001	/* x87 fpu present */
1457c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_VME	0x00000002	/* virtual-8086 extension */
1467c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_DE	0x00000004	/* debugging extensions */
1477c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_PSE	0x00000008	/* page size extensions */
1487c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_TSC	0x00000010	/* time stamp counter */
1497c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_MSR	0x00000020	/* rdmsr and wrmsr */
1507c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_PAE	0x00000040	/* physical addr extension */
1517c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_MCE	0x00000080	/* machine check exception */
1527c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_CX8	0x00000100	/* cmpxchg8b instruction */
1537c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_APIC	0x00000200	/* local APIC */
1547c478bd9Sstevel@tonic-gate 						/* 0x00000400 - sysc on K6m6 */
1557c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_SYSC	0x00000800	/* AMD: syscall and sysret */
1567c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_MTRR	0x00001000	/* memory type and range reg */
1577c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_PGE	0x00002000	/* page global enable */
1587c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_MCA	0x00004000	/* machine check arch */
1597c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_CMOV	0x00008000	/* conditional move insns */
160ae115bc7Smrj #define	CPUID_AMD_EDX_PAT	0x00010000	/* K7: page attribute table */
161ae115bc7Smrj #define	CPUID_AMD_EDX_FCMOV	0x00010000	/* FCMOVcc etc. */
1627c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_PSE36	0x00020000	/* 36-bit pagesize extension */
1637c478bd9Sstevel@tonic-gate 				/* 0x00040000 - reserved */
1647c478bd9Sstevel@tonic-gate 				/* 0x00080000 - reserved */
1657c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_NX	0x00100000	/* AMD: no-execute page prot */
1667c478bd9Sstevel@tonic-gate 				/* 0x00200000 - reserved */
1677c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_MMXamd	0x00400000	/* AMD: MMX extensions */
1687c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_MMX	0x00800000	/* MMX instructions */
1697c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_FXSR	0x01000000	/* fxsave and fxrstor */
170ae115bc7Smrj #define	CPUID_AMD_EDX_FFXSR	0x02000000	/* fast fxsave/fxrstor */
17102bc52beSkchow #define	CPUID_AMD_EDX_1GPG	0x04000000	/* 1GB page */
172ae115bc7Smrj #define	CPUID_AMD_EDX_TSCP	0x08000000	/* rdtscp instruction */
1737c478bd9Sstevel@tonic-gate 				/* 0x10000000 - reserved */
1747c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_LM	0x20000000	/* AMD: long mode */
1757c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_3DNowx	0x40000000	/* AMD: extensions to 3DNow! */
1767c478bd9Sstevel@tonic-gate #define	CPUID_AMD_EDX_3DNow	0x80000000	/* AMD: 3DNow! instructions */
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate #define	FMT_CPUID_AMD_EDX					\
1797c478bd9Sstevel@tonic-gate 	"\20"							\
180ae115bc7Smrj 	"\40a3d\37a3d+\36lm\34tscp\32ffxsr\31fxsr"		\
1817c478bd9Sstevel@tonic-gate 	"\30mmx\27mmxext\25nx\22pse\21pat"			\
1827c478bd9Sstevel@tonic-gate 	"\20cmov\17mca\16pge\15mtrr\14syscall\12apic\11cx8"	\
1837c478bd9Sstevel@tonic-gate 	"\10mce\7pae\6msr\5tsc\4pse\3de\2vme\1fpu"
1847c478bd9Sstevel@tonic-gate 
185*d573a566SRobert Mustacchi /*
186*d573a566SRobert Mustacchi  * AMD extended function 0x80000001 %ecx
187*d573a566SRobert Mustacchi  */
188*d573a566SRobert Mustacchi 
189ae115bc7Smrj #define	CPUID_AMD_ECX_AHF64	0x00000001	/* LAHF and SAHF in long mode */
190ae115bc7Smrj #define	CPUID_AMD_ECX_CMP_LGCY	0x00000002	/* AMD: multicore chip */
191ae115bc7Smrj #define	CPUID_AMD_ECX_SVM	0x00000004	/* AMD: secure VM */
192ae115bc7Smrj #define	CPUID_AMD_ECX_EAS	0x00000008	/* extended apic space */
193ae115bc7Smrj #define	CPUID_AMD_ECX_CR8D	0x00000010	/* AMD: 32-bit mov %cr8 */
194f8801251Skk208521 #define	CPUID_AMD_ECX_LZCNT	0x00000020	/* AMD: LZCNT insn */
195f8801251Skk208521 #define	CPUID_AMD_ECX_SSE4A	0x00000040	/* AMD: SSE4A insns */
196512cf780Skchow #define	CPUID_AMD_ECX_MAS	0x00000080	/* AMD: MisAlignSse mnode */
197512cf780Skchow #define	CPUID_AMD_ECX_3DNP	0x00000100	/* AMD: 3DNowPrefectch */
198512cf780Skchow #define	CPUID_AMD_ECX_OSVW	0x00000200	/* AMD: OSVW */
199512cf780Skchow #define	CPUID_AMD_ECX_IBS	0x00000400	/* AMD: IBS */
2004e348e74SJohn Levon #define	CPUID_AMD_ECX_SSE5	0x00000800	/* AMD: Extended AVX */
201512cf780Skchow #define	CPUID_AMD_ECX_SKINIT	0x00001000	/* AMD: SKINIT */
202512cf780Skchow #define	CPUID_AMD_ECX_WDT	0x00002000	/* AMD: WDT */
2034e348e74SJohn Levon 				/* 0x00004000 - reserved */
2044e348e74SJohn Levon #define	CPUID_AMD_ECX_LWP	0x00008000	/* AMD: Lightweight profiling */
2054e348e74SJohn Levon #define	CPUID_AMD_ECX_FMA4	0x00010000	/* AMD: 4-operand FMA support */
2064e348e74SJohn Levon 				/* 0x00020000 - reserved */
2074e348e74SJohn Levon 				/* 0x00040000 - reserved */
2084e348e74SJohn Levon #define	CPUID_AMD_ECX_NIDMSR	0x00080000	/* AMD: Node ID MSR */
2094e348e74SJohn Levon 				/* 0x00100000 - reserved */
2104e348e74SJohn Levon #define	CPUID_AMD_ECX_TBM	0x00200000	/* AMD: trailing bit manips. */
2117660e73fSHans Rosenfeld #define	CPUID_AMD_ECX_TOPOEXT	0x00400000	/* AMD: Topology Extensions */
21294888d45SMarcel Telka #define	CPUID_AMD_ECX_PCEC	0x00800000	/* AMD: Core ext perf counter */
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate #define	FMT_CPUID_AMD_ECX					\
2157c478bd9Sstevel@tonic-gate 	"\20"							\
2167660e73fSHans Rosenfeld 	"\22topoext"						\
217512cf780Skchow 	"\14wdt\13skinit\12sse5\11ibs\10osvw\93dnp\8mas"	\
218f8801251Skk208521 	"\7sse4a\6lzcnt\5cr8d\3svm\2lcmplgcy\1ahf64"
219ae115bc7Smrj 
220ae115bc7Smrj /*
221ae115bc7Smrj  * Intel now seems to have claimed part of the "extended" function
222ae115bc7Smrj  * space that we previously for non-Intel implementors to use.
223ae115bc7Smrj  * More excitingly still, they've claimed bit 20 to mean LAHF/SAHF
224ae115bc7Smrj  * is available in long mode i.e. what AMD indicate using bit 0.
225ae115bc7Smrj  * On the other hand, everything else is labelled as reserved.
226ae115bc7Smrj  */
227ae115bc7Smrj #define	CPUID_INTC_ECX_AHF64	0x00100000	/* LAHF and SAHF in long mode */
228ae115bc7Smrj 
229245ac945SRobert Mustacchi /*
230245ac945SRobert Mustacchi  * Intel also uses cpuid leaf 7 to have additional instructions and features.
231799823bbSRobert Mustacchi  * Like some other leaves, but unlike the current ones we care about, it
232245ac945SRobert Mustacchi  * requires us to specify both a leaf in %eax and a sub-leaf in %ecx. To deal
233245ac945SRobert Mustacchi  * with the potential use of additional sub-leaves in the future, we now
234245ac945SRobert Mustacchi  * specifically label the EBX features with their leaf and sub-leaf.
235245ac945SRobert Mustacchi  */
236245ac945SRobert Mustacchi #define	CPUID_INTC_EBX_7_0_BMI1		0x00000008	/* BMI1 instrs */
237245ac945SRobert Mustacchi #define	CPUID_INTC_EBX_7_0_AVX2		0x00000020	/* AVX2 supported */
238799823bbSRobert Mustacchi #define	CPUID_INTC_EBX_7_0_SMEP		0x00000080	/* SMEP in CR4 */
23931ef1933SRobert Mustacchi #define	CPUID_INTC_EBX_7_0_BMI2		0x00000100	/* BMI2 instrs */
24031ef1933SRobert Mustacchi #define	CPUID_INTC_EBX_7_0_RDSEED	0x00040000	/* RDSEED instr */
24131ef1933SRobert Mustacchi #define	CPUID_INTC_EBX_7_0_ADX		0x00080000	/* ADX instrs */
2420c63cd97SMarcel Telka #define	CPUID_INTC_EBX_7_0_SHA		0x20000000	/* SHA extensions */
2437c478bd9Sstevel@tonic-gate 
2441d03c31eSjohnlev #define	REG_PAT			0x277
2457c478bd9Sstevel@tonic-gate #define	REG_TSC			0x10	/* timestamp counter */
2467c478bd9Sstevel@tonic-gate #define	REG_APIC_BASE_MSR	0x1b
247b6917abeSmishra #define	REG_X2APIC_BASE_MSR	0x800	/* The MSR address offset of x2APIC */
2487c478bd9Sstevel@tonic-gate 
249e774b42bSBill Holler #if !defined(__xpv)
250e774b42bSBill Holler /*
251e774b42bSBill Holler  * AMD C1E
252e774b42bSBill Holler  */
253e774b42bSBill Holler #define	MSR_AMD_INT_PENDING_CMP_HALT	0xC0010055
254e774b42bSBill Holler #define	AMD_ACTONCMPHALT_SHIFT	27
255e774b42bSBill Holler #define	AMD_ACTONCMPHALT_MASK	3
256e774b42bSBill Holler #endif
257e774b42bSBill Holler 
2587c478bd9Sstevel@tonic-gate #define	MSR_DEBUGCTL		0x1d9
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate #define	DEBUGCTL_LBR		0x01
2617c478bd9Sstevel@tonic-gate #define	DEBUGCTL_BTF		0x02
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate /* Intel P6, AMD */
2647c478bd9Sstevel@tonic-gate #define	MSR_LBR_FROM		0x1db
2657c478bd9Sstevel@tonic-gate #define	MSR_LBR_TO		0x1dc
2667c478bd9Sstevel@tonic-gate #define	MSR_LEX_FROM		0x1dd
2677c478bd9Sstevel@tonic-gate #define	MSR_LEX_TO		0x1de
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate /* Intel P4 (pre-Prescott, non P4 M) */
2707c478bd9Sstevel@tonic-gate #define	MSR_P4_LBSTK_TOS	0x1da
2717c478bd9Sstevel@tonic-gate #define	MSR_P4_LBSTK_0		0x1db
2727c478bd9Sstevel@tonic-gate #define	MSR_P4_LBSTK_1		0x1dc
2737c478bd9Sstevel@tonic-gate #define	MSR_P4_LBSTK_2		0x1dd
2747c478bd9Sstevel@tonic-gate #define	MSR_P4_LBSTK_3		0x1de
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate /* Intel Pentium M */
2777c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_TOS	0x1c9
2787c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_0		0x040
2797c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_1		0x041
2807c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_2		0x042
2817c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_3		0x043
2827c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_4		0x044
2837c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_5		0x045
2847c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_6		0x046
2857c478bd9Sstevel@tonic-gate #define	MSR_P6M_LBSTK_7		0x047
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate /* Intel P4 (Prescott) */
2887c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TOS	0x1da
2897c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_0	0x680
2907c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_1	0x681
2917c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_2	0x682
2927c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_3	0x683
2937c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_4	0x684
2947c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_5	0x685
2957c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_6	0x686
2967c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_7	0x687
2977c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_8 	0x688
2987c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_9	0x689
2997c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_10	0x68a
3007c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_11 	0x68b
3017c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_12	0x68c
3027c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_13	0x68d
3037c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_14	0x68e
3047c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_FROM_15	0x68f
3057c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_0	0x6c0
3067c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_1	0x6c1
3077c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_2	0x6c2
3087c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_3	0x6c3
3097c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_4	0x6c4
3107c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_5	0x6c5
3117c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_6	0x6c6
3127c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_7	0x6c7
3137c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_8	0x6c8
3147c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_9 	0x6c9
3157c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_10	0x6ca
3167c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_11	0x6cb
3177c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_12	0x6cc
3187c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_13	0x6cd
3197c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_14	0x6ce
3207c478bd9Sstevel@tonic-gate #define	MSR_PRP4_LBSTK_TO_15	0x6cf
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate #define	MCI_CTL_VALUE		0xffffffff
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate #define	MTRR_TYPE_UC		0
3257c478bd9Sstevel@tonic-gate #define	MTRR_TYPE_WC		1
3267c478bd9Sstevel@tonic-gate #define	MTRR_TYPE_WT		4
3277c478bd9Sstevel@tonic-gate #define	MTRR_TYPE_WP		5
3287c478bd9Sstevel@tonic-gate #define	MTRR_TYPE_WB		6
3291d03c31eSjohnlev #define	MTRR_TYPE_UC_		7
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate /*
3321d03c31eSjohnlev  * For Solaris we set up the page attritubute table in the following way:
3331d03c31eSjohnlev  * PAT0	Write-Back
3347c478bd9Sstevel@tonic-gate  * PAT1	Write-Through
3351d03c31eSjohnlev  * PAT2	Unchacheable-
3367c478bd9Sstevel@tonic-gate  * PAT3	Uncacheable
3371d03c31eSjohnlev  * PAT4 Write-Back
3381d03c31eSjohnlev  * PAT5	Write-Through
3397c478bd9Sstevel@tonic-gate  * PAT6	Write-Combine
3407c478bd9Sstevel@tonic-gate  * PAT7 Uncacheable
3411d03c31eSjohnlev  * The only difference from h/w default is entry 6.
3427c478bd9Sstevel@tonic-gate  */
3437c478bd9Sstevel@tonic-gate #define	PAT_DEFAULT_ATTRIBUTE			\
3441d03c31eSjohnlev 	((uint64_t)MTRR_TYPE_WB |		\
3451d03c31eSjohnlev 	((uint64_t)MTRR_TYPE_WT << 8) |		\
3461d03c31eSjohnlev 	((uint64_t)MTRR_TYPE_UC_ << 16) |	\
3471d03c31eSjohnlev 	((uint64_t)MTRR_TYPE_UC << 24) |	\
3481d03c31eSjohnlev 	((uint64_t)MTRR_TYPE_WB << 32) |	\
3491d03c31eSjohnlev 	((uint64_t)MTRR_TYPE_WT << 40) |	\
3501d03c31eSjohnlev 	((uint64_t)MTRR_TYPE_WC << 48) |	\
3511d03c31eSjohnlev 	((uint64_t)MTRR_TYPE_UC << 56))
3527c478bd9Sstevel@tonic-gate 
3537417cfdeSKuriakose Kuruvilla #define	X86FSET_LARGEPAGE	0
3547417cfdeSKuriakose Kuruvilla #define	X86FSET_TSC		1
3557417cfdeSKuriakose Kuruvilla #define	X86FSET_MSR		2
3567417cfdeSKuriakose Kuruvilla #define	X86FSET_MTRR		3
3577417cfdeSKuriakose Kuruvilla #define	X86FSET_PGE		4
3587417cfdeSKuriakose Kuruvilla #define	X86FSET_DE		5
3597417cfdeSKuriakose Kuruvilla #define	X86FSET_CMOV		6
3607417cfdeSKuriakose Kuruvilla #define	X86FSET_MMX		7
3617417cfdeSKuriakose Kuruvilla #define	X86FSET_MCA		8
3627417cfdeSKuriakose Kuruvilla #define	X86FSET_PAE		9
3637417cfdeSKuriakose Kuruvilla #define	X86FSET_CX8		10
3647417cfdeSKuriakose Kuruvilla #define	X86FSET_PAT		11
3657417cfdeSKuriakose Kuruvilla #define	X86FSET_SEP		12
3667417cfdeSKuriakose Kuruvilla #define	X86FSET_SSE		13
3677417cfdeSKuriakose Kuruvilla #define	X86FSET_SSE2		14
3687417cfdeSKuriakose Kuruvilla #define	X86FSET_HTT		15
3697417cfdeSKuriakose Kuruvilla #define	X86FSET_ASYSC		16
3707417cfdeSKuriakose Kuruvilla #define	X86FSET_NX		17
3717417cfdeSKuriakose Kuruvilla #define	X86FSET_SSE3		18
3727417cfdeSKuriakose Kuruvilla #define	X86FSET_CX16		19
3737417cfdeSKuriakose Kuruvilla #define	X86FSET_CMP		20
3747417cfdeSKuriakose Kuruvilla #define	X86FSET_TSCP		21
3757417cfdeSKuriakose Kuruvilla #define	X86FSET_MWAIT		22
3767417cfdeSKuriakose Kuruvilla #define	X86FSET_SSE4A		23
3777417cfdeSKuriakose Kuruvilla #define	X86FSET_CPUID		24
3787417cfdeSKuriakose Kuruvilla #define	X86FSET_SSSE3		25
3797417cfdeSKuriakose Kuruvilla #define	X86FSET_SSE4_1		26
3807417cfdeSKuriakose Kuruvilla #define	X86FSET_SSE4_2		27
3817417cfdeSKuriakose Kuruvilla #define	X86FSET_1GPG		28
3827417cfdeSKuriakose Kuruvilla #define	X86FSET_CLFSH		29
3837417cfdeSKuriakose Kuruvilla #define	X86FSET_64		30
3847417cfdeSKuriakose Kuruvilla #define	X86FSET_AES		31
3857417cfdeSKuriakose Kuruvilla #define	X86FSET_PCLMULQDQ	32
3867af88ac7SKuriakose Kuruvilla #define	X86FSET_XSAVE		33
3877af88ac7SKuriakose Kuruvilla #define	X86FSET_AVX		34
388faa20166SBryan Cantrill #define	X86FSET_VMX		35
389faa20166SBryan Cantrill #define	X86FSET_SVM		36
3907660e73fSHans Rosenfeld #define	X86FSET_TOPOEXT		37
391ebb8ac07SRobert Mustacchi #define	X86FSET_F16C		38
392ebb8ac07SRobert Mustacchi #define	X86FSET_RDRAND		39
3936eedf6a5SJosef 'Jeff' Sipek #define	X86FSET_X2APIC		40
394245ac945SRobert Mustacchi #define	X86FSET_AVX2		41
395245ac945SRobert Mustacchi #define	X86FSET_BMI1		42
396245ac945SRobert Mustacchi #define	X86FSET_BMI2		43
397245ac945SRobert Mustacchi #define	X86FSET_FMA		44
398799823bbSRobert Mustacchi #define	X86FSET_SMEP		45
39931ef1933SRobert Mustacchi #define	X86FSET_ADX		47
40031ef1933SRobert Mustacchi #define	X86FSET_RDSEED		48
401*d573a566SRobert Mustacchi #define	X86FSET_AMD_PCEC	92
4027c478bd9Sstevel@tonic-gate 
403247dbb3dSsudheer /*
4040e751525SEric Saxe  * Intel Deep C-State invariant TSC in leaf 0x80000007.
4050e751525SEric Saxe  */
4060e751525SEric Saxe #define	CPUID_TSC_CSTATE_INVARIANCE	(0x100)
4070e751525SEric Saxe 
4080e751525SEric Saxe /*
409cef70d2cSBill Holler  * Intel Deep C-state always-running local APIC timer
410cef70d2cSBill Holler  */
411cef70d2cSBill Holler #define	CPUID_CSTATE_ARAT	(0x4)
412cef70d2cSBill Holler 
413cef70d2cSBill Holler /*
414f21ed392Saubrey.li@intel.com  * Intel ENERGY_PERF_BIAS MSR indicated by feature bit CPUID.6.ECX[3].
415f21ed392Saubrey.li@intel.com  */
416f21ed392Saubrey.li@intel.com #define	CPUID_EPB_SUPPORT	(1 << 3)
417f21ed392Saubrey.li@intel.com 
418f21ed392Saubrey.li@intel.com /*
41941afdfa7SKrishnendu Sadhukhan - Sun Microsystems  * Intel TSC deadline timer
42041afdfa7SKrishnendu Sadhukhan - Sun Microsystems  */
42141afdfa7SKrishnendu Sadhukhan - Sun Microsystems #define	CPUID_DEADLINE_TSC	(1 << 24)
42241afdfa7SKrishnendu Sadhukhan - Sun Microsystems 
42341afdfa7SKrishnendu Sadhukhan - Sun Microsystems /*
4247c478bd9Sstevel@tonic-gate  * x86_type is a legacy concept; this is supplanted
4257417cfdeSKuriakose Kuruvilla  * for most purposes by x86_featureset; modern CPUs
4267c478bd9Sstevel@tonic-gate  * should be X86_TYPE_OTHER
4277c478bd9Sstevel@tonic-gate  */
4287c478bd9Sstevel@tonic-gate #define	X86_TYPE_OTHER		0
4297c478bd9Sstevel@tonic-gate #define	X86_TYPE_486		1
4307c478bd9Sstevel@tonic-gate #define	X86_TYPE_P5		2
4317c478bd9Sstevel@tonic-gate #define	X86_TYPE_P6		3
4327c478bd9Sstevel@tonic-gate #define	X86_TYPE_CYRIX_486	4
4337c478bd9Sstevel@tonic-gate #define	X86_TYPE_CYRIX_6x86L	5
4347c478bd9Sstevel@tonic-gate #define	X86_TYPE_CYRIX_6x86	6
4357c478bd9Sstevel@tonic-gate #define	X86_TYPE_CYRIX_GXm	7
4367c478bd9Sstevel@tonic-gate #define	X86_TYPE_CYRIX_6x86MX	8
4377c478bd9Sstevel@tonic-gate #define	X86_TYPE_CYRIX_MediaGX	9
4387c478bd9Sstevel@tonic-gate #define	X86_TYPE_CYRIX_MII	10
4397c478bd9Sstevel@tonic-gate #define	X86_TYPE_VIA_CYRIX_III	11
4407c478bd9Sstevel@tonic-gate #define	X86_TYPE_P4		12
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate /*
4437c478bd9Sstevel@tonic-gate  * x86_vendor allows us to select between
4447c478bd9Sstevel@tonic-gate  * implementation features and helps guide
4457c478bd9Sstevel@tonic-gate  * the interpretation of the cpuid instruction.
4467c478bd9Sstevel@tonic-gate  */
447e4b86885SCheng Sean Ye #define	X86_VENDOR_Intel	0
448e4b86885SCheng Sean Ye #define	X86_VENDORSTR_Intel	"GenuineIntel"
4497c478bd9Sstevel@tonic-gate 
450e4b86885SCheng Sean Ye #define	X86_VENDOR_IntelClone	1
451e4b86885SCheng Sean Ye 
452e4b86885SCheng Sean Ye #define	X86_VENDOR_AMD		2
453e4b86885SCheng Sean Ye #define	X86_VENDORSTR_AMD	"AuthenticAMD"
454e4b86885SCheng Sean Ye 
455e4b86885SCheng Sean Ye #define	X86_VENDOR_Cyrix	3
456e4b86885SCheng Sean Ye #define	X86_VENDORSTR_CYRIX	"CyrixInstead"
457e4b86885SCheng Sean Ye 
458e4b86885SCheng Sean Ye #define	X86_VENDOR_UMC		4
459e4b86885SCheng Sean Ye #define	X86_VENDORSTR_UMC	"UMC UMC UMC "
460e4b86885SCheng Sean Ye 
461e4b86885SCheng Sean Ye #define	X86_VENDOR_NexGen	5
462e4b86885SCheng Sean Ye #define	X86_VENDORSTR_NexGen	"NexGenDriven"
463e4b86885SCheng Sean Ye 
464e4b86885SCheng Sean Ye #define	X86_VENDOR_Centaur	6
465e4b86885SCheng Sean Ye #define	X86_VENDORSTR_Centaur	"CentaurHauls"
466e4b86885SCheng Sean Ye 
467e4b86885SCheng Sean Ye #define	X86_VENDOR_Rise		7
468e4b86885SCheng Sean Ye #define	X86_VENDORSTR_Rise	"RiseRiseRise"
469e4b86885SCheng Sean Ye 
470e4b86885SCheng Sean Ye #define	X86_VENDOR_SiS		8
471e4b86885SCheng Sean Ye #define	X86_VENDORSTR_SiS	"SiS SiS SiS "
472e4b86885SCheng Sean Ye 
473e4b86885SCheng Sean Ye #define	X86_VENDOR_TM		9
474e4b86885SCheng Sean Ye #define	X86_VENDORSTR_TM	"GenuineTMx86"
475e4b86885SCheng Sean Ye 
476e4b86885SCheng Sean Ye #define	X86_VENDOR_NSC		10
477e4b86885SCheng Sean Ye #define	X86_VENDORSTR_NSC	"Geode by NSC"
478e4b86885SCheng Sean Ye 
479e4b86885SCheng Sean Ye /*
480e4b86885SCheng Sean Ye  * Vendor string max len + \0
481e4b86885SCheng Sean Ye  */
482e4b86885SCheng Sean Ye #define	X86_VENDOR_STRLEN	13
4837aec1d6eScindi 
4848a40a695Sgavinm /*
4858a40a695Sgavinm  * Some vendor/family/model/stepping ranges are commonly grouped under
4868a40a695Sgavinm  * a single identifying banner by the vendor.  The following encode
4878a40a695Sgavinm  * that "revision" in a uint32_t with the 8 most significant bits
4888a40a695Sgavinm  * identifying the vendor with X86_VENDOR_*, the next 8 identifying the
4898a40a695Sgavinm  * family, and the remaining 16 typically forming a bitmask of revisions
4908a40a695Sgavinm  * within that family with more significant bits indicating "later" revisions.
4918a40a695Sgavinm  */
4928a40a695Sgavinm 
4938a40a695Sgavinm #define	_X86_CHIPREV_VENDOR_MASK	0xff000000u
4948a40a695Sgavinm #define	_X86_CHIPREV_VENDOR_SHIFT	24
4958a40a695Sgavinm #define	_X86_CHIPREV_FAMILY_MASK	0x00ff0000u
4968a40a695Sgavinm #define	_X86_CHIPREV_FAMILY_SHIFT	16
4978a40a695Sgavinm #define	_X86_CHIPREV_REV_MASK		0x0000ffffu
4988a40a695Sgavinm 
4998a40a695Sgavinm #define	_X86_CHIPREV_VENDOR(x) \
5008a40a695Sgavinm 	(((x) & _X86_CHIPREV_VENDOR_MASK) >> _X86_CHIPREV_VENDOR_SHIFT)
5018a40a695Sgavinm #define	_X86_CHIPREV_FAMILY(x) \
5028a40a695Sgavinm 	(((x) & _X86_CHIPREV_FAMILY_MASK) >> _X86_CHIPREV_FAMILY_SHIFT)
5038a40a695Sgavinm #define	_X86_CHIPREV_REV(x) \
5048a40a695Sgavinm 	((x) & _X86_CHIPREV_REV_MASK)
5058a40a695Sgavinm 
5068a40a695Sgavinm /* True if x matches in vendor and family and if x matches the given rev mask */
5078a40a695Sgavinm #define	X86_CHIPREV_MATCH(x, mask) \
5088a40a695Sgavinm 	(_X86_CHIPREV_VENDOR(x) == _X86_CHIPREV_VENDOR(mask) && \
5098a40a695Sgavinm 	_X86_CHIPREV_FAMILY(x) == _X86_CHIPREV_FAMILY(mask) && \
5108a40a695Sgavinm 	((_X86_CHIPREV_REV(x) & _X86_CHIPREV_REV(mask)) != 0))
5118a40a695Sgavinm 
5122c8230b0SSrihari Venkatesan /* True if x matches in vendor and family, and rev is at least minx */
5138a40a695Sgavinm #define	X86_CHIPREV_ATLEAST(x, minx) \
5148a40a695Sgavinm 	(_X86_CHIPREV_VENDOR(x) == _X86_CHIPREV_VENDOR(minx) && \
5158a40a695Sgavinm 	_X86_CHIPREV_FAMILY(x) == _X86_CHIPREV_FAMILY(minx) && \
5168a40a695Sgavinm 	_X86_CHIPREV_REV(x) >= _X86_CHIPREV_REV(minx))
5178a40a695Sgavinm 
5188a40a695Sgavinm #define	_X86_CHIPREV_MKREV(vendor, family, rev) \
5198a40a695Sgavinm 	((uint32_t)(vendor) << _X86_CHIPREV_VENDOR_SHIFT | \
5208a40a695Sgavinm 	(family) << _X86_CHIPREV_FAMILY_SHIFT | (rev))
5218a40a695Sgavinm 
5222c8230b0SSrihari Venkatesan /* True if x matches in vendor, and family is at least minx */
5232c8230b0SSrihari Venkatesan #define	X86_CHIPFAM_ATLEAST(x, minx) \
5242c8230b0SSrihari Venkatesan 	(_X86_CHIPREV_VENDOR(x) == _X86_CHIPREV_VENDOR(minx) && \
5252c8230b0SSrihari Venkatesan 	_X86_CHIPREV_FAMILY(x) >= _X86_CHIPREV_FAMILY(minx))
5262c8230b0SSrihari Venkatesan 
5278a40a695Sgavinm /* Revision default */
5288a40a695Sgavinm #define	X86_CHIPREV_UNKNOWN	0x0
5298a40a695Sgavinm 
5308a40a695Sgavinm /*
53120c794b3Sgavinm  * Definitions for AMD Family 0xf. Minor revisions C0 and CG are
53220c794b3Sgavinm  * sufficiently different that we will distinguish them; in all other
5338a40a695Sgavinm  * case we will identify the major revision.
5348a40a695Sgavinm  */
5358a40a695Sgavinm #define	X86_CHIPREV_AMD_F_REV_B _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0001)
5368a40a695Sgavinm #define	X86_CHIPREV_AMD_F_REV_C0 _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0002)
5378a40a695Sgavinm #define	X86_CHIPREV_AMD_F_REV_CG _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0004)
5388a40a695Sgavinm #define	X86_CHIPREV_AMD_F_REV_D _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0008)
5398a40a695Sgavinm #define	X86_CHIPREV_AMD_F_REV_E _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0010)
5408a40a695Sgavinm #define	X86_CHIPREV_AMD_F_REV_F _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0020)
5418a40a695Sgavinm #define	X86_CHIPREV_AMD_F_REV_G _X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0xf, 0x0040)
54220c794b3Sgavinm 
54320c794b3Sgavinm /*
54420c794b3Sgavinm  * Definitions for AMD Family 0x10.  Rev A was Engineering Samples only.
54520c794b3Sgavinm  */
54620c794b3Sgavinm #define	X86_CHIPREV_AMD_10_REV_A \
54731725658Sksadhukh 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0001)
54820c794b3Sgavinm #define	X86_CHIPREV_AMD_10_REV_B \
54920c794b3Sgavinm 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0002)
55079321794SJens Elkner #define	X86_CHIPREV_AMD_10_REV_C2 \
55164452efdSKit Chow 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0004)
55279321794SJens Elkner #define	X86_CHIPREV_AMD_10_REV_C3 \
55389e921d5SKuriakose Kuruvilla 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0008)
55479321794SJens Elkner #define	X86_CHIPREV_AMD_10_REV_D0 \
55579321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0010)
55679321794SJens Elkner #define	X86_CHIPREV_AMD_10_REV_D1 \
55779321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0020)
55879321794SJens Elkner #define	X86_CHIPREV_AMD_10_REV_E \
55979321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x10, 0x0040)
56089e921d5SKuriakose Kuruvilla 
56189e921d5SKuriakose Kuruvilla /*
56289e921d5SKuriakose Kuruvilla  * Definitions for AMD Family 0x11.
56389e921d5SKuriakose Kuruvilla  */
56479321794SJens Elkner #define	X86_CHIPREV_AMD_11_REV_B \
56579321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x11, 0x0002)
56689e921d5SKuriakose Kuruvilla 
56779321794SJens Elkner /*
56879321794SJens Elkner  * Definitions for AMD Family 0x12.
56979321794SJens Elkner  */
57079321794SJens Elkner #define	X86_CHIPREV_AMD_12_REV_B \
57179321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x12, 0x0002)
57279321794SJens Elkner 
57379321794SJens Elkner /*
57479321794SJens Elkner  * Definitions for AMD Family 0x14.
57579321794SJens Elkner  */
57679321794SJens Elkner #define	X86_CHIPREV_AMD_14_REV_B \
57779321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x14, 0x0002)
57879321794SJens Elkner #define	X86_CHIPREV_AMD_14_REV_C \
57979321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x14, 0x0004)
58079321794SJens Elkner 
58179321794SJens Elkner /*
58279321794SJens Elkner  * Definitions for AMD Family 0x15
58379321794SJens Elkner  */
58479321794SJens Elkner #define	X86_CHIPREV_AMD_15OR_REV_B2 \
58579321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x15, 0x0001)
58679321794SJens Elkner 
58779321794SJens Elkner #define	X86_CHIPREV_AMD_15TN_REV_A1 \
58879321794SJens Elkner 	_X86_CHIPREV_MKREV(X86_VENDOR_AMD, 0x15, 0x0002)
5898a40a695Sgavinm 
5908a40a695Sgavinm /*
5918a40a695Sgavinm  * Various socket/package types, extended as the need to distinguish
5928a40a695Sgavinm  * a new type arises.  The top 8 byte identfies the vendor and the
5938a40a695Sgavinm  * remaining 24 bits describe 24 socket types.
5948a40a695Sgavinm  */
5958a40a695Sgavinm 
5968a40a695Sgavinm #define	_X86_SOCKET_VENDOR_SHIFT	24
5978a40a695Sgavinm #define	_X86_SOCKET_VENDOR(x)	((x) >> _X86_SOCKET_VENDOR_SHIFT)
5988a40a695Sgavinm #define	_X86_SOCKET_TYPE_MASK	0x00ffffff
5998a40a695Sgavinm #define	_X86_SOCKET_TYPE(x)		((x) & _X86_SOCKET_TYPE_MASK)
6008a40a695Sgavinm 
6018a40a695Sgavinm #define	_X86_SOCKET_MKVAL(vendor, bitval) \
6028a40a695Sgavinm 	((uint32_t)(vendor) << _X86_SOCKET_VENDOR_SHIFT | (bitval))
6038a40a695Sgavinm 
6048a40a695Sgavinm #define	X86_SOCKET_MATCH(s, mask) \
6058a40a695Sgavinm 	(_X86_SOCKET_VENDOR(s) == _X86_SOCKET_VENDOR(mask) && \
606a24e89c4SKuriakose Kuruvilla 	(_X86_SOCKET_TYPE(s) & _X86_SOCKET_TYPE(mask)) != 0)
6078a40a695Sgavinm 
6088a40a695Sgavinm #define	X86_SOCKET_UNKNOWN 0x0
6098a40a695Sgavinm 	/*
6108a40a695Sgavinm 	 * AMD socket types
6118a40a695Sgavinm 	 */
6128a40a695Sgavinm #define	X86_SOCKET_754		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000001)
6138a40a695Sgavinm #define	X86_SOCKET_939		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000002)
6148a40a695Sgavinm #define	X86_SOCKET_940		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000004)
6158a40a695Sgavinm #define	X86_SOCKET_S1g1		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000008)
6168a40a695Sgavinm #define	X86_SOCKET_AM2		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000010)
6178a40a695Sgavinm #define	X86_SOCKET_F1207	_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000020)
618a24e89c4SKuriakose Kuruvilla #define	X86_SOCKET_S1g2		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000040)
619a24e89c4SKuriakose Kuruvilla #define	X86_SOCKET_S1g3		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000080)
620a24e89c4SKuriakose Kuruvilla #define	X86_SOCKET_AM		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000100)
621a24e89c4SKuriakose Kuruvilla #define	X86_SOCKET_AM2R2	_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000200)
622a24e89c4SKuriakose Kuruvilla #define	X86_SOCKET_AM3		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000400)
623a24e89c4SKuriakose Kuruvilla #define	X86_SOCKET_G34		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x000800)
624bd15239eSSrihari Venkatesan #define	X86_SOCKET_ASB2		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x001000)
625bd15239eSSrihari Venkatesan #define	X86_SOCKET_C32		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x002000)
62679321794SJens Elkner #define	X86_SOCKET_S1g4		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x004000)
62779321794SJens Elkner #define	X86_SOCKET_FT1		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x008000)
62879321794SJens Elkner #define	X86_SOCKET_FM1		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x010000)
62979321794SJens Elkner #define	X86_SOCKET_FS1		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x020000)
63079321794SJens Elkner #define	X86_SOCKET_AM3R2	_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x040000)
63179321794SJens Elkner #define	X86_SOCKET_FP2		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x080000)
63279321794SJens Elkner #define	X86_SOCKET_FS1R2	_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x100000)
63379321794SJens Elkner #define	X86_SOCKET_FM2		_X86_SOCKET_MKVAL(X86_VENDOR_AMD, 0x200000)
6348a40a695Sgavinm 
63512ae924aSRobert Mustacchi 
63612ae924aSRobert Mustacchi /*
63712ae924aSRobert Mustacchi  * Definitions for Intel processor models. These are all for Family 6
63812ae924aSRobert Mustacchi  * processors. This list and the Atom set below it are not exhuastive.
63912ae924aSRobert Mustacchi  */
64012ae924aSRobert Mustacchi #define	INTC_MODEL_MEROM		0x0f
64112ae924aSRobert Mustacchi #define	INTC_MODEL_PENRYN		0x17
64212ae924aSRobert Mustacchi #define	INTC_MODEL_DUNNINGTON		0x1d
64312ae924aSRobert Mustacchi 
64412ae924aSRobert Mustacchi #define	INTC_MODEL_NEHALEM		0x1e
64512ae924aSRobert Mustacchi #define	INTC_MODEL_NEHALEM2		0x1f
64612ae924aSRobert Mustacchi #define	INTC_MODEL_NEHALEM_EP		0x1a
64712ae924aSRobert Mustacchi #define	INTC_MODEL_NEHALEM_EX		0x2e
64812ae924aSRobert Mustacchi 
64912ae924aSRobert Mustacchi #define	INTC_MODEL_WESTMERE		0x25
65012ae924aSRobert Mustacchi #define	INTC_MODEL_WESTMERE_EP		0x2c
65112ae924aSRobert Mustacchi #define	INTC_MODEL_WESTMERE_EX		0x2f
65212ae924aSRobert Mustacchi 
65312ae924aSRobert Mustacchi #define	INTC_MODEL_SANDYBRIDGE		0x2a
65412ae924aSRobert Mustacchi #define	INTC_MODEL_SANDYBRIDGE_XEON	0x2d
65512ae924aSRobert Mustacchi #define	INTC_MODEL_IVYBRIDGE		0x3a
65612ae924aSRobert Mustacchi #define	INTC_MODEL_IVYBRIDGE_XEON	0x3e
65712ae924aSRobert Mustacchi 
65812ae924aSRobert Mustacchi #define	INTC_MODEL_HASWELL		0x3c
65912ae924aSRobert Mustacchi #define	INTC_MODEL_HASWELL_ULT		0x45
66012ae924aSRobert Mustacchi #define	INTC_MODEL_HASWELL_GT3E		0x46
66112ae924aSRobert Mustacchi #define	INTC_MODEL_HASWELL_XEON		0x3f
66212ae924aSRobert Mustacchi 
66312ae924aSRobert Mustacchi #define	INTC_MODEL_BROADWELL		0x3d
66412ae924aSRobert Mustacchi #define	INTC_MODEL_BROADELL_2		0x47
66512ae924aSRobert Mustacchi #define	INTC_MODEL_BROADWELL_XEON	0x4f
66612ae924aSRobert Mustacchi 
66712ae924aSRobert Mustacchi #define	INCC_MODEL_SKYLAKE_MOBILE	0x4e
66812ae924aSRobert Mustacchi #define	INTC_MODEL_SKYLAKE_DESKTOP	0x5e
66912ae924aSRobert Mustacchi 
67012ae924aSRobert Mustacchi #define	INTC_MODEL_KABYLAKE_MOBILE	0x8e
67112ae924aSRobert Mustacchi #define	INTC_MODEL_KABYLAKE_DESKTOP	0x9e
67212ae924aSRobert Mustacchi 
67312ae924aSRobert Mustacchi /*
67412ae924aSRobert Mustacchi  * Atom Processors
67512ae924aSRobert Mustacchi  */
67612ae924aSRobert Mustacchi #define	INTC_MODEL_SILVERTHORNE		0x1c
67712ae924aSRobert Mustacchi #define	INTC_MODEL_LINCROFT		0x26
67812ae924aSRobert Mustacchi #define	INTC_MODEL_PENWELL		0x27
67912ae924aSRobert Mustacchi #define	INTC_MODEL_CLOVERVIEW		0x35
68012ae924aSRobert Mustacchi #define	INTC_MODEL_CEDARVIEW		0x36
68112ae924aSRobert Mustacchi #define	INTC_MODEL_BAY_TRAIL		0x37
68212ae924aSRobert Mustacchi #define	INTC_MODEL_AVATON		0x4d
68312ae924aSRobert Mustacchi #define	INTC_MODEL_AIRMONT		0x4c
68412ae924aSRobert Mustacchi #define	INTC_MODEL_GOLDMONT		0x5c
68512ae924aSRobert Mustacchi #define	INTC_MODEL_DENVERTON		0x5f
68612ae924aSRobert Mustacchi #define	INTC_MODEL_GEMINI_LAKE		0x7a
68712ae924aSRobert Mustacchi 
6887af88ac7SKuriakose Kuruvilla /*
6897af88ac7SKuriakose Kuruvilla  * xgetbv/xsetbv support
6907af88ac7SKuriakose Kuruvilla  */
6917af88ac7SKuriakose Kuruvilla 
6927af88ac7SKuriakose Kuruvilla #define	XFEATURE_ENABLED_MASK	0x0
6937af88ac7SKuriakose Kuruvilla /*
6947af88ac7SKuriakose Kuruvilla  * XFEATURE_ENABLED_MASK values (eax)
6957af88ac7SKuriakose Kuruvilla  */
6967af88ac7SKuriakose Kuruvilla #define	XFEATURE_LEGACY_FP	0x1
6977af88ac7SKuriakose Kuruvilla #define	XFEATURE_SSE		0x2
6987af88ac7SKuriakose Kuruvilla #define	XFEATURE_AVX		0x4
6997af88ac7SKuriakose Kuruvilla #define	XFEATURE_MAX		XFEATURE_AVX
700ebb8ac07SRobert Mustacchi #define	XFEATURE_FP_ALL	\
701ebb8ac07SRobert Mustacchi 	(XFEATURE_LEGACY_FP|XFEATURE_SSE|XFEATURE_AVX)
7027af88ac7SKuriakose Kuruvilla 
7037c478bd9Sstevel@tonic-gate #if !defined(_ASM)
7047c478bd9Sstevel@tonic-gate 
7057c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER)
7067c478bd9Sstevel@tonic-gate 
707*d573a566SRobert Mustacchi #define	NUM_X86_FEATURES	93
708dfea898aSKuriakose Kuruvilla extern uchar_t x86_featureset[];
7097417cfdeSKuriakose Kuruvilla 
7107417cfdeSKuriakose Kuruvilla extern void free_x86_featureset(void *featureset);
7117417cfdeSKuriakose Kuruvilla extern boolean_t is_x86_feature(void *featureset, uint_t feature);
7127417cfdeSKuriakose Kuruvilla extern void add_x86_feature(void *featureset, uint_t feature);
7137417cfdeSKuriakose Kuruvilla extern void remove_x86_feature(void *featureset, uint_t feature);
7147417cfdeSKuriakose Kuruvilla extern boolean_t compare_x86_featureset(void *setA, void *setB);
7157417cfdeSKuriakose Kuruvilla extern void print_x86_featureset(void *featureset);
7167417cfdeSKuriakose Kuruvilla 
7177417cfdeSKuriakose Kuruvilla 
7187c478bd9Sstevel@tonic-gate extern uint_t x86_type;
7197c478bd9Sstevel@tonic-gate extern uint_t x86_vendor;
72086c1f4dcSVikram Hegde extern uint_t x86_clflush_size;
7217c478bd9Sstevel@tonic-gate 
7227c478bd9Sstevel@tonic-gate extern uint_t pentiumpro_bug4046376;
7237c478bd9Sstevel@tonic-gate 
7247c478bd9Sstevel@tonic-gate extern const char CyrixInstead[];
7257c478bd9Sstevel@tonic-gate 
7267c478bd9Sstevel@tonic-gate #endif
7277c478bd9Sstevel@tonic-gate 
7287c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
7297c478bd9Sstevel@tonic-gate 
7308949bcd6Sandrei /*
7318949bcd6Sandrei  * This structure is used to pass arguments and get return values back
7328949bcd6Sandrei  * from the CPUID instruction in __cpuid_insn() routine.
7338949bcd6Sandrei  */
7348949bcd6Sandrei struct cpuid_regs {
7358949bcd6Sandrei 	uint32_t	cp_eax;
7368949bcd6Sandrei 	uint32_t	cp_ebx;
7378949bcd6Sandrei 	uint32_t	cp_ecx;
7388949bcd6Sandrei 	uint32_t	cp_edx;
7398949bcd6Sandrei };
7407c478bd9Sstevel@tonic-gate 
7417af88ac7SKuriakose Kuruvilla /*
7427af88ac7SKuriakose Kuruvilla  * Utility functions to get/set extended control registers (XCR)
7437af88ac7SKuriakose Kuruvilla  * Initial use is to get/set the contents of the XFEATURE_ENABLED_MASK.
7447af88ac7SKuriakose Kuruvilla  */
7457af88ac7SKuriakose Kuruvilla extern uint64_t get_xcr(uint_t);
7467af88ac7SKuriakose Kuruvilla extern void set_xcr(uint_t, uint64_t);
7477af88ac7SKuriakose Kuruvilla 
7480ac7d7d8Skucharsk extern uint64_t rdmsr(uint_t);
7490ac7d7d8Skucharsk extern void wrmsr(uint_t, const uint64_t);
750ee88d2b9Skchow extern uint64_t xrdmsr(uint_t);
751ee88d2b9Skchow extern void xwrmsr(uint_t, const uint64_t);
752ae115bc7Smrj extern int checked_rdmsr(uint_t, uint64_t *);
753ae115bc7Smrj extern int checked_wrmsr(uint_t, uint64_t);
754ae115bc7Smrj 
7557c478bd9Sstevel@tonic-gate extern void invalidate_cache(void);
7567c478bd9Sstevel@tonic-gate extern ulong_t getcr4(void);
7577c478bd9Sstevel@tonic-gate extern void setcr4(ulong_t);
758ae115bc7Smrj 
7597c478bd9Sstevel@tonic-gate extern void mtrr_sync(void);
7607c478bd9Sstevel@tonic-gate 
7617c478bd9Sstevel@tonic-gate extern void cpu_fast_syscall_enable(void *);
7627c478bd9Sstevel@tonic-gate extern void cpu_fast_syscall_disable(void *);
7637c478bd9Sstevel@tonic-gate 
7647c478bd9Sstevel@tonic-gate struct cpu;
7657c478bd9Sstevel@tonic-gate 
7667c478bd9Sstevel@tonic-gate extern int cpuid_checkpass(struct cpu *, int);
7678949bcd6Sandrei extern uint32_t cpuid_insn(struct cpu *, struct cpuid_regs *);
7688949bcd6Sandrei extern uint32_t __cpuid_insn(struct cpuid_regs *);
7697c478bd9Sstevel@tonic-gate extern int cpuid_getbrandstr(struct cpu *, char *, size_t);
7707c478bd9Sstevel@tonic-gate extern int cpuid_getidstr(struct cpu *, char *, size_t);
7717c478bd9Sstevel@tonic-gate extern const char *cpuid_getvendorstr(struct cpu *);
7727c478bd9Sstevel@tonic-gate extern uint_t cpuid_getvendor(struct cpu *);
7737c478bd9Sstevel@tonic-gate extern uint_t cpuid_getfamily(struct cpu *);
7747c478bd9Sstevel@tonic-gate extern uint_t cpuid_getmodel(struct cpu *);
7757c478bd9Sstevel@tonic-gate extern uint_t cpuid_getstep(struct cpu *);
7762449e17fSsherrym extern uint_t cpuid_getsig(struct cpu *);
7777c478bd9Sstevel@tonic-gate extern uint_t cpuid_get_ncpu_per_chip(struct cpu *);
7788949bcd6Sandrei extern uint_t cpuid_get_ncore_per_chip(struct cpu *);
779d129bde2Sesaxe extern uint_t cpuid_get_ncpu_sharing_last_cache(struct cpu *);
780d129bde2Sesaxe extern id_t cpuid_get_last_lvl_cacheid(struct cpu *);
781fb2f18f8Sesaxe extern int cpuid_get_chipid(struct cpu *);
782fb2f18f8Sesaxe extern id_t cpuid_get_coreid(struct cpu *);
78310569901Sgavinm extern int cpuid_get_pkgcoreid(struct cpu *);
784fb2f18f8Sesaxe extern int cpuid_get_clogid(struct cpu *);
785b885580bSAlexander Kolbasov extern int cpuid_get_cacheid(struct cpu *);
786fa96bd91SMichael Corcoran extern uint32_t cpuid_get_apicid(struct cpu *);
7878031591dSSrihari Venkatesan extern uint_t cpuid_get_procnodeid(struct cpu *cpu);
7888031591dSSrihari Venkatesan extern uint_t cpuid_get_procnodes_per_pkg(struct cpu *cpu);
7897660e73fSHans Rosenfeld extern uint_t cpuid_get_compunitid(struct cpu *cpu);
7907660e73fSHans Rosenfeld extern uint_t cpuid_get_cores_per_compunit(struct cpu *cpu);
7918949bcd6Sandrei extern int cpuid_is_cmt(struct cpu *);
7927c478bd9Sstevel@tonic-gate extern int cpuid_syscall32_insn(struct cpu *);
7937c478bd9Sstevel@tonic-gate extern int getl2cacheinfo(struct cpu *, int *, int *, int *);
7947c478bd9Sstevel@tonic-gate 
7958a40a695Sgavinm extern uint32_t cpuid_getchiprev(struct cpu *);
7968a40a695Sgavinm extern const char *cpuid_getchiprevstr(struct cpu *);
7978a40a695Sgavinm extern uint32_t cpuid_getsockettype(struct cpu *);
79889e921d5SKuriakose Kuruvilla extern const char *cpuid_getsocketstr(struct cpu *);
7998a40a695Sgavinm 
8002ef50f01SJoe Bonasera extern int cpuid_have_cr8access(struct cpu *);
8012ef50f01SJoe Bonasera 
8027c478bd9Sstevel@tonic-gate extern int cpuid_opteron_erratum(struct cpu *, uint_t);
8037c478bd9Sstevel@tonic-gate 
8047c478bd9Sstevel@tonic-gate struct cpuid_info;
8057c478bd9Sstevel@tonic-gate 
8067c478bd9Sstevel@tonic-gate extern void setx86isalist(void);
807ae115bc7Smrj extern void cpuid_alloc_space(struct cpu *);
808ae115bc7Smrj extern void cpuid_free_space(struct cpu *);
809dfea898aSKuriakose Kuruvilla extern void cpuid_pass1(struct cpu *, uchar_t *);
8107c478bd9Sstevel@tonic-gate extern void cpuid_pass2(struct cpu *);
8117c478bd9Sstevel@tonic-gate extern void cpuid_pass3(struct cpu *);
812ebb8ac07SRobert Mustacchi extern void cpuid_pass4(struct cpu *, uint_t *);
813fa96bd91SMichael Corcoran extern void cpuid_set_cpu_properties(void *, processorid_t,
814fa96bd91SMichael Corcoran     struct cpuid_info *);
8157c478bd9Sstevel@tonic-gate 
8167c478bd9Sstevel@tonic-gate extern void cpuid_get_addrsize(struct cpu *, uint_t *, uint_t *);
8177c478bd9Sstevel@tonic-gate extern uint_t cpuid_get_dtlb_nent(struct cpu *, size_t);
818843e1988Sjohnlev 
819843e1988Sjohnlev #if !defined(__xpv)
8205b8a6efeSbholler extern uint32_t *cpuid_mwait_alloc(struct cpu *);
8215b8a6efeSbholler extern void cpuid_mwait_free(struct cpu *);
8220e751525SEric Saxe extern int cpuid_deep_cstates_supported(void);
823cef70d2cSBill Holler extern int cpuid_arat_supported(void);
824f21ed392Saubrey.li@intel.com extern int cpuid_iepb_supported(struct cpu *);
82541afdfa7SKrishnendu Sadhukhan - Sun Microsystems extern int cpuid_deadline_tsc_supported(void);
82679ec9da8SYuri Pankov extern void vmware_port(int, uint32_t *);
827843e1988Sjohnlev #endif
8287c478bd9Sstevel@tonic-gate 
8292449e17fSsherrym struct cpu_ucode_info;
8302449e17fSsherrym 
8312449e17fSsherrym extern void ucode_alloc_space(struct cpu *);
8322449e17fSsherrym extern void ucode_free_space(struct cpu *);
8332449e17fSsherrym extern void ucode_check(struct cpu *);
834adc586deSMark Johnson extern void ucode_cleanup();
8352449e17fSsherrym 
836247dbb3dSsudheer #if !defined(__xpv)
837247dbb3dSsudheer extern	char _tsc_mfence_start;
838247dbb3dSsudheer extern	char _tsc_mfence_end;
839247dbb3dSsudheer extern	char _tscp_start;
840247dbb3dSsudheer extern	char _tscp_end;
841247dbb3dSsudheer extern	char _no_rdtsc_start;
842247dbb3dSsudheer extern	char _no_rdtsc_end;
84315363b27Ssudheer extern	char _tsc_lfence_start;
84415363b27Ssudheer extern	char _tsc_lfence_end;
845247dbb3dSsudheer #endif
846247dbb3dSsudheer 
84722cc0e45SBill Holler #if !defined(__xpv)
84822cc0e45SBill Holler extern	char bcopy_patch_start;
84922cc0e45SBill Holler extern	char bcopy_patch_end;
85022cc0e45SBill Holler extern	char bcopy_ck_size;
85122cc0e45SBill Holler #endif
85222cc0e45SBill Holler 
853e774b42bSBill Holler extern void post_startup_cpu_fixups(void);
854e774b42bSBill Holler 
8557c478bd9Sstevel@tonic-gate extern uint_t workaround_errata(struct cpu *);
8567c478bd9Sstevel@tonic-gate 
8577c478bd9Sstevel@tonic-gate #if defined(OPTERON_ERRATUM_93)
8587c478bd9Sstevel@tonic-gate extern int opteron_erratum_93;
8597c478bd9Sstevel@tonic-gate #endif
8607c478bd9Sstevel@tonic-gate 
8617c478bd9Sstevel@tonic-gate #if defined(OPTERON_ERRATUM_91)
8627c478bd9Sstevel@tonic-gate extern int opteron_erratum_91;
8637c478bd9Sstevel@tonic-gate #endif
8647c478bd9Sstevel@tonic-gate 
8657c478bd9Sstevel@tonic-gate #if defined(OPTERON_ERRATUM_100)
8667c478bd9Sstevel@tonic-gate extern int opteron_erratum_100;
8677c478bd9Sstevel@tonic-gate #endif
8687c478bd9Sstevel@tonic-gate 
8697c478bd9Sstevel@tonic-gate #if defined(OPTERON_ERRATUM_121)
8707c478bd9Sstevel@tonic-gate extern int opteron_erratum_121;
8717c478bd9Sstevel@tonic-gate #endif
8727c478bd9Sstevel@tonic-gate 
873ee88d2b9Skchow #if defined(OPTERON_WORKAROUND_6323525)
874ee88d2b9Skchow extern int opteron_workaround_6323525;
875ee88d2b9Skchow extern void patch_workaround_6323525(void);
876ee88d2b9Skchow #endif
877ee88d2b9Skchow 
878cfe84b82SMatt Amdur #if !defined(__xpv)
879cfe84b82SMatt Amdur extern void determine_platform(void);
880cfe84b82SMatt Amdur #endif
881b9bfdccdSStuart Maybee extern int get_hwenv(void);
882b9bfdccdSStuart Maybee extern int is_controldom(void);
883b9bfdccdSStuart Maybee 
8847af88ac7SKuriakose Kuruvilla extern void xsave_setup_msr(struct cpu *);
8857af88ac7SKuriakose Kuruvilla 
886b9bfdccdSStuart Maybee /*
88779ec9da8SYuri Pankov  * Hypervisor signatures
88879ec9da8SYuri Pankov  */
88979ec9da8SYuri Pankov #define	HVSIG_XEN_HVM	"XenVMMXenVMM"
89079ec9da8SYuri Pankov #define	HVSIG_VMWARE	"VMwareVMware"
89179ec9da8SYuri Pankov #define	HVSIG_KVM	"KVMKVMKVM"
89279ec9da8SYuri Pankov #define	HVSIG_MICROSOFT	"Microsoft Hv"
89379ec9da8SYuri Pankov 
89479ec9da8SYuri Pankov /*
895b9bfdccdSStuart Maybee  * Defined hardware environments
896b9bfdccdSStuart Maybee  */
89779ec9da8SYuri Pankov #define	HW_NATIVE	(1 << 0)	/* Running on bare metal */
89879ec9da8SYuri Pankov #define	HW_XEN_PV	(1 << 1)	/* Running on Xen PVM */
89979ec9da8SYuri Pankov 
90079ec9da8SYuri Pankov #define	HW_XEN_HVM	(1 << 2)	/* Running on Xen HVM */
90179ec9da8SYuri Pankov #define	HW_VMWARE	(1 << 3)	/* Running on VMware hypervisor */
90279ec9da8SYuri Pankov #define	HW_KVM		(1 << 4)	/* Running on KVM hypervisor */
90379ec9da8SYuri Pankov #define	HW_MICROSOFT	(1 << 5)	/* Running on Microsoft hypervisor */
90479ec9da8SYuri Pankov 
90579ec9da8SYuri Pankov #define	HW_VIRTUAL	(HW_XEN_HVM | HW_VMWARE | HW_KVM | HW_MICROSOFT)
906b9bfdccdSStuart Maybee 
9077c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
9087c478bd9Sstevel@tonic-gate 
90979ec9da8SYuri Pankov #endif	/* !_ASM */
91079ec9da8SYuri Pankov 
91179ec9da8SYuri Pankov /*
91279ec9da8SYuri Pankov  * VMware hypervisor related defines
91379ec9da8SYuri Pankov  */
91479ec9da8SYuri Pankov #define	VMWARE_HVMAGIC		0x564d5868
91579ec9da8SYuri Pankov #define	VMWARE_HVPORT		0x5658
91679ec9da8SYuri Pankov #define	VMWARE_HVCMD_GETVERSION	0x0a
91779ec9da8SYuri Pankov #define	VMWARE_HVCMD_GETTSCFREQ	0x2d
9187c478bd9Sstevel@tonic-gate 
9197c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
9207c478bd9Sstevel@tonic-gate }
9217c478bd9Sstevel@tonic-gate #endif
9227c478bd9Sstevel@tonic-gate 
9237c478bd9Sstevel@tonic-gate #endif	/* _SYS_X86_ARCHEXT_H */
924