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);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to