summaryrefslogtreecommitdiffstats
path: root/sys/amd64/amd64/mp_machdep.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2009-04-30 22:10:04 +0000
committerjkim <jkim@FreeBSD.org>2009-04-30 22:10:04 +0000
commit680fc00a3e0b2498c18515235235803888960e24 (patch)
tree1b244cce17d8a8160dd8c239c63350ddd2878b5b /sys/amd64/amd64/mp_machdep.c
parentdfaf9ddf7b444de81f8b3622ee8cc24da37b6256 (diff)
downloadFreeBSD-src-680fc00a3e0b2498c18515235235803888960e24.zip
FreeBSD-src-680fc00a3e0b2498c18515235235803888960e24.tar.gz
- Fix divide-by-zero panic when SMP kernel is used on UP system[1].
- Avoid possible divide-by-zero panic on SMP system when the CPUID is disabled, unsupported, or buggy. Submitted by: pluknet (pluknet at gmail dot com)[1]
Diffstat (limited to 'sys/amd64/amd64/mp_machdep.c')
-rw-r--r--sys/amd64/amd64/mp_machdep.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index 8bc47e5..ffda046 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -292,6 +292,10 @@ topo_probe_0x4(void)
static void
topo_probe(void)
{
+ static int cpu_topo_probed = 0;
+
+ if (cpu_topo_probed)
+ return;
logical_cpus = logical_cpus_mask = 0;
if (cpu_high >= 0xb)
@@ -299,9 +303,10 @@ topo_probe(void)
else if (cpu_high)
topo_probe_0x4();
if (cpu_cores == 0)
- cpu_cores = mp_ncpus;
+ cpu_cores = mp_ncpus > 0 ? mp_ncpus : 1;
if (cpu_logical == 0)
cpu_logical = 1;
+ cpu_topo_probed = 1;
}
struct cpu_group *
@@ -313,6 +318,7 @@ cpu_topo(void)
* Determine whether any threading flags are
* necessry.
*/
+ topo_probe();
if (cpu_logical > 1 && hyperthreading_cpus)
cg_flags = CG_FLAG_HTT;
else if (cpu_logical > 1)
OpenPOWER on IntegriCloud