summaryrefslogtreecommitdiffstats
path: root/commands/bootm.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-11-01 12:42:40 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-01 16:27:21 +0100
commitb8d7c3a95c55cc8d36414e9344f2852f633924d5 (patch)
treea249f68ec0600e1822debd83fe114d734f2a8566 /commands/bootm.c
parentda7d19b9d8cce610b329ca84eb44e5a215537363 (diff)
downloadbarebox-b8d7c3a95c55cc8d36414e9344f2852f633924d5.tar.gz
barebox-b8d7c3a95c55cc8d36414e9344f2852f633924d5.tar.xz
bootm: Do not cross 1MiB sections for the devicetree
ARM Linux only maps a single 1MiB section for the devicetree. This has a 1Mib alignment, so we are not allowed to cross such a boundary. Align the devicetree to the next power of two so that this never happens. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/bootm.c')
-rw-r--r--commands/bootm.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/commands/bootm.c b/commands/bootm.c
index d14ec2ba51..98d2e4faf6 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -141,6 +141,7 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
struct fdt_header *fdt, *fixfdt;
int ret;
size_t size;
+ unsigned int align;
if (bootm_verbose(data))
printf("Loading oftree from '%s'\n", oftree);
@@ -189,7 +190,14 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
file_type_to_string(ft));
}
- fixfdt = xmemalign(4096, size + OFTREE_SIZE_INCREASE);
+ /*
+ * ARM Linux uses a single 1MiB section (with 1MiB alignment)
+ * for mapping the devicetree, so we are not allowed to cross
+ * 1MiB boundaries.
+ */
+ align = 1 << fls(size + OFTREE_SIZE_INCREASE - 1);
+
+ fixfdt = xmemalign(align, size + OFTREE_SIZE_INCREASE);
memcpy(fixfdt, fdt, size);