Go to the documentation of this file.
4 #ifndef _ASM_X86_CPUFEATURE_H
5 #define _ASM_X86_CPUFEATURE_H
7 #ifndef _ASM_X86_REQUIRED_FEATURES_H
8 #include <asm/required-features.h>
20 #define X86_FEATURE_FPU (0*32+ 0)
21 #define X86_FEATURE_VME (0*32+ 1)
22 #define X86_FEATURE_DE (0*32+ 2)
23 #define X86_FEATURE_PSE (0*32+ 3)
24 #define X86_FEATURE_TSC (0*32+ 4)
25 #define X86_FEATURE_MSR (0*32+ 5)
26 #define X86_FEATURE_PAE (0*32+ 6)
27 #define X86_FEATURE_MCE (0*32+ 7)
28 #define X86_FEATURE_CX8 (0*32+ 8)
29 #define X86_FEATURE_APIC (0*32+ 9)
30 #define X86_FEATURE_SEP (0*32+11)
31 #define X86_FEATURE_MTRR (0*32+12)
32 #define X86_FEATURE_PGE (0*32+13)
33 #define X86_FEATURE_MCA (0*32+14)
34 #define X86_FEATURE_CMOV (0*32+15)
36 #define X86_FEATURE_PAT (0*32+16)
37 #define X86_FEATURE_PSE36 (0*32+17)
38 #define X86_FEATURE_PN (0*32+18)
39 #define X86_FEATURE_CLFLSH (0*32+19)
40 #define X86_FEATURE_DS (0*32+21)
41 #define X86_FEATURE_ACPI (0*32+22)
42 #define X86_FEATURE_MMX (0*32+23)
43 #define X86_FEATURE_FXSR (0*32+24)
44 #define X86_FEATURE_XMM (0*32+25)
45 #define X86_FEATURE_XMM2 (0*32+26)
46 #define X86_FEATURE_SELFSNOOP (0*32+27)
47 #define X86_FEATURE_HT (0*32+28)
48 #define X86_FEATURE_ACC (0*32+29)
49 #define X86_FEATURE_IA64 (0*32+30)
50 #define X86_FEATURE_PBE (0*32+31)
54 #define X86_FEATURE_SYSCALL (1*32+11)
55 #define X86_FEATURE_MP (1*32+19)
56 #define X86_FEATURE_NX (1*32+20)
57 #define X86_FEATURE_MMXEXT (1*32+22)
58 #define X86_FEATURE_FXSR_OPT (1*32+25)
59 #define X86_FEATURE_GBPAGES (1*32+26)
60 #define X86_FEATURE_RDTSCP (1*32+27)
61 #define X86_FEATURE_LM (1*32+29)
62 #define X86_FEATURE_3DNOWEXT (1*32+30)
63 #define X86_FEATURE_3DNOW (1*32+31)
66 #define X86_FEATURE_RECOVERY (2*32+ 0)
67 #define X86_FEATURE_LONGRUN (2*32+ 1)
68 #define X86_FEATURE_LRTI (2*32+ 3)
72 #define X86_FEATURE_CXMMX (3*32+ 0)
73 #define X86_FEATURE_K6_MTRR (3*32+ 1)
74 #define X86_FEATURE_CYRIX_ARR (3*32+ 2)
75 #define X86_FEATURE_CENTAUR_MCR (3*32+ 3)
77 #define X86_FEATURE_K8 (3*32+ 4)
78 #define X86_FEATURE_K7 (3*32+ 5)
79 #define X86_FEATURE_P3 (3*32+ 6)
80 #define X86_FEATURE_P4 (3*32+ 7)
81 #define X86_FEATURE_CONSTANT_TSC (3*32+ 8)
82 #define X86_FEATURE_UP (3*32+ 9)
83 #define X86_FEATURE_FXSAVE_LEAK (3*32+10)
84 #define X86_FEATURE_ARCH_PERFMON (3*32+11)
85 #define X86_FEATURE_PEBS (3*32+12)
86 #define X86_FEATURE_BTS (3*32+13)
87 #define X86_FEATURE_SYSCALL32 (3*32+14)
88 #define X86_FEATURE_SYSENTER32 (3*32+15)
89 #define X86_FEATURE_REP_GOOD (3*32+16)
90 #define X86_FEATURE_MFENCE_RDTSC (3*32+17)
91 #define X86_FEATURE_LFENCE_RDTSC (3*32+18)
92 #define X86_FEATURE_11AP (3*32+19)
93 #define X86_FEATURE_NOPL (3*32+20)
95 #define X86_FEATURE_XTOPOLOGY (3*32+22)
96 #define X86_FEATURE_TSC_RELIABLE (3*32+23)
97 #define X86_FEATURE_NONSTOP_TSC (3*32+24)
98 #define X86_FEATURE_CLFLUSH_MONITOR (3*32+25)
99 #define X86_FEATURE_EXTD_APICID (3*32+26)
100 #define X86_FEATURE_AMD_DCM (3*32+27)
101 #define X86_FEATURE_APERFMPERF (3*32+28)
102 #define X86_FEATURE_EAGER_FPU (3*32+29)
105 #define X86_FEATURE_XMM3 (4*32+ 0)
106 #define X86_FEATURE_PCLMULQDQ (4*32+ 1)
107 #define X86_FEATURE_DTES64 (4*32+ 2)
108 #define X86_FEATURE_MWAIT (4*32+ 3)
109 #define X86_FEATURE_DSCPL (4*32+ 4)
110 #define X86_FEATURE_VMX (4*32+ 5)
111 #define X86_FEATURE_SMX (4*32+ 6)
112 #define X86_FEATURE_EST (4*32+ 7)
113 #define X86_FEATURE_TM2 (4*32+ 8)
114 #define X86_FEATURE_SSSE3 (4*32+ 9)
115 #define X86_FEATURE_CID (4*32+10)
116 #define X86_FEATURE_FMA (4*32+12)
117 #define X86_FEATURE_CX16 (4*32+13)
118 #define X86_FEATURE_XTPR (4*32+14)
119 #define X86_FEATURE_PDCM (4*32+15)
120 #define X86_FEATURE_PCID (4*32+17)
121 #define X86_FEATURE_DCA (4*32+18)
122 #define X86_FEATURE_XMM4_1 (4*32+19)
123 #define X86_FEATURE_XMM4_2 (4*32+20)
124 #define X86_FEATURE_X2APIC (4*32+21)
125 #define X86_FEATURE_MOVBE (4*32+22)
126 #define X86_FEATURE_POPCNT (4*32+23)
127 #define X86_FEATURE_TSC_DEADLINE_TIMER (4*32+24)
128 #define X86_FEATURE_AES (4*32+25)
129 #define X86_FEATURE_XSAVE (4*32+26)
130 #define X86_FEATURE_OSXSAVE (4*32+27)
131 #define X86_FEATURE_AVX (4*32+28)
132 #define X86_FEATURE_F16C (4*32+29)
133 #define X86_FEATURE_RDRAND (4*32+30)
134 #define X86_FEATURE_HYPERVISOR (4*32+31)
137 #define X86_FEATURE_XSTORE (5*32+ 2)
138 #define X86_FEATURE_XSTORE_EN (5*32+ 3)
139 #define X86_FEATURE_XCRYPT (5*32+ 6)
140 #define X86_FEATURE_XCRYPT_EN (5*32+ 7)
141 #define X86_FEATURE_ACE2 (5*32+ 8)
142 #define X86_FEATURE_ACE2_EN (5*32+ 9)
143 #define X86_FEATURE_PHE (5*32+10)
144 #define X86_FEATURE_PHE_EN (5*32+11)
145 #define X86_FEATURE_PMM (5*32+12)
146 #define X86_FEATURE_PMM_EN (5*32+13)
149 #define X86_FEATURE_LAHF_LM (6*32+ 0)
150 #define X86_FEATURE_CMP_LEGACY (6*32+ 1)
151 #define X86_FEATURE_SVM (6*32+ 2)
152 #define X86_FEATURE_EXTAPIC (6*32+ 3)
153 #define X86_FEATURE_CR8_LEGACY (6*32+ 4)
154 #define X86_FEATURE_ABM (6*32+ 5)
155 #define X86_FEATURE_SSE4A (6*32+ 6)
156 #define X86_FEATURE_MISALIGNSSE (6*32+ 7)
157 #define X86_FEATURE_3DNOWPREFETCH (6*32+ 8)
158 #define X86_FEATURE_OSVW (6*32+ 9)
159 #define X86_FEATURE_IBS (6*32+10)
160 #define X86_FEATURE_XOP (6*32+11)
161 #define X86_FEATURE_SKINIT (6*32+12)
162 #define X86_FEATURE_WDT (6*32+13)
163 #define X86_FEATURE_LWP (6*32+15)
164 #define X86_FEATURE_FMA4 (6*32+16)
165 #define X86_FEATURE_TCE (6*32+17)
166 #define X86_FEATURE_NODEID_MSR (6*32+19)
167 #define X86_FEATURE_TBM (6*32+21)
168 #define X86_FEATURE_TOPOEXT (6*32+22)
169 #define X86_FEATURE_PERFCTR_CORE (6*32+23)
175 #define X86_FEATURE_IDA (7*32+ 0)
176 #define X86_FEATURE_ARAT (7*32+ 1)
177 #define X86_FEATURE_CPB (7*32+ 2)
178 #define X86_FEATURE_EPB (7*32+ 3)
179 #define X86_FEATURE_XSAVEOPT (7*32+ 4)
180 #define X86_FEATURE_PLN (7*32+ 5)
181 #define X86_FEATURE_PTS (7*32+ 6)
182 #define X86_FEATURE_DTHERM (7*32+ 7)
183 #define X86_FEATURE_HW_PSTATE (7*32+ 8)
186 #define X86_FEATURE_TPR_SHADOW (8*32+ 0)
187 #define X86_FEATURE_VNMI (8*32+ 1)
188 #define X86_FEATURE_FLEXPRIORITY (8*32+ 2)
189 #define X86_FEATURE_EPT (8*32+ 3)
190 #define X86_FEATURE_VPID (8*32+ 4)
191 #define X86_FEATURE_NPT (8*32+ 5)
192 #define X86_FEATURE_LBRV (8*32+ 6)
193 #define X86_FEATURE_SVML (8*32+ 7)
194 #define X86_FEATURE_NRIPS (8*32+ 8)
195 #define X86_FEATURE_TSCRATEMSR (8*32+ 9)
196 #define X86_FEATURE_VMCBCLEAN (8*32+10)
197 #define X86_FEATURE_FLUSHBYASID (8*32+11)
198 #define X86_FEATURE_DECODEASSISTS (8*32+12)
199 #define X86_FEATURE_PAUSEFILTER (8*32+13)
200 #define X86_FEATURE_PFTHRESHOLD (8*32+14)
204 #define X86_FEATURE_FSGSBASE (9*32+ 0)
205 #define X86_FEATURE_BMI1 (9*32+ 3)
206 #define X86_FEATURE_HLE (9*32+ 4)
207 #define X86_FEATURE_AVX2 (9*32+ 5)
208 #define X86_FEATURE_SMEP (9*32+ 7)
209 #define X86_FEATURE_BMI2 (9*32+ 8)
210 #define X86_FEATURE_ERMS (9*32+ 9)
211 #define X86_FEATURE_INVPCID (9*32+10)
212 #define X86_FEATURE_RTM (9*32+11)
213 #define X86_FEATURE_RDSEED (9*32+18)
214 #define X86_FEATURE_ADX (9*32+19)
215 #define X86_FEATURE_SMAP (9*32+20)
217 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
220 #include <linux/bitops.h>
222 extern const char *
const x86_cap_flags[
NCAPINTS*32];
225 #define test_cpu_cap(c, bit) \
226 test_bit(bit, (unsigned long *)((c)->x86_capability))
228 #define REQUIRED_MASK_BIT_SET(bit) \
229 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
230 (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
231 (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
232 (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
233 (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
234 (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
235 (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
236 (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) || \
237 (((bit)>>5)==8 && (1UL<<((bit)&31) & REQUIRED_MASK8)) || \
238 (((bit)>>5)==9 && (1UL<<((bit)&31) & REQUIRED_MASK9)) )
240 #define cpu_has(c, bit) \
241 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
242 test_cpu_cap(c, bit))
244 #define this_cpu_has(bit) \
245 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
246 x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))
248 #define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
250 #define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability))
251 #define clear_cpu_cap(c, bit) clear_bit(bit, (unsigned long *)((c)->x86_capability))
252 #define setup_clear_cpu_cap(bit) do { \
253 clear_cpu_cap(&boot_cpu_data, bit); \
254 set_bit(bit, (unsigned long *)cpu_caps_cleared); \
256 #define setup_force_cpu_cap(bit) do { \
257 set_cpu_cap(&boot_cpu_data, bit); \
258 set_bit(bit, (unsigned long *)cpu_caps_set); \
261 #define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
262 #define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
263 #define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
264 #define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
265 #define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
266 #define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
267 #define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
268 #define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
269 #define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)
270 #define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR)
271 #define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)
272 #define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
273 #define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM)
274 #define cpu_has_xmm2 boot_cpu_has(X86_FEATURE_XMM2)
275 #define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
276 #define cpu_has_ssse3 boot_cpu_has(X86_FEATURE_SSSE3)
277 #define cpu_has_aes boot_cpu_has(X86_FEATURE_AES)
278 #define cpu_has_avx boot_cpu_has(X86_FEATURE_AVX)
279 #define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
280 #define cpu_has_mp boot_cpu_has(X86_FEATURE_MP)
281 #define cpu_has_nx boot_cpu_has(X86_FEATURE_NX)
282 #define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
283 #define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
284 #define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
285 #define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE)
286 #define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN)
287 #define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT)
288 #define cpu_has_xcrypt_enabled boot_cpu_has(X86_FEATURE_XCRYPT_EN)
289 #define cpu_has_ace2 boot_cpu_has(X86_FEATURE_ACE2)
290 #define cpu_has_ace2_enabled boot_cpu_has(X86_FEATURE_ACE2_EN)
291 #define cpu_has_phe boot_cpu_has(X86_FEATURE_PHE)
292 #define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN)
293 #define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM)
294 #define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN)
295 #define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
296 #define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
297 #define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
298 #define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
299 #define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)
300 #define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
301 #define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT)
302 #define cpu_has_xmm4_1 boot_cpu_has(X86_FEATURE_XMM4_1)
303 #define cpu_has_xmm4_2 boot_cpu_has(X86_FEATURE_XMM4_2)
304 #define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC)
305 #define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE)
306 #define cpu_has_xsaveopt boot_cpu_has(X86_FEATURE_XSAVEOPT)
307 #define cpu_has_osxsave boot_cpu_has(X86_FEATURE_OSXSAVE)
308 #define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR)
309 #define cpu_has_pclmulqdq boot_cpu_has(X86_FEATURE_PCLMULQDQ)
310 #define cpu_has_perfctr_core boot_cpu_has(X86_FEATURE_PERFCTR_CORE)
311 #define cpu_has_cx8 boot_cpu_has(X86_FEATURE_CX8)
312 #define cpu_has_cx16 boot_cpu_has(X86_FEATURE_CX16)
313 #define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU)
315 #if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64)
316 # define cpu_has_invlpg 1
318 # define cpu_has_invlpg (boot_cpu_data.x86 > 3)
324 #define cpu_has_vme 0
327 #define cpu_has_pae ___BUG___
332 #undef cpu_has_k6_mtrr
333 #define cpu_has_k6_mtrr 0
335 #undef cpu_has_cyrix_arr
336 #define cpu_has_cyrix_arr 0
338 #undef cpu_has_centaur_mcr
339 #define cpu_has_centaur_mcr 0
352 #if __GNUC__ > 4 || __GNUC_MINOR__ >= 5
353 asm goto(
"1: jmp %l[t_no]\n"
355 ".section .altinstructions,\"a\"\n"
363 : :
"i" (bit) : : t_no);
370 asm volatile(
"1: movb $0,%0\n"
372 ".section .altinstructions,\"a\"\n"
379 ".section .discard,\"aw\",@progbits\n"
380 " .byte 0xff + (4f-3f) - (2b-1b)\n"
382 ".section .altinstr_replacement,\"ax\"\n"
386 :
"=qm" (
flag) :
"i" (bit));
391 #define static_cpu_has(bit) \
393 __builtin_constant_p(boot_cpu_has(bit)) ? \
394 boot_cpu_has(bit) : \
395 __builtin_constant_p(bit) ? \
396 __static_cpu_has(bit) : \
403 #define static_cpu_has(bit) boot_cpu_has(bit)