1 /* SPDX-License-Identifier: GPL-2.0-only */
6 #if !defined(__ASSEMBLER__)
10 #define COMPILER_BARRIER "memory"
13 #define CRx_TYPE uint64_t
17 #define CRx_TYPE uint32_t
21 static __always_inline CRx_TYPE
read_cr0(void)
24 __asm__
__volatile__ (
33 static __always_inline
void write_cr0(CRx_TYPE data
)
35 __asm__
__volatile__ (
43 static __always_inline CRx_TYPE
read_cr2(void)
46 __asm__
__volatile__ (
55 static __always_inline CRx_TYPE
read_cr3(void)
58 __asm__
__volatile__ (
67 static __always_inline
void write_cr3(CRx_TYPE data
)
69 __asm__
__volatile__ (
76 static __always_inline CRx_TYPE
read_cr4(void)
79 __asm__
__volatile__ (
88 static __always_inline
void write_cr4(CRx_TYPE data
)
90 __asm__
__volatile__ (
98 #endif /* !defined(__ASSEMBLER__) */
101 #define CR0_PE (1 << 0)
102 #define CR0_MP (1 << 1)
103 #define CR0_EM (1 << 2)
104 #define CR0_TS (1 << 3)
105 #define CR0_ET (1 << 4)
106 #define CR0_NE (1 << 5)
107 #define CR0_WP (1 << 16)
108 #define CR0_AM (1 << 18)
109 #define CR0_NW (1 << 29)
110 #define CR0_CD (1 << 30)
111 #define CR0_PG (1 << 31)
114 #define CR4_VME (1 << 0)
115 #define CR4_PVI (1 << 1)
116 #define CR4_TSD (1 << 2)
117 #define CR4_DE (1 << 3)
118 #define CR4_PSE (1 << 4)
119 #define CR4_PAE (1 << 5)
120 #define CR4_MCE (1 << 6)
121 #define CR4_PGE (1 << 7)
122 #define CR4_PCE (1 << 8)
123 #define CR4_OSFXSR (1 << 9)
124 #define CR4_OSXMMEXCPT (1 << 10)
125 #define CR4_VMXE (1 << 13)
126 #define CR4_SMXE (1 << 14)
127 #define CR4_FSGSBASE (1 << 16)
128 #define CR4_PCIDE (1 << 17)
129 #define CR4_OSXSAVE (1 << 18)
130 #define CR4_SMEP (1 << 20)
132 #endif /* CPU_X86_CR_H */