From patchwork Tue Jun 19 18:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10475179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 589DF60383 for ; Tue, 19 Jun 2018 18:17:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B5002889C for ; Tue, 19 Jun 2018 18:17:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FD3428926; Tue, 19 Jun 2018 18:17:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C6E42889C for ; Tue, 19 Jun 2018 18:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: References:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d8NzAwlbzzf49j16kD89ffZ63u2tsnceWvu1j5wcMvY=; b=arrUi9R9pQM3xg BtMnlVPcI2Mn0VgEHfOz5dK4qmeG8x67PQkYlJYW6Ds/WLJcIuXDLsMx+VmFxhi/4G3lcaTi/QJZV Ip1v0c9pKPKBXFL3j0LUoqjaFbPXdp2ZbofJa0JDWXSCsQL1l5pcfb6CprglBjFYu+jOFl4NDv4iZ NCpXLpgO1Z7gYuqXvzA50vf2Kh5ixXfdWAW2lmMo5sMiEEnch1pJehyn/EXnxBlK3w3AdseY2SOKo 7iSDUOf0jiwroTiMoYNN2trk4yrt8flrbzME89pbTkJlKc6GIOfiwjMCq4yPriJWIpcmlkGgpcY1J rnozo5J2VfzCmawQP/VQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVLC3-0001wZ-5j; Tue, 19 Jun 2018 18:17:27 +0000 Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVLBz-0001uh-No for linux-arm-kernel@lists.infradead.org; Tue, 19 Jun 2018 18:17:25 +0000 Received: by mail-it0-x244.google.com with SMTP id v83-v6so1766025itc.3 for ; Tue, 19 Jun 2018 11:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=g/pfRCYasrsCwiSKtQ0NDcmNjEABD04kZ9h5VC5JQ+o=; b=kCEV9rSFH+8QTiY4ByQR/udgBb1PgFxFDH84BVD6gzGceAydxsneq27TVRiCJN7Gzd /YXCfasFbo5xrhFuebstAcp+ug9UuhkO88AaZnSiskSwsqaGKX57xnO7uQZtOmA8oSGK 6tZc0yTUr1W5cnklpIfYKaARGOnJRL9YLkq5o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=g/pfRCYasrsCwiSKtQ0NDcmNjEABD04kZ9h5VC5JQ+o=; b=X8rX9SceqffGxFP4kqKSAaZ0trQGnpK4C2PpsgpN4Mjs9gykiyr2ZKwxj0ybLKcD54 m9ZRlmDIErsEHJX6XEHjCc+pZjIKr6PNKoMpYVuTCoF5h+msz099nfcg8Ulyn/x8oyT+ lLZHiJpHhF8lE55Fy6fGjMWmUEk5qmCYsY1BHaIjpwd5jjbggkhh/PtK8upmnTywR7Kj E0rwDnU1fUVMvT+W0zBEEmGm/2e+oWMx9t84qc1JrmzzhTlctsta32/L3F71h2yChj4n a15NZJaPYwJ0qz0WANe+/D3r/59etgQvXg157oqhsBCY3qk0a6MUDKa73RUIKU8ilSgb uC0w== X-Gm-Message-State: APt69E1X8XDXRr/i4C8QtcbyzY8tJfnZqKWVsmwc775OLKUxHp4kEWGi orYX00X5iPVC7QSnp+xAFSrySp82T+fGOgyHCEFL/jaFCQk= X-Google-Smtp-Source: ADUXVKJHSOKJ3b/IomiqSbBecFzIhLElAnCtD34hv8LK/kyF0dRo5gelj5rYxFicfjRX/Ywt8QEk5OLcBnaumS0lTd8= X-Received: by 2002:a24:1d0e:: with SMTP id 14-v6mr13697204itj.50.1529432231668; Tue, 19 Jun 2018 11:17:11 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:bbc7:0:0:0:0:0 with HTTP; Tue, 19 Jun 2018 11:17:11 -0700 (PDT) In-Reply-To: <20180619172422.GB16846@roeck-us.net> References: <1529384828-2452-1-git-send-email-linux@roeck-us.net> <20180619172422.GB16846@roeck-us.net> From: Ard Biesheuvel Date: Tue, 19 Jun 2018 20:17:11 +0200 Message-ID: Subject: Re: [RFC PATCH] ARM: Use logical or instead of addition for badr address calculation To: Guenter Roeck X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180619_111723_777841_B726BBC9 X-CRM114-Status: GOOD ( 18.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Arnd Bergmann , Russell King , linux-arm-kernel , Linux Kernel Mailing List Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 19 June 2018 at 19:24, Guenter Roeck wrote: > On Tue, Jun 19, 2018 at 03:35:07PM +0200, Ard Biesheuvel wrote: >> >> >> >> + /* this needs to be a separate macro or \@ does not work correctly >> >> */ >> >> + .macro __badr, c, rd, sym >> >> + .eqv .Lsym\@, \sym >> >> + adr\c \rd, .Lsym\@ + 1 >> > >> > >> > Wild shot, but the following works for me. >> > >> > .eqv .Lsym\@, \sym + 1 >> > adr\c \rd, .Lsym\@ >> > >> > Does it make sense ? >> > >> >> Interesting. Do you mean this works with your 2.30 binutils that >> triggers the original issue? >> > > Yes, it does. It is also the solution used for some graphics libraries, > though of course now I don't find the link anymore. > > Guess this is going nowhere given Russell's response, so I'll just > live with it, like obviously everyone else does already. I built > a toolchain using gcc 7.3.0 and binutils 2.28.1 which "solves" > the problem for me. > If we can live with using a wide encoding unconditionally, we could consider something like below. That forces the symbol references to be resolved at link time, which means we completely sidestep the new GAS code. -----------8<---------------- From: Ard Biesheuvel Date: Tue, 16 Jan 2018 12:12:45 +0000 Subject: [PATCH] ARM: assembler: prevent ADR from setting the Thumb bit twice To work around recent issues where ADR references to Thumb function symbols may or may not have the Thumb bit set already when they are resolved by GAS, reference the symbol indirectly via a global symbol typed as 'function', and emit a relocation that lets the linker fix up the reference. Signed-off-by: Ard Biesheuvel diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index 6ae42ad29518..1a55ce4b245c 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -195,13 +195,22 @@ .irp c,,eq,ne,cs,cc,mi,pl,vs,vc,hi,ls,ge,lt,gt,le,hs,lo .macro badr\c, rd, sym #ifdef CONFIG_THUMB2_KERNEL - adr\c \rd, \sym + 1 + __badr \c, \rd, \sym #else adr\c \rd, \sym #endif .endm .endr + /* this needs to be a separate macro or \@ does not work correctly */ + .macro __badr, c, rd, sym + .globl .Lsym_\sym\()_\@ + .type .Lsym_\sym\()_\@, %function + .set .Lsym_\sym\()_\@, \sym + .reloc ., R_ARM_THM_ALU_PREL_11_0, .Lsym_\sym\()_\@ + adr\c\().w \rd, . + .endm + /* * Get current thread_info. */