From patchwork Wed Oct 12 19:00:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 681388 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3svNXL74Kcz9t0t for ; Thu, 13 Oct 2016 06:02:26 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=WAJdMROW; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3svNXL5xnkzDsxh for ; Thu, 13 Oct 2016 06:02:26 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=WAJdMROW; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3svNVf6sWqzDsxJ for ; Thu, 13 Oct 2016 06:00:58 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=WAJdMROW; dkim-atps=neutral Received: by mail-lf0-x242.google.com with SMTP id b75so8454796lfg.3 for ; Wed, 12 Oct 2016 12:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=27ffPJNrtoVp5ggQUNZk11urv0XLJOwBu3uv38BF4wA=; b=WAJdMROWJxGHwyD9kW/pydbadqmYJroFZjroOtcWJAuuqK+l3FSGpx6yB9LeRQGD4q y1nzPx1ayJ0r5Is7MifvEMHh1YW2zNCNIhEUzOUpRRj+vcKvdCHOrUV8EanAAx54rBZl Ru6awk3KaS3X6L03zy5sMark4ZhM50h/ol9EEj1TYWkkZZS6Ee6Nq44IFmGBLZBdAnx5 iqqokhbZ7kbxYEUulDKhrV6AgoGxOWXjKwad1FbGixm+iQnEESuseMU7KelcW8eD7by+ uJ/hX+R3YyRvVH86YHvE9JwTpHsvyFyXsNLXXU5JkTP2C/twpV3Z3x6sxaM3e4brxRy3 jw3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=27ffPJNrtoVp5ggQUNZk11urv0XLJOwBu3uv38BF4wA=; b=HMBibaOk0jpihtk2Iet5ksDzlJKUw0zZDVdEhn0/1LZKv0u89g9S/dBs49W9+vF6Tz oix471RGrmIz2jimiuk/2T6ptJOSxBN+qkbhF4NEZvOMvmjDNwp4bkPTu76vRnX9qqCa qtfyhnU8XcEEmDhjCxbKH2kuOzwz/bTKxLMfxGruwylfji0h52hhmiZNWJoTawVNtcUQ A4Bi32etlqsp7ci0C0WIP7xfd46R1GTpOdmm/TnpY9E466E9uHcEevA+ny97XMENFOkB bSkIz/RjWwUH+fbYRYh/LkcqaUnRVXLWBAtHCBP+WxijDJEOlZfjngYm4ugtEOnFcVTn X8yA== X-Gm-Message-State: AA6/9RmE3TIgllHDPW8wvTJToGmfFAa0cxxqACDZT76sGghgW77d5Oos1FTxIfWpjXZcSg== X-Received: by 10.25.44.8 with SMTP id s8mr3573728lfs.54.1476298855582; Wed, 12 Oct 2016 12:00:55 -0700 (PDT) Received: from ?IPv6:2003:62:5f3c:200:1b9:7533:b807:8bc0? (p200300625F3C020001B97533B8078BC0.dip0.t-ipconnect.de. [2003:62:5f3c:200:1b9:7533:b807:8bc0]) by smtp.googlemail.com with ESMTPSA id p3sm2625227lfe.1.2016.10.12.12.00.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Oct 2016 12:00:55 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH] powerpc/boot: fix boot on systems with uncompressed kernel image To: Michael Ellerman Message-ID: <4a99340c-b773-51e4-0466-3d9a72ac83b2@gmail.com> Date: Wed, 12 Oct 2016 21:00:43 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, Oliver O'Halloran Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This commit broke boot on systems with an uncompressed kernel image, namely systems using a cuImage. On such systems the compressed boot image (boot wrapper, uncompressed kernel image, ..) is decompressed by u-boot already, therefore the boot wrapper code sees an uncompressed kernel image. The old decompression code silently assumed an uncompressed kernel image if it found no valid gzip signature, whilst the new code bailed out in this case. Fix this by re-introducing such a fallback if no valid compressed image is found. Fixes: 1b7898ee276b ("Use the pre-boot decompression API") Signed-off-by: Heiner Kallweit --- arch/powerpc/boot/main.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index f7a184b..57d42d1 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -32,9 +32,16 @@ static struct addr_range prep_kernel(void) void *addr = 0; struct elf_info ei; long len; + int uncompressed_image = 0; - partial_decompress(vmlinuz_addr, vmlinuz_size, + len = partial_decompress(vmlinuz_addr, vmlinuz_size, elfheader, sizeof(elfheader), 0); + /* assume uncompressed data if -1 is returned */ + if (len == -1) { + uncompressed_image = 1; + memcpy(elfheader, vmlinuz_addr, sizeof(elfheader)); + printf("No valid compressed data found, assume uncompressed data\n\r"); + } if (!parse_elf64(elfheader, &ei) && !parse_elf32(elfheader, &ei)) fatal("Error: not a valid PPC32 or PPC64 ELF file!\n\r"); @@ -67,6 +74,13 @@ static struct addr_range prep_kernel(void) "device tree\n\r"); } + if (uncompressed_image) { + memcpy(addr, vmlinuz_addr + ei.elfoffset, ei.loadsize); + printf("0x%lx bytes of uncompressed data copied\n\r", + ei.loadsize); + goto out; + } + /* Finally, decompress the kernel */ printf("Decompressing (0x%p <- 0x%p:0x%p)...\n\r", addr, vmlinuz_addr, vmlinuz_addr+vmlinuz_size); @@ -82,7 +96,7 @@ static struct addr_range prep_kernel(void) len, ei.loadsize); printf("Done! Decompressed 0x%lx bytes\n\r", len); - +out: flush_cache(addr, ei.loadsize); return (struct addr_range){addr, ei.memsize};