Blame 0002-aarch64-Allow-kernel-option-to-take-a-gzip-compresse.patch

4ced99
From fc77c3116f7e4b3400e576c51e73ade2edee350a Mon Sep 17 00:00:00 2001
4ced99
From: "Richard W.M. Jones" <rjones@redhat.com>
4ced99
Date: Tue, 29 Jul 2014 23:32:31 +0100
4ced99
Subject: [PATCH 2/2] aarch64: Allow -kernel option to take a gzip-compressed
4ced99
 kernel.
4ced99
MIME-Version: 1.0
4ced99
Content-Type: text/plain; charset=UTF-8
4ced99
Content-Transfer-Encoding: 8bit
4ced99
4ced99
On aarch64 it is the bootloader's job to uncompress the kernel.  UEFI
4ced99
and u-boot bootloaders do this automatically when the kernel is
4ced99
gzip-compressed.
4ced99
4ced99
However the qemu -kernel option does not do this.  The following
4ced99
command does not work:
4ced99
4ced99
  qemu-system-aarch64 [...] -kernel /boot/vmlinuz
4ced99
4ced99
because it tries to execute the gzip-compressed data.
4ced99
4ced99
This commit lets gzip-compressed kernels be uncompressed
4ced99
transparently.
4ced99
4ced99
Currently this is only done when emulating aarch64.
4ced99
4ced99
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
4ced99
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4ced99
---
4ced99
 hw/arm/boot.c | 9 +++++++++
4ced99
 1 file changed, 9 insertions(+)
4ced99
4ced99
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
4ced99
index 1241761..c71c4d5 100644
4ced99
--- a/hw/arm/boot.c
4ced99
+++ b/hw/arm/boot.c
4ced99
@@ -448,6 +448,7 @@ static void do_cpu_reset(void *opaque)
4ced99
 void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
4ced99
 {
4ced99
     CPUState *cs = CPU(cpu);
4ced99
+    int allow_compressed_kernels = 0;
4ced99
     int kernel_size;
4ced99
     int initrd_size;
4ced99
     int is_linux = 0;
4ced99
@@ -469,6 +470,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
4ced99
         primary_loader = bootloader_aarch64;
4ced99
         kernel_load_offset = KERNEL64_LOAD_ADDR;
4ced99
         elf_machine = EM_AARCH64;
4ced99
+        allow_compressed_kernels = 1;
4ced99
     } else {
4ced99
         primary_loader = bootloader;
4ced99
         kernel_load_offset = KERNEL_LOAD_ADDR;
4ced99
@@ -514,6 +516,13 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
4ced99
         kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
4ced99
                                   &is_linux);
4ced99
     }
4ced99
+    /* On aarch64, it's the bootloader's job to uncompress the kernel. */
4ced99
+    if (allow_compressed_kernels && kernel_size < 0) {
4ced99
+        entry = info->loader_start + kernel_load_offset;
4ced99
+        kernel_size = load_image_gzipped(info->kernel_filename, entry,
4ced99
+                                         info->ram_size - kernel_load_offset);
4ced99
+        is_linux = 1;
4ced99
+    }
4ced99
     if (kernel_size < 0) {
4ced99
         entry = info->loader_start + kernel_load_offset;
4ced99
         kernel_size = load_image_targphys(info->kernel_filename, entry,
4ced99
-- 
4ced99
2.0.4
4ced99