From 3a60607d9c86f8a3fcab4147175c522c3e112d9b Mon Sep 17 00:00:00 2001 From: Wenhui Fan Date: Fri, 17 Apr 2026 15:39:33 +0800 Subject: [PATCH] anolis: x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon models 0x4-0x8 ANBZ: #33318 The die ID should be got from the NodeId field of CPUID leaf 0x8000001e ecx for Hygon models 0x4-0x8 processors. Hygon-SIG: commit none hygon anolis: x86/cpu/hygon: Adjust the die_id and logical_die_id for Hygon models 0x4-0x8 Signed-off-by: Wenhui Fan --- arch/x86/kernel/cpu/hygon.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c index a4d667ef2068..1746578a0c72 100644 --- a/arch/x86/kernel/cpu/hygon.c +++ b/arch/x86/kernel/cpu/hygon.c @@ -251,6 +251,18 @@ static void early_init_hygon(struct cpuinfo_x86 *c) early_detect_mem_encrypt(c); } +/* + * Adjust the die_id and logical_die_id for Hygon model4h~8h. + */ +static void cpu_topology_fixup_hygon(struct cpuinfo_x86 *c) +{ + 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); + } +} + static void init_hygon(struct cpuinfo_x86 *c) { u64 vm_cr; @@ -280,6 +292,8 @@ static void init_hygon(struct cpuinfo_x86 *c) init_hygon_cacheinfo(c); + cpu_topology_fixup_hygon(c); + if (cpu_has(c, X86_FEATURE_SVM)) { rdmsrl(MSR_VM_CR, vm_cr); if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) { -- Gitee