aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/cpufeature.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/include/asm/cpufeature.h')
-rw-r--r--arch/x86/include/asm/cpufeature.h52
1 files changed, 28 insertions, 24 deletions
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 094292a63e74..0bb1335313b2 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -8,6 +8,10 @@
8#include <asm/required-features.h> 8#include <asm/required-features.h>
9#endif 9#endif
10 10
11#ifndef _ASM_X86_DISABLED_FEATURES_H
12#include <asm/disabled-features.h>
13#endif
14
11#define NCAPINTS 11 /* N 32-bit words worth of info */ 15#define NCAPINTS 11 /* N 32-bit words worth of info */
12#define NBUGINTS 1 /* N 32-bit bug flags */ 16#define NBUGINTS 1 /* N 32-bit bug flags */
13 17
@@ -282,6 +286,18 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
282 (((bit)>>5)==8 && (1UL<<((bit)&31) & REQUIRED_MASK8)) || \ 286 (((bit)>>5)==8 && (1UL<<((bit)&31) & REQUIRED_MASK8)) || \
283 (((bit)>>5)==9 && (1UL<<((bit)&31) & REQUIRED_MASK9)) ) 287 (((bit)>>5)==9 && (1UL<<((bit)&31) & REQUIRED_MASK9)) )
284 288
289#define DISABLED_MASK_BIT_SET(bit) \
290 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & DISABLED_MASK0)) || \
291 (((bit)>>5)==1 && (1UL<<((bit)&31) & DISABLED_MASK1)) || \
292 (((bit)>>5)==2 && (1UL<<((bit)&31) & DISABLED_MASK2)) || \
293 (((bit)>>5)==3 && (1UL<<((bit)&31) & DISABLED_MASK3)) || \
294 (((bit)>>5)==4 && (1UL<<((bit)&31) & DISABLED_MASK4)) || \
295 (((bit)>>5)==5 && (1UL<<((bit)&31) & DISABLED_MASK5)) || \
296 (((bit)>>5)==6 && (1UL<<((bit)&31) & DISABLED_MASK6)) || \
297 (((bit)>>5)==7 && (1UL<<((bit)&31) & DISABLED_MASK7)) || \
298 (((bit)>>5)==8 && (1UL<<((bit)&31) & DISABLED_MASK8)) || \
299 (((bit)>>5)==9 && (1UL<<((bit)&31) & DISABLED_MASK9)) )
300
285#define cpu_has(c, bit) \ 301#define cpu_has(c, bit) \
286 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ 302 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
287 test_cpu_cap(c, bit)) 303 test_cpu_cap(c, bit))
@@ -290,6 +306,18 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
290 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ 306 (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
291 x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability)) 307 x86_this_cpu_test_bit(bit, (unsigned long *)&cpu_info.x86_capability))
292 308
309/*
310 * This macro is for detection of features which need kernel
311 * infrastructure to be used. It may *not* directly test the CPU
312 * itself. Use the cpu_has() family if you want true runtime
313 * testing of CPU features, like in hypervisor code where you are
314 * supporting a possible guest feature where host support for it
315 * is not relevant.
316 */
317#define cpu_feature_enabled(bit) \
318 (__builtin_constant_p(bit) && DISABLED_MASK_BIT_SET(bit) ? 0 : \
319 cpu_has(&boot_cpu_data, bit))
320
293#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit) 321#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
294 322
295#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability)) 323#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability))
@@ -304,11 +332,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
304} while (0) 332} while (0)
305 333
306#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU) 334#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
307#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
308#define cpu_has_de boot_cpu_has(X86_FEATURE_DE) 335#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
309#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE) 336#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
310#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC) 337#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
311#define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
312#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE) 338#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
313#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC) 339#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
314#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP) 340#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)
@@ -324,9 +350,6 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
324#define cpu_has_avx2 boot_cpu_has(X86_FEATURE_AVX2) 350#define cpu_has_avx2 boot_cpu_has(X86_FEATURE_AVX2)
325#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT) 351#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
326#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX) 352#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX)
327#define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
328#define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
329#define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
330#define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE) 353#define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE)
331#define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN) 354#define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN)
332#define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT) 355#define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT)
@@ -361,25 +384,6 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
361#define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU) 384#define cpu_has_eager_fpu boot_cpu_has(X86_FEATURE_EAGER_FPU)
362#define cpu_has_topoext boot_cpu_has(X86_FEATURE_TOPOEXT) 385#define cpu_has_topoext boot_cpu_has(X86_FEATURE_TOPOEXT)
363 386
364#ifdef CONFIG_X86_64
365
366#undef cpu_has_vme
367#define cpu_has_vme 0
368
369#undef cpu_has_pae
370#define cpu_has_pae ___BUG___
371
372#undef cpu_has_k6_mtrr
373#define cpu_has_k6_mtrr 0
374
375#undef cpu_has_cyrix_arr
376#define cpu_has_cyrix_arr 0
377
378#undef cpu_has_centaur_mcr
379#define cpu_has_centaur_mcr 0
380
381#endif /* CONFIG_X86_64 */
382
383#if __GNUC__ >= 4 387#if __GNUC__ >= 4
384extern void warn_pre_alternatives(void); 388extern void warn_pre_alternatives(void);
385extern bool __static_cpu_has_safe(u16 bit); 389extern bool __static_cpu_has_safe(u16 bit);