x86/cpu/hygon: Fix the CPU topology evaluation for real
[platform/kernel/linux-rpi.git] / arch / x86 / kernel / cpu / hygon.c
index defdc59..a7b3ef4 100644 (file)
@@ -87,8 +87,12 @@ static void hygon_get_topology(struct cpuinfo_x86 *c)
                if (!err)
                        c->x86_coreid_bits = get_count_order(c->x86_max_cores);
 
-               /* Socket ID is ApicId[6] for these processors. */
-               c->phys_proc_id = c->apicid >> APICID_SOCKET_ID_BIT;
+               /*
+                * Socket ID is ApicId[6] for the processors with model <= 0x3
+                * when running on host.
+                */
+               if (!boot_cpu_has(X86_FEATURE_HYPERVISOR) && c->x86_model <= 0x3)
+                       c->phys_proc_id = c->apicid >> APICID_SOCKET_ID_BIT;
 
                cacheinfo_hygon_init_llc_id(c, cpu);
        } else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {