18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci#ifndef _UAPI_ASM_X86_PROCESSOR_FLAGS_H
38c2ecf20Sopenharmony_ci#define _UAPI_ASM_X86_PROCESSOR_FLAGS_H
48c2ecf20Sopenharmony_ci/* Various flags defined: can be included from assembler. */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/const.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci * EFLAGS bits
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci#define X86_EFLAGS_CF_BIT	0 /* Carry Flag */
128c2ecf20Sopenharmony_ci#define X86_EFLAGS_CF		_BITUL(X86_EFLAGS_CF_BIT)
138c2ecf20Sopenharmony_ci#define X86_EFLAGS_FIXED_BIT	1 /* Bit 1 - always on */
148c2ecf20Sopenharmony_ci#define X86_EFLAGS_FIXED	_BITUL(X86_EFLAGS_FIXED_BIT)
158c2ecf20Sopenharmony_ci#define X86_EFLAGS_PF_BIT	2 /* Parity Flag */
168c2ecf20Sopenharmony_ci#define X86_EFLAGS_PF		_BITUL(X86_EFLAGS_PF_BIT)
178c2ecf20Sopenharmony_ci#define X86_EFLAGS_AF_BIT	4 /* Auxiliary carry Flag */
188c2ecf20Sopenharmony_ci#define X86_EFLAGS_AF		_BITUL(X86_EFLAGS_AF_BIT)
198c2ecf20Sopenharmony_ci#define X86_EFLAGS_ZF_BIT	6 /* Zero Flag */
208c2ecf20Sopenharmony_ci#define X86_EFLAGS_ZF		_BITUL(X86_EFLAGS_ZF_BIT)
218c2ecf20Sopenharmony_ci#define X86_EFLAGS_SF_BIT	7 /* Sign Flag */
228c2ecf20Sopenharmony_ci#define X86_EFLAGS_SF		_BITUL(X86_EFLAGS_SF_BIT)
238c2ecf20Sopenharmony_ci#define X86_EFLAGS_TF_BIT	8 /* Trap Flag */
248c2ecf20Sopenharmony_ci#define X86_EFLAGS_TF		_BITUL(X86_EFLAGS_TF_BIT)
258c2ecf20Sopenharmony_ci#define X86_EFLAGS_IF_BIT	9 /* Interrupt Flag */
268c2ecf20Sopenharmony_ci#define X86_EFLAGS_IF		_BITUL(X86_EFLAGS_IF_BIT)
278c2ecf20Sopenharmony_ci#define X86_EFLAGS_DF_BIT	10 /* Direction Flag */
288c2ecf20Sopenharmony_ci#define X86_EFLAGS_DF		_BITUL(X86_EFLAGS_DF_BIT)
298c2ecf20Sopenharmony_ci#define X86_EFLAGS_OF_BIT	11 /* Overflow Flag */
308c2ecf20Sopenharmony_ci#define X86_EFLAGS_OF		_BITUL(X86_EFLAGS_OF_BIT)
318c2ecf20Sopenharmony_ci#define X86_EFLAGS_IOPL_BIT	12 /* I/O Privilege Level (2 bits) */
328c2ecf20Sopenharmony_ci#define X86_EFLAGS_IOPL		(_AC(3,UL) << X86_EFLAGS_IOPL_BIT)
338c2ecf20Sopenharmony_ci#define X86_EFLAGS_NT_BIT	14 /* Nested Task */
348c2ecf20Sopenharmony_ci#define X86_EFLAGS_NT		_BITUL(X86_EFLAGS_NT_BIT)
358c2ecf20Sopenharmony_ci#define X86_EFLAGS_RF_BIT	16 /* Resume Flag */
368c2ecf20Sopenharmony_ci#define X86_EFLAGS_RF		_BITUL(X86_EFLAGS_RF_BIT)
378c2ecf20Sopenharmony_ci#define X86_EFLAGS_VM_BIT	17 /* Virtual Mode */
388c2ecf20Sopenharmony_ci#define X86_EFLAGS_VM		_BITUL(X86_EFLAGS_VM_BIT)
398c2ecf20Sopenharmony_ci#define X86_EFLAGS_AC_BIT	18 /* Alignment Check/Access Control */
408c2ecf20Sopenharmony_ci#define X86_EFLAGS_AC		_BITUL(X86_EFLAGS_AC_BIT)
418c2ecf20Sopenharmony_ci#define X86_EFLAGS_VIF_BIT	19 /* Virtual Interrupt Flag */
428c2ecf20Sopenharmony_ci#define X86_EFLAGS_VIF		_BITUL(X86_EFLAGS_VIF_BIT)
438c2ecf20Sopenharmony_ci#define X86_EFLAGS_VIP_BIT	20 /* Virtual Interrupt Pending */
448c2ecf20Sopenharmony_ci#define X86_EFLAGS_VIP		_BITUL(X86_EFLAGS_VIP_BIT)
458c2ecf20Sopenharmony_ci#define X86_EFLAGS_ID_BIT	21 /* CPUID detection */
468c2ecf20Sopenharmony_ci#define X86_EFLAGS_ID		_BITUL(X86_EFLAGS_ID_BIT)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/*
498c2ecf20Sopenharmony_ci * Basic CPU control in CR0
508c2ecf20Sopenharmony_ci */
518c2ecf20Sopenharmony_ci#define X86_CR0_PE_BIT		0 /* Protection Enable */
528c2ecf20Sopenharmony_ci#define X86_CR0_PE		_BITUL(X86_CR0_PE_BIT)
538c2ecf20Sopenharmony_ci#define X86_CR0_MP_BIT		1 /* Monitor Coprocessor */
548c2ecf20Sopenharmony_ci#define X86_CR0_MP		_BITUL(X86_CR0_MP_BIT)
558c2ecf20Sopenharmony_ci#define X86_CR0_EM_BIT		2 /* Emulation */
568c2ecf20Sopenharmony_ci#define X86_CR0_EM		_BITUL(X86_CR0_EM_BIT)
578c2ecf20Sopenharmony_ci#define X86_CR0_TS_BIT		3 /* Task Switched */
588c2ecf20Sopenharmony_ci#define X86_CR0_TS		_BITUL(X86_CR0_TS_BIT)
598c2ecf20Sopenharmony_ci#define X86_CR0_ET_BIT		4 /* Extension Type */
608c2ecf20Sopenharmony_ci#define X86_CR0_ET		_BITUL(X86_CR0_ET_BIT)
618c2ecf20Sopenharmony_ci#define X86_CR0_NE_BIT		5 /* Numeric Error */
628c2ecf20Sopenharmony_ci#define X86_CR0_NE		_BITUL(X86_CR0_NE_BIT)
638c2ecf20Sopenharmony_ci#define X86_CR0_WP_BIT		16 /* Write Protect */
648c2ecf20Sopenharmony_ci#define X86_CR0_WP		_BITUL(X86_CR0_WP_BIT)
658c2ecf20Sopenharmony_ci#define X86_CR0_AM_BIT		18 /* Alignment Mask */
668c2ecf20Sopenharmony_ci#define X86_CR0_AM		_BITUL(X86_CR0_AM_BIT)
678c2ecf20Sopenharmony_ci#define X86_CR0_NW_BIT		29 /* Not Write-through */
688c2ecf20Sopenharmony_ci#define X86_CR0_NW		_BITUL(X86_CR0_NW_BIT)
698c2ecf20Sopenharmony_ci#define X86_CR0_CD_BIT		30 /* Cache Disable */
708c2ecf20Sopenharmony_ci#define X86_CR0_CD		_BITUL(X86_CR0_CD_BIT)
718c2ecf20Sopenharmony_ci#define X86_CR0_PG_BIT		31 /* Paging */
728c2ecf20Sopenharmony_ci#define X86_CR0_PG		_BITUL(X86_CR0_PG_BIT)
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/*
758c2ecf20Sopenharmony_ci * Paging options in CR3
768c2ecf20Sopenharmony_ci */
778c2ecf20Sopenharmony_ci#define X86_CR3_PWT_BIT		3 /* Page Write Through */
788c2ecf20Sopenharmony_ci#define X86_CR3_PWT		_BITUL(X86_CR3_PWT_BIT)
798c2ecf20Sopenharmony_ci#define X86_CR3_PCD_BIT		4 /* Page Cache Disable */
808c2ecf20Sopenharmony_ci#define X86_CR3_PCD		_BITUL(X86_CR3_PCD_BIT)
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#define X86_CR3_PCID_BITS	12
838c2ecf20Sopenharmony_ci#define X86_CR3_PCID_MASK	(_AC((1UL << X86_CR3_PCID_BITS) - 1, UL))
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define X86_CR3_PCID_NOFLUSH_BIT 63 /* Preserve old PCID */
868c2ecf20Sopenharmony_ci#define X86_CR3_PCID_NOFLUSH    _BITULL(X86_CR3_PCID_NOFLUSH_BIT)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/*
898c2ecf20Sopenharmony_ci * Intel CPU features in CR4
908c2ecf20Sopenharmony_ci */
918c2ecf20Sopenharmony_ci#define X86_CR4_VME_BIT		0 /* enable vm86 extensions */
928c2ecf20Sopenharmony_ci#define X86_CR4_VME		_BITUL(X86_CR4_VME_BIT)
938c2ecf20Sopenharmony_ci#define X86_CR4_PVI_BIT		1 /* virtual interrupts flag enable */
948c2ecf20Sopenharmony_ci#define X86_CR4_PVI		_BITUL(X86_CR4_PVI_BIT)
958c2ecf20Sopenharmony_ci#define X86_CR4_TSD_BIT		2 /* disable time stamp at ipl 3 */
968c2ecf20Sopenharmony_ci#define X86_CR4_TSD		_BITUL(X86_CR4_TSD_BIT)
978c2ecf20Sopenharmony_ci#define X86_CR4_DE_BIT		3 /* enable debugging extensions */
988c2ecf20Sopenharmony_ci#define X86_CR4_DE		_BITUL(X86_CR4_DE_BIT)
998c2ecf20Sopenharmony_ci#define X86_CR4_PSE_BIT		4 /* enable page size extensions */
1008c2ecf20Sopenharmony_ci#define X86_CR4_PSE		_BITUL(X86_CR4_PSE_BIT)
1018c2ecf20Sopenharmony_ci#define X86_CR4_PAE_BIT		5 /* enable physical address extensions */
1028c2ecf20Sopenharmony_ci#define X86_CR4_PAE		_BITUL(X86_CR4_PAE_BIT)
1038c2ecf20Sopenharmony_ci#define X86_CR4_MCE_BIT		6 /* Machine check enable */
1048c2ecf20Sopenharmony_ci#define X86_CR4_MCE		_BITUL(X86_CR4_MCE_BIT)
1058c2ecf20Sopenharmony_ci#define X86_CR4_PGE_BIT		7 /* enable global pages */
1068c2ecf20Sopenharmony_ci#define X86_CR4_PGE		_BITUL(X86_CR4_PGE_BIT)
1078c2ecf20Sopenharmony_ci#define X86_CR4_PCE_BIT		8 /* enable performance counters at ipl 3 */
1088c2ecf20Sopenharmony_ci#define X86_CR4_PCE		_BITUL(X86_CR4_PCE_BIT)
1098c2ecf20Sopenharmony_ci#define X86_CR4_OSFXSR_BIT	9 /* enable fast FPU save and restore */
1108c2ecf20Sopenharmony_ci#define X86_CR4_OSFXSR		_BITUL(X86_CR4_OSFXSR_BIT)
1118c2ecf20Sopenharmony_ci#define X86_CR4_OSXMMEXCPT_BIT	10 /* enable unmasked SSE exceptions */
1128c2ecf20Sopenharmony_ci#define X86_CR4_OSXMMEXCPT	_BITUL(X86_CR4_OSXMMEXCPT_BIT)
1138c2ecf20Sopenharmony_ci#define X86_CR4_UMIP_BIT	11 /* enable UMIP support */
1148c2ecf20Sopenharmony_ci#define X86_CR4_UMIP		_BITUL(X86_CR4_UMIP_BIT)
1158c2ecf20Sopenharmony_ci#define X86_CR4_LA57_BIT	12 /* enable 5-level page tables */
1168c2ecf20Sopenharmony_ci#define X86_CR4_LA57		_BITUL(X86_CR4_LA57_BIT)
1178c2ecf20Sopenharmony_ci#define X86_CR4_VMXE_BIT	13 /* enable VMX virtualization */
1188c2ecf20Sopenharmony_ci#define X86_CR4_VMXE		_BITUL(X86_CR4_VMXE_BIT)
1198c2ecf20Sopenharmony_ci#define X86_CR4_SMXE_BIT	14 /* enable safer mode (TXT) */
1208c2ecf20Sopenharmony_ci#define X86_CR4_SMXE		_BITUL(X86_CR4_SMXE_BIT)
1218c2ecf20Sopenharmony_ci#define X86_CR4_FSGSBASE_BIT	16 /* enable RDWRFSGS support */
1228c2ecf20Sopenharmony_ci#define X86_CR4_FSGSBASE	_BITUL(X86_CR4_FSGSBASE_BIT)
1238c2ecf20Sopenharmony_ci#define X86_CR4_PCIDE_BIT	17 /* enable PCID support */
1248c2ecf20Sopenharmony_ci#define X86_CR4_PCIDE		_BITUL(X86_CR4_PCIDE_BIT)
1258c2ecf20Sopenharmony_ci#define X86_CR4_OSXSAVE_BIT	18 /* enable xsave and xrestore */
1268c2ecf20Sopenharmony_ci#define X86_CR4_OSXSAVE		_BITUL(X86_CR4_OSXSAVE_BIT)
1278c2ecf20Sopenharmony_ci#define X86_CR4_SMEP_BIT	20 /* enable SMEP support */
1288c2ecf20Sopenharmony_ci#define X86_CR4_SMEP		_BITUL(X86_CR4_SMEP_BIT)
1298c2ecf20Sopenharmony_ci#define X86_CR4_SMAP_BIT	21 /* enable SMAP support */
1308c2ecf20Sopenharmony_ci#define X86_CR4_SMAP		_BITUL(X86_CR4_SMAP_BIT)
1318c2ecf20Sopenharmony_ci#define X86_CR4_PKE_BIT		22 /* enable Protection Keys support */
1328c2ecf20Sopenharmony_ci#define X86_CR4_PKE		_BITUL(X86_CR4_PKE_BIT)
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci/*
1358c2ecf20Sopenharmony_ci * x86-64 Task Priority Register, CR8
1368c2ecf20Sopenharmony_ci */
1378c2ecf20Sopenharmony_ci#define X86_CR8_TPR		_AC(0x0000000f,UL) /* task priority register */
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/*
1408c2ecf20Sopenharmony_ci * AMD and Transmeta use MSRs for configuration; see <asm/msr-index.h>
1418c2ecf20Sopenharmony_ci */
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci/*
1448c2ecf20Sopenharmony_ci *      NSC/Cyrix CPU configuration register indexes
1458c2ecf20Sopenharmony_ci */
1468c2ecf20Sopenharmony_ci#define CX86_PCR0	0x20
1478c2ecf20Sopenharmony_ci#define CX86_GCR	0xb8
1488c2ecf20Sopenharmony_ci#define CX86_CCR0	0xc0
1498c2ecf20Sopenharmony_ci#define CX86_CCR1	0xc1
1508c2ecf20Sopenharmony_ci#define CX86_CCR2	0xc2
1518c2ecf20Sopenharmony_ci#define CX86_CCR3	0xc3
1528c2ecf20Sopenharmony_ci#define CX86_CCR4	0xe8
1538c2ecf20Sopenharmony_ci#define CX86_CCR5	0xe9
1548c2ecf20Sopenharmony_ci#define CX86_CCR6	0xea
1558c2ecf20Sopenharmony_ci#define CX86_CCR7	0xeb
1568c2ecf20Sopenharmony_ci#define CX86_PCR1	0xf0
1578c2ecf20Sopenharmony_ci#define CX86_DIR0	0xfe
1588c2ecf20Sopenharmony_ci#define CX86_DIR1	0xff
1598c2ecf20Sopenharmony_ci#define CX86_ARR_BASE	0xc4
1608c2ecf20Sopenharmony_ci#define CX86_RCR_BASE	0xdc
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define CR0_STATE	(X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \
1638c2ecf20Sopenharmony_ci			 X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \
1648c2ecf20Sopenharmony_ci			 X86_CR0_PG)
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci#endif /* _UAPI_ASM_X86_PROCESSOR_FLAGS_H */
167