Message ID | 1407152873-16772-3-git-send-email-rjones@redhat.com |
---|---|
State | New |
Headers | show |
Richard W.M. Jones writes: > On aarch64 it is the bootloader's job to uncompress the kernel. UEFI > and u-boot bootloaders do this automatically when the kernel is > gzip-compressed. > > However the qemu -kernel option does not do this. The following > command does not work: > > qemu-system-aarch64 [...] -kernel /boot/vmlinuz > > because it tries to execute the gzip-compressed data. > > This commit lets gzip-compressed kernels be uncompressed > transparently. > > Currently this is only done when emulating aarch64. > > Signed-off-by: Richard W.M. Jones <rjones@redhat.com> > --- > hw/arm/boot.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/hw/arm/boot.c b/hw/arm/boot.c > index 3d1f4a2..1d541db 100644 > --- a/hw/arm/boot.c > +++ b/hw/arm/boot.c > @@ -444,6 +444,7 @@ static void do_cpu_reset(void *opaque) > void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) > { > CPUState *cs = CPU(cpu); > + int allow_compressed_kernels = 0; > int kernel_size; > int initrd_size; > int is_linux = 0; > @@ -465,6 +466,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) > primary_loader = bootloader_aarch64; > kernel_load_offset = KERNEL64_LOAD_ADDR; > elf_machine = EM_AARCH64; > + allow_compressed_kernels = 1; > } else { > primary_loader = bootloader; > kernel_load_offset = KERNEL_LOAD_ADDR; > @@ -510,6 +512,13 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) > kernel_size = load_uimage(info->kernel_filename, &entry, NULL, > &is_linux); > } > + /* On aarch64, it's the bootloader's job to uncompress the kernel. */ > + if (allow_compressed_kernels && kernel_size < 0) { > + entry = info->loader_start + kernel_load_offset; > + kernel_size = load_image_gzipped(info->kernel_filename, entry, > + info->ram_size - kernel_load_offset); > + is_linux = 1; > + } > if (kernel_size < 0) { > entry = info->loader_start + kernel_load_offset; > kernel_size = load_image_targphys(info->kernel_filename, entry, Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 3d1f4a2..1d541db 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -444,6 +444,7 @@ static void do_cpu_reset(void *opaque) void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) { CPUState *cs = CPU(cpu); + int allow_compressed_kernels = 0; int kernel_size; int initrd_size; int is_linux = 0; @@ -465,6 +466,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) primary_loader = bootloader_aarch64; kernel_load_offset = KERNEL64_LOAD_ADDR; elf_machine = EM_AARCH64; + allow_compressed_kernels = 1; } else { primary_loader = bootloader; kernel_load_offset = KERNEL_LOAD_ADDR; @@ -510,6 +512,13 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) kernel_size = load_uimage(info->kernel_filename, &entry, NULL, &is_linux); } + /* On aarch64, it's the bootloader's job to uncompress the kernel. */ + if (allow_compressed_kernels && kernel_size < 0) { + entry = info->loader_start + kernel_load_offset; + kernel_size = load_image_gzipped(info->kernel_filename, entry, + info->ram_size - kernel_load_offset); + is_linux = 1; + } if (kernel_size < 0) { entry = info->loader_start + kernel_load_offset; kernel_size = load_image_targphys(info->kernel_filename, entry,
On aarch64 it is the bootloader's job to uncompress the kernel. UEFI and u-boot bootloaders do this automatically when the kernel is gzip-compressed. However the qemu -kernel option does not do this. The following command does not work: qemu-system-aarch64 [...] -kernel /boot/vmlinuz because it tries to execute the gzip-compressed data. This commit lets gzip-compressed kernels be uncompressed transparently. Currently this is only done when emulating aarch64. Signed-off-by: Richard W.M. Jones <rjones@redhat.com> --- hw/arm/boot.c | 9 +++++++++ 1 file changed, 9 insertions(+)