Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 May 2014 09:07:46 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r265317 - projects/arm64/sys/arm64/arm64
Message-ID:  <201405040907.s4497kjS080003@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Sun May  4 09:07:45 2014
New Revision: 265317
URL: http://svnweb.freebsd.org/changeset/base/265317

Log:
  Check if the end address is within the new range before using it.

Modified:
  projects/arm64/sys/arm64/arm64/pmap.c

Modified: projects/arm64/sys/arm64/arm64/pmap.c
==============================================================================
--- projects/arm64/sys/arm64/arm64/pmap.c	Sun May  4 08:32:53 2014	(r265316)
+++ projects/arm64/sys/arm64/arm64/pmap.c	Sun May  4 09:07:45 2014	(r265317)
@@ -162,13 +162,24 @@ pmap_bootstrap(vm_offset_t l1pt, vm_padd
 		KASSERT(((va >> L2_SHIFT) & Ln_ADDR_MASK) == l2_slot,
 		    ("VA inconsistency detected"));
 
-		if (pa >= physmap[map_slot] + physmap[map_slot + 1]) {
+		/*
+		 * Check if we can use the current pa, some of it
+		 * may fall out side the current physmap slot.
+		 */
+		if (pa + L2_SIZE > physmap[map_slot] + physmap[map_slot + 1]) {
 			map_slot += 2;
-			KASSERT(map_slot < physmap_idx, ("..."));
 			pa = physmap[map_slot];
+			pa = roundup2(pa, L2_SIZE);
+
+			/* TODO: should we wrap if we hit this? */
+			KASSERT(map_slot < physmap_idx,
+			    ("Attempting to use invalid physical memory"));
+			/* TODO: This should be easy to fix */
+			KASSERT(pa + L2_SIZE <
+			    physmap[map_slot] + physmap[map_slot + 1],
+			    ("Physical slot too small"));
 		}
 
-		/* TODO: Check if this pa is valid */
 		ptep[l2_slot] = (pa & ~L2_OFFSET) | ATTR_AF | L2_BLOCK;
 
 		va += L2_SIZE;



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