aboutsummaryrefslogtreecommitdiff
path: root/hw/arm/boot.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-03-21 18:44:36 +0000
committerPeter Maydell <peter.maydell@linaro.org>2014-03-24 16:41:10 +0000
commitda0af40dd70c8f8f821d79c367aecb08618af28e (patch)
tree9d09bf39b9efeaba3bbffc477c4618dab99304eb /hw/arm/boot.c
parentd108609bf9ba160d2e2044ce7d553f691ac96dbd (diff)
downloadqemu-da0af40dd70c8f8f821d79c367aecb08618af28e.zip
qemu-da0af40dd70c8f8f821d79c367aecb08618af28e.tar.gz
qemu-da0af40dd70c8f8f821d79c367aecb08618af28e.tar.bz2
target-arm: Load ELF images with the correct machine type for CPU
When trying to load an ELF file specified via -kernel, we need to pass load_elf() the ELF machine type corresponding to the CPU we're booting with, not the one corresponding to the softmmu binary we happen to be running. (The two are different in the case of loading a 32-bit ARM ELF file into a 32 bit CPU being emulated by qemu-system aarch64.) This was causing us to incorrectly fail to load ELF images in this situation. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Andreas Färber <afaerber@suse.de> Message-id: 1395427476-25546-1-git-send-email-peter.maydell@linaro.org
Diffstat (limited to 'hw/arm/boot.c')
-rw-r--r--hw/arm/boot.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index dc62918..3d1f4a2 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -448,6 +448,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
int initrd_size;
int is_linux = 0;
uint64_t elf_entry;
+ int elf_machine;
hwaddr entry, kernel_load_offset;
int big_endian;
static const ARMInsnFixup *primary_loader;
@@ -463,9 +464,11 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
primary_loader = bootloader_aarch64;
kernel_load_offset = KERNEL64_LOAD_ADDR;
+ elf_machine = EM_AARCH64;
} else {
primary_loader = bootloader;
kernel_load_offset = KERNEL_LOAD_ADDR;
+ elf_machine = EM_ARM;
}
info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
@@ -501,7 +504,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
/* Assume that raw images are linux kernels, and ELF images are not. */
kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry,
- NULL, NULL, big_endian, ELF_MACHINE, 1);
+ NULL, NULL, big_endian, elf_machine, 1);
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(info->kernel_filename, &entry, NULL,