x86: cpu/common*.c, merge generic_identify()
authorYinghai Lu <yhlu.kernel@gmail.com>
Fri, 5 Sep 2008 03:09:12 +0000 (20:09 -0700)
committerIngo Molnar <mingo@elte.hu>
Fri, 5 Sep 2008 07:40:55 +0000 (09:40 +0200)
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/common_64.c

index 61a70748213e687ee15de2d6c5186266852453e1..f35baa7f3036fb4bf003111770028cfffab51d3a 100644 (file)
@@ -548,6 +548,10 @@ void __init early_cpu_init(void)
  * of early VIA chips and (more importantly) broken virtualizers that
  * are not easy to detect.  Hence, probe for it based on first
  * principles.
+ *
+ * Note: no 64-bit chip is known to lack these, but put the code here
+ * for consistency with 32 bits, and to make it utterly trivial to
+ * diagnose the problem should it ever surface.
  */
 static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
 {
@@ -586,11 +590,16 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 
        if (c->cpuid_level >= 0x00000001) {
                c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xFF;
-#ifdef CONFIG_X86_HT
+#ifdef CONFIG_X86_32
+# ifdef CONFIG_X86_HT
                c->apicid = phys_pkg_id(c->initial_apicid, 0);
-               c->phys_proc_id = c->initial_apicid;
-#else
+# else
                c->apicid = c->initial_apicid;
+# endif
+#endif
+
+#ifdef CONFIG_X86_HT
+               c->phys_proc_id = c->initial_apicid;
 #endif
        }
 
index 68b06a39dcaca1e6ffaac7e283a563f35665c71a..869a6ff9f7dc0cf8f889ae797cbbeff887731071 100644 (file)
@@ -581,6 +581,9 @@ static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
 
 static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 {
+       if (!have_cpuid_p())
+               return;
+
        c->extended_cpuid_level = 0;
 
        cpu_detect(c);
@@ -589,11 +592,21 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 
        get_cpu_cap(c);
 
-       c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xff;
-#ifdef CONFIG_SMP
-       c->phys_proc_id = c->initial_apicid;
+       if (c->cpuid_level >= 0x00000001) {
+               c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xFF;
+#ifdef CONFIG_X86_32
+# ifdef CONFIG_X86_HT
+               c->apicid = phys_pkg_id(c->initial_apicid, 0);
+# else
+               c->apicid = c->initial_apicid;
+# endif
 #endif
 
+#ifdef CONFIG_X86_HT
+               c->phys_proc_id = c->initial_apicid;
+#endif
+       }
+
        if (c->extended_cpuid_level >= 0x80000004)
                get_model_name(c); /* Default name */