[PATCH v2 1/8] x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon models 0x4-0x8

From: Fu Hao

Date: Tue Apr 07 2026 - 04:25:46 EST


The die ID should be got from the NodeId field of CPUID leaf 0x8000001e
ecx for Hygon models 0x4-0x8 processors.

Signed-off-by: Fu Hao <fuhao@xxxxxxxxxxxxxx>
---
arch/x86/kernel/cpu/hygon.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c
index 7f95a74e4..0bf99072f 100644
--- a/arch/x86/kernel/cpu/hygon.c
+++ b/arch/x86/kernel/cpu/hygon.c
@@ -191,6 +191,16 @@ static void init_hygon(struct cpuinfo_x86 *c)

init_hygon_cacheinfo(c);

+ /*
+ * 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);
+ }
+
if (cpu_has(c, X86_FEATURE_SVM)) {
rdmsrq(MSR_VM_CR, vm_cr);
if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) {
--
2.34.1