From patchwork Mon Jan 26 18:57:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 43772 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2510420D5D for ; Mon, 26 Jan 2015 18:57:24 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gm9sf5300833lab.0 for ; Mon, 26 Jan 2015 10:57:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:in-reply-to :message-id:references:user-agent:mime-version:content-type:sender :precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=G4ZiL2R+MH9IvnpgORuhP9qhJMXIBvBJIChEZBjbD28=; b=NsplsuTUjHGdnyqk+ZRMK18yFERauj9nCVRDUmfCIWfVqGeAyXPg8ItK1j66fnN+Mb C5Lu5FK/emvcM4Xm0HoZalPHFr2phBwGh/9ZRzK4o75hFPTmbiCKtXaPLOh5pIcatYqZ dsBUah19Y3ExgB2HVa52iPnePANoZX9uv92v2N3EYwZuMPAdkDOsE1J/7lf/aeuiqIqP eD/b8LIERA5uSLuJMFD13k9OZle8MsK3PulbnQuYR5Mj6QNYcGuBzbhFbTgvWrzsFaE5 oN8qZVucGsq8Jcg7RfksJs7HxTvaYEPoTh+zlIDO9N1MaTCXJp6zekE6e6vrTSfWWnLf RxqQ== X-Gm-Message-State: ALoCoQnTK2kbIx0Mv++JDlwsnq4czyYeZ+H/YsY0H98joV25EuFdtL8XBJZ4tR2FAKZzQsXe2McT X-Received: by 10.152.170.201 with SMTP id ao9mr2061091lac.5.1422298642977; Mon, 26 Jan 2015 10:57:22 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.121.35 with SMTP id lh3ls425910lab.12.gmail; Mon, 26 Jan 2015 10:57:22 -0800 (PST) X-Received: by 10.112.135.196 with SMTP id pu4mr3007871lbb.41.1422298642760; Mon, 26 Jan 2015 10:57:22 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id bj4si9780749lbc.69.2015.01.26.10.57.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 10:57:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id gm9so9433207lab.0 for ; Mon, 26 Jan 2015 10:57:22 -0800 (PST) X-Received: by 10.112.52.229 with SMTP id w5mr22919525lbo.52.1422298642611; Mon, 26 Jan 2015 10:57:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp868497lbj; Mon, 26 Jan 2015 10:57:21 -0800 (PST) X-Received: by 10.70.10.100 with SMTP id h4mr13763875pdb.10.1422298640171; Mon, 26 Jan 2015 10:57:20 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ns6si13272578pbb.93.2015.01.26.10.57.18; Mon, 26 Jan 2015 10:57:20 -0800 (PST) Received-SPF: none (google.com: linux-omap-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752460AbbAZS5O (ORCPT + 5 others); Mon, 26 Jan 2015 13:57:14 -0500 Received: from mail-qg0-f44.google.com ([209.85.192.44]:61700 "EHLO mail-qg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753521AbbAZS5M (ORCPT ); Mon, 26 Jan 2015 13:57:12 -0500 Received: by mail-qg0-f44.google.com with SMTP id l89so8316414qgf.3 for ; Mon, 26 Jan 2015 10:57:11 -0800 (PST) X-Received: by 10.224.4.196 with SMTP id 4mr6768268qas.10.1422298631260; Mon, 26 Jan 2015 10:57:11 -0800 (PST) Received: from xanadu.home (modemcable142.180-131-66.mc.videotron.ca. [66.131.180.142]) by mx.google.com with ESMTPSA id 17sm10771479qgk.8.2015.01.26.10.57.09 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 10:57:10 -0800 (PST) Date: Mon, 26 Jan 2015 13:57:08 -0500 (EST) From: Nicolas Pitre To: Tony Lindgren cc: =?ISO-8859-15?Q?Pali_Roh=E1r?= , linux-omap , Linux Kernel Mailing List , Aaro Koskinen , Sebastian Reichel , Ivaylo Dimitrov , Pavel Machek , Russell King , linux-arm-kernel@lists.infradead.org, Laura Abbott Subject: Re: N900 v3.19-rc5 arm atags_to_fdt.c is broken In-Reply-To: <20150126170323.GF28663@atomide.com> Message-ID: References: <201501232239.55801@pali> <201501232336.36187@pali> <20150126161454.GE28663@atomide.com> <201501261723.10505@pali> <20150126170323.GF28663@atomide.com> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: nicolas.pitre@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On Mon, 26 Jan 2015, Tony Lindgren wrote: > * Pali Rohár [150126 08:26]: > > On Monday 26 January 2015 17:14:55 Tony Lindgren wrote: > > > * Pali Rohár [150123 14:39]: > > > > On Friday 23 January 2015 22:39:55 Pali Rohár wrote: > > > > > Hello, > > > > > > > > > > when I boot zImage with appended DT n900 in qemu > > > > > fdt_open_into() function called from file > > > > > arch/arm/boot/compressed/atags_to_fdt.c (in function > > > > > atags_to_fdt) always returns -FDT_ERR_NOSPACE. > > > > > > > > > > It means that all ATAGS (including cmdline arguments) > > > > > passed by bootloader are ignored. > > > > > > > > > > On real n900 device I see that booted DT version also > > > > > ignore cmdline arguments from bootloader. I cannot debug > > > > > decompress code on real device, but I think it is same > > > > > problem as in qemu. > > > > > > > > Looks like this quick patch is fixing above problem: > > > > > > > > diff --git a/arch/arm/boot/compressed/head.S > > > > b/arch/arm/boot/compressed/head.S index 68be901..4a7d75b > > > > 100644 > > > > --- a/arch/arm/boot/compressed/head.S > > > > +++ b/arch/arm/boot/compressed/head.S > > > > @@ -268,7 +268,7 @@ restart: adr r0, LC0 > > > > > > > > * area. No GOT fixup has occurred yet, but none of > > the > > > > * code we're about to call uses any global variable. > > > > > > > > */ > > > > > > > > - add sp, sp, #0x10000 > > > > + add sp, sp, #0x20000 > > > > > > > > stmfd sp!, {r0-r3, ip, lr} > > > > mov r0, r8 > > > > mov r1, r6 > > > > > > > > @@ -289,7 +289,7 @@ restart: adr r0, LC0 > > > > > > > > bleq atags_to_fdt > > > > > > > > ldmfd sp!, {r0-r3, ip, lr} > > > > > > > > - sub sp, sp, #0x10000 > > > > + sub sp, sp, #0x20000 > > > > > > > > #endif > > > > > > > > mov r8, r6 @ use the appended device tree > > > > > > Nico, got any ideas about this one? This seems like a > > > regression somewhere.. > > > > > > Regards, > > > > > > Tony > > > > $ du -b arch/arm/boot/dts/omap3-n900.dtb > > 70212 arch/arm/boot/dts/omap3-n900.dtb > > > > $ echo $((0x10000)) > > 65536 > > > > I would say, problem is because omap3-n900 binary DT is too large I agree. > OK if that's the case, then your patch makes sense to me. It also > seems we can have the temporary stack be larger than the initial > stack just for atags_to_fdt. The stack size isn't the issue, but rather its location. We need to position it away from the DT data. The DT size is known and we could use that, plus some room for the insertion of new data coming from the ATAG conversion. Something like the following would be a more robust solution: diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 68be901759..89718de9dd 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -263,16 +263,37 @@ restart: adr r0, LC0 * OK... Let's do some funky business here. * If we do have a DTB appended to zImage, and we do have * an ATAG list around, we want the later to be translated - * and folded into the former here. To be on the safe side, - * let's temporarily move the stack away into the malloc - * area. No GOT fixup has occurred yet, but none of the - * code we're about to call uses any global variable. + * and folded into the former here. No GOT fixup has occurred + * yet, but none of the code we're about to call uses any + * global variable. */ - add sp, sp, #0x10000 + + /* Get the initial DTB size */ + ldr r5, [r6, #4] +#ifndef __ARMEB__ + /* convert to little endian */ + eor r1, r5, r5, ror #16 + bic r1, r1, #0x00ff0000 + mov r5, r5, ror #8 + eor r5, r5, r1, lsr #8 +#endif + /* 50% DTB growth should be good enough */ + add r5, r5, r5, lsr #1 + /* preserve 64-bit alignment */ + add r5, r5, #7 + bic r5, r5, #7 + /* clamp to 32KB min and 1MB max */ + movs r1, r5, lsr #15 + moveq r5, #(1 << 15) + movs r1, r5, lsr #20 + movne r5, #(1 << 20) + + /* Temporarily relocate the stack past the DTB work space */ + add sp, sp, r5 stmfd sp!, {r0-r3, ip, lr} mov r0, r8 mov r1, r6 - sub r2, sp, r6 + mov r2, r5 bl atags_to_fdt /* @@ -285,11 +306,11 @@ restart: adr r0, LC0 bic r0, r0, #1 add r0, r0, #0x100 mov r1, r6 - sub r2, sp, r6 + mov r2, r5 bleq atags_to_fdt ldmfd sp!, {r0-r3, ip, lr} - sub sp, sp, #0x10000 + sub sp, sp, r5 #endif mov r8, r6 @ use the appended device tree @@ -306,7 +327,7 @@ restart: adr r0, LC0 subs r1, r5, r1 addhi r9, r9, r1 - /* Get the dtb's size */ + /* Get the current DTB size */ ldr r5, [r6, #4] #ifndef __ARMEB__ /* convert r5 (dtb size) to little endian */