summaryrefslogtreecommitdiffstats
path: root/sys/amd64/amd64/mp_machdep.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2011-05-06 22:45:33 +0000
committerattilio <attilio@FreeBSD.org>2011-05-06 22:45:33 +0000
commita0b51ba62fa86f5faf7bbd81e0b91ba497fec05a (patch)
treeb6f763bb2e3a9eaf32a3ee9adca98cc9e867998c /sys/amd64/amd64/mp_machdep.c
parent8534b0c2951283889da00ca8a244058185638240 (diff)
downloadFreeBSD-src-a0b51ba62fa86f5faf7bbd81e0b91ba497fec05a.zip
FreeBSD-src-a0b51ba62fa86f5faf7bbd81e0b91ba497fec05a.tar.gz
MFC
Diffstat (limited to 'sys/amd64/amd64/mp_machdep.c')
-rw-r--r--sys/amd64/amd64/mp_machdep.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index 57e91a8..9e20f95 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -177,11 +177,34 @@ mem_range_AP_init(void)
static void
topo_probe_amd(void)
{
+ int core_id_bits;
+ int id;
/* AMD processors do not support HTT. */
- cpu_cores = (amd_feature2 & AMDID2_CMP) != 0 ?
- (cpu_procinfo2 & AMDID_CMP_CORES) + 1 : 1;
cpu_logical = 1;
+
+ if ((amd_feature2 & AMDID2_CMP) == 0) {
+ cpu_cores = 1;
+ return;
+ }
+
+ core_id_bits = (cpu_procinfo2 & AMDID_COREID_SIZE) >>
+ AMDID_COREID_SIZE_SHIFT;
+ if (core_id_bits == 0) {
+ cpu_cores = (cpu_procinfo2 & AMDID_CMP_CORES) + 1;
+ return;
+ }
+
+ /* Fam 10h and newer should get here. */
+ for (id = 0; id <= MAX_APIC_ID; id++) {
+ /* Check logical CPU availability. */
+ if (!cpu_info[id].cpu_present || cpu_info[id].cpu_disabled)
+ continue;
+ /* Check if logical CPU has the same package ID. */
+ if ((id >> core_id_bits) != (boot_cpu_id >> core_id_bits))
+ continue;
+ cpu_cores++;
+ }
}
/*
OpenPOWER on IntegriCloud