mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
When booting from an FDT, make sure the FDT itself isn't included the range
of available memory. Boot loaders are supposed to add a reserved entry for it, but not all do. MFC after: 2 weeks
This commit is contained in:
parent
5bcc3e4277
commit
c0650b2f69
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326213
|
@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$");
|
|||
#include <machine/ofw_machdep.h>
|
||||
#include <machine/trap.h>
|
||||
|
||||
#include <contrib/libfdt/libfdt.h>
|
||||
|
||||
static void *fdt;
|
||||
int ofw_real_mode;
|
||||
|
||||
|
@ -233,8 +235,17 @@ excise_fdt_reserved(struct mem_region *avail, int asz)
|
|||
fdtmapsize = OF_getprop(chosen, "fdtmemreserv", fdtmap, sizeof(fdtmap));
|
||||
|
||||
for (j = 0; j < fdtmapsize/sizeof(fdtmap[0]); j++) {
|
||||
fdtmap[j].address = be64toh(fdtmap[j].address);
|
||||
fdtmap[j].size = be64toh(fdtmap[j].size);
|
||||
fdtmap[j].address = be64toh(fdtmap[j].address) & ~PAGE_MASK;
|
||||
fdtmap[j].size = round_page(be64toh(fdtmap[j].size));
|
||||
}
|
||||
|
||||
KASSERT(j*sizeof(fdtmap[0]) < sizeof(fdtmap),
|
||||
("Exceeded number of FDT reservations"));
|
||||
/* Add a virtual entry for the FDT itself */
|
||||
if (fdt != NULL) {
|
||||
fdtmap[j].address = (vm_offset_t)fdt & ~PAGE_MASK;
|
||||
fdtmap[j].size = round_page(fdt_totalsize(fdt));
|
||||
fdtmapsize += sizeof(fdtmap[0]);
|
||||
}
|
||||
|
||||
for (i = 0; i < asz; i++) {
|
||||
|
|
Loading…
Reference in a new issue