From c10c178a92b032ea3dd7259dcbbd1b9331c05c41 Mon Sep 17 00:00:00 2001 From: Sebastian Siewior Date: Sun, 12 Oct 2008 23:15:26 +0000 Subject: powerpc/boot: Compare _start against ei.loadsize instead ei.memsize If the vmlinux binary in memory is larger than 4 MiB than it collides with the initial boot code which is linked at 4 MiB in case of cuBoot. If the the uncompressed image size (on disk size) is less than 4 MiB then it would fit. The difference between those two sizes is the bss section. In cuBoot we have the dtb embedded right after the data section so it is very likely that the reset of the bss section (in kernel's start up code) will overwrite the dtb blob. Therefore we reallocate the dtb. Something similar is allready done to the initrd. Signed-off-by: Sebastian Andrzej Siewior Acked-by: David Gibson Signed-off-by: Benjamin Herrenschmidt --- arch/powerpc/boot/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'arch/powerpc/boot/main.c') diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index 9e7f3ddd991..ae32801ebd6 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -56,9 +56,19 @@ static struct addr_range prep_kernel(void) if (platform_ops.vmlinux_alloc) { addr = platform_ops.vmlinux_alloc(ei.memsize); } else { - if ((unsigned long)_start < ei.memsize) + /* + * Check if the kernel image (without bss) would overwrite the + * bootwrapper. The device tree has been moved in fdt_init() + * to an area allocated with malloc() (somewhere past _end). + */ + if ((unsigned long)_start < ei.loadsize) fatal("Insufficient memory for kernel at address 0!" - " (_start=%p)\n\r", _start); + " (_start=%p, uncomressed size=%08x)\n\r", + _start, ei.loadsize); + + if ((unsigned long)_end < ei.memsize) + fatal("The final kernel image would overwrite the " + "device tree\n\r"); } /* Finally, gunzip the kernel */ -- cgit v1.2.3 From 8ba4773aee23a5e2e1ce386c5bd86e407496de99 Mon Sep 17 00:00:00 2001 From: Jon Smirl Date: Thu, 30 Oct 2008 16:51:32 +0000 Subject: powerpc: Fix format string warning in arch/powerpc/boot/main.c Fix format string warning in arch/powerpc/boot/main.c. Also correct a typo ("uncomressed") on the same line. BOOTCC arch/powerpc/boot/main.o arch/powerpc/boot/main.c: In function 'prep_kernel': arch/powerpc/boot/main.c:65: warning: format '%08x' expects type 'unsigned int', but argument 3 has type 'long unsigned int' Signed-off-by: Jon Smirl Acked-by: David Gibson Signed-off-by: Paul Mackerras --- arch/powerpc/boot/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/powerpc/boot/main.c') diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index ae32801ebd6..a28f02165e9 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -63,7 +63,7 @@ static struct addr_range prep_kernel(void) */ if ((unsigned long)_start < ei.loadsize) fatal("Insufficient memory for kernel at address 0!" - " (_start=%p, uncomressed size=%08x)\n\r", + " (_start=%p, uncompressed size=%08lx)\n\r", _start, ei.loadsize); if ((unsigned long)_end < ei.memsize) -- cgit v1.2.3