Merge branch 'sh-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal...
[pandora-kernel.git] / arch / x86 / kernel / cpu / common.c
index 173f3a3..c8b4162 100644 (file)
@@ -254,6 +254,25 @@ static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
 }
 #endif
 
+static int disable_smep __cpuinitdata;
+static __init int setup_disable_smep(char *arg)
+{
+       disable_smep = 1;
+       return 1;
+}
+__setup("nosmep", setup_disable_smep);
+
+static __cpuinit 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);