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 5255AC433F5 for ; Sun, 17 Oct 2021 13:19:13 +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 25F9E60F9E for ; Sun, 17 Oct 2021 13:19:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 25F9E60F9E 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=gsaFkdOqtVQMScZY2o+2PQSYgQlCfNwVgfZSn3g3iA0=; b=s3U+Ng528b/Oe3 AQDV4jkA/CWjV+E6bsEnEewFa+oOZqA1s9tAkn/mMJmUyMgiEucJnqQRjrQ3BZHdUrms4OWKzhUYK V3gXXZoCRE+a3D6PW51xs974tLD4VREWcjWVFCfzu6wA1Xe4F6tKvXqtZkVADOmfNbD/2ZX0Ny8wP gX5y22rEg+77D3my4mOZAxVWziXVNfqSbGxoEkijtChTPwyjjMIiVnHiiR5cQyuIexJQ+KfFkRDgM kt4WNHCZuTw7gOyOCrSI3OmJIfQqxdy42DC2bMtG+SABM5/94lSjP7+mm2wbXeYaX8x/X4HcNHXE+ 619Q3bcraRLiAZzI+nfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mc634-00CafF-L4; Sun, 17 Oct 2021 13:17:58 +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 1mc62j-00CaaZ-6M for linux-arm-kernel@lists.infradead.org; Sun, 17 Oct 2021 13:17:38 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id B34FB60FF2; Sun, 17 Oct 2021 13:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634476656; bh=zhPGaTjr4mYt5ZVj+I3r4jcIFtNN14alZ9CqE96rhlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qEBAqiWXhwuL7HROcvRv8GjvUxgtuC71AbABExcD7gdwP/Z+lhDKdJ3tssx5frpD6 p3FuIdPVSUJ9ZggfMjWG0edXW3J0i2ZT2UBYJ6fwM7OqiE3ZhjvNJZ9Q/fYbWuMU6/ /sOv3+74+sM41JFx2Erny1iHT8K2sypceR2IGnMK1lc5baQUddwU/pu8evVjtRfsiW W2fTMNPxJmeeYxZH8gnzCoQGmw6BWf1KCJHkLsYPuVscupnhrpQePV/JHwOIHkefGl lx20PITelMlNcoOR7ktmCyYURNo2pXb+7I93W5foootKU8aGlYTt/4/yBzo1T2CaWn uVddC0DIFSV0w== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Russell King , Arnd Bergmann , Kees Cook , Keith Packard , Linus Walleij , Nick Desaulniers , Nicolas Pitre Subject: [PATCH v3 02/10] ARM: assembler: introduce bl_r and bl_m macros Date: Sun, 17 Oct 2021 15:17:15 +0200 Message-Id: <20211017131723.4034662-3-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211017131723.4034662-1-ardb@kernel.org> References: <20211017131723.4034662-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1797; h=from:subject; bh=zhPGaTjr4mYt5ZVj+I3r4jcIFtNN14alZ9CqE96rhlA=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhbCJSvAHE3GyB8YcT2CYIx0jSPcZ+N5P9ht8vVJsb tmiQabOJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYWwiUgAKCRDDTyI5ktmPJA/hC/ 9L9Jn3jVc6XUpF+Ikz9Me5SmKqeUrWepfM7oanpDAyMNRG9y9GOdvBY9CWAJY6wv7O2LVhfoIwmIod u9U4mr8NvC5Dln/eyLu7pPkGQ/6tARGPoAfg1AGJYoJIuE7bjC2XSuzPg3RFmIUbDowcL4lggezdSn ZNT+TpXp1cO5RxFAzIHNSnhLubdsDPFopFX9BhJz+WSnZwvDeB8/Um2bOp2sbZFgnMp+KV/NVQBqbq eBLrx2CW1oFeW+TEXuM2LxZP3FVUcX0g42GFaLIowZh5Kv5J7nOvIP9qNjMOpM9e5a/L43o6wNpcTL cPR0JlzRHkCwKpupaP8gDr6S0tXc55/EMwCbZxWVJMhz1xFHxqCk0MP/UXTy6U8+BOBB0IakIX8xCv BysJnxeWOETweF90gCd7VcmZ5EX/6NM/42nzUncC6fj1MNmNc3KFPmgiYKd6lYijzB+8nHuCETpBPX PNyqtzimOV3y8chK990fyN1ALEn8Dh8akGFOy7e2WhroA= 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-20211017_061737_297192_E1132D08 X-CRM114-Status: GOOD ( 13.51 ) 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 Reviewed-by: Arnd Bergmann Acked-by: Linus Walleij Tested-by: Keith Packard --- 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