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 07305C433EF for ; Tue, 7 Dec 2021 18:04:47 +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=Lk0zHXQqp5wkn1bbwdxWVzkicToqvnwkIzrIsqpJczg=; b=hxQlLnQPxc3Gdo FffWahGmDnEHkO6fbawsOXO1ru1/teym0ehHhMgXCRKqBW98JR79batANoJJMiG5+pVNlYhzUHeRI rgW+pSvxJfcVUTT9aAUXK70xom/AfFid+MDMbVD7lejhKNePvhqAgxh+6TI0m/r05FUzHDK3Ot4vC U9DOCMmtQw3NsthTML8GI21brNYuwklu7R4yySlXirmjEENhaPH7fJRymDNbJYqLteon32KP4+s84 EoRWniiTp9hf052Esl5ev/cGQva6vccR6hFl2e7jlDPjPwDmXWI7Hxru3GFjQe3rx2ceuR9DeiRID Wpk7aRf/yNIDS4uxbobw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muens-009cvD-Fi; Tue, 07 Dec 2021 18:03:00 +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 1muene-009crZ-58 for linux-arm-kernel@lists.infradead.org; Tue, 07 Dec 2021 18:02:47 +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 E16ECB81DD3; Tue, 7 Dec 2021 18:02:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E334C341CB; Tue, 7 Dec 2021 18:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638900163; bh=xCXxkfGTacFYpPvHQNE7PdyVSeHav4DYNwzM5gADjqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKpgQGKhDyQz52QorenYe8LNraeeHUbY44S4jrt4jAr9wdTqrheG+QJyDtFVODEK2 jGaeu7Iaa5l5pQvNX6J6EaZq6P6YIiA87c/wQIdQi4guC8Cj8QKC8SA6pkQzXMHnS2 FPQcfuV6O3Z7yM7gJRWJrBBCeqveKaadse40wv/GLDy+4NKssz1RE+Upvm1S+iHFYB qM2UmfTbxMkTjul9x+qa6ImYAWZZzISwLd0YUh6DyLGe0cQR+XSWfSXGGwjmETTdnd 6dK/a+rwawi2ds95F1VU8D5y0PbcvWSsbezIjAnbap0WjDqFrojnigu0+iyeAptbZ6 mheZHF7uR7B5A== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Mark Rutland , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v2 1/2] arm64: Add macro version of the BTI instruction Date: Tue, 7 Dec 2021 18:01:15 +0000 Message-Id: <20211207180116.1581807-2-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211207180116.1581807-1-broonie@kernel.org> References: <20211207180116.1581807-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2654; h=from:subject; bh=xCXxkfGTacFYpPvHQNE7PdyVSeHav4DYNwzM5gADjqk=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhr6Fqu2ydnceX0XMH0WV7OQWmXiAKrWs/mlmkQZ4o POvmBJ+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYa+hagAKCRAk1otyXVSH0M7AB/ 0eHmcj4pd72ei5zO7EapuvOPoj3Z10d142ADPXBTb0UNq19p5CXW3MnJUzoqNSDOoHhW3gshP7CkyV dPIYLMVqMmXlITqd618vpkSGgy4dfgjizho/97mN2xz+lYS6KwyTimpn5EQPRWJBqmKP7VNhQ22fFi tns7Xqj3Wpp/fNdl2kf42GWuuuZSnZpK6Auxx/GmUuevaH9xOyRJ9da4JLB1kDzoO+yofMJmwSlgtE QTkPtx0Bc9AzykuTDZ7gRUwZXnkso7ZJr3MChEdVzhX6ufeCgkBULD/O5DwxC4Bwch1iTIj8Jp1r6B Y9m65jocj4n/e+HZioo74O/idP3Zsw X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211207_100246_493135_260F6679 X-CRM114-Status: GOOD ( 14.49 ) 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 BTI is only available from v8.5 so we need to encode it using HINT in generic code and for older toolchains. Add an assembler macro written by Mark Rutland which lets us use the mnemonic and update the existing users. Suggested-by: Mark Rutland Signed-off-by: Mark Brown --- arch/arm64/crypto/aes-modes.S | 10 +++++----- arch/arm64/include/asm/assembler.h | 18 ++++++++++++++++++ arch/arm64/include/asm/linkage.h | 7 +------ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/arch/arm64/crypto/aes-modes.S b/arch/arm64/crypto/aes-modes.S index b495de22bb38..ff01f0167ba2 100644 --- a/arch/arm64/crypto/aes-modes.S +++ b/arch/arm64/crypto/aes-modes.S @@ -363,15 +363,15 @@ ST5( mov v4.16b, vctr.16b ) adr x16, 1f sub x16, x16, x12, lsl #3 br x16 - hint 34 // bti c + bti c mov v0.d[0], vctr.d[0] - hint 34 // bti c + bti c mov v1.d[0], vctr.d[0] - hint 34 // bti c + bti c mov v2.d[0], vctr.d[0] - hint 34 // bti c + bti c mov v3.d[0], vctr.d[0] -ST5( hint 34 ) +ST5( bti c ) ST5( mov v4.d[0], vctr.d[0] ) 1: b 2f .previous diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 136d13f3d6e9..87f296198366 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -790,6 +790,24 @@ alternative_endif .Lnoyield_\@: .endm +/* + * Branch Target Identifier (BTI) + */ + .macro bti, targets + .equ .L__bti_targets_c, 1 + .equ .L__bti_targets_j, 2 + .equ .L__bti_targets_jc,3 + .if .L__bti_targets_\targets == .L__bti_targets_c + hint #34 + .elseif .L__bti_targets_\targets == .L__bti_targets_j + hint #36 + .elseif .L__bti_targets_\targets == .L__bti_targets_jc + hint #38 + .else + .error "Unsupported BTI targets '\targets\()'" + .endif + .endm + /* * This macro emits a program property note section identifying * architecture features which require special handling, mainly for diff --git a/arch/arm64/include/asm/linkage.h b/arch/arm64/include/asm/linkage.h index 9906541a6861..c5d0c11d7709 100644 --- a/arch/arm64/include/asm/linkage.h +++ b/arch/arm64/include/asm/linkage.h @@ -6,12 +6,7 @@ #if defined(CONFIG_ARM64_BTI_KERNEL) && defined(__aarch64__) -/* - * Since current versions of gas reject the BTI instruction unless we - * set the architecture version to v8.5 we use the hint instruction - * instead. - */ -#define BTI_C hint 34 ; +#define BTI_C bti c ; /* * When using in-kernel BTI we need to ensure that PCS-conformant assembly -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel