From patchwork Fri Feb 12 12:06:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 61842 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp783649lbl; Fri, 12 Feb 2016 04:08:37 -0800 (PST) X-Received: by 10.98.0.194 with SMTP id 185mr1533176pfa.139.1455278917732; Fri, 12 Feb 2016 04:08:37 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id p70si19692466pfj.241.2016.02.12.04.08.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Feb 2016 04:08:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for 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: best guess record for 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 1aUCVS-0004qK-B3; Fri, 12 Feb 2016 12:07:26 +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 1aUCVP-0004nB-70 for linux-arm-kernel@lists.infradead.org; Fri, 12 Feb 2016 12:07:24 +0000 Received: by mail-wm0-x22a.google.com with SMTP id g62so16738225wme.0 for ; Fri, 12 Feb 2016 04:07:02 -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=tVm/ZwCzOwVecDfEIYNCCI9CAezkI2zErGy8/povKw4=; b=X7T/yejVCjNSEEXPSCa8u7vXdOgMGONmcw8hC009OwslUI5O01DfxpFuLK0agchR4P Ymfs1lMufe5eJVX1vZ9l1dV9Yb67C++HkxOLdZUxtRntBGHS8i+uKFGHYGgabE1gUx3Y A/vp7n7GGKw4uiz/TIdfBls0JYcqOxrf16h/w= 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=tVm/ZwCzOwVecDfEIYNCCI9CAezkI2zErGy8/povKw4=; b=hlEaKe4RTbGDpVnV6+2fclLbSHpOrAYi77pORAB5RVCQ09zTPWzMPuUxI1ykOQiKeF ZvPffL49PSVrH1N1rJhJ9RRtVen6mEYz1XCapUgCqE/QTzUA45yWJfQNtEVG92Gxjlsk Jf7B/Z2yAePSduj8/QGvQ+FrFUWGR9jYvD+dkLzGaAw43qoGmno72JcMT764cg+kV69N BtPTq8vfjLUJSkmu6s/bh0n2/bLsB6+JT3zxfbumSbtL6cjBOjdFXuskyLhM5McQWpl8 au5MPMpravp/Pf0Lceo9w9iMb2Mi8BGVslis/ItbHjUNf57REZaOWr6H786jzOWAQTrI KeYQ== X-Gm-Message-State: AG10YOT64VdFLoGH40EYFtxGuIk0GtADP3OHceqYSjHgec7HQ4UqW3+cEM+ZX/GWDs6gVUA/ X-Received: by 10.28.186.11 with SMTP id k11mr539002wmf.79.1455278821472; Fri, 12 Feb 2016 04:07:01 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id xx3sm11758718wjc.32.2016.02.12.04.06.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Feb 2016 04:07:00 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk Subject: [PATCH v2] ARM: vmlinux-xip.lds: assert that ROM and RAM don't overlap Date: Fri, 12 Feb 2016 13:06:43 +0100 Message-Id: <1455278803-27679-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-20160212_040723_463190_A4E3AC58 X-CRM114-Status: GOOD ( 14.25 ) 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 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: Chris Brandt , Ard Biesheuvel , Arnd Bergmann , nico@linaro.org 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: Chris Brandt Cc: Arnd Bergmann Signed-off-by: Ard Biesheuvel --- v2: rebased onto the split off XIP linker script arch/arm/kernel/vmlinux-xip.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 diff --git a/arch/arm/kernel/vmlinux-xip.lds.S b/arch/arm/kernel/vmlinux-xip.lds.S index 40bc4cadb959..07c642cff50e 100644 --- a/arch/arm/kernel/vmlinux-xip.lds.S +++ b/arch/arm/kernel/vmlinux-xip.lds.S @@ -213,6 +213,7 @@ SECTIONS _exiprom = .; /* End of XIP ROM area */ __data_loc = ALIGN(4); /* location in binary */ + ASSERT(. < PAGE_OFFSET + TEXT_OFFSET, "XIP_KERNEL: ROM and RAM overlap") . = PAGE_OFFSET + TEXT_OFFSET; .data : AT(__data_loc) {