From patchwork Fri Apr 24 12:53:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Longchamp X-Patchwork-Id: 6270351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4DD5ABF4A6 for ; Fri, 24 Apr 2015 12:57:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 366D0202DD for ; Fri, 24 Apr 2015 12:57:54 +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 CB783201CD for ; Fri, 24 Apr 2015 12:57:52 +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 1Yld7g-0005m8-8e; Fri, 24 Apr 2015 12:54:24 +0000 Received: from mail-de.keymile.com ([195.8.104.250]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yld7c-0005bW-Ry for linux-arm-kernel@lists.infradead.org; Fri, 24 Apr 2015 12:54:21 +0000 Received: from frodo.de.keymile.net ([10.9.1.54]:64395 helo=mailrelay.de.keymile.net) by mail-de.keymile.com with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1Yld7B-0008Tz-07; Fri, 24 Apr 2015 14:53:53 +0200 Received: from ch10650.keymile.net (ch10650.keymile.net [172.31.40.247]) by mailrelay.de.keymile.net (8.12.2/8.12.2) with ESMTP id t3OCroTp023278; Fri, 24 Apr 2015 14:53:50 +0200 (MEST) From: Valentin Longchamp To: nicolas.pitre@linaro.org, bones@secretlab.ca Subject: [RFC] arm: pick the r2 passed DTB over the appended one Date: Fri, 24 Apr 2015 14:53:50 +0200 Message-Id: <1429880030-21473-1-git-send-email-valentin.longchamp@keymile.com> X-Mailer: git-send-email 1.8.0.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150424_055421_087011_354A2168 X-CRM114-Status: GOOD ( 14.80 ) X-Spam-Score: -2.3 (--) Cc: Valentin Longchamp , 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: , MIME-Version: 1.0 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 Thanks to the APPENDED_DTB option, it is possible to append the dtb to the kernel's binary image. This is very convenient to accomodate old bootloaders that do not pass a dtb. We have updated a product with a new version of the bootloader that now passed the dtb properly in r2. However, we still want to support with the same software (i.e. kernel) the old bootloader, where the dtb must be appended, but give the priority to to the one passed in r2. This patch tries cover the above use case. It works for the case a dtb is passed in r2 and one is appended (the one pointed by r2 is picked). However, when there is only an appended dtb and r2 points to an ATAG list, this fails. Somehow, the presumably updated r2 does not point to a valid dtb and it gets zeroed by __vet_atags. Below is an example of this (end of bootloader, start of kernel): at 02000000 ... Image Name: Linux-3.10.60-7.2.2-00002-gc6acc Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2904550 Bytes = 2.8 MiB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum ... OK Loading Kernel Image ... OK OK r2 (0x00000100) points to (size, header): 0x00000005, 0x54410001 Starting kernel ... Uncompressing Linux... done, booting the kernel. e5943000 trying to parse the FDT dt_phys (r2) is NULL ! Error: unrecognized/unsupported machine ID (r1 = 0x000008cf). Available machine support: ID (hex) NAME ffffffff Marvell Kirkwood (Flattened Device Tree) Please check your kernel config and/or bootloader. Is this patch a correct approach to implement the above use case ? If yes, does anyone has an idea why this fails ? Note: this patch is for the 3.10 stable branch. Signed-off-by: Valentin Longchamp --- arch/arm/boot/compressed/head.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 032a8d9..a43c8a0 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -244,7 +244,7 @@ restart: adr r0, LC0 * dtb data will get relocated along with the kernel if necessary. */ - ldr lr, [r6, #0] + ldr lr, [r6, #0] @ potential appended dtb ? #ifndef __ARMEB__ ldr r1, =0xedfe0dd0 @ sig is 0xd00dfeed big endian #else @@ -253,6 +253,10 @@ restart: adr r0, LC0 cmp lr, r1 bne dtb_check_done @ not found + ldr lr, [r8, #0] @ conventionaly passed dtb ? + cmp lr, r1 + beq dtb_check_done @ yes, do not manage it + #ifdef CONFIG_ARM_ATAG_DTB_COMPAT /* * OK... Let's do some funky business here.