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 10
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_CLFLSH (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#define X86_FEATURE_FXSAVE_LEAK (3*32+10)
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#define X86_FEATURE_11AP (3*32+19)
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#define X86_FEATURE_CLFLUSH_MONITOR (3*32+25)
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_XSAVEOPT (7*32+ 4)
184#define X86_FEATURE_PLN (7*32+ 5)
185#define X86_FEATURE_PTS (7*32+ 6)
186#define X86_FEATURE_DTHERM (7*32+ 7)
187#define X86_FEATURE_HW_PSTATE (7*32+ 8)
188#define X86_FEATURE_PROC_FEEDBACK (7*32+ 9)
189
190
191#define X86_FEATURE_TPR_SHADOW (8*32+ 0)
192#define X86_FEATURE_VNMI (8*32+ 1)
193#define X86_FEATURE_FLEXPRIORITY (8*32+ 2)
194#define X86_FEATURE_EPT (8*32+ 3)
195#define X86_FEATURE_VPID (8*32+ 4)
196#define X86_FEATURE_NPT (8*32+ 5)
197#define X86_FEATURE_LBRV (8*32+ 6)
198#define X86_FEATURE_SVML (8*32+ 7)
199#define X86_FEATURE_NRIPS (8*32+ 8)
200#define X86_FEATURE_TSCRATEMSR (8*32+ 9)
201#define X86_FEATURE_VMCBCLEAN (8*32+10)
202#define X86_FEATURE_FLUSHBYASID (8*32+11)
203#define X86_FEATURE_DECODEASSISTS (8*32+12)
204#define X86_FEATURE_PAUSEFILTER (8*32+13)
205#define X86_FEATURE_PFTHRESHOLD (8*32+14)
206
207
208
209#define X86_FEATURE_FSGSBASE (9*32+ 0)
210#define X86_FEATURE_TSC_ADJUST (9*32+ 1)
211#define X86_FEATURE_BMI1 (9*32+ 3)
212#define X86_FEATURE_HLE (9*32+ 4)
213#define X86_FEATURE_AVX2 (9*32+ 5)
214#define X86_FEATURE_SMEP (9*32+ 7)
215#define X86_FEATURE_BMI2 (9*32+ 8)
216#define X86_FEATURE_ERMS (9*32+ 9)
217#define X86_FEATURE_INVPCID (9*32+10)
218#define X86_FEATURE_RTM (9*32+11)
219#define X86_FEATURE_RDSEED (9*32+18)
220#define X86_FEATURE_ADX (9*32+19)
221#define X86_FEATURE_SMAP (9*32+20)
222
223
224
225
226#define X86_BUG(x) (NCAPINTS*32 + (x))
227
228#define X86_BUG_F00F X86_BUG(0)
229#define X86_BUG_FDIV X86_BUG(1)
230#define X86_BUG_COMA X86_BUG(2)
231#define X86_BUG_AMD_TLB_MMATCH X86_BUG(3)
232#define X86_BUG_AMD_APIC_C1E X86_BUG(4)
233
234#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
235
236#include <asm/asm.h>
237#include <linux/bitops.h>
238
239extern const char * const x86_cap_flags[NCAPINTS*32];
240extern const char * const x86_power_flags[32];
241
242#define test_cpu_cap(c, bit) \
243 test_bit(bit, (unsigned long *)((c)->x86_capability))
244
245#define REQUIRED_MASK_BIT_SET(bit) \
246 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
247 (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
248 (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
249 (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
250 (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
251 (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
252 (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
253 (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) || \
254 (((bit)>>5)==8 && (1UL<<((bit)&31) & REQUIRED_MASK8)) || \
255 (((bit)>>5)==9 && (1UL<<((bit)&31) & REQUIRED_MASK9)) )
256
257#define cpu_has(c, bit) \
258 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
259 test_cpu_cap(c, bit))
260
261#define this_cpu_has(bit) \
262 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
263 x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))
264
265#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
266
267#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability))
268#define clear_cpu_cap(c, bit) clear_bit(bit, (unsigned long *)((c)->x86_capability))
269#define setup_clear_cpu_cap(bit) do { \
270 clear_cpu_cap(&boot_cpu_data, bit); \
271 set_bit(bit, (unsigned long *)cpu_caps_cleared); \
272} while (0)
273#define setup_force_cpu_cap(bit) do { \
274 set_cpu_cap(&boot_cpu_data, bit); \
275 set_bit(bit, (unsigned long *)cpu_caps_set); \
276} while (0)
277
278#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
279#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
280#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
281#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
282#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
283#define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
284#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
285#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
286#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)
287#define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR)
288#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)
289#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
290#define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM)
291#define cpu_has_xmm2 boot_cpu_has(X86_FEATURE_XMM2)
292#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
293#define cpu_has_ssse3 boot_cpu_has(X86_FEATURE_SSSE3)
294#define cpu_has_aes boot_cpu_has(X86_FEATURE_AES)
295#define cpu_has_avx boot_cpu_has(X86_FEATURE_AVX)
296#define cpu_has_avx2 boot_cpu_has(X86_FEATURE_AVX2)
297#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
298#define cpu_has_mp boot_cpu_has(X86_FEATURE_MP)
299#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX)
300#define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
301#define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
302#define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
303#define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE)
304#define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN)
305#define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT)
306#define cpu_has_xcrypt_enabled boot_cpu_has(X86_FEATURE_XCRYPT_EN)
307#define cpu_has_ace2 boot_cpu_has(X86_FEATURE_ACE2)
308#define cpu_has_ace2_enabled boot_cpu_has(X86_FEATURE_ACE2_EN)
309#define cpu_has_phe boot_cpu_has(X86_FEATURE_PHE)
310#define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN)
311#define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM)
312#define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN)
313#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
314#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
315#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
316#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
317#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)
318#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
319#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT)
320#define cpu_has_xmm4_1 boot_cpu_has(X86_FEATURE_XMM4_1)
321#define cpu_has_xmm4_2 boot_cpu_has(X86_FEATURE_XMM4_2)
322#define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC)
323#define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE)
324#define cpu_has_xsaveopt boot_cpu_has(X86_FEATURE_XSAVEOPT)
325#define cpu_has_osxsave boot_cpu_has(X86_FEATURE_OSXSAVE)
326#define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR)
327#define cpu_has_pclmulqdq boot_cpu_has(X86_FEATURE_PCLMULQDQ)
328#define cpu_has_perfctr_core boot_cpu_has(X86_FEATURE_PERFCTR_CORE)
329#define cpu_has_perfctr_nb boot_cpu_has(X86_FEATURE_PERFCTR_NB)
330#define cpu_has_perfctr_l2 boot_cpu_has(X86_FEATURE_PERFCTR_L2)
331#define cpu_has_cx8 boot_cpu_has(X86_FEATURE_CX8)
332#define cpu_has_cx16 boot_cpu_has(X86_FEATURE_CX16)
333#define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU)
334#define cpu_has_topoext boot_cpu_has(X86_FEATURE_TOPOEXT)
335
336#ifdef CONFIG_X86_64
337
338#undef cpu_has_vme
339#define cpu_has_vme 0
340
341#undef cpu_has_pae
342#define cpu_has_pae ___BUG___
343
344#undef cpu_has_mp
345#define cpu_has_mp 1
346
347#undef cpu_has_k6_mtrr
348#define cpu_has_k6_mtrr 0
349
350#undef cpu_has_cyrix_arr
351#define cpu_has_cyrix_arr 0
352
353#undef cpu_has_centaur_mcr
354#define cpu_has_centaur_mcr 0
355
356#endif
357
358#if __GNUC__ >= 4
359extern void warn_pre_alternatives(void);
360extern bool __static_cpu_has_safe(u16 bit);
361
362
363
364
365
366
367static __always_inline __pure bool __static_cpu_has(u16 bit)
368{
369#ifdef CC_HAVE_ASM_GOTO
370
371#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
372
373
374
375
376
377 asm_volatile_goto("1: jmp %l[t_warn]\n"
378 "2:\n"
379 ".section .altinstructions,\"a\"\n"
380 " .long 1b - .\n"
381 " .long 0\n"
382 " .word %P0\n"
383 " .byte 2b - 1b\n"
384 " .byte 0\n"
385 ".previous\n"
386
387 : : "i" (X86_FEATURE_ALWAYS) : : t_warn);
388
389#endif
390
391 asm_volatile_goto("1: jmp %l[t_no]\n"
392 "2:\n"
393 ".section .altinstructions,\"a\"\n"
394 " .long 1b - .\n"
395 " .long 0\n"
396 " .word %P0\n"
397 " .byte 2b - 1b\n"
398 " .byte 0\n"
399 ".previous\n"
400
401 : : "i" (bit) : : t_no);
402 return true;
403 t_no:
404 return false;
405
406#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
407 t_warn:
408 warn_pre_alternatives();
409 return false;
410#endif
411
412#else
413
414 u8 flag;
415
416 asm volatile("1: movb $0,%0\n"
417 "2:\n"
418 ".section .altinstructions,\"a\"\n"
419 " .long 1b - .\n"
420 " .long 3f - .\n"
421 " .word %P1\n"
422 " .byte 2b - 1b\n"
423 " .byte 4f - 3f\n"
424 ".previous\n"
425 ".section .discard,\"aw\",@progbits\n"
426 " .byte 0xff + (4f-3f) - (2b-1b)\n"
427 ".previous\n"
428 ".section .altinstr_replacement,\"ax\"\n"
429 "3: movb $1,%0\n"
430 "4:\n"
431 ".previous\n"
432 : "=qm" (flag) : "i" (bit));
433 return flag;
434
435#endif
436}
437
438#define static_cpu_has(bit) \
439( \
440 __builtin_constant_p(boot_cpu_has(bit)) ? \
441 boot_cpu_has(bit) : \
442 __builtin_constant_p(bit) ? \
443 __static_cpu_has(bit) : \
444 boot_cpu_has(bit) \
445)
446
447static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
448{
449#ifdef CC_HAVE_ASM_GOTO
450
451
452
453
454
455
456 asm_volatile_goto("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n"
457 "2:\n"
458 ".section .altinstructions,\"a\"\n"
459 " .long 1b - .\n"
460 " .long 3f - .\n"
461 " .word %P1\n"
462 " .byte 2b - 1b\n"
463 " .byte 4f - 3f\n"
464 ".previous\n"
465 ".section .altinstr_replacement,\"ax\"\n"
466 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
467 "4:\n"
468 ".previous\n"
469 ".section .altinstructions,\"a\"\n"
470 " .long 1b - .\n"
471 " .long 0\n"
472 " .word %P0\n"
473 " .byte 2b - 1b\n"
474 " .byte 0\n"
475 ".previous\n"
476 : : "i" (bit), "i" (X86_FEATURE_ALWAYS)
477 : : t_dynamic, t_no);
478 return true;
479 t_no:
480 return false;
481 t_dynamic:
482 return __static_cpu_has_safe(bit);
483#else
484 u8 flag;
485
486 asm volatile("1: movb $2,%0\n"
487 "2:\n"
488 ".section .altinstructions,\"a\"\n"
489 " .long 1b - .\n"
490 " .long 3f - .\n"
491 " .word %P2\n"
492 " .byte 2b - 1b\n"
493 " .byte 4f - 3f\n"
494 ".previous\n"
495 ".section .discard,\"aw\",@progbits\n"
496 " .byte 0xff + (4f-3f) - (2b-1b)\n"
497 ".previous\n"
498 ".section .altinstr_replacement,\"ax\"\n"
499 "3: movb $0,%0\n"
500 "4:\n"
501 ".previous\n"
502 ".section .altinstructions,\"a\"\n"
503 " .long 1b - .\n"
504 " .long 5f - .\n"
505 " .word %P1\n"
506 " .byte 4b - 3b\n"
507 " .byte 6f - 5f\n"
508 ".previous\n"
509 ".section .discard,\"aw\",@progbits\n"
510 " .byte 0xff + (6f-5f) - (4b-3b)\n"
511 ".previous\n"
512 ".section .altinstr_replacement,\"ax\"\n"
513 "5: movb $1,%0\n"
514 "6:\n"
515 ".previous\n"
516 : "=qm" (flag)
517 : "i" (bit), "i" (X86_FEATURE_ALWAYS));
518 return (flag == 2 ? __static_cpu_has_safe(bit) : flag);
519#endif
520}
521
522#define static_cpu_has_safe(bit) \
523( \
524 __builtin_constant_p(boot_cpu_has(bit)) ? \
525 boot_cpu_has(bit) : \
526 _static_cpu_has_safe(bit) \
527)
528#else
529
530
531
532#define static_cpu_has(bit) boot_cpu_has(bit)
533#define static_cpu_has_safe(bit) boot_cpu_has(bit)
534#endif
535
536#define cpu_has_bug(c, bit) cpu_has(c, (bit))
537#define set_cpu_bug(c, bit) set_cpu_cap(c, (bit))
538#define clear_cpu_bug(c, bit) clear_cpu_cap(c, (bit));
539
540#define static_cpu_has_bug(bit) static_cpu_has((bit))
541#define boot_cpu_has_bug(bit) cpu_has_bug(&boot_cpu_data, (bit))
542
543#endif
544
545#endif
546