162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
262306a36Sopenharmony_ci#ifndef _UAPI_ASM_X86_PROCESSOR_FLAGS_H
362306a36Sopenharmony_ci#define _UAPI_ASM_X86_PROCESSOR_FLAGS_H
462306a36Sopenharmony_ci/* Various flags defined: can be included from assembler. */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#include <linux/const.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci/*
962306a36Sopenharmony_ci * EFLAGS bits
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci#define X86_EFLAGS_CF_BIT	0 /* Carry Flag */
1262306a36Sopenharmony_ci#define X86_EFLAGS_CF		_BITUL(X86_EFLAGS_CF_BIT)
1362306a36Sopenharmony_ci#define X86_EFLAGS_FIXED_BIT	1 /* Bit 1 - always on */
1462306a36Sopenharmony_ci#define X86_EFLAGS_FIXED	_BITUL(X86_EFLAGS_FIXED_BIT)
1562306a36Sopenharmony_ci#define X86_EFLAGS_PF_BIT	2 /* Parity Flag */
1662306a36Sopenharmony_ci#define X86_EFLAGS_PF		_BITUL(X86_EFLAGS_PF_BIT)
1762306a36Sopenharmony_ci#define X86_EFLAGS_AF_BIT	4 /* Auxiliary carry Flag */
1862306a36Sopenharmony_ci#define X86_EFLAGS_AF		_BITUL(X86_EFLAGS_AF_BIT)
1962306a36Sopenharmony_ci#define X86_EFLAGS_ZF_BIT	6 /* Zero Flag */
2062306a36Sopenharmony_ci#define X86_EFLAGS_ZF		_BITUL(X86_EFLAGS_ZF_BIT)
2162306a36Sopenharmony_ci#define X86_EFLAGS_SF_BIT	7 /* Sign Flag */
2262306a36Sopenharmony_ci#define X86_EFLAGS_SF		_BITUL(X86_EFLAGS_SF_BIT)
2362306a36Sopenharmony_ci#define X86_EFLAGS_TF_BIT	8 /* Trap Flag */
2462306a36Sopenharmony_ci#define X86_EFLAGS_TF		_BITUL(X86_EFLAGS_TF_BIT)
2562306a36Sopenharmony_ci#define X86_EFLAGS_IF_BIT	9 /* Interrupt Flag */
2662306a36Sopenharmony_ci#define X86_EFLAGS_IF		_BITUL(X86_EFLAGS_IF_BIT)
2762306a36Sopenharmony_ci#define X86_EFLAGS_DF_BIT	10 /* Direction Flag */
2862306a36Sopenharmony_ci#define X86_EFLAGS_DF		_BITUL(X86_EFLAGS_DF_BIT)
2962306a36Sopenharmony_ci#define X86_EFLAGS_OF_BIT	11 /* Overflow Flag */
3062306a36Sopenharmony_ci#define X86_EFLAGS_OF		_BITUL(X86_EFLAGS_OF_BIT)
3162306a36Sopenharmony_ci#define X86_EFLAGS_IOPL_BIT	12 /* I/O Privilege Level (2 bits) */
3262306a36Sopenharmony_ci#define X86_EFLAGS_IOPL		(_AC(3,UL) << X86_EFLAGS_IOPL_BIT)
3362306a36Sopenharmony_ci#define X86_EFLAGS_NT_BIT	14 /* Nested Task */
3462306a36Sopenharmony_ci#define X86_EFLAGS_NT		_BITUL(X86_EFLAGS_NT_BIT)
3562306a36Sopenharmony_ci#define X86_EFLAGS_RF_BIT	16 /* Resume Flag */
3662306a36Sopenharmony_ci#define X86_EFLAGS_RF		_BITUL(X86_EFLAGS_RF_BIT)
3762306a36Sopenharmony_ci#define X86_EFLAGS_VM_BIT	17 /* Virtual Mode */
3862306a36Sopenharmony_ci#define X86_EFLAGS_VM		_BITUL(X86_EFLAGS_VM_BIT)
3962306a36Sopenharmony_ci#define X86_EFLAGS_AC_BIT	18 /* Alignment Check/Access Control */
4062306a36Sopenharmony_ci#define X86_EFLAGS_AC		_BITUL(X86_EFLAGS_AC_BIT)
4162306a36Sopenharmony_ci#define X86_EFLAGS_VIF_BIT	19 /* Virtual Interrupt Flag */
4262306a36Sopenharmony_ci#define X86_EFLAGS_VIF		_BITUL(X86_EFLAGS_VIF_BIT)
4362306a36Sopenharmony_ci#define X86_EFLAGS_VIP_BIT	20 /* Virtual Interrupt Pending */
4462306a36Sopenharmony_ci#define X86_EFLAGS_VIP		_BITUL(X86_EFLAGS_VIP_BIT)
4562306a36Sopenharmony_ci#define X86_EFLAGS_ID_BIT	21 /* CPUID detection */
4662306a36Sopenharmony_ci#define X86_EFLAGS_ID		_BITUL(X86_EFLAGS_ID_BIT)
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/*
4962306a36Sopenharmony_ci * Basic CPU control in CR0
5062306a36Sopenharmony_ci */
5162306a36Sopenharmony_ci#define X86_CR0_PE_BIT		0 /* Protection Enable */
5262306a36Sopenharmony_ci#define X86_CR0_PE		_BITUL(X86_CR0_PE_BIT)
5362306a36Sopenharmony_ci#define X86_CR0_MP_BIT		1 /* Monitor Coprocessor */
5462306a36Sopenharmony_ci#define X86_CR0_MP		_BITUL(X86_CR0_MP_BIT)
5562306a36Sopenharmony_ci#define X86_CR0_EM_BIT		2 /* Emulation */
5662306a36Sopenharmony_ci#define X86_CR0_EM		_BITUL(X86_CR0_EM_BIT)
5762306a36Sopenharmony_ci#define X86_CR0_TS_BIT		3 /* Task Switched */
5862306a36Sopenharmony_ci#define X86_CR0_TS		_BITUL(X86_CR0_TS_BIT)
5962306a36Sopenharmony_ci#define X86_CR0_ET_BIT		4 /* Extension Type */
6062306a36Sopenharmony_ci#define X86_CR0_ET		_BITUL(X86_CR0_ET_BIT)
6162306a36Sopenharmony_ci#define X86_CR0_NE_BIT		5 /* Numeric Error */
6262306a36Sopenharmony_ci#define X86_CR0_NE		_BITUL(X86_CR0_NE_BIT)
6362306a36Sopenharmony_ci#define X86_CR0_WP_BIT		16 /* Write Protect */
6462306a36Sopenharmony_ci#define X86_CR0_WP		_BITUL(X86_CR0_WP_BIT)
6562306a36Sopenharmony_ci#define X86_CR0_AM_BIT		18 /* Alignment Mask */
6662306a36Sopenharmony_ci#define X86_CR0_AM		_BITUL(X86_CR0_AM_BIT)
6762306a36Sopenharmony_ci#define X86_CR0_NW_BIT		29 /* Not Write-through */
6862306a36Sopenharmony_ci#define X86_CR0_NW		_BITUL(X86_CR0_NW_BIT)
6962306a36Sopenharmony_ci#define X86_CR0_CD_BIT		30 /* Cache Disable */
7062306a36Sopenharmony_ci#define X86_CR0_CD		_BITUL(X86_CR0_CD_BIT)
7162306a36Sopenharmony_ci#define X86_CR0_PG_BIT		31 /* Paging */
7262306a36Sopenharmony_ci#define X86_CR0_PG		_BITUL(X86_CR0_PG_BIT)
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/*
7562306a36Sopenharmony_ci * Paging options in CR3
7662306a36Sopenharmony_ci */
7762306a36Sopenharmony_ci#define X86_CR3_PWT_BIT		3 /* Page Write Through */
7862306a36Sopenharmony_ci#define X86_CR3_PWT		_BITUL(X86_CR3_PWT_BIT)
7962306a36Sopenharmony_ci#define X86_CR3_PCD_BIT		4 /* Page Cache Disable */
8062306a36Sopenharmony_ci#define X86_CR3_PCD		_BITUL(X86_CR3_PCD_BIT)
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#define X86_CR3_PCID_BITS	12
8362306a36Sopenharmony_ci#define X86_CR3_PCID_MASK	(_AC((1UL << X86_CR3_PCID_BITS) - 1, UL))
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define X86_CR3_LAM_U57_BIT	61 /* Activate LAM for userspace, 62:57 bits masked */
8662306a36Sopenharmony_ci#define X86_CR3_LAM_U57		_BITULL(X86_CR3_LAM_U57_BIT)
8762306a36Sopenharmony_ci#define X86_CR3_LAM_U48_BIT	62 /* Activate LAM for userspace, 62:48 bits masked */
8862306a36Sopenharmony_ci#define X86_CR3_LAM_U48		_BITULL(X86_CR3_LAM_U48_BIT)
8962306a36Sopenharmony_ci#define X86_CR3_PCID_NOFLUSH_BIT 63 /* Preserve old PCID */
9062306a36Sopenharmony_ci#define X86_CR3_PCID_NOFLUSH    _BITULL(X86_CR3_PCID_NOFLUSH_BIT)
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci/*
9362306a36Sopenharmony_ci * Intel CPU features in CR4
9462306a36Sopenharmony_ci */
9562306a36Sopenharmony_ci#define X86_CR4_VME_BIT		0 /* enable vm86 extensions */
9662306a36Sopenharmony_ci#define X86_CR4_VME		_BITUL(X86_CR4_VME_BIT)
9762306a36Sopenharmony_ci#define X86_CR4_PVI_BIT		1 /* virtual interrupts flag enable */
9862306a36Sopenharmony_ci#define X86_CR4_PVI		_BITUL(X86_CR4_PVI_BIT)
9962306a36Sopenharmony_ci#define X86_CR4_TSD_BIT		2 /* disable time stamp at ipl 3 */
10062306a36Sopenharmony_ci#define X86_CR4_TSD		_BITUL(X86_CR4_TSD_BIT)
10162306a36Sopenharmony_ci#define X86_CR4_DE_BIT		3 /* enable debugging extensions */
10262306a36Sopenharmony_ci#define X86_CR4_DE		_BITUL(X86_CR4_DE_BIT)
10362306a36Sopenharmony_ci#define X86_CR4_PSE_BIT		4 /* enable page size extensions */
10462306a36Sopenharmony_ci#define X86_CR4_PSE		_BITUL(X86_CR4_PSE_BIT)
10562306a36Sopenharmony_ci#define X86_CR4_PAE_BIT		5 /* enable physical address extensions */
10662306a36Sopenharmony_ci#define X86_CR4_PAE		_BITUL(X86_CR4_PAE_BIT)
10762306a36Sopenharmony_ci#define X86_CR4_MCE_BIT		6 /* Machine check enable */
10862306a36Sopenharmony_ci#define X86_CR4_MCE		_BITUL(X86_CR4_MCE_BIT)
10962306a36Sopenharmony_ci#define X86_CR4_PGE_BIT		7 /* enable global pages */
11062306a36Sopenharmony_ci#define X86_CR4_PGE		_BITUL(X86_CR4_PGE_BIT)
11162306a36Sopenharmony_ci#define X86_CR4_PCE_BIT		8 /* enable performance counters at ipl 3 */
11262306a36Sopenharmony_ci#define X86_CR4_PCE		_BITUL(X86_CR4_PCE_BIT)
11362306a36Sopenharmony_ci#define X86_CR4_OSFXSR_BIT	9 /* enable fast FPU save and restore */
11462306a36Sopenharmony_ci#define X86_CR4_OSFXSR		_BITUL(X86_CR4_OSFXSR_BIT)
11562306a36Sopenharmony_ci#define X86_CR4_OSXMMEXCPT_BIT	10 /* enable unmasked SSE exceptions */
11662306a36Sopenharmony_ci#define X86_CR4_OSXMMEXCPT	_BITUL(X86_CR4_OSXMMEXCPT_BIT)
11762306a36Sopenharmony_ci#define X86_CR4_UMIP_BIT	11 /* enable UMIP support */
11862306a36Sopenharmony_ci#define X86_CR4_UMIP		_BITUL(X86_CR4_UMIP_BIT)
11962306a36Sopenharmony_ci#define X86_CR4_LA57_BIT	12 /* enable 5-level page tables */
12062306a36Sopenharmony_ci#define X86_CR4_LA57		_BITUL(X86_CR4_LA57_BIT)
12162306a36Sopenharmony_ci#define X86_CR4_VMXE_BIT	13 /* enable VMX virtualization */
12262306a36Sopenharmony_ci#define X86_CR4_VMXE		_BITUL(X86_CR4_VMXE_BIT)
12362306a36Sopenharmony_ci#define X86_CR4_SMXE_BIT	14 /* enable safer mode (TXT) */
12462306a36Sopenharmony_ci#define X86_CR4_SMXE		_BITUL(X86_CR4_SMXE_BIT)
12562306a36Sopenharmony_ci#define X86_CR4_FSGSBASE_BIT	16 /* enable RDWRFSGS support */
12662306a36Sopenharmony_ci#define X86_CR4_FSGSBASE	_BITUL(X86_CR4_FSGSBASE_BIT)
12762306a36Sopenharmony_ci#define X86_CR4_PCIDE_BIT	17 /* enable PCID support */
12862306a36Sopenharmony_ci#define X86_CR4_PCIDE		_BITUL(X86_CR4_PCIDE_BIT)
12962306a36Sopenharmony_ci#define X86_CR4_OSXSAVE_BIT	18 /* enable xsave and xrestore */
13062306a36Sopenharmony_ci#define X86_CR4_OSXSAVE		_BITUL(X86_CR4_OSXSAVE_BIT)
13162306a36Sopenharmony_ci#define X86_CR4_SMEP_BIT	20 /* enable SMEP support */
13262306a36Sopenharmony_ci#define X86_CR4_SMEP		_BITUL(X86_CR4_SMEP_BIT)
13362306a36Sopenharmony_ci#define X86_CR4_SMAP_BIT	21 /* enable SMAP support */
13462306a36Sopenharmony_ci#define X86_CR4_SMAP		_BITUL(X86_CR4_SMAP_BIT)
13562306a36Sopenharmony_ci#define X86_CR4_PKE_BIT		22 /* enable Protection Keys support */
13662306a36Sopenharmony_ci#define X86_CR4_PKE		_BITUL(X86_CR4_PKE_BIT)
13762306a36Sopenharmony_ci#define X86_CR4_CET_BIT		23 /* enable Control-flow Enforcement Technology */
13862306a36Sopenharmony_ci#define X86_CR4_CET		_BITUL(X86_CR4_CET_BIT)
13962306a36Sopenharmony_ci#define X86_CR4_LAM_SUP_BIT	28 /* LAM for supervisor pointers */
14062306a36Sopenharmony_ci#define X86_CR4_LAM_SUP		_BITUL(X86_CR4_LAM_SUP_BIT)
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci/*
14362306a36Sopenharmony_ci * x86-64 Task Priority Register, CR8
14462306a36Sopenharmony_ci */
14562306a36Sopenharmony_ci#define X86_CR8_TPR		_AC(0x0000000f,UL) /* task priority register */
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci/*
14862306a36Sopenharmony_ci * AMD and Transmeta use MSRs for configuration; see <asm/msr-index.h>
14962306a36Sopenharmony_ci */
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/*
15262306a36Sopenharmony_ci *      NSC/Cyrix CPU configuration register indexes
15362306a36Sopenharmony_ci */
15462306a36Sopenharmony_ci#define CX86_PCR0	0x20
15562306a36Sopenharmony_ci#define CX86_GCR	0xb8
15662306a36Sopenharmony_ci#define CX86_CCR0	0xc0
15762306a36Sopenharmony_ci#define CX86_CCR1	0xc1
15862306a36Sopenharmony_ci#define CX86_CCR2	0xc2
15962306a36Sopenharmony_ci#define CX86_CCR3	0xc3
16062306a36Sopenharmony_ci#define CX86_CCR4	0xe8
16162306a36Sopenharmony_ci#define CX86_CCR5	0xe9
16262306a36Sopenharmony_ci#define CX86_CCR6	0xea
16362306a36Sopenharmony_ci#define CX86_CCR7	0xeb
16462306a36Sopenharmony_ci#define CX86_PCR1	0xf0
16562306a36Sopenharmony_ci#define CX86_DIR0	0xfe
16662306a36Sopenharmony_ci#define CX86_DIR1	0xff
16762306a36Sopenharmony_ci#define CX86_ARR_BASE	0xc4
16862306a36Sopenharmony_ci#define CX86_RCR_BASE	0xdc
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci#define CR0_STATE	(X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \
17162306a36Sopenharmony_ci			 X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \
17262306a36Sopenharmony_ci			 X86_CR0_PG)
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci#endif /* _UAPI_ASM_X86_PROCESSOR_FLAGS_H */
175