[POWERPC] Round up bootwrapper alloc size for vmlinux to page size

Mark A. Greer mgreer at mvista.com
Thu Oct 26 09:36:16 EST 2006


The powerpc kernel linker script, arch/powerpc/kernel/vmlinux.lds.S,
aligns '_end' up to a page boundary.  However, the bootwrapper
does not round up the size of the area that it allocates to gunzip
the kernel into.  This leaves space between '__bss_stop' and '_end'
where the bootwrapper could allocate other things (e.g., space for
a flattened device tree).  This patch rounds up the allocation size
to a multiple of the page size to match '_end' and prevent the latent
bug.

Signed-off-by: Mark A. Greer <mgreer at mvista.com>
---

 main.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
---

diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 4184974..234bb5b 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -198,7 +198,7 @@ static void prep_kernel(unsigned long *a
 	 * be claimed (it will be zero'd by the kernel itself)
 	 */
 	printf("Allocating 0x%lx bytes for kernel ...\n\r", vmlinux.memsize);
-	vmlinux.addr = (unsigned long)malloc(vmlinux.memsize);
+	vmlinux.addr = (unsigned long)malloc(_ALIGN(vmlinux.memsize, 4096));
 	if (vmlinux.addr == 0) {
 		printf("Can't allocate memory for kernel image !\n\r");
 		exit();



More information about the Linuxppc-dev mailing list