Allow us to be told about memory past the first 4GB point, but ignore it.

This allows, for example, UEFI pass a memory map with some ram in this
region, but for us to ignore it. This is the case when running under the
qemu virt machine type.

Sponsored by:	ABT Systems Ltd
This commit is contained in:
Andrew Turner 2016-01-25 23:04:40 +00:00
parent 57169cea64
commit 1e7b9e9e68
3 changed files with 20 additions and 11 deletions

View File

@ -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;

View File

@ -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_ */

View File

@ -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);