svn commit: r293061 - head/sys/arm/arm

Ian Lepore ian at FreeBSD.org
Sat Jan 2 22:00:53 UTC 2016


Author: ian
Date: Sat Jan  2 22:00:52 2016
New Revision: 293061
URL: https://svnweb.freebsd.org/changeset/base/293061

Log:
  Use 64-bit math when processing the lists of physical and excluded memory
  to generate the phys_avail and dump_avail arrays.
  
  This is a partial fix for the kernel side of the problem mentioned in the
  PR.  This part handles the cases where comparing start and end addresses of
  a block would fail because 32-bit wrap caused the end address to come out
  zero if the end of the region is the end of the address space (0xffffffff
  with 32-bit vm_paddr_t, but now the code should also work right if we ever
  support LPAE with 36-bit addresses).
  
  More work is necessary to make systems with ram at the end of the physical
  address space usable, but at least initially it's going to be more like a
  workaround than a fix, so this non-hacky part is being committed first.
  
  PR:		201614

Modified:
  head/sys/arm/arm/physmem.c

Modified: head/sys/arm/arm/physmem.c
==============================================================================
--- head/sys/arm/arm/physmem.c	Sat Jan  2 21:13:14 2016	(r293060)
+++ head/sys/arm/arm/physmem.c	Sat Jan  2 22:00:52 2016	(r293061)
@@ -161,7 +161,7 @@ static size_t
 regions_to_avail(vm_paddr_t *avail, uint32_t exflags, long *pavail)
 {
 	size_t acnt, exi, hwi;
-	vm_paddr_t end, start, xend, xstart;
+	uint64_t end, start, xend, xstart;
 	long availmem;
 	const struct region *exp, *hwp;
 
@@ -171,7 +171,7 @@ regions_to_avail(vm_paddr_t *avail, uint
 	for (hwi = 0, hwp = hwregions; hwi < hwcnt; ++hwi, ++hwp) {
 		start = hwp->addr;
 		end   = hwp->size + start;
-		realmem += arm32_btop(end - start);
+		realmem += arm32_btop((vm_offset_t)(end - start));
 		for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) {
 			/*
 			 * If the excluded region does not match given flags,
@@ -212,9 +212,10 @@ regions_to_avail(vm_paddr_t *avail, uint
 			 * could affect the remainder of this hw region.
 			 */
 			if ((xstart > start) && (xend < end)) {
-				avail[acnt++] = start;
-				avail[acnt++] = xstart;
-				availmem += arm32_btop(xstart - start);
+				avail[acnt++] = (vm_paddr_t)start;
+				avail[acnt++] = (vm_paddr_t)xstart;
+				availmem += 
+				    arm32_btop((vm_offset_t)(xstart - start));
 				start = xend;
 				continue;
 			}
@@ -233,9 +234,9 @@ regions_to_avail(vm_paddr_t *avail, uint
 		 * available entry for it.
 		 */
 		if (end > start) {
-			avail[acnt++] = start;
-			avail[acnt++] = end;
-			availmem += arm32_btop(end - start);
+			avail[acnt++] = (vm_paddr_t)start;
+			avail[acnt++] = (vm_paddr_t)end;
+			availmem += arm32_btop((vm_offset_t)(end - start));
 		}
 		if (acnt >= MAX_AVAIL_ENTRIES)
 			panic("Not enough space in the dump/phys_avail arrays");


More information about the svn-src-head mailing list