Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 May 2019 20:05:50 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r347164 - head/sys/powerpc/booke
Message-ID:  <201905052005.x45K5oHf070151@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Sun May  5 20:05:50 2019
New Revision: 347164
URL: https://svnweb.freebsd.org/changeset/base/347164

Log:
  powerpc/booke: Fix size check for phys_avail in pmap bootstrap
  
  Use the nitems() macro instead of the expansion, a'la r298352.  Also, fix the
  location of this check to after initializing availmem_regions_sz, so that the
  check isn't always against 0, thus always failing (nitems(phys_avail) is always
  more than 0).

Modified:
  head/sys/powerpc/booke/pmap.c

Modified: head/sys/powerpc/booke/pmap.c
==============================================================================
--- head/sys/powerpc/booke/pmap.c	Sun May  5 19:39:32 2019	(r347163)
+++ head/sys/powerpc/booke/pmap.c	Sun May  5 20:05:50 2019	(r347164)
@@ -1843,9 +1843,6 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_o
 	debugf(" kernstart   = 0x%"PRI0ptrX"\n", kernstart);
 	debugf(" kernsize    = 0x%"PRI0ptrX"\n", kernsize);
 
-	if (sizeof(phys_avail) / sizeof(phys_avail[0]) < availmem_regions_sz)
-		panic("mmu_booke_bootstrap: phys_avail too small");
-
 	/*
 	 * Remove kernel physical address range from avail regions list. Page
 	 * align all regions.  Non-page aligned memory isn't very interesting
@@ -1855,6 +1852,10 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_o
 	/* Retrieve phys/avail mem regions */
 	mem_regions(&physmem_regions, &physmem_regions_sz,
 	    &availmem_regions, &availmem_regions_sz);
+
+	if (nitems(phys_avail) < availmem_regions_sz)
+		panic("mmu_booke_bootstrap: phys_avail too small");
+
 	sz = 0;
 	cnt = availmem_regions_sz;
 	debugf("processing avail regions:\n");



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