From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7202C433F5 for ; Mon, 24 Jan 2022 17:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Y00I7NakePnmu1MmIUvt3e84MSMQkTC+hIVp0AZococ=; b=nclUPMakNkLsWz yTSZUWGnZMqzXYuJMRcKTplzFH7cGqmZkrsk0D9i2Yi+Ay2DJJXtE2u2Hby0KlgjZIBMRUaJALCDi L01v9MrhNuuwjjTB9UMNVGwZKGOmHv+ljPE57kIUPtWWt55fIVaLFmLd3fQgkP3/7J1gGcgwnzfFK 4TUCFYX8F5BbX8uNdc5Wqs3Pv99/ZxVm2ndZzUjwnMop1VD/Y+PejLK1M33QaMHvksPOXGSEWoJet EoIqDYy/nLohL70tzQCAHtDDqoOus/w6sxyLdHaCuElQNYEwRxG4DoBLHfx2BEZLS1R1wTzKBuw1j e1DaRD/Y4nup1a0XBLzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC3b6-004Jag-08; Mon, 24 Jan 2022 17:57:44 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC3SX-004FRL-5o for linux-arm-kernel@lists.infradead.org; Mon, 24 Jan 2022 17:48:56 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AEFD5B811AF; Mon, 24 Jan 2022 17:48:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E80CC36AE7; Mon, 24 Jan 2022 17:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643046530; bh=H0WV7vrKQbWB1Awhw9ySRwNXiJJ8r6SoJ0MYC3/Miog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Awa+SUSBVw4Cjv7gWC54/phF75tHavfcZJ6zxUoWwwY7oV0AXsx78lJoCMAP/IG2l 2Hb6PloN6IwJuvnRKd3uhtUfmC42lJ7yJdyyZbdAtoWgWS/+1eDga/CXU6dQf2IAV3 vrnGWOMsNqz0up1P1d8PxmTgDTgqCKoMWHQG569mMMmBmDtsxVzIcPpvvuWNBjmxSK MK1pS1bJ7U4N6628LJbloHdMwJloyOJa9gZhGmrZt0+rlHJFlER8DrIPEOM0d24g5A dXp41i8NKOJpXmKF187f6ZaIPE03BV/Sk9GzKKceX9MN23qReKS/lkaf/PuRd9z/6P VgQ3mmryaDgTA== From: Ard Biesheuvel To: linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org Cc: linux-hardening@vger.kernel.org, Ard Biesheuvel , Nicolas Pitre , Arnd Bergmann , Kees Cook , Keith Packard , Linus Walleij , Nick Desaulniers , Tony Lindgren , Marc Zyngier , Vladimir Murzin , Jesse Taube Subject: [PATCH v5 17/32] ARM: assembler: introduce bl_r macro Date: Mon, 24 Jan 2022 18:47:29 +0100 Message-Id: <20220124174744.1054712-18-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220124174744.1054712-1-ardb@kernel.org> References: <20220124174744.1054712-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1351; h=from:subject; bh=H0WV7vrKQbWB1Awhw9ySRwNXiJJ8r6SoJ0MYC3/Miog=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBh7uYi3TRRo6mSL1XuT8QGS5n8WjABJagybV0n3gU5 fN625YyJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYe7mIgAKCRDDTyI5ktmPJJLVC/ 0ZilvHXspKHYyuEMTRZkwch6X7zUEy1d/kLw4yxyn9Q4lVJlo55eCV2D3ScX8zAvtoBErnTp4hPr3T B4KxjQugAlsatQFWeR6VVSmkBU2CXyP05JWPVbcTTLE33LXICC7W0555MVLOOnH4mKrQJXyOoMseM2 yf97w9arzE2+OXu9s+uv0SlgK4S9riTNTFArSZtbV9pp9VQAvNSD8ruufKFA6yRYQe2vbAPiPVK3T5 0sU2YBS1cbni1SwKQoUcEtFhuO29dV0dMbSYBleO6RE9RCJ+sWamUOit7Qk/vE+LnFpZauJKf1DqO/ 4IXTdq4mvipX4FsDRVxceLuiNrbqICRgI4HXY4ifi6K/XOUsUVnWlM1OYMVej68RSDmmBrBoJdqRJo PUEhSiQO3+8ywAn4Uxsw7k5stq5nxfVCN06TrkUBXcsBKIKSSRPYKzDsmcx1ZhqmyOjjfxQ5go+l65 lfZAH0dfg2SaesPoQI7fnQ9WooeEYUtoQjByfAXfEhvuQ= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220124_094853_554066_6742110F X-CRM114-Status: GOOD ( 13.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a bl_r macro that abstract the difference between the ways indirect calls are performed on older and newer ARM architecture revisions. The main difference is to prefer blx instructions over explicit LR assignments when possible, as these tend to confuse the prediction logic in out-of-order cores when speculating across a function return. Signed-off-by: Ard Biesheuvel Reviewed-by: Arnd Bergmann Acked-by: Linus Walleij Tested-by: Keith Packard Tested-by: Marc Zyngier Tested-by: Vladimir Murzin # ARMv7M --- arch/arm/include/asm/assembler.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index bf304596f87e..7242e9a56650 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -744,4 +744,19 @@ THUMB( orr \reg , \reg , #PSR_T_BIT ) .endif .endm + /* + * bl_r - branch and link to register + * + * @dst: target to branch to + * @c: conditional opcode suffix + */ + .macro bl_r, dst:req, c + .if __LINUX_ARM_ARCH__ < 6 + mov\c lr, pc + mov\c pc, \dst + .else + blx\c \dst + .endif + .endm + #endif /* __ASM_ASSEMBLER_H__ */ -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel