4ced99f
From: "Richard W.M. Jones" <rjones@redhat.com>
723d954
Date: Tue, 19 Aug 2014 18:56:28 +0100
29e31e3
Subject: [PATCH] aarch64: Allow -kernel option to take a gzip-compressed
4ced99f
 kernel.
4ced99f
MIME-Version: 1.0
4ced99f
Content-Type: text/plain; charset=UTF-8
4ced99f
Content-Transfer-Encoding: 8bit
4ced99f
4ced99f
On aarch64 it is the bootloader's job to uncompress the kernel.  UEFI
4ced99f
and u-boot bootloaders do this automatically when the kernel is
4ced99f
gzip-compressed.
4ced99f
4ced99f
However the qemu -kernel option does not do this.  The following
4ced99f
command does not work:
4ced99f
4ced99f
  qemu-system-aarch64 [...] -kernel /boot/vmlinuz
4ced99f
4ced99f
because it tries to execute the gzip-compressed data.
4ced99f
4ced99f
This commit lets gzip-compressed kernels be uncompressed
4ced99f
transparently.
4ced99f
4ced99f
Currently this is only done when emulating aarch64.
4ced99f
4ced99f
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
4ced99f
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
723d954
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
723d954
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
723d954
Message-id: 1407831259-2115-3-git-send-email-rjones@redhat.com
723d954
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
723d954
(cherry picked from commit 6f5d3cbe8892367026526a7deed0ceecc700a7ad)
4ced99f
---
723d954
 hw/arm/boot.c | 7 +++++++
723d954
 1 file changed, 7 insertions(+)
4ced99f
4ced99f
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
150e95b
index 50b6c5c..4bad4e6 100644
4ced99f
--- a/hw/arm/boot.c
4ced99f
+++ b/hw/arm/boot.c
723d954
@@ -510,6 +510,13 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
4ced99f
         kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
150e95b
                                   &is_linux, NULL, NULL);
4ced99f
     }
4ced99f
+    /* On aarch64, it's the bootloader's job to uncompress the kernel. */
723d954
+    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) && kernel_size < 0) {
4ced99f
+        entry = info->loader_start + kernel_load_offset;
4ced99f
+        kernel_size = load_image_gzipped(info->kernel_filename, entry,
4ced99f
+                                         info->ram_size - kernel_load_offset);
4ced99f
+        is_linux = 1;
4ced99f
+    }
4ced99f
     if (kernel_size < 0) {
4ced99f
         entry = info->loader_start + kernel_load_offset;
4ced99f
         kernel_size = load_image_targphys(info->kernel_filename, entry,