diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-19 18:10:17 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-19 18:10:17 -0700 |
commit | 5765040ebfc9a28d9dcfaaaaf3d25840d922de96 (patch) | |
tree | 6fd0c9950beb3c9730ede405269c9a47bbcbf877 /arch/x86/kernel | |
parent | 08839ff8276bd1ba0ce8b2d595f9fe62a5b07210 (diff) | |
parent | de5397ad5b9ad22e2401c4dacdf1bb3b19c05679 (diff) | |
download | blackbird-op-linux-5765040ebfc9a28d9dcfaaaaf3d25840d922de96.tar.gz blackbird-op-linux-5765040ebfc9a28d9dcfaaaaf3d25840d922de96.zip |
Merge branch 'x86-smep-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-smep-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86, cpu: Enable/disable Supervisor Mode Execution Protection
x86, cpu: Add SMEP CPU feature in CR4
x86, cpufeature: Add cpufeature flag for SMEP
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 173f3a3fa1a6..cbc70a27430c 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) } #endif +static int disable_smep __initdata; +static __init int setup_disable_smep(char *arg) +{ + disable_smep = 1; + return 1; +} +__setup("nosmep", setup_disable_smep); + +static __init void setup_smep(struct cpuinfo_x86 *c) +{ + if (cpu_has(c, X86_FEATURE_SMEP)) { + if (unlikely(disable_smep)) { + setup_clear_cpu_cap(X86_FEATURE_SMEP); + clear_in_cr4(X86_CR4_SMEP); + } else + set_in_cr4(X86_CR4_SMEP); + } +} + /* * Some CPU features depend on higher CPUID levels, which may not always * be available due to CPUID level capping or broken virtualization @@ -667,6 +686,8 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) c->cpu_index = 0; #endif filter_cpuid_features(c, false); + + setup_smep(c); } void __init early_cpu_init(void) @@ -752,6 +773,8 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c) #endif } + setup_smep(c); + get_model_name(c); /* Default name */ detect_nopl(c); |