[RFC PATCH 3/7] powerpc: simpleboot get load address from ELF instead of assuming zero

Michal Simek monstr at monstr.eu
Fri Jun 17 00:14:24 EST 2011


From: John Williams <john.williams at petalogix.com>

simpleboot current assumes that the physical load address is zero, even if
the ELF payload has a non-zero paddr.

This is a simple fix that avoids a custom pltform_ops handler in this case.

Signed-off-by: John Williams <john.williams at petalogix.com>
---
 arch/powerpc/boot/elf.h      |    1 +
 arch/powerpc/boot/elf_util.c |    2 ++
 arch/powerpc/boot/main.c     |    1 +
 3 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/elf.h b/arch/powerpc/boot/elf.h
index 1941bc5..39af242 100644
--- a/arch/powerpc/boot/elf.h
+++ b/arch/powerpc/boot/elf.h
@@ -150,6 +150,7 @@ struct elf_info {
 	unsigned long loadsize;
 	unsigned long memsize;
 	unsigned long elfoffset;
+	unsigned long loadaddr;
 };
 int parse_elf64(void *hdr, struct elf_info *info);
 int parse_elf32(void *hdr, struct elf_info *info);
diff --git a/arch/powerpc/boot/elf_util.c b/arch/powerpc/boot/elf_util.c
index 1567a0c..3aef4f0 100644
--- a/arch/powerpc/boot/elf_util.c
+++ b/arch/powerpc/boot/elf_util.c
@@ -43,6 +43,7 @@ int parse_elf64(void *hdr, struct elf_info *info)
 	info->loadsize = (unsigned long)elf64ph->p_filesz;
 	info->memsize = (unsigned long)elf64ph->p_memsz;
 	info->elfoffset = (unsigned long)elf64ph->p_offset;
+	info->loadaddr = (unsigned long)elf64ph->p_paddr;
 
 	return 1;
 }
@@ -74,5 +75,6 @@ int parse_elf32(void *hdr, struct elf_info *info)
 	info->loadsize = elf32ph->p_filesz;
 	info->memsize = elf32ph->p_memsz;
 	info->elfoffset = elf32ph->p_offset;
+	info->loadaddr = elf32ph->p_paddr;
 	return 1;
 }
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index a28f021..fbbffa5 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -56,6 +56,7 @@ static struct addr_range prep_kernel(void)
 	if (platform_ops.vmlinux_alloc) {
 		addr = platform_ops.vmlinux_alloc(ei.memsize);
 	} else {
+		addr = ei.loadaddr;
 		/*
 		 * Check if the kernel image (without bss) would overwrite the
 		 * bootwrapper. The device tree has been moved in fdt_init()
-- 
1.5.5.6



More information about the Linuxppc-dev mailing list