From patchwork Mon Nov 30 01:45:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl van Schaik X-Patchwork-Id: 7719961 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 BA078BEEE1 for ; Mon, 30 Nov 2015 01:46:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF4D320561 for ; Mon, 30 Nov 2015 01:46:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9161420570 for ; Mon, 30 Nov 2015 01:46:40 +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 1a3DVb-0000mG-2s; Mon, 30 Nov 2015 01:44:03 +0000 Received: from cog.systems ([125.63.60.25] helo=mail.cog.systems) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a3DVX-0000lK-MK for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2015 01:44:00 +0000 Received: from [10.21.11.126] (203-174-176-86.syd.static-ipl.aapt.com.au [203.174.176.86]) by mail.cog.systems (Postfix) with ESMTPSA id 2D80422C076; Mon, 30 Nov 2015 12:43:15 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cog.systems; s=mail; t=1448847795; bh=6+qsRsfjo6GLaEx4aEw9Z3ucrMeGCWNSLpiFU/xU+so=; h=Date:From:To:CC:Subject:From; b=a2enrTAHxaX6j7P5BK/PwRn2kvrusaQx3j+aMb9wXgwTyZaavgkdzf1oUwvrVc37z 8ewM//7nAyoEj8TdLrKv0Z3dHKxBCD9UAOf6stdOTwHsMNorOwbyd+7FK2KtKLhzjT uMqVA/mZ6SB47DwgBbQNjWrkS4eZyo8z7YMWUS5M= Message-ID: <565BAA2E.5090102@cog.systems> Date: Mon, 30 Nov 2015 12:45:18 +1100 From: Carl van Schaik Organization: Cog Systems Pty. Ltd. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: linux-arm-kernel@lists.infradead.org Subject: arm64 boot requirements X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151129_174400_307238_B558225A X-CRM114-Status: GOOD ( 16.80 ) X-Spam-Score: -2.0 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 In commit bd00cd5f8c8c3c282bb1e1eac6a6679a4f808091, the idmap_pg_dir and swapper_pg_dir where moved from before the kernel to after it. The problem is that these symbols fall outside the range covered by the ELF file - outside of any section. A bootloader which loads the kernel ELF file and dynamically determines where to place the DTB, may try place it after the kernel. We've just run into this problem and the DTB gets overwritten as soon as the pagetables are created. I'd suggest that the kernel either: A. document this boot requirement for where not to load a DTB B. update the vmlinux.lds.S such that these symbols (and _end) are properly covered by a section in the ELF, and thus preventing this issue. thanks, Carl From 25f5edabb5a719e24cc1865eb50b7894d0f976cf Mon Sep 17 00:00:00 2001 From: Carl van Schaik Date: Mon, 30 Nov 2015 12:39:59 +1100 Subject: [PATCH] arm64: place initial page tables in ELF section The swapper_pg_dir and idmap_pg_dir are placed above the kernel image, after the BSS. Currently, these are outside of any section in the ELF, which means a bootloader cannot from the ELF file alone determine where to place data (DTB etc). It needs to reserve an arbitarty space. This patch places the idmap_pd_dir and swapper_pg_dir symbols into a new .pg_dir section. With this defined, the bootloader can safely place images using addresses after the ELF. Signed-off-by: Carl van Schaik --- arch/arm64/kernel/vmlinux.lds.S | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index a2c2986..759ae68 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -154,10 +154,12 @@ SECTIONS BSS_SECTION(0, 0, 0) . = ALIGN(PAGE_SIZE); - idmap_pg_dir = .; - . += IDMAP_DIR_SIZE; - swapper_pg_dir = .; - . += SWAPPER_DIR_SIZE; + .pg_dir : { + idmap_pg_dir = .; + . += IDMAP_DIR_SIZE; + swapper_pg_dir = .; + . += SWAPPER_DIR_SIZE; + } _end = .; -- 2.3.2