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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E329C433EF for ; Tue, 5 Oct 2021 07:18:12 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 09AE660F59 for ; Tue, 5 Oct 2021 07:18:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 09AE660F59 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=xJQbUeTFh1qDsz9f4pUBouf1ooW+WG8iybQ2Z0sgOaI=; b=fF7piTnRDWYT9k JpP/kkNMRhKeFC6BvGQh/4Q0sB1Yy1TosbobW9MYVl/xN0oPsYRm6ngNK5LvxGfBLQhXba8FSZxwL iGxYzlMWTPhyvcsFp1sibDPPsvQfEaTEo1d0v8wax0xAJX/bUn0FugbJDO2gcMLw/6VL+71caGqHt 84HZWHqrFUoaLm63suub8cQrbqExIFy3LbJn6DzBj0FSN2jKFaEoIRrX+gXPkFSbs6SvAozQydbHy C0C7AZg2nb4zoS5IbOzcfWcd5wI00jLqHuWXQ3RS+ctdFFCkDuvCdm1CNRGkrBRxJtHqg+7x3HACf nbvSowfdLYnjbTV3a8JQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXegm-009IPj-8J; Tue, 05 Oct 2021 07:16:36 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXegO-009IIH-9p for linux-arm-kernel@lists.infradead.org; Tue, 05 Oct 2021 07:16:13 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6568861409; Tue, 5 Oct 2021 07:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633418172; bh=eldpe3OD5DtorvmYYbs1PHLOj1oU8dj+5zjEKk4o0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DIRxALOfklWKd2fiKt4xpdzGLtt30Zm8Alq7Ik/e8JtCdIuORRuyLlbCergjqHV7h spOkbAmKR7iAOvFbC497y1j8XqcoJZWJsOIrzchNDaJRZsm4aIosqZimXSOqr3/O+r QTSQ9MP/i0bhZiKPh3e5LBlCiRM/OERjofxI0mE4Igm8skDZllx3xKxQGiMfZVDofo HHELU2N7+jUR2fGgh/fgV96HnvYIqUbeAYZJHawuNAMPbDDNS3q3MEpBiuD2ZRY2QJ EIDIx1AM0PKg3PNyipoRNEAieaO0Wn68v2T624oFTBI6kN3k80SYccO+Rc6ry8zH5h 7k8zU8EICpxrQ== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk Cc: Ard Biesheuvel , Arnd Bergmann , Kees Cook , Keith Packard , Linus Walleij Subject: [PATCH v2 2/9] ARM: assembler: introduce bl_r and bl_m macros Date: Tue, 5 Oct 2021 09:15:35 +0200 Message-Id: <20211005071542.3127341-3-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211005071542.3127341-1-ardb@kernel.org> References: <20211005071542.3127341-1-ardb@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211005_001612_390174_33A4B5D2 X-CRM114-Status: GOOD ( 12.41 ) 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 some macros 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 --- arch/arm/include/asm/assembler.h | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index 7d23d4bb2168..abb8202ef0da 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -624,4 +624,41 @@ 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 + + /* + * bl_m - branch and link to address held in memory + * + * @dst: memory reference to load the branch target from + * + * This uses the same syntax as ldr instructions, including things like + * register writeback (where it makes sense). For example, + * + * bl_m [ip, #] + * + * Note that @dst should not reference lr as it may be clobbered early. + */ + .macro bl_m, dst:vararg + .if __LINUX_ARM_ARCH__ < 6 + mov lr, pc + ldr pc, \dst + .else + ldr lr, \dst + blx lr + .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