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 331B1C433EF for ; Mon, 15 Nov 2021 08:49:17 +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 F042263213 for ; Mon, 15 Nov 2021 08:49:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F042263213 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=UT+peS+IOBpN2SN8nPtXFCGQgeyteEuONQJkBDZ/LDc=; b=1PsAHfQO8oh4ga SeDimkyNy06d93PrDYLpn7UeYJ6B2192z5zQFy53OBZ18xe3gPCyF4A2nENUnuFyQLUY40ykqxatD IeV0J5e9Kqqcr8/84fjl/k3eT0euUL4StldooiFWATBng8wuNYvzRMDw75VZQ6/jOgWfps1HjyqCq mS12HYNj4UCOUrPifXzt1O6jyVLFuUt7PXxeBbl3DznRPrQ6G6OTHWUy64MXSuKczh+ULC2GymvWK 6uRDzWUNwA28MbiKVPNRw4+z5hFQ07T4fR5sJ4pqFH1WMnkP9lp1FzrymYJwy2DVwMNWvUWrTR6Y+ lwc1EtxqftlLpr5QmZOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmXep-00EjB8-EM; Mon, 15 Nov 2021 08:48:07 +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 1mmXeS-00Ej5b-V1 for linux-arm-kernel@lists.infradead.org; Mon, 15 Nov 2021 08:47:46 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id B602763213; Mon, 15 Nov 2021 08:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636966064; bh=6/9VQac7x/GVAdOgmi5Ne/QV8xuHL+dNZFcQKyn348E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kx4jRMVg9WJ4jFv3PNj+5AJXj1+KhGfjWExhgwM/VRdt/gJ9CpPrAe4ZrpRWVIRKj WDbSG6nCJHJBTS8o/sTsSMjO9o9YHz+CMJcWbrXZLcChMyDtsMTE+0ecnEWN/usc/e ai0IAzVrAus0vz70v3Cunr0QH/7PPs4LFPv6ydTiGJOKnAf8AjeeBQ3X/VBX/r/10Q i9P5bA9qPiXLbTUKgMI2253TMRCJMcFX+wuXhtI+SgZT902HCkqVYVbJ+NdaAZOouS nXD/Ymk8vjvfFJbw8S1kY8Pw8E/Wd+UcxzIoyB8U5SjO5t9v1y3+NOtiOjjHBCcnu4 DmdK2y8DOAsQQ== 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 v4 2/9] ARM: assembler: introduce bl_r macro Date: Mon, 15 Nov 2021 09:47:25 +0100 Message-Id: <20211115084732.3704393-3-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211115084732.3704393-1-ardb@kernel.org> References: <20211115084732.3704393-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1246; h=from:subject; bh=6/9VQac7x/GVAdOgmi5Ne/QV8xuHL+dNZFcQKyn348E=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhkh6WRPKzEHv5u/2lQPAMmhDILRBJqSDhMMYyniDz CEc25C+JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYZIelgAKCRDDTyI5ktmPJL+4DA CVpCtHuqymv0PfjjPREDTW+pYStQgvT1LX9UYtA3cIIDEfDZN/cViAAs7rL3m+Wyz9ClZSVLjGq9fN PniDNrQ5t9eeUztBkyqlaYMDCrl+PPAvIGA2cQb2l9RChCBzVf+/d0+ubXzB7T3q7C0RmKSP7Wtv5e wngwIgrgQNHjHfOo3uGx+lP2sDzDDIgZ+WOIJaPqBlcio9QfhhTpoBeBF9xEx2/hWxq2WcZ3FobHmE aHrrlvu17FCVaYn7J3NJsFUUCVgUfKp0oaeW7n/OPT9XxQsfhfu9SBADQ2x/EOIU0zDwyvcToLIIld HOASAl6qZZMjC+xn8R96n7nQgUXlKhmZctR033IYUxzvQ+xW5g8mzE1qypji8ECVNEUQ+HbhXYBHe2 glhLapmKbq5yZdyarL5ritm1eA2MFEHPJNzsTL2FHRYEKnXHZTImPwmquAwtZ+Rz8/ogvD5wdc/QPV KOtmXJUhzknIH48xr5MYzOfOlWWgc+R+6zW5expakjWXY= 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-20211115_004745_046997_11004013 X-CRM114-Status: GOOD ( 12.39 ) 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 --- 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 7d23d4bb2168..870bfaea4318 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -624,4 +624,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