Skip to content

Commit

Permalink
arm64: kexec: !fixup vp_offset calculation
Browse files Browse the repository at this point in the history
vp_offset is the virtual address of physical address defined by
phys_offset.

/proc/iomem "Kernel Code" start is the physical address of location from
where kernel code starts. ehdr.e_entry is its corresponding virtual
address. Therefore, right definition of vp_offset should be [ehdr.e_entry -
"kernel Code Start PA" + phys_offset].

Signed-off-by: Pratyush Anand <panand@redhat.com>
  • Loading branch information
Pratyush Anand committed Aug 19, 2016
1 parent 77cb6d4 commit 2358de3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kexec/arch/arm64/kexec-elf-arm64.c
Expand Up @@ -43,13 +43,18 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
struct mem_ehdr ehdr;
int result;
int i;
uint64_t kernel_code_start;

result = build_elf_exec_info(kernel_buf, kernel_size, &ehdr, 0);

if (result < 0) {
dbgprintf("%s: build_elf_exec_info failed\n", __func__);
goto exit;
}
if (parse_iomem_single("Kernel code\n", &kernel_code_start, NULL)) {
dbgprintf("%s: Start of kenrel code could not be found\n", __func__);
goto exit;
}

/* Find and process the arm64 image header. */

Expand All @@ -75,7 +80,8 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
if (arm64_process_image_header(h))
continue;

arm64_mem.vp_offset = ehdr.e_entry - arm64_mem.text_offset;
arm64_mem.vp_offset = ehdr.e_entry - kernel_code_start +
arm64_mem.phys_offset;

dbgprintf("%s: e_entry: %016llx -> %016lx\n", __func__,
ehdr.e_entry,
Expand Down

0 comments on commit 2358de3

Please sign in to comment.