From patchwork Tue Mar 24 10:16:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46234 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D3403214B0 for ; Tue, 24 Mar 2015 10:18:41 +0000 (UTC) Received: by wghl18 with SMTP id l18sf31245983wgh.1 for ; Tue, 24 Mar 2015 03:18:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=DTYncj8lnclI7UoWpECkaYvYzINtxY3yWiQ9bTgaaks=; b=S+1ueh6e4tel9MOaR3WU63UTZTnruynBu/k6cl146pe1iWOpnM8Zc15B/2YHuwJmex ozeikufMekSKA69FXwr/hD0cfZTDLewrSps73RHAIDhTS1WukdXEk1lv8LvuxefKUv5Y EZ8FiXbWtK5BinpVmBaUB9N7R2rd7REo3boTfg3hmQXk3os2dfpFADESkxlSgl5ENH9o dJGq4Z7kILh/nexZ/xW6PNUe1R9zi+IQ+cyCAcrZ4WCNIep67WN32jFGHtvk4yPol0GM 8bOI5y8vpbOLoN0auKG4iPoN51NY7eP7rU0WQdRxy7Btm/zOmgqthPhTIHJUkoaTudw4 hyMA== X-Gm-Message-State: ALoCoQlDpPWHLzxrJlgM+DZwcB8pCe9Ifl8bbBCm/PirdXgIadzHxMvK6DWZlwn6jPG/cO9GrWvg X-Received: by 10.112.242.7 with SMTP id wm7mr675811lbc.1.1427192321134; Tue, 24 Mar 2015 03:18:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.69 with SMTP id kw5ls716488lac.86.gmail; Tue, 24 Mar 2015 03:18:41 -0700 (PDT) X-Received: by 10.152.3.196 with SMTP id e4mr3204575lae.40.1427192320996; Tue, 24 Mar 2015 03:18:40 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id xl4si2723425lac.1.2015.03.24.03.18.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Mar 2015 03:18:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by labto5 with SMTP id to5so47781751lab.0 for ; Tue, 24 Mar 2015 03:18:40 -0700 (PDT) X-Received: by 10.112.201.231 with SMTP id kd7mr3131639lbc.35.1427192320766; Tue, 24 Mar 2015 03:18:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp1352329lbq; Tue, 24 Mar 2015 03:18:39 -0700 (PDT) X-Received: by 10.68.102.228 with SMTP id fr4mr6038041pbb.87.1427192318994; Tue, 24 Mar 2015 03:18:38 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ko8si4838940pdb.191.2015.03.24.03.18.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Mar 2015 03:18:38 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1YaLtI-0000y5-SZ; Tue, 24 Mar 2015 10:16:56 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YaLtE-0000rf-Tx for linux-arm-kernel@lists.infradead.org; Tue, 24 Mar 2015 10:16:53 +0000 Received: by wixw10 with SMTP id w10so90759573wix.0 for ; Tue, 24 Mar 2015 03:16:30 -0700 (PDT) X-Received: by 10.180.108.81 with SMTP id hi17mr26619219wib.91.1427192190483; Tue, 24 Mar 2015 03:16:30 -0700 (PDT) Received: from ards-macbook-pro.local ([90.174.5.112]) by mx.google.com with ESMTPSA id w3sm15215656wiz.5.2015.03.24.03.16.28 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Mar 2015 03:16:29 -0700 (PDT) From: Ard Biesheuvel To: linux@arm.linux.org.uk, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, nico@linaro.org Subject: [PATCH] ARM: force linker to use PIC veneers Date: Tue, 24 Mar 2015 11:16:24 +0100 Message-Id: <1427192184-31261-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150324_031653_117807_B1EDE833 X-CRM114-Status: GOOD ( 11.17 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.177 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.177 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 When building a very large kernel, it is up to the linker to decide when and where to insert stubs to allow calls to functions that are out of range for the ordinary b/bl instructions. However, since the kernel is built as a position dependent binary, these stubs (aka veneers) may contain absolute addresses, which will break such veneer assisted far calls performed with the MMU off. For instance, the call from __enable_mmu() in the .head.text section to __turn_mmu_on() in the .idmap.text section may be turned into something like this: c0008168 <__enable_mmu>: c0008168: f020 0002 bic.w r0, r0, #2 c000816c: f420 5080 bic.w r0, r0, #4096 c0008170: f000 b846 b.w c0008200 <____turn_mmu_on_veneer> [...] c0008200 <____turn_mmu_on_veneer>: c0008200: 4778 bx pc c0008202: 46c0 nop c0008204: e59fc000 ldr ip, [pc] c0008208: e12fff1c bx ip c000820c: c13dfae1 teqgt sp, r1, ror #21 [...] c13dfae0 <__turn_mmu_on>: c13dfae0: 4600 mov r0, r0 [...] After adding --pic-veneer to the LDFLAGS, the veneer is emitted like this instead: c0008200 <____turn_mmu_on_veneer>: c0008200: 4778 bx pc c0008202: 46c0 nop c0008204: e59fc004 ldr ip, [pc, #4] c0008208: e08fc00c add ip, pc, ip c000820c: e12fff1c bx ip c0008210: 013d7d31 teqeq sp, r1, lsr sp c0008214: 00000000 andeq r0, r0, r0 Note that this particular example is best addressed by moving .head.text and .idmap.text closer together, but this issue could potentially affect any code that needs to execute with the MMU off. Signed-off-by: Ard Biesheuvel Acked-by: Nicolas Pitre --- arch/arm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/Makefile b/arch/arm/Makefile index eb7bb511f853..ae5b33527f32 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -13,7 +13,7 @@ # Ensure linker flags are correct LDFLAGS := -LDFLAGS_vmlinux :=-p --no-undefined -X +LDFLAGS_vmlinux :=-p --no-undefined -X --pic-veneer ifeq ($(CONFIG_CPU_ENDIAN_BE8),y) LDFLAGS_vmlinux += --be8 LDFLAGS_MODULE += --be8