From: "Jan Beulich" Subject: [PATCH] x86: always store APIC ID of CPU Date: Thu, 26 Jun 2014 11:11:50 +0100 Message-ID: <53AC0E06020000780001D873@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part97A562F6.0__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X06em-0005mG-Td for xen-devel@lists.xenproject.org; Thu, 26 Jun 2014 10:11:53 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part97A562F6.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline So far for non-Intel CPUs struct cpuinfo_x86's apicid field didn't get set, despite MCE code consuming it. Do some formatting/ordering adjustment to the touched code at once. Signed-off-by: Jan Beulich --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -152,6 +152,17 @@ static void __cpuinit get_cpu_vendor(str this_cpu =3D &default_cpu; } =20 +/* + * cpuid returns the value latched in the HW at reset, not the APIC ID + * register's value. For any box whose BIOS changes APIC IDs, like + * clustered APIC systems, we must use hard_smp_processor_id. + * + * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID. + */ +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) +{ + return hard_smp_processor_id() >> index_msb; +} =20 /* Do minimum CPU detection early. Fields really needed: vendor, cpuid_level, family, model, mask, cache = alignment. @@ -216,6 +227,7 @@ static void __cpuinit generic_identify(s if (c->x86 >=3D 0x6) c->x86_model +=3D ((tfms >> 16) & 0xF) << 4; c->x86_mask =3D tfms & 15; + c->apicid =3D phys_pkg_id((ebx >> 24) & 0xFF, 0); if ( cpu_has(c, X86_FEATURE_CLFLSH) ) c->x86_clflush_size =3D ((ebx >> 8) & 0xff) * 8; =20 @@ -339,17 +351,6 @@ void __cpuinit identify_cpu(struct cpuin } } =20 -/* cpuid returns the value latched in the HW at reset, not the APIC ID - * register's value. For any box whose BIOS changes APIC IDs, like - * clustered APIC systems, we must use hard_smp_processor_id. - * - * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID. - */ -static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) -{ - return hard_smp_processor_id() >> index_msb; -} - /* leaf 0xb SMT level */ #define SMT_LEVEL 0 =20 @@ -429,14 +430,12 @@ void __cpuinit detect_ht(struct cpuinfo_ u32 eax, ebx, ecx, edx; int index_msb, core_bits; =20 - cpuid(1, &eax, &ebx, &ecx, &edx); - - c->apicid =3D phys_pkg_id((ebx >> 24) & 0xFF, 0); - - if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGAC= Y) - || cpu_has(c, X86_FEATURE_XTOPOLOGY)) + if (!cpu_has(c, X86_FEATURE_HT) || + cpu_has(c, X86_FEATURE_CMP_LEGACY) || + cpu_has(c, X86_FEATURE_XTOPOLOGY)) return; =20 + cpuid(1, &eax, &ebx, &ecx, &edx); c->x86_num_siblings =3D (ebx & 0xff0000) >> 16; =20 if (c->x86_num_siblings =3D=3D 1) { --=__Part97A562F6.0__= Content-Type: text/plain; name="x86-AMD-set-APICID.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-AMD-set-APICID.patch" x86: always store APIC ID of CPU=0A=0ASo far for non-Intel CPUs struct = cpuinfo_x86's apicid field didn't get=0Aset, despite MCE code consuming = it.=0A=0ADo some formatting/ordering adjustment to the touched code at = once.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/cpu/common.c=0A+++ b/xen/arch/x86/cpu/common.c=0A@@ -152,6 = +152,17 @@ static void __cpuinit get_cpu_vendor(str=0A this_cpu =3D = &default_cpu;=0A }=0A =0A+/*=0A+ * cpuid returns the value latched in the = HW at reset, not the APIC ID=0A+ * register's value. For any box whose = BIOS changes APIC IDs, like=0A+ * clustered APIC systems, we must use = hard_smp_processor_id.=0A+ *=0A+ * See Intel's IA-32 SW Dev's Manual Vol2 = under CPUID.=0A+ */=0A+static inline u32 phys_pkg_id(u32 cpuid_apic, int = index_msb)=0A+{=0A+ return hard_smp_processor_id() >> index_msb;=0A+}= =0A =0A /* Do minimum CPU detection early.=0A Fields really needed: = vendor, cpuid_level, family, model, mask, cache alignment.=0A@@ -216,6 = +227,7 @@ static void __cpuinit generic_identify(s=0A if (c->x86 >=3D = 0x6)=0A c->x86_model +=3D ((tfms >> 16) & 0xF) << 4;=0A = c->x86_mask =3D tfms & 15;=0A+ c->apicid =3D phys_pkg_id((ebx >> 24) & = 0xFF, 0);=0A if ( cpu_has(c, X86_FEATURE_CLFLSH) )=0A = c->x86_clflush_size =3D ((ebx >> 8) & 0xff) * 8;=0A =0A@@ -339,17 +351,6 = @@ void __cpuinit identify_cpu(struct cpuin=0A }=0A }=0A =0A-/* cpuid = returns the value latched in the HW at reset, not the APIC ID=0A- * = register's value. For any box whose BIOS changes APIC IDs, like=0A- * = clustered APIC systems, we must use hard_smp_processor_id.=0A- *=0A- * See = Intel's IA-32 SW Dev's Manual Vol2 under CPUID.=0A- */=0A-static inline = u32 phys_pkg_id(u32 cpuid_apic, int index_msb)=0A-{=0A- return hard_smp_pro= cessor_id() >> index_msb;=0A-}=0A-=0A /* leaf 0xb SMT level */=0A #define = SMT_LEVEL 0=0A =0A@@ -429,14 +430,12 @@ void __cpuinit detect_ht(stru= ct cpuinfo_=0A u32 eax, ebx, ecx, edx;=0A int index_msb, = core_bits;=0A =0A- cpuid(1, &eax, &ebx, &ecx, &edx);=0A-=0A- = c->apicid =3D phys_pkg_id((ebx >> 24) & 0xFF, 0);=0A-=0A- if = (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY)=0A- = || cpu_has(c, X86_FEATURE_XTOPOLOGY))=0A+ if (!cpu_has(c, X86_FEATURE= _HT) ||=0A+ cpu_has(c, X86_FEATURE_CMP_LEGACY) ||=0A+ = cpu_has(c, X86_FEATURE_XTOPOLOGY))=0A return;=0A =0A+ cpuid(1, = &eax, &ebx, &ecx, &edx);=0A c->x86_num_siblings =3D (ebx & 0xff0000) = >> 16;=0A =0A if (c->x86_num_siblings =3D=3D 1) {=0A --=__Part97A562F6.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part97A562F6.0__=--