aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-09-21 15:43:13 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2012-09-21 15:45:27 -0400
commit52b6179ac87d33c2eeaff5292786a10fe98cff64 (patch)
tree6ec59d41c4840844031c5030c6fbbd4cdd40819d /arch
parent63bcff2a307b9bcc712a8251eb27df8b2e117967 (diff)
x86, smap: Turn on Supervisor Mode Access Prevention
If Supervisor Mode Access Prevention is available and not disabled by the user, turn it on. Also fix the expansion of SMEP (Supervisor Mode Execution Prevention.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Link: http://lkml.kernel.org/r/1348256595-29119-10-git-send-email-hpa@linux.intel.com
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/cpu/common.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index cd43e525fde8..7d35d6594118 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -278,6 +278,31 @@ static __cpuinit void setup_smep(struct cpuinfo_x86 *c)
278 } 278 }
279} 279}
280 280
281static int disable_smap __cpuinitdata;
282static __init int setup_disable_smap(char *arg)
283{
284 disable_smap = 1;
285 return 1;
286}
287__setup("nosmap", setup_disable_smap);
288
289static __cpuinit void setup_smap(struct cpuinfo_x86 *c)
290{
291 if (cpu_has(c, X86_FEATURE_SMAP)) {
292 if (unlikely(disable_smap)) {
293 setup_clear_cpu_cap(X86_FEATURE_SMAP);
294 clear_in_cr4(X86_CR4_SMAP);
295 } else {
296 set_in_cr4(X86_CR4_SMAP);
297 /*
298 * Don't use clac() here since alternatives
299 * haven't run yet...
300 */
301 asm volatile(__stringify(__ASM_CLAC) ::: "memory");
302 }
303 }
304}
305
281/* 306/*
282 * Some CPU features depend on higher CPUID levels, which may not always 307 * Some CPU features depend on higher CPUID levels, which may not always
283 * be available due to CPUID level capping or broken virtualization 308 * be available due to CPUID level capping or broken virtualization
@@ -713,6 +738,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
713 filter_cpuid_features(c, false); 738 filter_cpuid_features(c, false);
714 739
715 setup_smep(c); 740 setup_smep(c);
741 setup_smap(c);
716 742
717 if (this_cpu->c_bsp_init) 743 if (this_cpu->c_bsp_init)
718 this_cpu->c_bsp_init(c); 744 this_cpu->c_bsp_init(c);