From owner-svn-src-all@FreeBSD.ORG Thu Apr 30 22:10:05 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D0511065689; Thu, 30 Apr 2009 22:10:05 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20F888FC1E; Thu, 30 Apr 2009 22:10:05 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3UMA54X024214; Thu, 30 Apr 2009 22:10:05 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3UMA4Zq024212; Thu, 30 Apr 2009 22:10:04 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <200904302210.n3UMA4Zq024212@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 30 Apr 2009 22:10:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191708 - in head/sys: amd64/amd64 i386/i386 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2009 22:10:05 -0000 Author: jkim Date: Thu Apr 30 22:10:04 2009 New Revision: 191708 URL: http://svn.freebsd.org/changeset/base/191708 Log: - 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] Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/i386/i386/mp_machdep.c Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Thu Apr 30 21:48:31 2009 (r191707) +++ head/sys/amd64/amd64/mp_machdep.c Thu Apr 30 22:10:04 2009 (r191708) @@ -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) Modified: head/sys/i386/i386/mp_machdep.c ============================================================================== --- head/sys/i386/i386/mp_machdep.c Thu Apr 30 21:48:31 2009 (r191707) +++ head/sys/i386/i386/mp_machdep.c Thu Apr 30 22:10:04 2009 (r191708) @@ -345,6 +345,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) @@ -352,9 +356,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 * @@ -366,6 +371,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)