Re: [PATCH 2/2] x86/cpu/topology: Use initial APICID from XTOPOEXT on AMD/HYGON

From: K Prateek Nayak
Date: Wed Jun 18 2025 - 01:26:45 EST


Hello Naveen,

On 6/18/2025 9:30 AM, Naveen N Rao wrote:
diff --git a/arch/x86/kernel/cpu/topology_amd.c b/arch/x86/kernel/cpu/topology_amd.c
index fec849fff82f..2ff6988e020a 100644
--- a/arch/x86/kernel/cpu/topology_amd.c
+++ b/arch/x86/kernel/cpu/topology_amd.c
@@ -80,7 +80,13 @@ static bool parse_8000_001e(struct topo_scan *tscan, bool has_topoext)
cpuid_leaf(0x8000001e, &leaf);
- tscan->c->topo.initial_apicid = leaf.ext_apic_id;
+ /*
+ * Prefer initial_apicid parsed from CPUID leaf 0x8000026 or 0xb
+ * if available. Otherwise prefer the one from leaf 0x8000001e
+ * over 0x1.
+ */
+ if (!has_topoext)
+ tscan->c->topo.initial_apicid = leaf.ext_apic_id;

My understanding is that the rest of this function continues to work
properly with an all-zero return value from CPUID leaf 0x8000001e - data
from topoext is preferred where available, and other sources are used
for llc_id.

Yes. QEMU just errs on the side of caution for CoreID collision in
0x8000001e and "NumSharingCache" in 0x8000001d EAX[25:14] can still
represent 2^12 (4096) CPUs in each cache domain which is larger than
the total number of vCPUs possible currently I believe.

And, this fixes the firmware bug warning seen during a guest boot in
qemu for me, so for this patch:
Tested-by: Naveen N Rao (AMD) <naveen@xxxxxxxxxx>

Thank you for debugging the issue and testing :)

--
Thanks and Regards,
Prateek