16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2af170c50SDavid Howells #ifndef _UAPI_ASM_X86_PROCESSOR_FLAGS_H 3af170c50SDavid Howells #define _UAPI_ASM_X86_PROCESSOR_FLAGS_H 4af170c50SDavid Howells /* Various flags defined: can be included from assembler. */ 5af170c50SDavid Howells 6d1fbefcbSH. Peter Anvin #include <linux/const.h> 7d1fbefcbSH. Peter Anvin 8af170c50SDavid Howells /* 9af170c50SDavid Howells * EFLAGS bits 10af170c50SDavid Howells */ 11d1fbefcbSH. Peter Anvin #define X86_EFLAGS_CF_BIT 0 /* Carry Flag */ 12d1fbefcbSH. Peter Anvin #define X86_EFLAGS_CF _BITUL(X86_EFLAGS_CF_BIT) 13d1fbefcbSH. Peter Anvin #define X86_EFLAGS_FIXED_BIT 1 /* Bit 1 - always on */ 14d1fbefcbSH. Peter Anvin #define X86_EFLAGS_FIXED _BITUL(X86_EFLAGS_FIXED_BIT) 15d1fbefcbSH. Peter Anvin #define X86_EFLAGS_PF_BIT 2 /* Parity Flag */ 16d1fbefcbSH. Peter Anvin #define X86_EFLAGS_PF _BITUL(X86_EFLAGS_PF_BIT) 17d1fbefcbSH. Peter Anvin #define X86_EFLAGS_AF_BIT 4 /* Auxiliary carry Flag */ 18d1fbefcbSH. Peter Anvin #define X86_EFLAGS_AF _BITUL(X86_EFLAGS_AF_BIT) 19d1fbefcbSH. Peter Anvin #define X86_EFLAGS_ZF_BIT 6 /* Zero Flag */ 20d1fbefcbSH. Peter Anvin #define X86_EFLAGS_ZF _BITUL(X86_EFLAGS_ZF_BIT) 21d1fbefcbSH. Peter Anvin #define X86_EFLAGS_SF_BIT 7 /* Sign Flag */ 22d1fbefcbSH. Peter Anvin #define X86_EFLAGS_SF _BITUL(X86_EFLAGS_SF_BIT) 23d1fbefcbSH. Peter Anvin #define X86_EFLAGS_TF_BIT 8 /* Trap Flag */ 24d1fbefcbSH. Peter Anvin #define X86_EFLAGS_TF _BITUL(X86_EFLAGS_TF_BIT) 25d1fbefcbSH. Peter Anvin #define X86_EFLAGS_IF_BIT 9 /* Interrupt Flag */ 26d1fbefcbSH. Peter Anvin #define X86_EFLAGS_IF _BITUL(X86_EFLAGS_IF_BIT) 27d1fbefcbSH. Peter Anvin #define X86_EFLAGS_DF_BIT 10 /* Direction Flag */ 28d1fbefcbSH. Peter Anvin #define X86_EFLAGS_DF _BITUL(X86_EFLAGS_DF_BIT) 29d1fbefcbSH. Peter Anvin #define X86_EFLAGS_OF_BIT 11 /* Overflow Flag */ 30d1fbefcbSH. Peter Anvin #define X86_EFLAGS_OF _BITUL(X86_EFLAGS_OF_BIT) 31d1fbefcbSH. Peter Anvin #define X86_EFLAGS_IOPL_BIT 12 /* I/O Privilege Level (2 bits) */ 32d1fbefcbSH. Peter Anvin #define X86_EFLAGS_IOPL (_AC(3,UL) << X86_EFLAGS_IOPL_BIT) 33d1fbefcbSH. Peter Anvin #define X86_EFLAGS_NT_BIT 14 /* Nested Task */ 34d1fbefcbSH. Peter Anvin #define X86_EFLAGS_NT _BITUL(X86_EFLAGS_NT_BIT) 35d1fbefcbSH. Peter Anvin #define X86_EFLAGS_RF_BIT 16 /* Resume Flag */ 36d1fbefcbSH. Peter Anvin #define X86_EFLAGS_RF _BITUL(X86_EFLAGS_RF_BIT) 37d1fbefcbSH. Peter Anvin #define X86_EFLAGS_VM_BIT 17 /* Virtual Mode */ 38d1fbefcbSH. Peter Anvin #define X86_EFLAGS_VM _BITUL(X86_EFLAGS_VM_BIT) 39d1fbefcbSH. Peter Anvin #define X86_EFLAGS_AC_BIT 18 /* Alignment Check/Access Control */ 40d1fbefcbSH. Peter Anvin #define X86_EFLAGS_AC _BITUL(X86_EFLAGS_AC_BIT) 41d1fbefcbSH. Peter Anvin #define X86_EFLAGS_VIF_BIT 19 /* Virtual Interrupt Flag */ 42d1fbefcbSH. Peter Anvin #define X86_EFLAGS_VIF _BITUL(X86_EFLAGS_VIF_BIT) 43d1fbefcbSH. Peter Anvin #define X86_EFLAGS_VIP_BIT 20 /* Virtual Interrupt Pending */ 44d1fbefcbSH. Peter Anvin #define X86_EFLAGS_VIP _BITUL(X86_EFLAGS_VIP_BIT) 45d1fbefcbSH. Peter Anvin #define X86_EFLAGS_ID_BIT 21 /* CPUID detection */ 46d1fbefcbSH. Peter Anvin #define X86_EFLAGS_ID _BITUL(X86_EFLAGS_ID_BIT) 47af170c50SDavid Howells 48af170c50SDavid Howells /* 49af170c50SDavid Howells * Basic CPU control in CR0 50af170c50SDavid Howells */ 51d1fbefcbSH. Peter Anvin #define X86_CR0_PE_BIT 0 /* Protection Enable */ 52d1fbefcbSH. Peter Anvin #define X86_CR0_PE _BITUL(X86_CR0_PE_BIT) 53d1fbefcbSH. Peter Anvin #define X86_CR0_MP_BIT 1 /* Monitor Coprocessor */ 54d1fbefcbSH. Peter Anvin #define X86_CR0_MP _BITUL(X86_CR0_MP_BIT) 55d1fbefcbSH. Peter Anvin #define X86_CR0_EM_BIT 2 /* Emulation */ 56d1fbefcbSH. Peter Anvin #define X86_CR0_EM _BITUL(X86_CR0_EM_BIT) 57d1fbefcbSH. Peter Anvin #define X86_CR0_TS_BIT 3 /* Task Switched */ 58d1fbefcbSH. Peter Anvin #define X86_CR0_TS _BITUL(X86_CR0_TS_BIT) 59d1fbefcbSH. Peter Anvin #define X86_CR0_ET_BIT 4 /* Extension Type */ 60d1fbefcbSH. Peter Anvin #define X86_CR0_ET _BITUL(X86_CR0_ET_BIT) 61d1fbefcbSH. Peter Anvin #define X86_CR0_NE_BIT 5 /* Numeric Error */ 62d1fbefcbSH. Peter Anvin #define X86_CR0_NE _BITUL(X86_CR0_NE_BIT) 63d1fbefcbSH. Peter Anvin #define X86_CR0_WP_BIT 16 /* Write Protect */ 64d1fbefcbSH. Peter Anvin #define X86_CR0_WP _BITUL(X86_CR0_WP_BIT) 65d1fbefcbSH. Peter Anvin #define X86_CR0_AM_BIT 18 /* Alignment Mask */ 66d1fbefcbSH. Peter Anvin #define X86_CR0_AM _BITUL(X86_CR0_AM_BIT) 67d1fbefcbSH. Peter Anvin #define X86_CR0_NW_BIT 29 /* Not Write-through */ 68d1fbefcbSH. Peter Anvin #define X86_CR0_NW _BITUL(X86_CR0_NW_BIT) 69d1fbefcbSH. Peter Anvin #define X86_CR0_CD_BIT 30 /* Cache Disable */ 70d1fbefcbSH. Peter Anvin #define X86_CR0_CD _BITUL(X86_CR0_CD_BIT) 71d1fbefcbSH. Peter Anvin #define X86_CR0_PG_BIT 31 /* Paging */ 72d1fbefcbSH. Peter Anvin #define X86_CR0_PG _BITUL(X86_CR0_PG_BIT) 73af170c50SDavid Howells 74af170c50SDavid Howells /* 75af170c50SDavid Howells * Paging options in CR3 76af170c50SDavid Howells */ 77d1fbefcbSH. Peter Anvin #define X86_CR3_PWT_BIT 3 /* Page Write Through */ 78d1fbefcbSH. Peter Anvin #define X86_CR3_PWT _BITUL(X86_CR3_PWT_BIT) 79d1fbefcbSH. Peter Anvin #define X86_CR3_PCD_BIT 4 /* Page Cache Disable */ 80d1fbefcbSH. Peter Anvin #define X86_CR3_PCD _BITUL(X86_CR3_PCD_BIT) 816fd166aaSPeter Zijlstra 826fd166aaSPeter Zijlstra #define X86_CR3_PCID_BITS 12 836fd166aaSPeter Zijlstra #define X86_CR3_PCID_MASK (_AC((1UL << X86_CR3_PCID_BITS) - 1, UL)) 846fd166aaSPeter Zijlstra 856449dcb0SKirill A. Shutemov #define X86_CR3_LAM_U57_BIT 61 /* Activate LAM for userspace, 62:57 bits masked */ 866449dcb0SKirill A. Shutemov #define X86_CR3_LAM_U57 _BITULL(X86_CR3_LAM_U57_BIT) 876449dcb0SKirill A. Shutemov #define X86_CR3_LAM_U48_BIT 62 /* Activate LAM for userspace, 62:48 bits masked */ 886449dcb0SKirill A. Shutemov #define X86_CR3_LAM_U48 _BITULL(X86_CR3_LAM_U48_BIT) 896fd166aaSPeter Zijlstra #define X86_CR3_PCID_NOFLUSH_BIT 63 /* Preserve old PCID */ 906fd166aaSPeter Zijlstra #define X86_CR3_PCID_NOFLUSH _BITULL(X86_CR3_PCID_NOFLUSH_BIT) 91af170c50SDavid Howells 92af170c50SDavid Howells /* 93af170c50SDavid Howells * Intel CPU features in CR4 94af170c50SDavid Howells */ 95d1fbefcbSH. Peter Anvin #define X86_CR4_VME_BIT 0 /* enable vm86 extensions */ 96d1fbefcbSH. Peter Anvin #define X86_CR4_VME _BITUL(X86_CR4_VME_BIT) 97d1fbefcbSH. Peter Anvin #define X86_CR4_PVI_BIT 1 /* virtual interrupts flag enable */ 98d1fbefcbSH. Peter Anvin #define X86_CR4_PVI _BITUL(X86_CR4_PVI_BIT) 99d1fbefcbSH. Peter Anvin #define X86_CR4_TSD_BIT 2 /* disable time stamp at ipl 3 */ 100d1fbefcbSH. Peter Anvin #define X86_CR4_TSD _BITUL(X86_CR4_TSD_BIT) 101d1fbefcbSH. Peter Anvin #define X86_CR4_DE_BIT 3 /* enable debugging extensions */ 102d1fbefcbSH. Peter Anvin #define X86_CR4_DE _BITUL(X86_CR4_DE_BIT) 103d1fbefcbSH. Peter Anvin #define X86_CR4_PSE_BIT 4 /* enable page size extensions */ 104d1fbefcbSH. Peter Anvin #define X86_CR4_PSE _BITUL(X86_CR4_PSE_BIT) 105d1fbefcbSH. Peter Anvin #define X86_CR4_PAE_BIT 5 /* enable physical address extensions */ 106d1fbefcbSH. Peter Anvin #define X86_CR4_PAE _BITUL(X86_CR4_PAE_BIT) 107d1fbefcbSH. Peter Anvin #define X86_CR4_MCE_BIT 6 /* Machine check enable */ 108d1fbefcbSH. Peter Anvin #define X86_CR4_MCE _BITUL(X86_CR4_MCE_BIT) 109d1fbefcbSH. Peter Anvin #define X86_CR4_PGE_BIT 7 /* enable global pages */ 110d1fbefcbSH. Peter Anvin #define X86_CR4_PGE _BITUL(X86_CR4_PGE_BIT) 111d1fbefcbSH. Peter Anvin #define X86_CR4_PCE_BIT 8 /* enable performance counters at ipl 3 */ 112d1fbefcbSH. Peter Anvin #define X86_CR4_PCE _BITUL(X86_CR4_PCE_BIT) 113d1fbefcbSH. Peter Anvin #define X86_CR4_OSFXSR_BIT 9 /* enable fast FPU save and restore */ 114d1fbefcbSH. Peter Anvin #define X86_CR4_OSFXSR _BITUL(X86_CR4_OSFXSR_BIT) 115d1fbefcbSH. Peter Anvin #define X86_CR4_OSXMMEXCPT_BIT 10 /* enable unmasked SSE exceptions */ 116d1fbefcbSH. Peter Anvin #define X86_CR4_OSXMMEXCPT _BITUL(X86_CR4_OSXMMEXCPT_BIT) 1173522c2a6SRicardo Neri #define X86_CR4_UMIP_BIT 11 /* enable UMIP support */ 1183522c2a6SRicardo Neri #define X86_CR4_UMIP _BITUL(X86_CR4_UMIP_BIT) 119032370b9SKirill A. Shutemov #define X86_CR4_LA57_BIT 12 /* enable 5-level page tables */ 120032370b9SKirill A. Shutemov #define X86_CR4_LA57 _BITUL(X86_CR4_LA57_BIT) 121d1fbefcbSH. Peter Anvin #define X86_CR4_VMXE_BIT 13 /* enable VMX virtualization */ 122d1fbefcbSH. Peter Anvin #define X86_CR4_VMXE _BITUL(X86_CR4_VMXE_BIT) 123d1fbefcbSH. Peter Anvin #define X86_CR4_SMXE_BIT 14 /* enable safer mode (TXT) */ 124d1fbefcbSH. Peter Anvin #define X86_CR4_SMXE _BITUL(X86_CR4_SMXE_BIT) 125d1fbefcbSH. Peter Anvin #define X86_CR4_FSGSBASE_BIT 16 /* enable RDWRFSGS support */ 126d1fbefcbSH. Peter Anvin #define X86_CR4_FSGSBASE _BITUL(X86_CR4_FSGSBASE_BIT) 127d1fbefcbSH. Peter Anvin #define X86_CR4_PCIDE_BIT 17 /* enable PCID support */ 128d1fbefcbSH. Peter Anvin #define X86_CR4_PCIDE _BITUL(X86_CR4_PCIDE_BIT) 129d1fbefcbSH. Peter Anvin #define X86_CR4_OSXSAVE_BIT 18 /* enable xsave and xrestore */ 130d1fbefcbSH. Peter Anvin #define X86_CR4_OSXSAVE _BITUL(X86_CR4_OSXSAVE_BIT) 131d1fbefcbSH. Peter Anvin #define X86_CR4_SMEP_BIT 20 /* enable SMEP support */ 132d1fbefcbSH. Peter Anvin #define X86_CR4_SMEP _BITUL(X86_CR4_SMEP_BIT) 133d1fbefcbSH. Peter Anvin #define X86_CR4_SMAP_BIT 21 /* enable SMAP support */ 134d1fbefcbSH. Peter Anvin #define X86_CR4_SMAP _BITUL(X86_CR4_SMAP_BIT) 135f28b49d2SDave Hansen #define X86_CR4_PKE_BIT 22 /* enable Protection Keys support */ 136f28b49d2SDave Hansen #define X86_CR4_PKE _BITUL(X86_CR4_PKE_BIT) 137991625f3SPeter Zijlstra #define X86_CR4_CET_BIT 23 /* enable Control-flow Enforcement Technology */ 138991625f3SPeter Zijlstra #define X86_CR4_CET _BITUL(X86_CR4_CET_BIT) 1396449dcb0SKirill A. Shutemov #define X86_CR4_LAM_SUP_BIT 28 /* LAM for supervisor pointers */ 1406449dcb0SKirill A. Shutemov #define X86_CR4_LAM_SUP _BITUL(X86_CR4_LAM_SUP_BIT) 141af170c50SDavid Howells 142*ff45746fSH. Peter Anvin (Intel) #ifdef __x86_64__ 143*ff45746fSH. Peter Anvin (Intel) #define X86_CR4_FRED_BIT 32 /* enable FRED kernel entry */ 144*ff45746fSH. Peter Anvin (Intel) #define X86_CR4_FRED _BITUL(X86_CR4_FRED_BIT) 145*ff45746fSH. Peter Anvin (Intel) #else 146*ff45746fSH. Peter Anvin (Intel) #define X86_CR4_FRED (0) 147*ff45746fSH. Peter Anvin (Intel) #endif 148*ff45746fSH. Peter Anvin (Intel) 149af170c50SDavid Howells /* 150af170c50SDavid Howells * x86-64 Task Priority Register, CR8 151af170c50SDavid Howells */ 152d1fbefcbSH. Peter Anvin #define X86_CR8_TPR _AC(0x0000000f,UL) /* task priority register */ 153af170c50SDavid Howells 154af170c50SDavid Howells /* 155af170c50SDavid Howells * AMD and Transmeta use MSRs for configuration; see <asm/msr-index.h> 156af170c50SDavid Howells */ 157af170c50SDavid Howells 158af170c50SDavid Howells /* 159af170c50SDavid Howells * NSC/Cyrix CPU configuration register indexes 160af170c50SDavid Howells */ 161af170c50SDavid Howells #define CX86_PCR0 0x20 162af170c50SDavid Howells #define CX86_GCR 0xb8 163af170c50SDavid Howells #define CX86_CCR0 0xc0 164af170c50SDavid Howells #define CX86_CCR1 0xc1 165af170c50SDavid Howells #define CX86_CCR2 0xc2 166af170c50SDavid Howells #define CX86_CCR3 0xc3 167af170c50SDavid Howells #define CX86_CCR4 0xe8 168af170c50SDavid Howells #define CX86_CCR5 0xe9 169af170c50SDavid Howells #define CX86_CCR6 0xea 170af170c50SDavid Howells #define CX86_CCR7 0xeb 171af170c50SDavid Howells #define CX86_PCR1 0xf0 172af170c50SDavid Howells #define CX86_DIR0 0xfe 173af170c50SDavid Howells #define CX86_DIR1 0xff 174af170c50SDavid Howells #define CX86_ARR_BASE 0xc4 175af170c50SDavid Howells #define CX86_RCR_BASE 0xdc 176af170c50SDavid Howells 177b0ce5b8cSRicardo Neri #define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \ 178b0ce5b8cSRicardo Neri X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \ 179b0ce5b8cSRicardo Neri X86_CR0_PG) 180af170c50SDavid Howells 181af170c50SDavid Howells #endif /* _UAPI_ASM_X86_PROCESSOR_FLAGS_H */ 182