From owner-svn-src-head@FreeBSD.ORG Tue Jan 3 20:53:59 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29E6F106568F; Tue, 3 Jan 2012 20:53:59 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F322D8FC14; Tue, 3 Jan 2012 20:53:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q03KrwW5042661; Tue, 3 Jan 2012 20:53:58 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q03KrwAk042659; Tue, 3 Jan 2012 20:53:58 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201201032053.q03KrwAk042659@svn.freebsd.org> From: John Baldwin Date: Tue, 3 Jan 2012 20:53:58 +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: r229427 - head/sys/x86/acpica X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2012 20:53:59 -0000 Author: jhb Date: Tue Jan 3 20:53:58 2012 New Revision: 229427 URL: http://svn.freebsd.org/changeset/base/229427 Log: Fix a few bugs in the SRAT parsing code: - Actually increment ndomain when building our list of known domains so that we can properly renumber them to be 0-based and dense. - If the number of domains exceeds the configured maximum (VM_NDOMAIN), bail out of processing the SRAT and disable NUMA rather than hitting an obscure panic later. - Don't bother parsing the SRAT at all if VM_NDOMAIN is set to 1 to disable NUMA (the default). Reported by: phk (2) MFC after: 1 week Modified: head/sys/x86/acpica/srat.c Modified: head/sys/x86/acpica/srat.c ============================================================================== --- head/sys/x86/acpica/srat.c Tue Jan 3 20:53:16 2012 (r229426) +++ head/sys/x86/acpica/srat.c Tue Jan 3 20:53:58 2012 (r229427) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include +#if VM_NDOMAIN > 1 struct cpu_info { int enabled:1; int has_memory:1; @@ -237,9 +238,9 @@ check_phys_avail(void) /* * Renumber the memory domains to be compact and zero-based if not - * already. + * already. Returns an error if there are too many domains. */ -static void +static int renumber_domains(void) { int domains[VM_PHYSSEG_MAX]; @@ -261,6 +262,11 @@ renumber_domains(void) for (j = ndomain; j > slot; j--) domains[j] = domains[j - 1]; domains[slot] = mem_info[i].domain; + ndomain++; + if (ndomain > VM_NDOMAIN) { + printf("SRAT: Too many memory domains\n"); + return (EFBIG); + } } /* Renumber each domain to its index in the sorted 'domains' list. */ @@ -280,6 +286,7 @@ renumber_domains(void) if (cpus[j].enabled && cpus[j].domain == domains[i]) cpus[j].domain = i; } + return (0); } /* @@ -306,13 +313,12 @@ parse_srat(void *dummy) srat_walk_table(srat_parse_entry, &error); acpi_unmap_table(srat); srat = NULL; - if (error || check_domains() != 0 || check_phys_avail() != 0) { + if (error || check_domains() != 0 || check_phys_avail() != 0 || + renumber_domains() != 0) { srat_physaddr = 0; return; } - renumber_domains(); - /* Point vm_phys at our memory affinity table. */ mem_affinity = mem_info; } @@ -354,3 +360,4 @@ srat_set_cpus(void *dummy) } } SYSINIT(srat_set_cpus, SI_SUB_CPU, SI_ORDER_ANY, srat_set_cpus, NULL); +#endif /* VM_NDOMAIN > 1 */