summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kexec/arch/ppc/kexec-elf-ppc.c12
-rw-r--r--kexec/arch/ppc/kexec-uImage-ppc.c6
2 files changed, 13 insertions, 5 deletions
diff --git a/kexec/arch/ppc/kexec-elf-ppc.c b/kexec/arch/ppc/kexec-elf-ppc.c
index 8e408cc..5f63a64 100644
--- a/kexec/arch/ppc/kexec-elf-ppc.c
+++ b/kexec/arch/ppc/kexec-elf-ppc.c
@@ -397,10 +397,14 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len,
die("Error device tree not loadded to address it was expecting to be loaded too!\n");
}
- /* set various variables for the purgatory ehdr.e_entry is a
- * virtual address, we can use kernel_addr which
- * should be the physical start address of the kernel */
- addr = kernel_addr;
+ /*
+ * set various variables for the purgatory.
+ * ehdr.e_entry is a virtual address. we know physical start
+ * address of the kernel (kernel_addr). Find the offset of
+ * e_entry from the virtual start address(e_phdr[0].p_vaddr)
+ * and calculate the actual physical address of the 'kernel entry'.
+ */
+ addr = kernel_addr + (ehdr.e_entry - ehdr.e_phdr[0].p_vaddr);
elf_rel_set_symbol(&info->rhdr, "kernel", &addr, sizeof(addr));
addr = dtb_addr;
diff --git a/kexec/arch/ppc/kexec-uImage-ppc.c b/kexec/arch/ppc/kexec-uImage-ppc.c
index e55bf94..eb477f1 100644
--- a/kexec/arch/ppc/kexec-uImage-ppc.c
+++ b/kexec/arch/ppc/kexec-uImage-ppc.c
@@ -134,15 +134,19 @@ static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
/*
* If the provided load_addr cannot be allocated, find a new
- * area.
+ * area. Rebase the entry point based on the new load_addr.
*/
if (!valid_memory_range(info, load_addr, load_addr + (len + _1MiB))) {
+ int ep_offset = ep - load_addr;
+
load_addr = locate_hole(info, len + _1MiB, 0, 0, max_addr, 1);
if (load_addr == ULONG_MAX) {
printf("Can't allocate memory for kernel of len %ld\n",
len + _1MiB);
return -1;
}
+
+ ep = load_addr + ep_offset;
}
add_segment(info, buf, len, load_addr, len + _1MiB);