svn commit: r323713 - projects/powernv/powerpc/ofw

Nathan Whitehorn nwhitehorn at FreeBSD.org
Mon Sep 18 18:44:46 UTC 2017


Author: nwhitehorn
Date: Mon Sep 18 18:44:45 2017
New Revision: 323713
URL: https://svnweb.freebsd.org/changeset/base/323713

Log:
  Work around yet another kexec-lite bug: no reserved entry is added for the
  memory of the FDT itself. This is at worst redundant, and at best works
  around buggy bootloaders.

Modified:
  projects/powernv/powerpc/ofw/ofw_machdep.c

Modified: projects/powernv/powerpc/ofw/ofw_machdep.c
==============================================================================
--- projects/powernv/powerpc/ofw/ofw_machdep.c	Mon Sep 18 18:42:28 2017	(r323712)
+++ projects/powernv/powerpc/ofw/ofw_machdep.c	Mon Sep 18 18:44:45 2017	(r323713)
@@ -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;
 
@@ -240,8 +242,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 = (uint64_t)fdt & ~PAGE_MASK;
+		fdtmap[j].size = round_page(fdt_totalsize(fdt));
+		fdtmapsize += sizeof(fdtmap[0]);
 	}
 
 	for (i = 0; i < asz; i++) {


More information about the svn-src-projects mailing list