[PATCH] ppc64: Fix zImage boot

Benjamin Herrenschmidt benh at kernel.crashing.org
Mon Nov 7 14:22:18 EST 2005


The zImage wrapper has a bug where it doesn't claim() the memory for the
kernel properly, it forgets to take into account the offset between the
ELF header and the kernel itself. This results on some machines, like
G5s, into a kernel that crashes at boot when clearing the BSS.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>

Index: linux-work/arch/ppc64/boot/main.c
===================================================================
--- linux-work.orig/arch/ppc64/boot/main.c	2005-11-01 14:13:53.000000000 +1100
+++ linux-work/arch/ppc64/boot/main.c	2005-11-07 14:20:54.000000000 +1100
@@ -203,8 +203,15 @@
 		if (elf64ph->p_type == PT_LOAD && elf64ph->p_offset != 0)
 			break;
 	}
-	vmlinux.size = (unsigned long)elf64ph->p_filesz;
-	vmlinux.memsize = (unsigned long)elf64ph->p_memsz;
+	vmlinux.size = (unsigned long)elf64ph->p_filesz +
+		(unsigned long)elf64ph->p_offset;
+	/* We need to claim the memsize plus the file offset since gzip
+	 * will expand the header (file offset), then the kernel, then
+	 * possible rubbish we don't care about. But the kernel bss must
+	 * be claimed (it will be zero'd by the kernel itself)
+	 */
+	vmlinux.memsize = (unsigned long)elf64ph->p_memsz +
+		(unsigned long)elf64ph->p_offset;
 	printf("Allocating 0x%lx bytes for kernel ...\n\r", vmlinux.memsize);
 	vmlinux.addr = try_claim(vmlinux.memsize);
 	if (vmlinux.addr == 0) {






More information about the Linuxppc64-dev mailing list