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 /* 22*13134Skuriakose.kuruvilla@oracle.com * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SYS_CONTROLREGS_H 260Sstevel@tonic-gate #define _SYS_CONTROLREGS_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #ifndef _ASM 290Sstevel@tonic-gate #include <sys/types.h> 300Sstevel@tonic-gate #endif 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate /* 370Sstevel@tonic-gate * This file describes the x86 architecture control registers which 380Sstevel@tonic-gate * are part of the privileged architecture. 390Sstevel@tonic-gate * 400Sstevel@tonic-gate * Many of these definitions are shared between IA-32-style and 410Sstevel@tonic-gate * AMD64-style processors. 420Sstevel@tonic-gate */ 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* CR0 Register */ 450Sstevel@tonic-gate 460Sstevel@tonic-gate #define CR0_PG 0x80000000 /* paging enabled */ 470Sstevel@tonic-gate #define CR0_CD 0x40000000 /* cache disable */ 480Sstevel@tonic-gate #define CR0_NW 0x20000000 /* not writethrough */ 490Sstevel@tonic-gate #define CR0_AM 0x00040000 /* alignment mask */ 500Sstevel@tonic-gate #define CR0_WP 0x00010000 /* write protect */ 510Sstevel@tonic-gate #define CR0_NE 0x00000020 /* numeric error */ 520Sstevel@tonic-gate #define CR0_ET 0x00000010 /* extension type */ 530Sstevel@tonic-gate #define CR0_TS 0x00000008 /* task switch */ 540Sstevel@tonic-gate #define CR0_EM 0x00000004 /* emulation */ 550Sstevel@tonic-gate #define CR0_MP 0x00000002 /* monitor coprocessor */ 560Sstevel@tonic-gate #define CR0_PE 0x00000001 /* protection enabled */ 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* XX64 eliminate these compatibility defines */ 590Sstevel@tonic-gate 600Sstevel@tonic-gate #define CR0_CE CR0_CD 610Sstevel@tonic-gate #define CR0_WT CR0_NW 620Sstevel@tonic-gate 630Sstevel@tonic-gate #define FMT_CR0 \ 640Sstevel@tonic-gate "\20\40pg\37cd\36nw\35am\21wp\6ne\5et\4ts\3em\2mp\1pe" 650Sstevel@tonic-gate 663446Smrj /* 673446Smrj * Set the FPU-related control bits to explain to the processor that 683446Smrj * we're managing FPU state: 693446Smrj * - set monitor coprocessor (allow TS bit to control FPU) 703446Smrj * - set numeric exception (disable IGNNE# mechanism) 713446Smrj * - set task switch (#nm on first fp instruction) 723446Smrj * - clear emulate math bit (cause we're not emulating!) 733446Smrj */ 743446Smrj #define CR0_ENABLE_FPU_FLAGS(cr) \ 753446Smrj (((cr) | CR0_MP | CR0_NE | CR0_TS) & (uint32_t)~CR0_EM) 763446Smrj 773446Smrj /* 783446Smrj * Set the FPU-related control bits to explain to the processor that 793446Smrj * we're -not- managing FPU state: 803446Smrj * - set emulate (all fp instructions cause #nm) 813446Smrj * - clear monitor coprocessor (so fwait/wait doesn't #nm) 823446Smrj */ 833446Smrj #define CR0_DISABLE_FPU_FLAGS(cr) \ 843446Smrj (((cr) | CR0_EM) & (uint32_t)~CR0_MP) 853446Smrj 860Sstevel@tonic-gate /* CR3 Register */ 870Sstevel@tonic-gate 880Sstevel@tonic-gate #define CR3_PCD 0x00000010 /* cache disable */ 890Sstevel@tonic-gate #define CR3_PWT 0x00000008 /* write through */ 900Sstevel@tonic-gate 910Sstevel@tonic-gate #define FMT_CR3 "\20\5pcd\4pwt" 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* CR4 Register */ 940Sstevel@tonic-gate 950Sstevel@tonic-gate #define CR4_VME 0x0001 /* virtual-8086 mode extensions */ 960Sstevel@tonic-gate #define CR4_PVI 0x0002 /* protected-mode virtual interrupts */ 970Sstevel@tonic-gate #define CR4_TSD 0x0004 /* time stamp disable */ 980Sstevel@tonic-gate #define CR4_DE 0x0008 /* debugging extensions */ 990Sstevel@tonic-gate #define CR4_PSE 0x0010 /* page size extensions */ 1000Sstevel@tonic-gate #define CR4_PAE 0x0020 /* physical address extension */ 1010Sstevel@tonic-gate #define CR4_MCE 0x0040 /* machine check enable */ 1020Sstevel@tonic-gate #define CR4_PGE 0x0080 /* page global enable */ 1030Sstevel@tonic-gate #define CR4_PCE 0x0100 /* perf-monitoring counter enable */ 1040Sstevel@tonic-gate #define CR4_OSFXSR 0x0200 /* OS fxsave/fxrstor support */ 1050Sstevel@tonic-gate #define CR4_OSXMMEXCPT 0x0400 /* OS unmasked exception support */ 1063446Smrj /* 0x0800 reserved */ 1073446Smrj /* 0x1000 reserved */ 1083446Smrj #define CR4_VMXE 0x2000 1093446Smrj #define CR4_SMXE 0x4000 110*13134Skuriakose.kuruvilla@oracle.com #define CR4_OSXSAVE 0x40000 /* OS xsave/xrestore support */ 1110Sstevel@tonic-gate 1123446Smrj #define FMT_CR4 \ 113*13134Skuriakose.kuruvilla@oracle.com "\20\23osxsav\17smxe\16vmxe\13xmme\12fxsr\11pce\10pge" \ 1143446Smrj "\7mce\6pae\5pse\4de\3tsd\2pvi\1vme" 1153446Smrj 1163446Smrj /* 1173446Smrj * Enable the SSE-related control bits to explain to the processor that 1183446Smrj * we're managing XMM state and exceptions 1193446Smrj */ 1203446Smrj #define CR4_ENABLE_SSE_FLAGS(cr) \ 1213446Smrj ((cr) | CR4_OSFXSR | CR4_OSXMMEXCPT) 1223446Smrj 1233446Smrj /* 1243446Smrj * Disable the SSE-related control bits to explain to the processor 1253446Smrj * that we're NOT managing XMM state 1263446Smrj */ 1273446Smrj #define CR4_DISABLE_SSE_FLAGS(cr) \ 1283446Smrj ((cr) & ~(uint32_t)(CR4_OSFXSR | CR4_OSXMMEXCPT)) 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate /* Intel's SYSENTER configuration registers */ 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate #define MSR_INTC_SEP_CS 0x174 /* kernel code selector MSR */ 1330Sstevel@tonic-gate #define MSR_INTC_SEP_ESP 0x175 /* kernel esp MSR */ 1340Sstevel@tonic-gate #define MSR_INTC_SEP_EIP 0x176 /* kernel eip MSR */ 1350Sstevel@tonic-gate 1364581Ssherrym /* Intel's microcode registers */ 1374581Ssherrym #define MSR_INTC_UCODE_WRITE 0x79 /* microcode write */ 1384581Ssherrym #define MSR_INTC_UCODE_REV 0x8b /* microcode revision */ 1394581Ssherrym #define INTC_UCODE_REV_SHIFT 32 /* Bits 63:32 */ 1404581Ssherrym 1414581Ssherrym /* Intel's platform identification */ 1424581Ssherrym #define MSR_INTC_PLATFORM_ID 0x17 1434581Ssherrym #define INTC_PLATFORM_ID_SHIFT 50 /* Bit 52:50 */ 1444581Ssherrym #define INTC_PLATFORM_ID_MASK 0x7 1454581Ssherrym 1460Sstevel@tonic-gate /* AMD's EFER register */ 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #define MSR_AMD_EFER 0xc0000080 /* extended feature enable MSR */ 1490Sstevel@tonic-gate 1503446Smrj #define AMD_EFER_FFXSR 0x4000 /* fast fxsave/fxrstor */ 1513446Smrj #define AMD_EFER_SVME 0x1000 /* svm enable */ 1523446Smrj #define AMD_EFER_NXE 0x0800 /* no-execute enable */ 1533446Smrj #define AMD_EFER_LMA 0x0400 /* long mode active (read-only) */ 1543446Smrj #define AMD_EFER_LME 0x0100 /* long mode enable */ 1553446Smrj #define AMD_EFER_SCE 0x0001 /* system call extensions */ 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate #define FMT_AMD_EFER \ 1583446Smrj "\20\17ffxsr\15svme\14nxe\13lma\11lme\1sce" 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate /* AMD's SYSCFG register */ 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate #define MSR_AMD_SYSCFG 0xc0000010 /* system configuration MSR */ 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate #define AMD_SYSCFG_TOM2 0x200000 /* MtrrTom2En */ 1650Sstevel@tonic-gate #define AMD_SYSCFG_MVDM 0x100000 /* MtrrVarDramEn */ 1660Sstevel@tonic-gate #define AMD_SYSCFG_MFDM 0x080000 /* MtrrFixDramModEn */ 1670Sstevel@tonic-gate #define AMD_SYSCFG_MFDE 0x040000 /* MtrrFixDramEn */ 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate #define FMT_AMD_SYSCFG \ 1700Sstevel@tonic-gate "\20\26tom2\25mvdm\24mfdm\23mfde" 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate /* AMD's syscall/sysret MSRs */ 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate #define MSR_AMD_STAR 0xc0000081 /* %cs:%ss:%cs:%ss:%eip for syscall */ 1750Sstevel@tonic-gate #define MSR_AMD_LSTAR 0xc0000082 /* target %rip of 64-bit syscall */ 1760Sstevel@tonic-gate #define MSR_AMD_CSTAR 0xc0000083 /* target %rip of 32-bit syscall */ 1770Sstevel@tonic-gate #define MSR_AMD_SFMASK 0xc0000084 /* syscall flag mask */ 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate /* AMD's FS.base and GS.base MSRs */ 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate #define MSR_AMD_FSBASE 0xc0000100 /* 64-bit base address for %fs */ 1820Sstevel@tonic-gate #define MSR_AMD_GSBASE 0xc0000101 /* 64-bit base address for %gs */ 1830Sstevel@tonic-gate #define MSR_AMD_KGSBASE 0xc0000102 /* swapgs swaps this with gsbase */ 1843446Smrj #define MSR_AMD_TSCAUX 0xc0000103 /* %ecx value on rdtscp insn */ 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate /* AMD's configuration MSRs, weakly documented in the revision guide */ 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate #define MSR_AMD_DC_CFG 0xc0011022 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate #define AMD_DC_CFG_DIS_CNV_WC_SSO (UINT64_C(1) << 3) 1910Sstevel@tonic-gate #define AMD_DC_CFG_DIS_SMC_CHK_BUF (UINT64_C(1) << 10) 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate /* AMD's HWCR MSR */ 194359Skucharsk 1950Sstevel@tonic-gate #define MSR_AMD_HWCR 0xc0010015 1960Sstevel@tonic-gate 1976691Skchow #define AMD_HWCR_TLBCACHEDIS (UINT64_C(1) << 3) 1981414Scindi #define AMD_HWCR_FFDIS 0x00040 /* disable TLB Flush Filter */ 1991414Scindi #define AMD_HWCR_MCI_STATUS_WREN 0x40000 /* enable write of MCi_STATUS */ 2000Sstevel@tonic-gate 201359Skucharsk /* AMD's NorthBridge Config MSR, SHOULD ONLY BE WRITTEN TO BY BIOS */ 202359Skucharsk 203359Skucharsk #define MSR_AMD_NB_CFG 0xc001001f 204359Skucharsk 205359Skucharsk #define AMD_NB_CFG_SRQ_HEARTBEAT (UINT64_C(1) << 20) 2062519Skchow #define AMD_NB_CFG_SRQ_SPR (UINT64_C(1) << 32) 207359Skucharsk 2086691Skchow #define MSR_AMD_BU_CFG 0xc0011023 2096691Skchow 2106691Skchow #define AMD_BU_CFG_E298 (UINT64_C(1) << 1) 2116691Skchow 2126691Skchow /* AMD's osvw MSRs */ 2136691Skchow #define MSR_AMD_OSVW_ID_LEN 0xc0010140 2146691Skchow #define MSR_AMD_OSVW_STATUS 0xc0010141 2156691Skchow 2166691Skchow 2176691Skchow #define OSVW_ID_LEN_MASK 0xffffULL 2186691Skchow #define OSVW_ID_CNT_PER_MSR 64 2196691Skchow 2204898Sjjc /* 2214898Sjjc * Enable PCI Extended Configuration Space (ECS) on Greyhound 2224898Sjjc */ 2234898Sjjc #define AMD_GH_NB_CFG_EN_ECS (UINT64_C(1) << 46) 2244898Sjjc 2257605SMark.Johnson@Sun.COM /* AMD microcode patch loader */ 2260Sstevel@tonic-gate #define MSR_AMD_PATCHLEVEL 0x8b 2277605SMark.Johnson@Sun.COM #define MSR_AMD_PATCHLOADER 0xc0010020 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate #ifdef __cplusplus 2300Sstevel@tonic-gate } 2310Sstevel@tonic-gate #endif 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate #endif /* !_SYS_CONTROLREGS_H */ 234