diff options
-rw-r--r-- | sys/arm/arm/physmem.c | 25 | ||||
-rw-r--r-- | sys/arm/include/ofw_machdep.h | 4 | ||||
-rw-r--r-- | sys/arm/include/physmem.h | 2 |
3 files changed, 20 insertions, 11 deletions
diff --git a/sys/arm/arm/physmem.c b/sys/arm/arm/physmem.c index 999d38c283c9..d023905dacbb 100644 --- a/sys/arm/arm/physmem.c +++ b/sys/arm/arm/physmem.c @@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$"); #define MAX_HWCNT 10 #define MAX_EXCNT 10 +#define MAX_PHYS_ADDR 0xFFFFFFFFull + struct region { vm_paddr_t addr; vm_size_t size; @@ -273,14 +275,25 @@ insert_region(struct region *regions, size_t rcnt, vm_paddr_t addr, * Add a hardware memory region. */ void -arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz) +arm_physmem_hardware_region(uint64_t pa, uint64_t sz) { vm_offset_t adj; /* * Filter out the page at PA 0x00000000. The VM can't handle it, as * pmap_extract() == 0 means failure. - * + */ + if (pa == 0) { + if (sz <= PAGE_SIZE) + return; + pa = PAGE_SIZE; + sz -= PAGE_SIZE; + } else if (pa > MAX_PHYS_ADDR) { + /* This range is past usable memory, ignore it */ + return; + } + + /* * Also filter out the page at the end of the physical address space -- * if addr is non-zero and addr+size is zero we wrapped to the next byte * beyond what vm_paddr_t can express. That leads to a NULL pointer @@ -291,12 +304,8 @@ arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz) * pointer deref in _vm_map_lock_read(). Better to give up a megabyte * than leave some folks with an unusable system while we investigate. */ - if (pa == 0) { - if (sz <= PAGE_SIZE) - return; - pa = PAGE_SIZE; - sz -= PAGE_SIZE; - } else if (pa + sz == 0) { + if ((pa + sz) > (MAX_PHYS_ADDR - 1024 * 1024)) { + sz = MAX_PHYS_ADDR - pa + 1; if (sz <= 1024 * 1024) return; sz -= 1024 * 1024; diff --git a/sys/arm/include/ofw_machdep.h b/sys/arm/include/ofw_machdep.h index 54033eaa03b1..941be82fd1c4 100644 --- a/sys/arm/include/ofw_machdep.h +++ b/sys/arm/include/ofw_machdep.h @@ -40,8 +40,8 @@ typedef uint32_t cell_t; struct mem_region { - vm_offset_t mr_start; - vm_size_t mr_size; + uint64_t mr_start; + uint64_t mr_size; }; #endif /* _MACHINE_OFW_MACHDEP_H_ */ diff --git a/sys/arm/include/physmem.h b/sys/arm/include/physmem.h index ae6e4d0ab4c4..5e5968d06968 100644 --- a/sys/arm/include/physmem.h +++ b/sys/arm/include/physmem.h @@ -52,7 +52,7 @@ extern vm_paddr_t arm_physmem_kernaddr; #define EXFLAG_NODUMP 0x01 #define EXFLAG_NOALLOC 0x02 -void arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz); +void arm_physmem_hardware_region(uint64_t pa, uint64_t sz); void arm_physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags); void arm_physmem_init_kernel_globals(void); void arm_physmem_print_tables(void); |