From patchwork Mon Oct 10 20:06:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 680553 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 3stB5b4vwzz9s9N for ; Tue, 11 Oct 2016 07:08:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=kGFoB9Gy; 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 3stB5b3fYwzDsqr for ; Tue, 11 Oct 2016 07:08:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=kGFoB9Gy; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) (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 3stB3m6NkqzDskZ for ; Tue, 11 Oct 2016 07:07:00 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=kGFoB9Gy; dkim-atps=neutral Received: by mail-lf0-x244.google.com with SMTP id p80so33284lfp.1 for ; Mon, 10 Oct 2016 13:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=+m22EZ2bF+/IUy4Isuv5sjradAMO8Y1A93yon+ZkoF0=; b=kGFoB9GyiLDHGz63pGd0VKw2L3wcjn7HLL6msQD6Txcr/SVGoURunP7nM+vVJ+zXYx 5ChKtbb9j7RVAcH1p7G9aIhEg6/shvmQ5wjnvNpvg9+PmusRTV5Xm+fCgEM3tvx8qpKO lGjxmv7+zSdyWrZCQuzXhtH6fxMzMcKxD/xAdfNYmJqeJwl3czY93kQUfGWoUbk1BDjA r1VPyzpCZ8uEzo7cecD79xXcaeaBvRLg3UgsHHpz+uC2B7r0sWig49EK0MSt6xAusnKZ fAISTDtVk8mqEtm64rag4OXpKIv34AssurMJwztsirha+BCVPUJYcKExZHj+bMoldGGo 4dIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=+m22EZ2bF+/IUy4Isuv5sjradAMO8Y1A93yon+ZkoF0=; b=Hx/FbBXJMyV5GplV198PvzHzoa90wv8tZ3Oijbfu9I6cMyKBD6bIbMp0wPak0Spafi C/k7YjZ+mVZeW08bUrtYb3lkJHPDdy6zsAC3GA94UTgQy/mypJBeSC7POuxB0Rl3/hTI eERTnY/SWroA49gwdAzEVi5dZEhbDK3V7DRCVeHKDFby+WWuKr6BJcadI8/kmnwR0WyZ SqG5mCH/umx17IIT1HxVdztxRh9FIxUG7AMA8xbosDgIIYh4zW37BTkIXwCijaWhw7rR 3ItjA1zImsjcxrz7f9bwld4b4jB3Qc1sZktuB3ooBQzp/Yp4hTO+h4CRxgwYP8EpjsR4 TBpw== X-Gm-Message-State: AA6/9RkVSwCW4C/YRWC5893q+dhYkCmuDtPQ07XZPj4Mlsx8LzI8vvCEIhsAUVNXrORatg== X-Received: by 10.25.132.18 with SMTP id g18mr16853940lfd.7.1476130016551; Mon, 10 Oct 2016 13:06:56 -0700 (PDT) Received: from ?IPv6:2003:62:5f1b:3000:ecb6:2643:869a:2540? (p200300625F1B3000ECB62643869A2540.dip0.t-ipconnect.de. [2003:62:5f1b:3000:ecb6:2643:869a:2540]) by smtp.googlemail.com with ESMTPSA id h73sm6067228lji.28.2016.10.10.13.06.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 13:06:55 -0700 (PDT) Subject: Re: Commit 1b7898ee276b "powerpc/boot: Use the pre-boot decompression API" breaks boot To: Michael Ellerman , Oliver O'Halloran References: <8db8ecac-4022-7df9-4e81-3d490c50821d@gmail.com> <80c9c42c-45d3-9f24-b3e1-5a5042686b1b@gmail.com> <877f9g7r4l.fsf@concordia.ellerman.id.au> <62241a1e-51c0-c1cd-1ecd-fa54a3842da0@gmail.com> From: Heiner Kallweit Message-ID: <0a0d0909-cee3-f375-4cf4-75f0beb5b8b7@gmail.com> Date: Mon, 10 Oct 2016 22:06:48 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <62241a1e-51c0-c1cd-1ecd-fa54a3842da0@gmail.com> 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 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Am 10.10.2016 um 08:10 schrieb Heiner Kallweit: > Am 10.10.2016 um 06:41 schrieb Michael Ellerman: >> Heiner Kallweit writes: >> >>> Am 07.10.2016 um 21:26 schrieb Heiner Kallweit: >>>> Am 07.10.2016 um 07:51 schrieb Oliver O'Halloran: >>>>> Hi, Heiner >>>>> >>>>> Could you send me a copy of the kernel .config (or which defconfig) >>>>> that you're using, the name of the HW platform that you're using and >>>>> if possible the kernel image itself? >>>>> >>>>> Thanks, >>>>> Oliver >>>>> >>>> Thanks for the quick reply. Attached are .config and cuImage. >>>> HW is a TP-Link TL-WDR4900 WiFi router (P1014-based) running OpenWRT. >>>> >>> After further checking I think I found the issue. The old gunzip code >>> handled uncompressed data transparently whilst the new one bails out >>> if it doesn't find a proper gzip header. >>> And in my case the actual kernel image is uncompressed. >>> With the following patch the system boots fine again (at least for me). >> >> Thanks for testing and tracking it down. >> >> I wonder why the actual image is uncompressed? Or alternately why do we >> tell uboot the image is compressed when it's not? >> > Uboot is provided with a compressed image, but what gets compressed is > not the pure kernel image but the resulting image incl. boot wrapper code, > see this part of the wrapper script: > > cuboot*) > gzip -n -f -9 "$ofile" > ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a "$base" -e "$entry" \ > $uboot_version -d "$ofile".gz "$ofile" > > And this resulting image is decompressed by uboot already during boot. > Therefore the boot wrapper code sees an uncompressed kernel image. > > IMHO in case of using cuboot no CONFIG_KERNEL_ config option > should be set and Makefile + code in arch/powerpc/boot should be able > to deal with this situation: > - don't copy and build the decompression stuff > - use an alternative version of prep_kernel() in main.c which doesn't > attempt to decompress the kernel image > > This should be a cleaner solution than probing the kernel image whether > it's compressed or not. > This would be the patch implementing the idea. Advantage is that all the unnecessary decompression code isn't built. Works fine for me. --- arch/powerpc/boot/Makefile | 7 ++++++- arch/powerpc/boot/main.c | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index eae2dc8..1f18847 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -19,6 +19,7 @@ all: $(obj)/zImage +compress-y := CONFIG_KERNEL_UNCOMPRESSED compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ @@ -95,12 +96,15 @@ libfdtheader := fdt.h libfdt.h libfdt_internal.h $(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o): \ $(addprefix $(obj)/,$(libfdtheader)) -src-wlib-y := string.S crt0.S crtsavres.S stdio.c decompress.c main.c \ +src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \ $(libfdt) libfdt-wrapper.c \ ns16550.c serial.c simple_alloc.c div64.S util.S \ elf_util.c $(zlib-y) devtree.c stdlib.c \ oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \ uartlite.c mpc52xx-psc.c opal.c opal-calls.S +ifneq ($(compress-y),CONFIG_KERNEL_UNCOMPRESSED) +src-wlib-y += decompress.c +endif src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c fsl-soc.c @@ -226,6 +230,7 @@ CROSSWRAP := -C "$(CROSS_COMPILE)" endif endif +compressor-y := none compressor-$(CONFIG_KERNEL_GZIP) := gz compressor-$(CONFIG_KERNEL_XZ) := xz diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index f7a184b..5a28c18 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -28,14 +28,19 @@ static struct addr_range prep_kernel(void) { char elfheader[256]; unsigned char *vmlinuz_addr = (unsigned char *)_vmlinux_start; - unsigned long vmlinuz_size = _vmlinux_end - _vmlinux_start; void *addr = 0; struct elf_info ei; +#ifndef CONFIG_KERNEL_UNCOMPRESSED + unsigned long vmlinuz_size = _vmlinux_end - _vmlinux_start; long len; +#endif +#ifdef CONFIG_KERNEL_UNCOMPRESSED + memcpy(elfheader, vmlinuz_addr, sizeof(elfheader)); +#else partial_decompress(vmlinuz_addr, vmlinuz_size, elfheader, sizeof(elfheader), 0); - +#endif if (!parse_elf64(elfheader, &ei) && !parse_elf32(elfheader, &ei)) fatal("Error: not a valid PPC32 or PPC64 ELF file!\n\r"); @@ -67,6 +72,10 @@ static struct addr_range prep_kernel(void) "device tree\n\r"); } +#ifdef CONFIG_KERNEL_UNCOMPRESSED + memcpy(addr, vmlinuz_addr + ei.elfoffset, ei.loadsize); + printf("%ld bytes of uncompressed data copied\n\r", ei.loadsize); +#else /* Finally, decompress the kernel */ printf("Decompressing (0x%p <- 0x%p:0x%p)...\n\r", addr, vmlinuz_addr, vmlinuz_addr+vmlinuz_size); @@ -82,7 +91,7 @@ static struct addr_range prep_kernel(void) len, ei.loadsize); printf("Done! Decompressed 0x%lx bytes\n\r", len); - +#endif flush_cache(addr, ei.loadsize); return (struct addr_range){addr, ei.memsize};