Merge branch 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb...
[pandora-kernel.git] / arch / x86 / kernel / cpu / common.c
index 745a602..22a073d 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
@@ -458,13 +477,6 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
        if (smp_num_siblings <= 1)
                goto out;
 
-       if (smp_num_siblings > nr_cpu_ids) {
-               pr_warning("CPU: Unsupported number of siblings %d",
-                          smp_num_siblings);
-               smp_num_siblings = 1;
-               return;
-       }
-
        index_msb = get_count_order(smp_num_siblings);
        c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, index_msb);
 
@@ -565,8 +577,7 @@ void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
 
                cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx);
 
-               if (eax > 0)
-                       c->x86_capability[9] = ebx;
+               c->x86_capability[9] = ebx;
        }
 
        /* AMD-defined flags: level 0x80000001 */
@@ -668,6 +679,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)
@@ -675,7 +688,7 @@ void __init early_cpu_init(void)
        const struct cpu_dev *const *cdev;
        int count = 0;
 
-#ifdef PROCESSOR_SELECT
+#ifdef CONFIG_PROCESSOR_SELECT
        printk(KERN_INFO "KERNEL supported cpus:\n");
 #endif
 
@@ -687,7 +700,7 @@ void __init early_cpu_init(void)
                cpu_devs[count] = cpudev;
                count++;
 
-#ifdef PROCESSOR_SELECT
+#ifdef CONFIG_PROCESSOR_SELECT
                {
                        unsigned int j;
 
@@ -753,6 +766,8 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 #endif
        }
 
+       setup_smep(c);
+
        get_model_name(c); /* Default name */
 
        detect_nopl(c);
@@ -869,7 +884,7 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
 
        select_idle_routine(c);
 
-#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64)
+#ifdef CONFIG_NUMA
        numa_add_cpu(smp_processor_id());
 #endif
 }