Skip to contentSkip to conversation

Round up bootwrapper alloc size for vmlinux to page size

POWERPC Mark A. Greer 1 participant 1 message Oct 25, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

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.

---

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

---

arch/powerpc/boot/main.c +1 -1
index 4184974..234bb5b 100644
@@ -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();