From patchwork Thu Jun 4 09:35:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 6545331 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 737459F326 for ; Thu, 4 Jun 2015 09:45:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88AF620713 for ; Thu, 4 Jun 2015 09:44:59 +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 A3951205FC for ; Thu, 4 Jun 2015 09:44:58 +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 1Z0Rg7-00028x-1g; Thu, 04 Jun 2015 09:43:11 +0000 Received: from szxga01-in.huawei.com ([58.251.152.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z0Rg1-0001xE-2F for linux-arm-kernel@lists.infradead.org; Thu, 04 Jun 2015 09:43:06 +0000 Received: from 172.24.2.119 (EHLO szxeml433-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CPB31580; Thu, 04 Jun 2015 17:42:03 +0800 (CST) Received: from localhost (10.177.18.231) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.158.1; Thu, 4 Jun 2015 17:35:07 +0800 From: Yang Yingliang To: , Subject: [RFC PATCH] arm64: Image: Allow the appending of a device tree binary Date: Thu, 4 Jun 2015 17:35:04 +0800 Message-ID: <1433410504-11628-1-git-send-email-yangyingliang@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.18.231] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150604_024305_836978_57C22F4C X-CRM114-Status: UNSURE ( 9.65 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) Cc: bones@secretlab.ca, linux-kernel@vger.kernel.org, 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 This patch provides the ability to boot using a device tree that is appended to the raw binary Image (e.g. cat Image .dtb > Image_w_dtb). Both BE and LE conditions are tested. Got references from e2a6a3aa ("ARM: zImage: Allow the appending of a device tree binary"). Signed-off-by: Yang Yingliang --- arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/kernel/head.S | 12 ++++++++++++ arch/arm64/kernel/vmlinux.lds.S | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7796af4..d402448 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -660,6 +660,17 @@ endmenu menu "Boot options" +config ARM64_APPENDED_DTB + bool "Use appended device tree blob to Image" + depends on OF + help + With this option, the boot code will look for a device tree binary + (DTB) appended to Image + (e.g. cat Image .dtb > Image_w_dtb). + + With this option, the size of Image will be extended to be 2MB aligned. + The 2MB memory followed by Image is used for FDT blob. + config CMDLINE string "Default kernel command string" default "" diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 19f915e..ac00c8a 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -274,6 +274,18 @@ ENDPROC(preserve_boot_args) * The dtb must be 8-byte aligned and live in the first 512M of memory. */ __vet_fdt: +#ifdef CONFIG_ARM64_APPENDED_DTB + ldr x21, =_edata + add x21, x21, x28 + ldr w0, [x21] +#ifndef __AARCH64EB__ + ldr w1, =0xedfe0dd0 // FDT magic word +#else + ldr w1, =0xd00dfeed +#endif + cmp w0, w1 + b.ne 1f // no FDT found +#endif tst x21, #0x7 b.ne 1f cmp x21, x24 diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index a2c2986..c71bac3 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -54,6 +54,18 @@ PECOFF_FILE_ALIGNMENT = 0x200; #define PECOFF_EDATA_PADDING #endif +/* + * Set FDT pointer 2MB aligned to ensure + * it don't cross a 2-megabyte boundary. + */ +FDT_FILE_ALIGNMENT = (1 << 21); +#ifdef CONFIG_ARM64_APPENDED_DTB +#define FDT_EDATA_PADDING \ + .fdt_edata_padding : { BYTE(0); . = ALIGN(FDT_FILE_ALIGNMENT); } +#else +#define FDT_EDATA_PADDING +#endif + #ifdef CONFIG_DEBUG_ALIGN_RODATA #define ALIGN_DEBUG_RO . = ALIGN(1<