svn commit: r353897 - head/sys/powerpc/ofw

Leandro Lupori luporl at FreeBSD.org
Tue Oct 22 18:28:59 UTC 2019


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);


More information about the svn-src-head mailing list