Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Oct 2019 18:28:58 +0000 (UTC)
From:      Leandro Lupori <luporl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r353897 - head/sys/powerpc/ofw
Message-ID:  <201910221828.x9MISwK5035952@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luporl
Date: Tue Oct 22 18:28:58 2019
New Revision: 353897
URL: https://svnweb.freebsd.org/changeset/base/353897

Log:
  [PPC] Avoid underflows in NUMA domains
  
  On POWER8 systems with only one memory domain, the "ibm,associativity"
  number that corresponds to it is 0, unlike POWER9 systems with two
  or more domains, in which the minimum value is 1.
  
  In POWER8 case, subtracting 1 causes an underflow on the unsigned domain
  variable and a subsequent index out-of-bounds access.
  
  Reviewed by:	jhibbits
  Tested by:	bdragon, luporl

Modified:
  head/sys/powerpc/ofw/ofw_machdep.c
  head/sys/powerpc/ofw/ofw_pcibus.c

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_machdep.c	Tue Oct 22 18:05:15 2019	(r353896)
+++ head/sys/powerpc/ofw/ofw_machdep.c	Tue Oct 22 18:28:58 2019	(r353897)
@@ -487,7 +487,7 @@ ofw_numa_mem_regions(struct numa_mem_region *memp, int
 		MPASS(count == 1);
 		OF_getencprop(phandle, "ibm,associativity",
 			associativity, res);
-		curmemp->mr_domain = associativity[3] - 1;
+		curmemp->mr_domain = associativity[3];
 		if (bootverbose)
 			printf("%s %#jx-%#jx domain(%ju)\n",
 			    name, (uintmax_t)curmemp->mr_start,

Modified: head/sys/powerpc/ofw/ofw_pcibus.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_pcibus.c	Tue Oct 22 18:05:15 2019	(r353896)
+++ head/sys/powerpc/ofw/ofw_pcibus.c	Tue Oct 22 18:28:58 2019	(r353897)
@@ -403,7 +403,7 @@ ofw_pcibus_parse_associativity(device_t dev, int *doma
 	OF_getencprop(node, "ibm,associativity",
 		associativity, res);
 
-	*domain = associativity[3] - 1;
+	*domain = associativity[3];
 	if (bootverbose)
 		device_printf(dev, "domain(%d)\n", *domain);
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910221828.x9MISwK5035952>