svn commit: r295157 - head/sys/arm64/arm64

Andrew Turner andrew at FreeBSD.org
Tue Feb 2 17:57:17 UTC 2016


Author: andrew
Date: Tue Feb  2 17:57:15 2016
New Revision: 295157
URL: https://svnweb.freebsd.org/changeset/base/295157

Log:
  Ensure we don't overflow the phys_avail array. Some firmware may provide
  more memory locations than we have space to record.
  
  Sponsored by:	ABT Systems Ltd

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

Modified: head/sys/arm64/arm64/pmap.c
==============================================================================
--- head/sys/arm64/arm64/pmap.c	Tue Feb  2 17:33:37 2016	(r295156)
+++ head/sys/arm64/arm64/pmap.c	Tue Feb  2 17:57:15 2016	(r295157)
@@ -596,7 +596,8 @@ pmap_bootstrap(vm_offset_t l1pt, vm_padd
 	 * up to the physical address KERNBASE points at.
 	 */
 	map_slot = avail_slot = 0;
-	for (; map_slot < (physmap_idx * 2); map_slot += 2) {
+	for (; map_slot < (physmap_idx * 2) &&
+	    avail_slot < (PHYS_AVAIL_SIZE - 2); map_slot += 2) {
 		if (physmap[map_slot] == physmap[map_slot + 1])
 			continue;
 
@@ -612,7 +613,7 @@ pmap_bootstrap(vm_offset_t l1pt, vm_padd
 	}
 
 	/* Add the memory before the kernel */
-	if (physmap[avail_slot] < pa) {
+	if (physmap[avail_slot] < pa && avail_slot < (PHYS_AVAIL_SIZE - 2)) {
 		phys_avail[avail_slot] = physmap[map_slot];
 		phys_avail[avail_slot + 1] = pa;
 		physmem += (phys_avail[avail_slot + 1] -


More information about the svn-src-all mailing list