diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c index a4d667ef2068352a0cea2410a76585c945601d7f..1746578a0c7207bb1c2b473f373bd3e65d9b6eb2 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) {