10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51582Skchow  * Common Development and Distribution License (the "License").
61582Skchow  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
221414Scindi  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_CONTROLREGS_H
270Sstevel@tonic-gate #define	_SYS_CONTROLREGS_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifndef _ASM
320Sstevel@tonic-gate #include <sys/types.h>
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef __cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * This file describes the x86 architecture control registers which
410Sstevel@tonic-gate  * are part of the privileged architecture.
420Sstevel@tonic-gate  *
430Sstevel@tonic-gate  * Many of these definitions are shared between IA-32-style and
440Sstevel@tonic-gate  * AMD64-style processors.
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /* CR0 Register */
480Sstevel@tonic-gate 
490Sstevel@tonic-gate #define	CR0_PG	0x80000000		/* paging enabled	*/
500Sstevel@tonic-gate #define	CR0_CD	0x40000000		/* cache disable	*/
510Sstevel@tonic-gate #define	CR0_NW	0x20000000		/* not writethrough	*/
520Sstevel@tonic-gate #define	CR0_AM	0x00040000		/* alignment mask	*/
530Sstevel@tonic-gate #define	CR0_WP	0x00010000		/* write protect	*/
540Sstevel@tonic-gate #define	CR0_NE	0x00000020		/* numeric error	*/
550Sstevel@tonic-gate #define	CR0_ET	0x00000010		/* extension type	*/
560Sstevel@tonic-gate #define	CR0_TS	0x00000008		/* task switch		*/
570Sstevel@tonic-gate #define	CR0_EM	0x00000004		/* emulation		*/
580Sstevel@tonic-gate #define	CR0_MP	0x00000002		/* monitor coprocessor	*/
590Sstevel@tonic-gate #define	CR0_PE	0x00000001		/* protection enabled	*/
600Sstevel@tonic-gate 
610Sstevel@tonic-gate /* XX64 eliminate these compatibility defines */
620Sstevel@tonic-gate 
630Sstevel@tonic-gate #define	CR0_CE	CR0_CD
640Sstevel@tonic-gate #define	CR0_WT	CR0_NW
650Sstevel@tonic-gate 
660Sstevel@tonic-gate #define	FMT_CR0	\
670Sstevel@tonic-gate 	"\20\40pg\37cd\36nw\35am\21wp\6ne\5et\4ts\3em\2mp\1pe"
680Sstevel@tonic-gate 
690Sstevel@tonic-gate /* CR3 Register */
700Sstevel@tonic-gate 
710Sstevel@tonic-gate #define	CR3_PCD	0x00000010		/* cache disable 		*/
720Sstevel@tonic-gate #define	CR3_PWT 0x00000008		/* write through 		*/
730Sstevel@tonic-gate 
740Sstevel@tonic-gate #define	FMT_CR3	"\20\5pcd\4pwt"
750Sstevel@tonic-gate 
760Sstevel@tonic-gate /* CR4 Register */
770Sstevel@tonic-gate 
780Sstevel@tonic-gate #define	CR4_VME		0x0001		/* virtual-8086 mode extensions	*/
790Sstevel@tonic-gate #define	CR4_PVI		0x0002		/* protected-mode virtual interrupts */
800Sstevel@tonic-gate #define	CR4_TSD		0x0004		/* time stamp disable		*/
810Sstevel@tonic-gate #define	CR4_DE		0x0008		/* debugging extensions		*/
820Sstevel@tonic-gate #define	CR4_PSE		0x0010		/* page size extensions		*/
830Sstevel@tonic-gate #define	CR4_PAE		0x0020		/* physical address extension	*/
840Sstevel@tonic-gate #define	CR4_MCE		0x0040		/* machine check enable		*/
850Sstevel@tonic-gate #define	CR4_PGE		0x0080		/* page global enable		*/
860Sstevel@tonic-gate #define	CR4_PCE		0x0100		/* perf-monitoring counter enable */
870Sstevel@tonic-gate #define	CR4_OSFXSR	0x0200		/* OS fxsave/fxrstor support	*/
880Sstevel@tonic-gate #define	CR4_OSXMMEXCPT	0x0400		/* OS unmasked exception support */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #define	FMT_CR4	\
910Sstevel@tonic-gate 	"\20\13xmme\12fxsr\11pce\10pge\7mce\6pae\5pse\4de\3tsd\2pvi\1vme"
920Sstevel@tonic-gate 
930Sstevel@tonic-gate /* Intel's SYSENTER configuration registers */
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #define	MSR_INTC_SEP_CS	0x174		/* kernel code selector MSR */
960Sstevel@tonic-gate #define	MSR_INTC_SEP_ESP 0x175		/* kernel esp MSR */
970Sstevel@tonic-gate #define	MSR_INTC_SEP_EIP 0x176		/* kernel eip MSR */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /* AMD's EFER register */
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate #define	MSR_AMD_EFER	0xc0000080	/* extended feature enable MSR */
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate #define	AMD_EFER_NXE	0x800		/* no-execute enable		*/
1040Sstevel@tonic-gate #define	AMD_EFER_LMA	0x400		/* long mode active (read-only)	*/
1050Sstevel@tonic-gate #define	AMD_EFER_LME	0x100		/* long mode enable		*/
1060Sstevel@tonic-gate #define	AMD_EFER_SCE	0x001		/* system call extensions	*/
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate #define	FMT_AMD_EFER \
1090Sstevel@tonic-gate 	"\20\14nxe\13lma\11lme\1sce"
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate /* AMD's SYSCFG register */
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate #define	MSR_AMD_SYSCFG	0xc0000010	/* system configuration MSR */
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate #define	AMD_SYSCFG_TOM2	0x200000	/* MtrrTom2En */
1160Sstevel@tonic-gate #define	AMD_SYSCFG_MVDM	0x100000	/* MtrrVarDramEn */
1170Sstevel@tonic-gate #define	AMD_SYSCFG_MFDM	0x080000	/* MtrrFixDramModEn */
1180Sstevel@tonic-gate #define	AMD_SYSCFG_MFDE	0x040000	/* MtrrFixDramEn */
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate #define	FMT_AMD_SYSCFG \
1210Sstevel@tonic-gate 	"\20\26tom2\25mvdm\24mfdm\23mfde"
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate /* AMD's syscall/sysret MSRs */
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate #define	MSR_AMD_STAR	0xc0000081	/* %cs:%ss:%cs:%ss:%eip for syscall */
1260Sstevel@tonic-gate #define	MSR_AMD_LSTAR	0xc0000082	/* target %rip of 64-bit syscall */
1270Sstevel@tonic-gate #define	MSR_AMD_CSTAR	0xc0000083	/* target %rip of 32-bit syscall */
1280Sstevel@tonic-gate #define	MSR_AMD_SFMASK	0xc0000084	/* syscall flag mask */
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate /* AMD's FS.base and GS.base MSRs */
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate #define	MSR_AMD_FSBASE	0xc0000100	/* 64-bit base address for %fs */
1330Sstevel@tonic-gate #define	MSR_AMD_GSBASE	0xc0000101	/* 64-bit base address for %gs */
1340Sstevel@tonic-gate #define	MSR_AMD_KGSBASE	0xc0000102	/* swapgs swaps this with gsbase */
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate /* AMD's configuration MSRs, weakly documented in the revision guide */
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate #define	MSR_AMD_DC_CFG	0xc0011022
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate #define	AMD_DC_CFG_DIS_CNV_WC_SSO	(UINT64_C(1) << 3)
1410Sstevel@tonic-gate #define	AMD_DC_CFG_DIS_SMC_CHK_BUF	(UINT64_C(1) << 10)
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate /* AMD's HWCR MSR */
144359Skucharsk 
1450Sstevel@tonic-gate #define	MSR_AMD_HWCR	0xc0010015
1460Sstevel@tonic-gate 
1471414Scindi #define	AMD_HWCR_FFDIS			0x00040	/* disable TLB Flush Filter */
1481414Scindi #define	AMD_HWCR_MCI_STATUS_WREN	0x40000	/* enable write of MCi_STATUS */
1490Sstevel@tonic-gate 
150359Skucharsk /* AMD's NorthBridge Config MSR, SHOULD ONLY BE WRITTEN TO BY BIOS */
151359Skucharsk 
152359Skucharsk #define	MSR_AMD_NB_CFG	0xc001001f
153359Skucharsk 
1541582Skchow #define	MSR_BU_CFG	0xc0011023
1551582Skchow 
156359Skucharsk #define	AMD_NB_CFG_SRQ_HEARTBEAT	(UINT64_C(1) << 20)
157*2519Skchow #define	AMD_NB_CFG_SRQ_SPR		(UINT64_C(1) << 32)
158359Skucharsk 
1590Sstevel@tonic-gate /* AMD */
1600Sstevel@tonic-gate #define	MSR_AMD_PATCHLEVEL	0x8b
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #ifdef __cplusplus
1630Sstevel@tonic-gate }
1640Sstevel@tonic-gate #endif
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate #endif	/* !_SYS_CONTROLREGS_H */
167