public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yhlu.kernel@gmail.com>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Yinghai Lu <yhlu.kernel@gmail.com>
Subject: [PATCH 14/16] x86: cpu common merge generic_identify
Date: Thu,  4 Sep 2008 20:09:12 -0700	[thread overview]
Message-ID: <1220584154-32497-14-git-send-email-yhlu.kernel@gmail.com> (raw)
In-Reply-To: <1220584154-32497-1-git-send-email-yhlu.kernel@gmail.com>

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
---
 arch/x86/kernel/cpu/common.c    |   15 ++++++++++++---
 arch/x86/kernel/cpu/common_64.c |   19 ++++++++++++++++---
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 61a7074..f35baa7 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -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
 	}
 
diff --git a/arch/x86/kernel/cpu/common_64.c b/arch/x86/kernel/cpu/common_64.c
index 68b06a3..869a6ff 100644
--- a/arch/x86/kernel/cpu/common_64.c
+++ b/arch/x86/kernel/cpu/common_64.c
@@ -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 */
 
-- 
1.5.4.5


  parent reply	other threads:[~2008-09-05  3:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-05  3:08 [PATCH 01/16] x86: make detect_ht depends on X86_HT Yinghai Lu
2008-09-05  3:09 ` [PATCH 02/16] x86: make header file the same in common_xx.c Yinghai Lu
2008-09-05  3:09 ` [PATCH 03/16] x86: same gdt_page with marco Yinghai Lu
2008-09-05  3:09 ` [PATCH 04/16] x86: cpu common let 64bit code have 32bit only func Yinghai Lu
2008-09-05  3:09 ` [PATCH 05/16] x86: cpu common make 32bit have 64bit only funcs Yinghai Lu
2008-09-05  3:09 ` [PATCH 06/16] x86: cpu commont have same cpu_init with copying and macro Yinghai Lu
2008-09-05  3:09 ` [PATCH 07/16] x86: cpu common merge switch_to_new_gdt Yinghai Lu
2008-09-05  3:09 ` [PATCH 08/16] x86: cpu common merge default_init Yinghai Lu
2008-09-05  3:09 ` [PATCH 09/16] x86: cpu common merge display_cacheinfo Yinghai Lu
2008-09-05  3:09 ` [PATCH 10/16] x86: cpu common merge detect_ht Yinghai Lu
2008-09-05  3:09 ` [PATCH 11/16] x86: cpu common merge get_cpu_cap Yinghai Lu
2008-09-05  3:09 ` [PATCH 12/16] x86: cpu common merge early_identify_cpu Yinghai Lu
2008-09-05  3:09 ` [PATCH 13/16] x86: cpu common merge print_cpu_info Yinghai Lu
2008-09-05  3:09 ` Yinghai Lu [this message]
2008-09-05  3:09 ` [PATCH 15/16] x86: cpu common merge identify_cpu Yinghai Lu
2008-09-05  3:09 ` [PATCH 16/16] x86: use common.c for 64 bit Yinghai Lu
2008-09-05  7:46   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1220584154-32497-14-git-send-email-yhlu.kernel@gmail.com \
    --to=yhlu.kernel@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox