aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 20:19:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-13 20:19:47 -0400
commit708d0b41a26907ac83cde41dd5a75b5a2f8f1218 (patch)
tree81fec9b45c052e98b563a93d5b6548e9e7630e34 /arch
parentf1d0d14120a8a6224a8aead925cf4310f48947d5 (diff)
parent9298b815efe500b272e4084ed05eeae7a92b5340 (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')
-rw-r--r--arch/x86/boot/mkcpustr.c1
-rw-r--r--arch/x86/include/asm/cpufeature.h52
-rw-r--r--arch/x86/include/asm/disabled-features.h39
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/cpu/mtrr/main.c6
-rw-r--r--arch/x86/kernel/machine_kexec_32.c3
6 files changed, 74 insertions, 29 deletions
diff --git a/arch/x86/boot/mkcpustr.c b/arch/x86/boot/mkcpustr.c
index 4579eff0ef4d..637097e66a62 100644
--- a/arch/x86/boot/mkcpustr.c
+++ b/arch/x86/boot/mkcpustr.c
@@ -16,6 +16,7 @@
16#include <stdio.h> 16#include <stdio.h>
17 17
18#include "../include/asm/required-features.h" 18#include "../include/asm/required-features.h"
19#include "../include/asm/disabled-features.h"
19#include "../include/asm/cpufeature.h" 20#include "../include/asm/cpufeature.h"
20#include "../kernel/cpu/capflags.c" 21#include "../kernel/cpu/capflags.c"
21 22
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);
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 */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index d8b1166c7888..ef58886ba61c 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1398,7 +1398,7 @@ void cpu_init(void)
1398 1398
1399 printk(KERN_INFO "Initializing CPU#%d\n", cpu); 1399 printk(KERN_INFO "Initializing CPU#%d\n", cpu);
1400 1400
1401 if (cpu_has_vme || cpu_has_tsc || cpu_has_de) 1401 if (cpu_feature_enabled(X86_FEATURE_VME) || cpu_has_tsc || cpu_has_de)
1402 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); 1402 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
1403 1403
1404 load_current_idt(); 1404 load_current_idt();
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index f961de9964c7..ea5f363a1948 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -707,7 +707,7 @@ void __init mtrr_bp_init(void)
707 } else { 707 } else {
708 switch (boot_cpu_data.x86_vendor) { 708 switch (boot_cpu_data.x86_vendor) {
709 case X86_VENDOR_AMD: 709 case X86_VENDOR_AMD:
710 if (cpu_has_k6_mtrr) { 710 if (cpu_feature_enabled(X86_FEATURE_K6_MTRR)) {
711 /* Pre-Athlon (K6) AMD CPU MTRRs */ 711 /* Pre-Athlon (K6) AMD CPU MTRRs */
712 mtrr_if = mtrr_ops[X86_VENDOR_AMD]; 712 mtrr_if = mtrr_ops[X86_VENDOR_AMD];
713 size_or_mask = SIZE_OR_MASK_BITS(32); 713 size_or_mask = SIZE_OR_MASK_BITS(32);
@@ -715,14 +715,14 @@ void __init mtrr_bp_init(void)
715 } 715 }
716 break; 716 break;
717 case X86_VENDOR_CENTAUR: 717 case X86_VENDOR_CENTAUR:
718 if (cpu_has_centaur_mcr) { 718 if (cpu_feature_enabled(X86_FEATURE_CENTAUR_MCR)) {
719 mtrr_if = mtrr_ops[X86_VENDOR_CENTAUR]; 719 mtrr_if = mtrr_ops[X86_VENDOR_CENTAUR];
720 size_or_mask = SIZE_OR_MASK_BITS(32); 720 size_or_mask = SIZE_OR_MASK_BITS(32);
721 size_and_mask = 0; 721 size_and_mask = 0;
722 } 722 }
723 break; 723 break;
724 case X86_VENDOR_CYRIX: 724 case X86_VENDOR_CYRIX:
725 if (cpu_has_cyrix_arr) { 725 if (cpu_feature_enabled(X86_FEATURE_CYRIX_ARR)) {
726 mtrr_if = mtrr_ops[X86_VENDOR_CYRIX]; 726 mtrr_if = mtrr_ops[X86_VENDOR_CYRIX];
727 size_or_mask = SIZE_OR_MASK_BITS(32); 727 size_or_mask = SIZE_OR_MASK_BITS(32);
728 size_and_mask = 0; 728 size_and_mask = 0;
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
index 1667b1de8d5d..72e8e310258d 100644
--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -247,7 +247,8 @@ void machine_kexec(struct kimage *image)
247 /* now call it */ 247 /* now call it */
248 image->start = relocate_kernel_ptr((unsigned long)image->head, 248 image->start = relocate_kernel_ptr((unsigned long)image->head,
249 (unsigned long)page_list, 249 (unsigned long)page_list,
250 image->start, cpu_has_pae, 250 image->start,
251 boot_cpu_has(X86_FEATURE_PAE),
251 image->preserve_context); 252 image->preserve_context);
252 253
253#ifdef CONFIG_KEXEC_JUMP 254#ifdef CONFIG_KEXEC_JUMP