diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-13 20:19:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-13 20:19:47 -0400 |
commit | 708d0b41a26907ac83cde41dd5a75b5a2f8f1218 (patch) | |
tree | 81fec9b45c052e98b563a93d5b6548e9e7630e34 /arch/x86/include | |
parent | f1d0d14120a8a6224a8aead925cf4310f48947d5 (diff) | |
parent | 9298b815efe500b272e4084ed05eeae7a92b5340 (diff) |
Merge branch 'x86-cpufeature-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cpufeature updates from Ingo Molnar:
"This tree includes the following changes:
- Introduce DISABLED_MASK to list disabled CPU features, to simplify
CPU feature handling and avoid excessive #ifdefs
- Remove the lightly used cpu_has_pae() primitive"
* 'x86-cpufeature-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86: Add more disabled features
x86: Introduce disabled-features
x86: Axe the lightly-used cpu_has_pae
Diffstat (limited to 'arch/x86/include')
-rw-r--r-- | arch/x86/include/asm/cpufeature.h | 52 | ||||
-rw-r--r-- | arch/x86/include/asm/disabled-features.h | 39 |
2 files changed, 67 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 |
384 | extern void warn_pre_alternatives(void); | 388 | extern void warn_pre_alternatives(void); |
385 | extern bool __static_cpu_has_safe(u16 bit); | 389 | extern bool __static_cpu_has_safe(u16 bit); |
diff --git a/arch/x86/include/asm/disabled-features.h b/arch/x86/include/asm/disabled-features.h new file mode 100644 index 000000000000..97534a7d38e3 --- /dev/null +++ b/arch/x86/include/asm/disabled-features.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef _ASM_X86_DISABLED_FEATURES_H | ||
2 | #define _ASM_X86_DISABLED_FEATURES_H | ||
3 | |||
4 | /* These features, although they might be available in a CPU | ||
5 | * will not be used because the compile options to support | ||
6 | * them are not present. | ||
7 | * | ||
8 | * This code allows them to be checked and disabled at | ||
9 | * compile time without an explicit #ifdef. Use | ||
10 | * cpu_feature_enabled(). | ||
11 | */ | ||
12 | |||
13 | #ifdef CONFIG_X86_64 | ||
14 | # define DISABLE_VME (1<<(X86_FEATURE_VME & 31)) | ||
15 | # define DISABLE_K6_MTRR (1<<(X86_FEATURE_K6_MTRR & 31)) | ||
16 | # define DISABLE_CYRIX_ARR (1<<(X86_FEATURE_CYRIX_ARR & 31)) | ||
17 | # define DISABLE_CENTAUR_MCR (1<<(X86_FEATURE_CENTAUR_MCR & 31)) | ||
18 | #else | ||
19 | # define DISABLE_VME 0 | ||
20 | # define DISABLE_K6_MTRR 0 | ||
21 | # define DISABLE_CYRIX_ARR 0 | ||
22 | # define DISABLE_CENTAUR_MCR 0 | ||
23 | #endif /* CONFIG_X86_64 */ | ||
24 | |||
25 | /* | ||
26 | * Make sure to add features to the correct mask | ||
27 | */ | ||
28 | #define DISABLED_MASK0 (DISABLE_VME) | ||
29 | #define DISABLED_MASK1 0 | ||
30 | #define DISABLED_MASK2 0 | ||
31 | #define DISABLED_MASK3 (DISABLE_CYRIX_ARR|DISABLE_CENTAUR_MCR|DISABLE_K6_MTRR) | ||
32 | #define DISABLED_MASK4 0 | ||
33 | #define DISABLED_MASK5 0 | ||
34 | #define DISABLED_MASK6 0 | ||
35 | #define DISABLED_MASK7 0 | ||
36 | #define DISABLED_MASK8 0 | ||
37 | #define DISABLED_MASK9 0 | ||
38 | |||
39 | #endif /* _ASM_X86_DISABLED_FEATURES_H */ | ||