Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 326238
b: refs/heads/master
c: 52b6179
h: refs/heads/master
v: v3
  • Loading branch information
H. Peter Anvin committed Sep 21, 2012
1 parent e802d0b commit a08319e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 63bcff2a307b9bcc712a8251eb27df8b2e117967
refs/heads/master: 52b6179ac87d33c2eeaff5292786a10fe98cff64
6 changes: 5 additions & 1 deletion trunk/Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
noexec=on: enable non-executable mappings (default)
noexec=off: disable non-executable mappings

nosmap [X86]
Disable SMAP (Supervisor Mode Access Prevention)
even if it is supported by processor.

nosmep [X86]
Disable SMEP (Supervisor Mode Execution Protection)
Disable SMEP (Supervisor Mode Execution Prevention)
even if it is supported by processor.

noexec32 [X86-64]
Expand Down
26 changes: 26 additions & 0 deletions trunk/arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,31 @@ static __cpuinit void setup_smep(struct cpuinfo_x86 *c)
}
}

static int disable_smap __cpuinitdata;
static __init int setup_disable_smap(char *arg)
{
disable_smap = 1;
return 1;
}
__setup("nosmap", setup_disable_smap);

static __cpuinit void setup_smap(struct cpuinfo_x86 *c)
{
if (cpu_has(c, X86_FEATURE_SMAP)) {
if (unlikely(disable_smap)) {
setup_clear_cpu_cap(X86_FEATURE_SMAP);
clear_in_cr4(X86_CR4_SMAP);
} else {
set_in_cr4(X86_CR4_SMAP);
/*
* Don't use clac() here since alternatives
* haven't run yet...
*/
asm volatile(__stringify(__ASM_CLAC) ::: "memory");
}
}
}

/*
* Some CPU features depend on higher CPUID levels, which may not always
* be available due to CPUID level capping or broken virtualization
Expand Down Expand Up @@ -713,6 +738,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
filter_cpuid_features(c, false);

setup_smep(c);
setup_smap(c);

if (this_cpu->c_bsp_init)
this_cpu->c_bsp_init(c);
Expand Down

0 comments on commit a08319e

Please sign in to comment.