Re: [PATCH v3 1/7] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon models 0x4 through 0x8
From: Fu Hao
Date: Tue Jun 16 2026 - 03:18:18 EST
On 6/15/2026 10:07 PM, Dave Hansen wrote:
On 6/15/26 05:17, Fu Hao wrote:
+ /*
+ * Adjust the die_id and logical_die_id for Hygon models 0x4-0x8.
+ */
+ if (c->x86_model >= 0x4 && c->x86_model <= 0x8) {
+ c->topo.die_id = cpuid_ecx(0x8000001e) & 0xff;
+ c->topo.logical_die_id = (c->topo.die_id >> 4) *
+ topology_amd_nodes_per_pkg() +
+ (c->topo.die_id & 0xf);
+ }
My assumption for Hygon stuff is that there's AMD code _somewhere_ for
99% of it. It's just a matter of using it.
Why doesn't this use parse_8000_001e()?
I think that kind of justification needs to be the baseline for Hygon
work when it adds code. It needs to explain why the code is being added
and why the existing (AMD usually) code doesn't work.
Hi Dave Hansen,
Thank you for the feedback. Let me clarify the situation regarding Hygon
Family 18h Model 4h and newer.
Starting with these models, Hygon CPUs support CPUID leaf 0xb but do not
support leaf 0x80000026. Consequently, the Die ID and Logical Die ID
cannot be derived from the APIC ID space. CPUID leaf 0xb only supports
core and package levels, it cannot enumerate die IDs within a socket.
However, we found that CPUID leaf 0x8000001e (ECX) provides the
necessary information. In Hygon CPU design, the NodeId field [7:0]
encodes both Socket and Die IDs in the format:
Bits [7:4]: Socket ID
Bits [3:0]: Die ID
We can calculate the correct IDs(die_id and logical_die_id) by parsing
this field.
Regarding the reuse of parse_8000_001e():
1. On AMD, this function retrieves amd_node_id, which is an AMD-specific
Node ID. We suspect this is kept for CDD compatibility, but its
semantics differ from Hygon's requirements.
2. AMD derives its Die ID via leaf 0x80000026 (from APIC ID shifts),
whereas Hygon must use the NodeId field from leaf 0x8000001e.
Due to these architectural divergences, the current implementation is
inconsistent for Hygon. To ensure correct topology detection and to
facilitate subsequent Node management and EDAC address translation, we
must explicitly parse the NodeId field for Hygon instead of relying on
amd_node_id.
Please let me know if this explanation clears up the rationale for the
change.
--
Regards,
Fu Hao