From patchwork Wed Apr 29 16:43:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 6297131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2782A9F1C2 for ; Wed, 29 Apr 2015 16:46:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A64C2015E for ; Wed, 29 Apr 2015 16:46:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1607920149 for ; Wed, 29 Apr 2015 16:46:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YnV5K-0004Dl-I3; Wed, 29 Apr 2015 16:43:42 +0000 Received: from mail-qc0-f175.google.com ([209.85.216.175]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YnV58-00041i-Hi for linux-arm-kernel@lists.infradead.org; Wed, 29 Apr 2015 16:43:31 +0000 Received: by qcyk17 with SMTP id k17so15951403qcy.1 for ; Wed, 29 Apr 2015 09:43:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; bh=RF129vGbMfO/eHZLXCMgY3htGP2SVK0dCvWxQNdQt5I=; b=A/wA7nV2QwTdaPUHyLLlMPN4iiYWG0t/dKdrd/d4F6y5OoMI1X6KQ1IRwSmnSIy/9b ejsZ2VTD8K/kxKTIcSU5857XLdOcgdu+deoUe65PrCYgN9ywKhzcW5ti2T7Uh+TuvjT5 BcCHPPKUsfW4piX/EOF2jkDTQo/MFrF5huES4jT+SL8hKLlwfugyCn7EJnc9EbK6ZRm8 mE8zsmVKUKUPbp0j+DAMpvu1uLhbpz8iNWyCWcJpct7Fruqye9TDi/iP8spvmWS2NoWO pAy4iX8JyU5eh7Aps+TB4zdME01zXKmC2F3bXv7Vx8QbzNrw1NqOYBT1EovMZEDYat/5 7/og== X-Gm-Message-State: ALoCoQk47KsV2S5uGyBK1KZSoSIvL9o2EDpgYhkcofgyJgjZBlLMwFNnCIL9mWQVlZuN2SGTemnp X-Received: by 10.55.20.65 with SMTP id e62mr29516471qkh.90.1430325788021; Wed, 29 Apr 2015 09:43:08 -0700 (PDT) Received: from xanadu.home (modemcable142.180-131-66.mc.videotron.ca. [66.131.180.142]) by mx.google.com with ESMTPSA id n72sm14888887qha.19.2015.04.29.09.43.05 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Apr 2015 09:43:06 -0700 (PDT) Date: Wed, 29 Apr 2015 12:43:04 -0400 (EDT) From: Nicolas Pitre To: Valentin Longchamp Subject: Re: [RFC] arm: pick the r2 passed DTB over the appended one In-Reply-To: <5540FD7A.8040002@keymile.com> Message-ID: References: <1429880030-21473-1-git-send-email-valentin.longchamp@keymile.com> <5540A0DA.9060409@keymile.com> <5540FD7A.8040002@keymile.com> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150429_094330_684797_63AAF1E2 X-CRM114-Status: GOOD ( 19.89 ) X-Spam-Score: -0.7 (/) Cc: "bones@secretlab.ca" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 29 Apr 2015, Valentin Longchamp wrote: > On 04/29/2015 03:58 PM, Nicolas Pitre wrote: > > Now, to fix your test, you'd simply have to augment it with: > > > > + cmp r6, r8 @ is r8 pointing to the appended DTB? > > + beq 1f > > ldr lr, [r8, #0] @ conventionaly passed dtb ? > > cmp lr, r1 > > beq dtb_check_done @ yes, do not manage it > > +1: > > > > I had thought the same and implemented a similar test as you propose (patch > attached, with some more debug code - please excuse my poor assembler). However > it does not work ! The reason for it is that on the second run, r6 contains > another value. As the output below seems to show, this 2nd run r6 value seems to > point to a DTB since the first jump to dtb_check_done is not performed. However, > since r8 now points to the "initial" appended DTB, the 2nd test jumps to > dtb_check_done. Please see the output below. Right. On the second run, r6 points at the relocated DTB. That's the one that should be used. r8 points at the initial, non relocated and about to be overwritten DTB. By giving priority to r8 with your patch, you're picking the wrong one. The following should fix this issue: Nicolas diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index c41a793b51..bbce6a0f0d 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -399,6 +399,16 @@ dtb_check_done: 1: #endif +#ifdef CONFIG_ARM_APPENDED_DTB + /* + * If r8 refers to an appended DTB, it is no longer valid + * and should be revalidated once relocated. + */ + cmp r8, r5 + cmpcs r6, r8 + movcs r8, #0 +#endif + sub r9, r6, r5 @ size to copy add r9, r9, #31 @ rounded up to a multiple bic r9, r9, #31 @ ... of 32 bytes