Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10056315imu; Wed, 5 Dec 2018 15:20:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vr+ZpMTB+Ai01+XfSKzx9L0Dy5nDfWGqZqFL83zOcmzHmldCKyrvP4wwfEzUuaKSrQXfRU X-Received: by 2002:a65:48c4:: with SMTP id o4mr21393630pgs.371.1544052030224; Wed, 05 Dec 2018 15:20:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544052030; cv=none; d=google.com; s=arc-20160816; b=jE7TEJ8QrCx99XOW/hfO/lJuUQwyFtJdF/El35dCSjZ25aq5DmqNLU39/pCRThOh0w ZDnf+aGQ/ZGpj4dn5u/s6b10bpX6KfTRZGKz+O7hfalTwHZ2O9EtWjIfw5yS3+GfFWWu kDq6uTp2QbTf5m6bc+Q3W72+LPDIpG8iw2n1J+AJgsPWPkhRsXTo2WxCRRsrR/sDcTU/ rVBc0ImHnyUFey/fNeoGUO/e8qVwDmLwOTZgQGcsqfzEMkFJA4W2SWDAFa4SJ1sivIJO cjWWZwr0XinNxqZRumoPtPA7M8tdawlXR+MfYK6uYaZRrvlGGkyQucyBFxyJKMd7s84R ji6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2YlBMkJkpTpZ3nrqYYdySevUvE+u+8g6B7blYj0tBs8=; b=v/F86Ffoonsw8VNfUXi3Rp+lvYx7CIGSoEnxhztfK/n/XmXofqgHrjpXlFqIrxhxqA szR7ncD5zqEhI4nzUFSC9+HjzdIl0g9p99FhS5shG4CsBqwfrQfDU7q0OvKZK104pl7S HndiSCuTlsbOIY8NTc9CorI15SbKNCFSbxLuE6Lvrj1D+w2hGQjjAoWSB6Ps0736Np4K 91oynDlDH8LuPrXRxE9wsiJ+PTYaGDAX5xsHrOwX5crBnd8kTNseuK3aWi859vU07ITD RWCzAaJHg/VEzN3IwiUDXY/t2uQ3xJXxF9bST9HmCt4Lf1ZbTsf0tfQC2e1RfYE54PIB 1gWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jvh1W6hm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m15si19167003pgc.381.2018.12.05.15.20.10; Wed, 05 Dec 2018 15:20:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jvh1W6hm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728546AbeLEXTc (ORCPT + 99 others); Wed, 5 Dec 2018 18:19:32 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33308 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727701AbeLEXTc (ORCPT ); Wed, 5 Dec 2018 18:19:32 -0500 Received: by mail-pl1-f195.google.com with SMTP id z23so10804318plo.0 for ; Wed, 05 Dec 2018 15:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2YlBMkJkpTpZ3nrqYYdySevUvE+u+8g6B7blYj0tBs8=; b=jvh1W6hmIRYaI3y1y+H9ApY1qXlPNwYhkTQvi+M3YoIYvAZO5pALSYFKeo+IS+KiJz Vyu/6dtD1XrP29uUPJoHIFLLZSXwZQTxjL8onnGXKBXMZ8v+HohQNEv8sQgE1NXGpZ8U Vm07LvNw0BhVaK5/tB/rutNGMPKPS3mQ3oWW277EBF267AsFhaKfrO/QcKCbOjKjZ4wf fa+uKySQ0LECB4kPVNwwGNOMIWeCb+wXdrNwtxgm6f6yMHDlLW8CY8g0Y8FLD0yHg3p2 Dj/layW3Edppy4iT7ZG79EeX8IspnsFShhxBcs3nNcVTwOpnu9C9d91aMmX1Gti4BuPd IyOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2YlBMkJkpTpZ3nrqYYdySevUvE+u+8g6B7blYj0tBs8=; b=Neb1c/edWffzobcIgviLeliowOPHmlzDxOPDqqHNXMU4u5KspMfzaRyMEtghliJewW dN99OxE3BvcpZZ84LjyIseDrr9GzkFQlxHY6oyXl8V+bKavYKK6eywR6FldhzMUL0fL2 mwwgTLT1PXI1gqKyPrqREDJaWyi/JLxfvwUIupOlH737CuzLtLjZiA0ykPxBx8g2OgUJ VYyFJrymMUo+Wh27AUHPRSsxqyGsnZ4T/Qe/WmEn3+8pCqfyY1tzZZzDTzeRHjS6LuWp nHwGuBdbn4wjDYLB9oEEe3FjOjb+HBco+/LAKYpdsUt1B/ukZ98deqQMKt3t9d85EfN/ rSTw== X-Gm-Message-State: AA+aEWYlCEkn+to650L+O7MeH0ccEfoE3xcgJtSTFns5tD/QKkbNH0ml uPqIiBOrzQ1UN0oZLzxhcJpHdM47s2ZCJ9asM7Wq/Q== X-Received: by 2002:a17:902:7b88:: with SMTP id w8mr25785398pll.320.1544051970720; Wed, 05 Dec 2018 15:19:30 -0800 (PST) MIME-Version: 1.0 References: <20181205014213.943-1-natechancellor@gmail.com> <20181205014213.943-2-natechancellor@gmail.com> <20181205080645.GA11936@flashbox> <20181205183606.GA7274@flashbox> In-Reply-To: From: Nick Desaulniers Date: Wed, 5 Dec 2018 15:19:19 -0800 Message-ID: Subject: Re: [PATCH 2/2] ARM: Wrap '--pic-veneer' with ld-option To: Stefan Agner Cc: Ard Biesheuvel , Nathan Chancellor , Arnd Bergmann , linux@armlinux.org.uk, Linux ARM , LKML , Nicolas Pitre Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 5, 2018 at 2:59 PM Stefan Agner wrote: > > On 05.12.2018 19:41, Nick Desaulniers wrote: > > On Wed, Dec 5, 2018 at 10:40 AM Ard Biesheuvel > > wrote: > >> > >> On Wed, 5 Dec 2018 at 19:36, Nathan Chancellor wrote: > >> > > >> > On Wed, Dec 05, 2018 at 09:09:56AM +0100, Ard Biesheuvel wrote: > >> > > (+ Arnd) > >> > > > >> > > On Wed, 5 Dec 2018 at 09:06, Nathan Chancellor wrote: > >> > > > > >> > > > On Wed, Dec 05, 2018 at 08:37:05AM +0100, Ard Biesheuvel wrote: > >> > > > > On Wed, 5 Dec 2018 at 02:42, Nathan Chancellor wrote: > >> > > > > > > >> > > > > > This flag is not supported by lld: > >> > > > > > > >> > > > > > ld.lld: error: unknown argument: --pic-veneer > >> > > > > > > >> > > > > > Signed-off-by: Nathan Chancellor > >> > > > > > >> > > > > Hi Nate, > >> > > > > > >> > > > > Does this mean ld.lld is guaranteed to produce position independent > >> > > > > veneers if you build kernels that are bigger than the typical range of > >> > > > > a relative branch? > >> > > > > > >> > > > > >> > > > Hi Ard, > >> > > > > >> > > > Honestly, I'm not quite sure. I saw your commit that introduced this > >> > > > flag and I wasn't quite sure what to make of it for lld. What > >> > > > configuration would I use to verify and what would I check for? > >> > > > > >> > > > >> > > Try building allyesconfig, and check the resulting binary for veneers > >> > > (which have 'veneer' in the symbol name, at least when ld.bfd emits > >> > > them). These veneers should not take the [virtual] address of the > >> > > branch target directly, but take a PC relative offset (as in the > >> > > example in the commit log of that patch you are referring to) > >> > > > >> > > >> > Alright, compiling with allyesconfig is a little rough at the moment > >> > (bug reports I will file in due time) but I was able to do it. Here's > >> > the disassembly specifically for the functions you had in your commit, > >> > my assembly knowledge is pretty much non-existent unfortunately so I am > >> > not sure what to make of it (it doesn't look like there is a virtual > >> > address for pc in that mix?). I am happy to provide any more information > >> > that is needed. > >> > > >> > c03030cc <__enable_mmu>: > >> > c03030cc: e3c00002 bic r0, r0, #2 > >> > c03030d0: e3c00b02 bic r0, r0, #2048 ; 0x800 > >> > c03030d4: e3c00a01 bic r0, r0, #4096 ; 0x1000 > >> > c03030d8: e3a05051 mov r5, #81 ; 0x51 > >> > c03030dc: ee035f10 mcr 15, 0, r5, cr3, cr0, {0} > >> > c03030e0: ee024f10 mcr 15, 0, r4, cr2, cr0, {0} > >> > c03030e4: eafff3c5 b c0300000 <__turn_mmu_on> > >> > c03030e8: e320f000 nop {0} > >> > c03030ec: e320f000 nop {0} > >> > c03030f0: e320f000 nop {0} > >> > c03030f4: e320f000 nop {0} > >> > c03030f8: e320f000 nop {0} > >> > c03030fc: e320f000 nop {0} > >> > > >> > c0300000 <__turn_mmu_on>: > >> > c0300000: e1a00000 nop ; (mov r0, r0) > >> > c0300004: ee070f95 mcr 15, 0, r0, cr7, cr5, {4} > >> > c0300008: ee010f10 mcr 15, 0, r0, cr1, cr0, {0} > >> > c030000c: ee103f10 mrc 15, 0, r3, cr0, cr0, {0} > >> > c0300010: ee070f95 mcr 15, 0, r0, cr7, cr5, {4} > >> > c0300014: e1a03003 mov r3, r3 > >> > c0300018: e1a0300d mov r3, sp > >> > c030001c: e1a0f003 mov pc, r3 > >> > > >> > >> Thanks Nate. > >> > >> So these functions no longer appear to reside far away from each > >> other, so there no veneer has been emitted. > >> > >> What we're looking for are veneers, i.e., snippets inserted by the > >> linker that serve as a trampoline so a branch target that is far away > >> can be reached. > >> > >> If no symbols exist with 'veneer' in their name *, it might make sense > >> to rebuild the kernel as Thumb2, which has a branching range of only 8 > >> MB (as opposed to 16 MB for ARM mode) > > > > Heh, Arnd and I were just talking about this yesterday. Is there a > > config that sets Thumb2 mode for the kernel? > > > > Yes there is CONFIG_THUMB2_KERNEL, and it works also with LLVM/Clang. Sounds like something we should put under CI? https://github.com/ClangBuiltLinux/continuous-integration/issues/94 > > However, it sometimes leads to surprising issues, like I just > encountered a few days ago: > > https://lore.kernel.org/linux-pci/20181126161645.8177-1-stefan@agner.ch/ > > -- > Stefan > > >> > >> * I have no idea whether lld names its veneers like this, or even at all -- Thanks, ~Nick Desaulniers