1
2
3
4#ifndef _ASM_X86_CPUFEATURE_H
5#define _ASM_X86_CPUFEATURE_H
6
7#ifndef _ASM_X86_REQUIRED_FEATURES_H
8#include <asm/required-features.h>
9#endif
10
11#define NCAPINTS 11
12#define NBUGINTS 1
13
14
15
16
17
18
19
20
21#define X86_FEATURE_FPU ( 0*32+ 0)
22#define X86_FEATURE_VME ( 0*32+ 1)
23#define X86_FEATURE_DE ( 0*32+ 2)
24#define X86_FEATURE_PSE ( 0*32+ 3)
25#define X86_FEATURE_TSC ( 0*32+ 4)
26#define X86_FEATURE_MSR ( 0*32+ 5)
27#define X86_FEATURE_PAE ( 0*32+ 6)
28#define X86_FEATURE_MCE ( 0*32+ 7)
29#define X86_FEATURE_CX8 ( 0*32+ 8)
30#define X86_FEATURE_APIC ( 0*32+ 9)
31#define X86_FEATURE_SEP ( 0*32+11)
32#define X86_FEATURE_MTRR ( 0*32+12)
33#define X86_FEATURE_PGE ( 0*32+13)
34#define X86_FEATURE_MCA ( 0*32+14)
35#define X86_FEATURE_CMOV ( 0*32+15)
36
37#define X86_FEATURE_PAT ( 0*32+16)
38#define X86_FEATURE_PSE36 ( 0*32+17)
39#define X86_FEATURE_PN ( 0*32+18)
40#define X86_FEATURE_CLFLUSH ( 0*32+19)
41#define X86_FEATURE_DS ( 0*32+21)
42#define X86_FEATURE_ACPI ( 0*32+22)
43#define X86_FEATURE_MMX ( 0*32+23)
44#define X86_FEATURE_FXSR ( 0*32+24)
45#define X86_FEATURE_XMM ( 0*32+25)
46#define X86_FEATURE_XMM2 ( 0*32+26)
47#define X86_FEATURE_SELFSNOOP ( 0*32+27)
48#define X86_FEATURE_HT ( 0*32+28)
49#define X86_FEATURE_ACC ( 0*32+29)
50#define X86_FEATURE_IA64 ( 0*32+30)
51#define X86_FEATURE_PBE ( 0*32+31)
52
53
54
55#define X86_FEATURE_SYSCALL ( 1*32+11)
56#define X86_FEATURE_MP ( 1*32+19)
57#define X86_FEATURE_NX ( 1*32+20)
58#define X86_FEATURE_MMXEXT ( 1*32+22)
59#define X86_FEATURE_FXSR_OPT ( 1*32+25)
60#define X86_FEATURE_GBPAGES ( 1*32+26)
61#define X86_FEATURE_RDTSCP ( 1*32+27)
62#define X86_FEATURE_LM ( 1*32+29)
63#define X86_FEATURE_3DNOWEXT ( 1*32+30)
64#define X86_FEATURE_3DNOW ( 1*32+31)
65
66
67#define X86_FEATURE_RECOVERY ( 2*32+ 0)
68#define X86_FEATURE_LONGRUN ( 2*32+ 1)
69#define X86_FEATURE_LRTI ( 2*32+ 3)
70
71
72
73#define X86_FEATURE_CXMMX ( 3*32+ 0)
74#define X86_FEATURE_K6_MTRR ( 3*32+ 1)
75#define X86_FEATURE_CYRIX_ARR ( 3*32+ 2)
76#define X86_FEATURE_CENTAUR_MCR ( 3*32+ 3)
77
78#define X86_FEATURE_K8 ( 3*32+ 4)
79#define X86_FEATURE_K7 ( 3*32+ 5)
80#define X86_FEATURE_P3 ( 3*32+ 6)
81#define X86_FEATURE_P4 ( 3*32+ 7)
82#define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8)
83#define X86_FEATURE_UP ( 3*32+ 9)
84
85#define X86_FEATURE_ARCH_PERFMON ( 3*32+11)
86#define X86_FEATURE_PEBS ( 3*32+12)
87#define X86_FEATURE_BTS ( 3*32+13)
88#define X86_FEATURE_SYSCALL32 ( 3*32+14)
89#define X86_FEATURE_SYSENTER32 ( 3*32+15)
90#define X86_FEATURE_REP_GOOD ( 3*32+16)
91#define X86_FEATURE_MFENCE_RDTSC ( 3*32+17)
92#define X86_FEATURE_LFENCE_RDTSC ( 3*32+18)
93
94#define X86_FEATURE_NOPL ( 3*32+20)
95#define X86_FEATURE_ALWAYS ( 3*32+21)
96#define X86_FEATURE_XTOPOLOGY ( 3*32+22)
97#define X86_FEATURE_TSC_RELIABLE ( 3*32+23)
98#define X86_FEATURE_NONSTOP_TSC ( 3*32+24)
99
100#define X86_FEATURE_EXTD_APICID ( 3*32+26)
101#define X86_FEATURE_AMD_DCM ( 3*32+27)
102#define X86_FEATURE_APERFMPERF ( 3*32+28)
103#define X86_FEATURE_EAGER_FPU ( 3*32+29)
104#define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30)
105
106
107#define X86_FEATURE_XMM3 ( 4*32+ 0)
108#define X86_FEATURE_PCLMULQDQ ( 4*32+ 1)
109#define X86_FEATURE_DTES64 ( 4*32+ 2)
110#define X86_FEATURE_MWAIT ( 4*32+ 3)
111#define X86_FEATURE_DSCPL ( 4*32+ 4)
112#define X86_FEATURE_VMX ( 4*32+ 5)
113#define X86_FEATURE_SMX ( 4*32+ 6)
114#define X86_FEATURE_EST ( 4*32+ 7)
115#define X86_FEATURE_TM2 ( 4*32+ 8)
116#define X86_FEATURE_SSSE3 ( 4*32+ 9)
117#define X86_FEATURE_CID ( 4*32+10)
118#define X86_FEATURE_FMA ( 4*32+12)
119#define X86_FEATURE_CX16 ( 4*32+13)
120#define X86_FEATURE_XTPR ( 4*32+14)
121#define X86_FEATURE_PDCM ( 4*32+15)
122#define X86_FEATURE_PCID ( 4*32+17)
123#define X86_FEATURE_DCA ( 4*32+18)
124#define X86_FEATURE_XMM4_1 ( 4*32+19)
125#define X86_FEATURE_XMM4_2 ( 4*32+20)
126#define X86_FEATURE_X2APIC ( 4*32+21)
127#define X86_FEATURE_MOVBE ( 4*32+22)
128#define X86_FEATURE_POPCNT ( 4*32+23)
129#define X86_FEATURE_TSC_DEADLINE_TIMER ( 4*32+24)
130#define X86_FEATURE_AES ( 4*32+25)
131#define X86_FEATURE_XSAVE ( 4*32+26)
132#define X86_FEATURE_OSXSAVE ( 4*32+27)
133#define X86_FEATURE_AVX ( 4*32+28)
134#define X86_FEATURE_F16C ( 4*32+29)
135#define X86_FEATURE_RDRAND ( 4*32+30)
136#define X86_FEATURE_HYPERVISOR ( 4*32+31)
137
138
139#define X86_FEATURE_XSTORE ( 5*32+ 2)
140#define X86_FEATURE_XSTORE_EN ( 5*32+ 3)
141#define X86_FEATURE_XCRYPT ( 5*32+ 6)
142#define X86_FEATURE_XCRYPT_EN ( 5*32+ 7)
143#define X86_FEATURE_ACE2 ( 5*32+ 8)
144#define X86_FEATURE_ACE2_EN ( 5*32+ 9)
145#define X86_FEATURE_PHE ( 5*32+10)
146#define X86_FEATURE_PHE_EN ( 5*32+11)
147#define X86_FEATURE_PMM ( 5*32+12)
148#define X86_FEATURE_PMM_EN ( 5*32+13)
149
150
151#define X86_FEATURE_LAHF_LM ( 6*32+ 0)
152#define X86_FEATURE_CMP_LEGACY ( 6*32+ 1)
153#define X86_FEATURE_SVM ( 6*32+ 2)
154#define X86_FEATURE_EXTAPIC ( 6*32+ 3)
155#define X86_FEATURE_CR8_LEGACY ( 6*32+ 4)
156#define X86_FEATURE_ABM ( 6*32+ 5)
157#define X86_FEATURE_SSE4A ( 6*32+ 6)
158#define X86_FEATURE_MISALIGNSSE ( 6*32+ 7)
159#define X86_FEATURE_3DNOWPREFETCH ( 6*32+ 8)
160#define X86_FEATURE_OSVW ( 6*32+ 9)
161#define X86_FEATURE_IBS ( 6*32+10)
162#define X86_FEATURE_XOP ( 6*32+11)
163#define X86_FEATURE_SKINIT ( 6*32+12)
164#define X86_FEATURE_WDT ( 6*32+13)
165#define X86_FEATURE_LWP ( 6*32+15)
166#define X86_FEATURE_FMA4 ( 6*32+16)
167#define X86_FEATURE_TCE ( 6*32+17)
168#define X86_FEATURE_NODEID_MSR ( 6*32+19)
169#define X86_FEATURE_TBM ( 6*32+21)
170#define X86_FEATURE_TOPOEXT ( 6*32+22)
171#define X86_FEATURE_PERFCTR_CORE ( 6*32+23)
172#define X86_FEATURE_PERFCTR_NB ( 6*32+24)
173#define X86_FEATURE_PERFCTR_L2 ( 6*32+28)
174
175
176
177
178
179#define X86_FEATURE_IDA ( 7*32+ 0)
180#define X86_FEATURE_ARAT ( 7*32+ 1)
181#define X86_FEATURE_CPB ( 7*32+ 2)
182#define X86_FEATURE_EPB ( 7*32+ 3)
183#define X86_FEATURE_PLN ( 7*32+ 5)
184#define X86_FEATURE_PTS ( 7*32+ 6)
185#define X86_FEATURE_DTHERM ( 7*32+ 7)
186#define X86_FEATURE_HW_PSTATE ( 7*32+ 8)
187#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)
188
189
190#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0)
191#define X86_FEATURE_VNMI ( 8*32+ 1)
192#define X86_FEATURE_FLEXPRIORITY ( 8*32+ 2)
193#define X86_FEATURE_EPT ( 8*32+ 3)
194#define X86_FEATURE_VPID ( 8*32+ 4)
195#define X86_FEATURE_NPT ( 8*32+ 5)
196#define X86_FEATURE_LBRV ( 8*32+ 6)
197#define X86_FEATURE_SVML ( 8*32+ 7)
198#define X86_FEATURE_NRIPS ( 8*32+ 8)
199#define X86_FEATURE_TSCRATEMSR ( 8*32+ 9)
200#define X86_FEATURE_VMCBCLEAN ( 8*32+10)
201#define X86_FEATURE_FLUSHBYASID ( 8*32+11)
202#define X86_FEATURE_DECODEASSISTS ( 8*32+12)
203#define X86_FEATURE_PAUSEFILTER ( 8*32+13)
204#define X86_FEATURE_PFTHRESHOLD ( 8*32+14)
205
206
207
208#define X86_FEATURE_FSGSBASE ( 9*32+ 0)
209#define X86_FEATURE_TSC_ADJUST ( 9*32+ 1)
210#define X86_FEATURE_BMI1 ( 9*32+ 3)
211#define X86_FEATURE_HLE ( 9*32+ 4)
212#define X86_FEATURE_AVX2 ( 9*32+ 5)
213#define X86_FEATURE_SMEP ( 9*32+ 7)
214#define X86_FEATURE_BMI2 ( 9*32+ 8)
215#define X86_FEATURE_ERMS ( 9*32+ 9)
216#define X86_FEATURE_INVPCID ( 9*32+10)
217#define X86_FEATURE_RTM ( 9*32+11)
218#define X86_FEATURE_MPX ( 9*32+14)
219#define X86_FEATURE_AVX512F ( 9*32+16)
220#define X86_FEATURE_RDSEED ( 9*32+18)
221#define X86_FEATURE_ADX ( 9*32+19)
222#define X86_FEATURE_SMAP ( 9*32+20)
223#define X86_FEATURE_CLFLUSHOPT ( 9*32+23)
224#define X86_FEATURE_AVX512PF ( 9*32+26)
225#define X86_FEATURE_AVX512ER ( 9*32+27)
226#define X86_FEATURE_AVX512CD ( 9*32+28)
227
228
229#define X86_FEATURE_XSAVEOPT (10*32+ 0)
230#define X86_FEATURE_XSAVEC (10*32+ 1)
231#define X86_FEATURE_XGETBV1 (10*32+ 2)
232#define X86_FEATURE_XSAVES (10*32+ 3)
233
234
235
236
237#define X86_BUG(x) (NCAPINTS*32 + (x))
238
239#define X86_BUG_F00F X86_BUG(0)
240#define X86_BUG_FDIV X86_BUG(1)
241#define X86_BUG_COMA X86_BUG(2)
242#define X86_BUG_AMD_TLB_MMATCH X86_BUG(3)
243#define X86_BUG_AMD_APIC_C1E X86_BUG(4)
244#define X86_BUG_11AP X86_BUG(5)
245#define X86_BUG_FXSAVE_LEAK X86_BUG(6)
246#define X86_BUG_CLFLUSH_MONITOR X86_BUG(7)
247
248#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
249
250#include <asm/asm.h>
251#include <linux/bitops.h>
252
253extern const char * const x86_cap_flags[NCAPINTS*32];
254extern const char * const x86_power_flags[32];
255
256
257
258
259
260extern const char * const x86_bug_flags[NBUGINTS*32];
261
262#define test_cpu_cap(c, bit) \
263 test_bit(bit, (unsigned long *)((c)->x86_capability))
264
265#define REQUIRED_MASK_BIT_SET(bit) \
266 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
267 (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
268 (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
269 (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
270 (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
271 (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
272 (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
273 (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) || \
274 (((bit)>>5)==8 && (1UL<<((bit)&31) & REQUIRED_MASK8)) || \
275 (((bit)>>5)==9 && (1UL<<((bit)&31) & REQUIRED_MASK9)) )
276
277#define cpu_has(c, bit) \
278 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
279 test_cpu_cap(c, bit))
280
281#define this_cpu_has(bit) \
282 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
283 x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))
284
285#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
286
287#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability))
288#define clear_cpu_cap(c, bit) clear_bit(bit, (unsigned long *)((c)->x86_capability))
289#define setup_clear_cpu_cap(bit) do { \
290 clear_cpu_cap(&boot_cpu_data, bit); \
291 set_bit(bit, (unsigned long *)cpu_caps_cleared); \
292} while (0)
293#define setup_force_cpu_cap(bit) do { \
294 set_cpu_cap(&boot_cpu_data, bit); \
295 set_bit(bit, (unsigned long *)cpu_caps_set); \
296} while (0)
297
298#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
299#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
300#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
301#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
302#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
303#define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
304#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
305#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
306#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)
307#define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR)
308#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)
309#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
310#define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM)
311#define cpu_has_xmm2 boot_cpu_has(X86_FEATURE_XMM2)
312#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
313#define cpu_has_ssse3 boot_cpu_has(X86_FEATURE_SSSE3)
314#define cpu_has_aes boot_cpu_has(X86_FEATURE_AES)
315#define cpu_has_avx boot_cpu_has(X86_FEATURE_AVX)
316#define cpu_has_avx2 boot_cpu_has(X86_FEATURE_AVX2)
317#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
318#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX)
319#define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
320#define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
321#define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
322#define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE)
323#define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN)
324#define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT)
325#define cpu_has_xcrypt_enabled boot_cpu_has(X86_FEATURE_XCRYPT_EN)
326#define cpu_has_ace2 boot_cpu_has(X86_FEATURE_ACE2)
327#define cpu_has_ace2_enabled boot_cpu_has(X86_FEATURE_ACE2_EN)
328#define cpu_has_phe boot_cpu_has(X86_FEATURE_PHE)
329#define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN)
330#define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM)
331#define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN)
332#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
333#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
334#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLUSH)
335#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
336#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)
337#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
338#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT)
339#define cpu_has_xmm4_1 boot_cpu_has(X86_FEATURE_XMM4_1)
340#define cpu_has_xmm4_2 boot_cpu_has(X86_FEATURE_XMM4_2)
341#define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC)
342#define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE)
343#define cpu_has_xsaveopt boot_cpu_has(X86_FEATURE_XSAVEOPT)
344#define cpu_has_xsaves boot_cpu_has(X86_FEATURE_XSAVES)
345#define cpu_has_osxsave boot_cpu_has(X86_FEATURE_OSXSAVE)
346#define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR)
347#define cpu_has_pclmulqdq boot_cpu_has(X86_FEATURE_PCLMULQDQ)
348#define cpu_has_perfctr_core boot_cpu_has(X86_FEATURE_PERFCTR_CORE)
349#define cpu_has_perfctr_nb boot_cpu_has(X86_FEATURE_PERFCTR_NB)
350#define cpu_has_perfctr_l2 boot_cpu_has(X86_FEATURE_PERFCTR_L2)
351#define cpu_has_cx8 boot_cpu_has(X86_FEATURE_CX8)
352#define cpu_has_cx16 boot_cpu_has(X86_FEATURE_CX16)
353#define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU)
354#define cpu_has_topoext boot_cpu_has(X86_FEATURE_TOPOEXT)
355
356#ifdef CONFIG_X86_64
357
358#undef cpu_has_vme
359#define cpu_has_vme 0
360
361#undef cpu_has_pae
362#define cpu_has_pae ___BUG___
363
364#undef cpu_has_k6_mtrr
365#define cpu_has_k6_mtrr 0
366
367#undef cpu_has_cyrix_arr
368#define cpu_has_cyrix_arr 0
369
370#undef cpu_has_centaur_mcr
371#define cpu_has_centaur_mcr 0
372
373#endif
374
375#if __GNUC__ >= 4
376extern void warn_pre_alternatives(void);
377extern bool __static_cpu_has_safe(u16 bit);
378
379
380
381
382
383
384static __always_inline __pure bool __static_cpu_has(u16 bit)
385{
386#ifdef CC_HAVE_ASM_GOTO
387
388#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
389
390
391
392
393
394 asm_volatile_goto("1: jmp %l[t_warn]\n"
395 "2:\n"
396 ".section .altinstructions,\"a\"\n"
397 " .long 1b - .\n"
398 " .long 0\n"
399 " .word %P0\n"
400 " .byte 2b - 1b\n"
401 " .byte 0\n"
402 ".previous\n"
403
404 : : "i" (X86_FEATURE_ALWAYS) : : t_warn);
405
406#endif
407
408 asm_volatile_goto("1: jmp %l[t_no]\n"
409 "2:\n"
410 ".section .altinstructions,\"a\"\n"
411 " .long 1b - .\n"
412 " .long 0\n"
413 " .word %P0\n"
414 " .byte 2b - 1b\n"
415 " .byte 0\n"
416 ".previous\n"
417
418 : : "i" (bit) : : t_no);
419 return true;
420 t_no:
421 return false;
422
423#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
424 t_warn:
425 warn_pre_alternatives();
426 return false;
427#endif
428
429#else
430
431 u8 flag;
432
433 asm volatile("1: movb $0,%0\n"
434 "2:\n"
435 ".section .altinstructions,\"a\"\n"
436 " .long 1b - .\n"
437 " .long 3f - .\n"
438 " .word %P1\n"
439 " .byte 2b - 1b\n"
440 " .byte 4f - 3f\n"
441 ".previous\n"
442 ".section .discard,\"aw\",@progbits\n"
443 " .byte 0xff + (4f-3f) - (2b-1b)\n"
444 ".previous\n"
445 ".section .altinstr_replacement,\"ax\"\n"
446 "3: movb $1,%0\n"
447 "4:\n"
448 ".previous\n"
449 : "=qm" (flag) : "i" (bit));
450 return flag;
451
452#endif
453}
454
455#define static_cpu_has(bit) \
456( \
457 __builtin_constant_p(boot_cpu_has(bit)) ? \
458 boot_cpu_has(bit) : \
459 __builtin_constant_p(bit) ? \
460 __static_cpu_has(bit) : \
461 boot_cpu_has(bit) \
462)
463
464static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
465{
466#ifdef CC_HAVE_ASM_GOTO
467
468
469
470
471
472
473 asm_volatile_goto("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n"
474 "2:\n"
475 ".section .altinstructions,\"a\"\n"
476 " .long 1b - .\n"
477 " .long 3f - .\n"
478 " .word %P1\n"
479 " .byte 2b - 1b\n"
480 " .byte 4f - 3f\n"
481 ".previous\n"
482 ".section .altinstr_replacement,\"ax\"\n"
483 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
484 "4:\n"
485 ".previous\n"
486 ".section .altinstructions,\"a\"\n"
487 " .long 1b - .\n"
488 " .long 0\n"
489 " .word %P0\n"
490 " .byte 2b - 1b\n"
491 " .byte 0\n"
492 ".previous\n"
493 : : "i" (bit), "i" (X86_FEATURE_ALWAYS)
494 : : t_dynamic, t_no);
495 return true;
496 t_no:
497 return false;
498 t_dynamic:
499 return __static_cpu_has_safe(bit);
500#else
501 u8 flag;
502
503 asm volatile("1: movb $2,%0\n"
504 "2:\n"
505 ".section .altinstructions,\"a\"\n"
506 " .long 1b - .\n"
507 " .long 3f - .\n"
508 " .word %P2\n"
509 " .byte 2b - 1b\n"
510 " .byte 4f - 3f\n"
511 ".previous\n"
512 ".section .discard,\"aw\",@progbits\n"
513 " .byte 0xff + (4f-3f) - (2b-1b)\n"
514 ".previous\n"
515 ".section .altinstr_replacement,\"ax\"\n"
516 "3: movb $0,%0\n"
517 "4:\n"
518 ".previous\n"
519 ".section .altinstructions,\"a\"\n"
520 " .long 1b - .\n"
521 " .long 5f - .\n"
522 " .word %P1\n"
523 " .byte 4b - 3b\n"
524 " .byte 6f - 5f\n"
525 ".previous\n"
526 ".section .discard,\"aw\",@progbits\n"
527 " .byte 0xff + (6f-5f) - (4b-3b)\n"
528 ".previous\n"
529 ".section .altinstr_replacement,\"ax\"\n"
530 "5: movb $1,%0\n"
531 "6:\n"
532 ".previous\n"
533 : "=qm" (flag)
534 : "i" (bit), "i" (X86_FEATURE_ALWAYS));
535 return (flag == 2 ? __static_cpu_has_safe(bit) : flag);
536#endif
537}
538
539#define static_cpu_has_safe(bit) \
540( \
541 __builtin_constant_p(boot_cpu_has(bit)) ? \
542 boot_cpu_has(bit) : \
543 _static_cpu_has_safe(bit) \
544)
545#else
546
547
548
549#define static_cpu_has(bit) boot_cpu_has(bit)
550#define static_cpu_has_safe(bit) boot_cpu_has(bit)
551#endif
552
553#define cpu_has_bug(c, bit) cpu_has(c, (bit))
554#define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))
555#define clear_cpu_bug(c, bit) clear_cpu_cap(c, (bit))
556
557#define static_cpu_has_bug(bit) static_cpu_has((bit))
558#define static_cpu_has_bug_safe(bit) static_cpu_has_safe((bit))
559#define boot_cpu_has_bug(bit) cpu_has_bug(&boot_cpu_data, (bit))
560
561#define MAX_CPU_FEATURES (NCAPINTS * 32)
562#define cpu_have_feature boot_cpu_has
563
564#define CPU_FEATURE_TYPEFMT "x86,ven%04Xfam%04Xmod%04X"
565#define CPU_FEATURE_TYPEVAL boot_cpu_data.x86_vendor, boot_cpu_data.x86, \
566 boot_cpu_data.x86_model
567
568#endif
569#endif
570