diff options
Diffstat (limited to 'arch/x86/kernel/cpu/common.c')
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index e2ced0074a45..c8b41623377f 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -254,6 +254,25 @@ static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c) | |||
254 | } | 254 | } |
255 | #endif | 255 | #endif |
256 | 256 | ||
257 | static int disable_smep __cpuinitdata; | ||
258 | static __init int setup_disable_smep(char *arg) | ||
259 | { | ||
260 | disable_smep = 1; | ||
261 | return 1; | ||
262 | } | ||
263 | __setup("nosmep", setup_disable_smep); | ||
264 | |||
265 | static __cpuinit void setup_smep(struct cpuinfo_x86 *c) | ||
266 | { | ||
267 | if (cpu_has(c, X86_FEATURE_SMEP)) { | ||
268 | if (unlikely(disable_smep)) { | ||
269 | setup_clear_cpu_cap(X86_FEATURE_SMEP); | ||
270 | clear_in_cr4(X86_CR4_SMEP); | ||
271 | } else | ||
272 | set_in_cr4(X86_CR4_SMEP); | ||
273 | } | ||
274 | } | ||
275 | |||
257 | /* | 276 | /* |
258 | * Some CPU features depend on higher CPUID levels, which may not always | 277 | * Some CPU features depend on higher CPUID levels, which may not always |
259 | * be available due to CPUID level capping or broken virtualization | 278 | * be available due to CPUID level capping or broken virtualization |
@@ -565,8 +584,7 @@ void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c) | |||
565 | 584 | ||
566 | cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx); | 585 | cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx); |
567 | 586 | ||
568 | if (eax > 0) | 587 | c->x86_capability[9] = ebx; |
569 | c->x86_capability[9] = ebx; | ||
570 | } | 588 | } |
571 | 589 | ||
572 | /* AMD-defined flags: level 0x80000001 */ | 590 | /* AMD-defined flags: level 0x80000001 */ |
@@ -668,6 +686,8 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) | |||
668 | c->cpu_index = 0; | 686 | c->cpu_index = 0; |
669 | #endif | 687 | #endif |
670 | filter_cpuid_features(c, false); | 688 | filter_cpuid_features(c, false); |
689 | |||
690 | setup_smep(c); | ||
671 | } | 691 | } |
672 | 692 | ||
673 | void __init early_cpu_init(void) | 693 | void __init early_cpu_init(void) |
@@ -753,6 +773,8 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c) | |||
753 | #endif | 773 | #endif |
754 | } | 774 | } |
755 | 775 | ||
776 | setup_smep(c); | ||
777 | |||
756 | get_model_name(c); /* Default name */ | 778 | get_model_name(c); /* Default name */ |
757 | 779 | ||
758 | detect_nopl(c); | 780 | detect_nopl(c); |