From patchwork Mon Feb 1 17:02:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 60942 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp151662lbb; Mon, 1 Feb 2016 09:04:31 -0800 (PST) X-Received: by 10.98.7.219 with SMTP id 88mr7813882pfh.49.1454346270927; Mon, 01 Feb 2016 09:04:30 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ym10si25307213pab.146.2016.02.01.09.04.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Feb 2016 09:04:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org 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 1aQHse-00082D-1C; Mon, 01 Feb 2016 17:03:12 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQHsb-0007vy-7p for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2016 17:03:10 +0000 Received: by mail-wm0-x22a.google.com with SMTP id l66so81083997wml.0 for ; Mon, 01 Feb 2016 09:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Y/O2t9eXhwrLXpujjIfNo93pVHyxUUT+l7lxs1GJWQU=; b=jqKJSEMLvCEZ2mEkeEnKTrLJmhUJtTTDDszTNA3x9d6nXNKDU8hH8tneFavBpef8XW 2NxR9rtooc342hGq4ttHYub2svuX/ZiQ6t+L/5FDEeWLnFYMDagfEsMF1lJsC4TOC1IR Sf2jn2NKBXo9REbptZWghMmJ6reJ6fpjuMdY8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Y/O2t9eXhwrLXpujjIfNo93pVHyxUUT+l7lxs1GJWQU=; b=GY0JUAtyzoleaa0/lLsBCjBEd9BEntX698+oaopCur3ZQ/wuONDN1vaq42PPXyqtZk bHCq/eZ8+JBmJ3irOrMKYAVjTpeSs0WUa3hv8Z69aE9UJRXYbosm/SYVhw94ytt/2xTb +98bYOdLM+WHgXfAIa4K7/gMWUFbkuPcIUgEwUaDTU1CM96+YWVCo3XQhHtr3jhW8W78 nx80Ivy5BSZ9KVk0F1GRSWrmu3kvE88hzEs0ZyjogMoJ9ceNvL3yQ9Wx73WdkAceGDn+ SwEWv5KvUyDGFJXY91TSIX1LmI3g/ZM9F2ygGDZ1rZZdnwz6YR8675K7rTnXasGpzBGh 7hLA== X-Gm-Message-State: AG10YORbxdr0h/yN2mvOM6hU3EOjeFSOH2QXwiac/6/GXmRWtbcvziKx/Y76ll/Yb4u+gvGw X-Received: by 10.194.176.170 with SMTP id cj10mr23886619wjc.165.1454346166010; Mon, 01 Feb 2016 09:02:46 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id i12sm1520367wmf.10.2016.02.01.09.02.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Feb 2016 09:02:45 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, arnd@arndb.de, linux@arm.linux.org.uk Subject: [PATCH] ARM: vmlinux.lds: assert that ROM and RAM don't overlap when XIP_KERNEL=y Date: Mon, 1 Feb 2016 18:02:34 +0100 Message-Id: <1454346154-12931-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160201_090309_454252_8DEB7A6F X-CRM114-Status: GOOD ( 14.00 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org When building an XIP kernel, the linker produces two disjoint VMA regions, where the first is mapped onto ROM and the second onto RAM. For this reason, the linker output pointer '.' is updated halfway through the linker script, and set to a value that corresponds with the start of the RAM region. However, in some cases, the ROM region exceeds the expected size, and the assignment of the output pointer results in a decrement rather than an increment, causing the virtual addresses of the .data region to clash with the .text region. Such a kernel cannot boot normally, but it also confuses the hell out of kallsyms, since .data symbols may appear inside the [_stext, _etext] or [_sinittext, _einittext] intervals in the first pass, but not in the second (or vice versa), resulting in inconsistent kallsyms data. So let's make sure that the output pointer only advances, and never jumps back into the ROM region. Cc: arnd@arndb.de Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel Acked-by: Arnd Bergmann diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 8b60fde5ce48..950114d533e1 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -229,6 +229,7 @@ SECTIONS #ifdef CONFIG_XIP_KERNEL __data_loc = ALIGN(4); /* location in binary */ + ASSERT(. < PAGE_OFFSET + TEXT_OFFSET, "XIP_KERNEL: ROM and RAM overlap") . = PAGE_OFFSET + TEXT_OFFSET; #else #ifdef CONFIG_ARM_KERNMEM_PERMS