}
}
+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
filter_cpuid_features(c, false);
setup_smep(c);
+ setup_smap(c);
if (this_cpu->c_bsp_init)
this_cpu->c_bsp_init(c);
/* Flags to clear on syscall */
wrmsrl(MSR_SYSCALL_MASK,
- X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|X86_EFLAGS_IOPL);
+ X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|
+ X86_EFLAGS_IOPL|X86_EFLAGS_AC);
}
unsigned long kernel_eflags;