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 X-Spam-Level: X-Spam-Status: No, score=-18.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1069DC433F5 for ; Tue, 21 Sep 2021 09:57:07 +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 CF16761168 for ; Tue, 21 Sep 2021 09:57:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CF16761168 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=nhCXcmabbZ9GhM uT2pL+5+KcFloDMvCncJcNnAifIzu7vbrM4jQ0x1WKIaIK9Idr7Dis4cRqtJ9u/8sHQYayilMrMQc Z6TL2v7j4/AhxvTHAGvD9AkU48u4wydjNBpL50X4r1Oc3ioDKWAaoQSbaGCI7iE3E9rxdLyVSk4wU P9TjFL6KqBFpNzgn0Kp0vcyKs5ZbAYqv9upe57mi5p+Y24bTgF0oP2EmRoVjp57Yd7gyobYQEbczi ONekhjPkLI/igzwsMCqYFuImH0nAuTH9fM5vV6mDRTAM/TFR87cnGn/WcMEl5hT0gjTzoMlZ0UljU gDC3LpMt91NhNj30DuSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mScUI-00459A-O5; Tue, 21 Sep 2021 09:54:54 +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 1mScTm-00452Z-Ar for linux-arm-kernel@lists.infradead.org; Tue, 21 Sep 2021 09:54:23 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4DF3C61184; Tue, 21 Sep 2021 09:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632218062; bh=eldpe3OD5DtorvmYYbs1PHLOj1oU8dj+5zjEKk4o0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cv/CQUuq9HSD+xsuL/aBVFuY23WhS11OtJ+l2vy7lNh/Pw286jC/1MpBI8R6EzExx pD233L6OOP4oU04LokFMd80Z9xJWEd8qi2KT40r7cJ/jQvFrJjO/99Q/fbPFH3M/TD 5+FsAe9CYZNN7JpiIoOpXHXiJOn2OdDj6jSSYUAQBk382UERsAXHt1j+Zv1Zubk/kT vTOF1veG5nf/U1DiLBWkcr6g1YMn4lkNargu043iZctHIUzPLCM6DdEIbjCH5qdE4D ZU247qN6e9CC3t/9g59o1FKeUL1rualzrruS2kcU5TLUdzAeVH2hr03Otwld3ExqUZ RFqSW1r8TsrKw== From: Ard Biesheuvel To: linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Arnd Bergmann , Kees Cook , Keith Packard , Linus Walleij Subject: [PATCH 03/10] ARM: assembler: introduce bl_r and bl_m macros Date: Tue, 21 Sep 2021 11:54:01 +0200 Message-Id: <20210921095408.133210-4-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210921095408.133210-1-ardb@kernel.org> References: <20210921095408.133210-1-ardb@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210921_025422_438281_6E6EBDB1 X-CRM114-Status: GOOD ( 12.74 ) 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