Commit 9be34be8 authored by Mark Brown's avatar Mark Brown Committed by Catalin Marinas

arm64: Add macro version of the BTI instruction

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 based on
one written by Mark Rutland which lets us use the mnemonic and update
the existing users.
Suggested-by: default avatarMark Rutland <mark.rutland@arm.com>
Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
Acked-by: default avatarWill Deacon <will@kernel.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20211214152714.2380849-2-broonie@kernel.orgSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 580b536b
...@@ -363,15 +363,15 @@ ST5( mov v4.16b, vctr.16b ) ...@@ -363,15 +363,15 @@ ST5( mov v4.16b, vctr.16b )
adr x16, 1f adr x16, 1f
sub x16, x16, x12, lsl #3 sub x16, x16, x12, lsl #3
br x16 br x16
hint 34 // bti c bti c
mov v0.d[0], vctr.d[0] mov v0.d[0], vctr.d[0]
hint 34 // bti c bti c
mov v1.d[0], vctr.d[0] mov v1.d[0], vctr.d[0]
hint 34 // bti c bti c
mov v2.d[0], vctr.d[0] mov v2.d[0], vctr.d[0]
hint 34 // bti c bti c
mov v3.d[0], vctr.d[0] mov v3.d[0], vctr.d[0]
ST5( hint 34 ) ST5( bti c )
ST5( mov v4.d[0], vctr.d[0] ) ST5( mov v4.d[0], vctr.d[0] )
1: b 2f 1: b 2f
.previous .previous
......
...@@ -790,6 +790,16 @@ alternative_endif ...@@ -790,6 +790,16 @@ alternative_endif
.Lnoyield_\@: .Lnoyield_\@:
.endm .endm
/*
* Branch Target Identifier (BTI)
*/
.macro bti, targets
.equ .L__bti_targets_c, 34
.equ .L__bti_targets_j, 36
.equ .L__bti_targets_jc,38
hint #.L__bti_targets_\targets
.endm
/* /*
* This macro emits a program property note section identifying * This macro emits a program property note section identifying
* architecture features which require special handling, mainly for * architecture features which require special handling, mainly for
......
...@@ -6,12 +6,7 @@ ...@@ -6,12 +6,7 @@
#if defined(CONFIG_ARM64_BTI_KERNEL) && defined(__aarch64__) #if defined(CONFIG_ARM64_BTI_KERNEL) && defined(__aarch64__)
/* #define BTI_C bti c ;
* 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 ;
/* /*
* When using in-kernel BTI we need to ensure that PCS-conformant assembly * When using in-kernel BTI we need to ensure that PCS-conformant assembly
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment