Skip to content

Commit 9be34be

Browse files
brooniectmarinas
authored andcommitted
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: Mark Rutland <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Mark Brown <[email protected]> Acked-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 580b536 commit 9be34be

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

arch/arm64/crypto/aes-modes.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,15 @@ ST5( mov v4.16b, vctr.16b )
363363
adr x16, 1f
364364
sub x16, x16, x12, lsl #3
365365
br x16
366-
hint 34 // bti c
366+
bti c
367367
mov v0.d[0], vctr.d[0]
368-
hint 34 // bti c
368+
bti c
369369
mov v1.d[0], vctr.d[0]
370-
hint 34 // bti c
370+
bti c
371371
mov v2.d[0], vctr.d[0]
372-
hint 34 // bti c
372+
bti c
373373
mov v3.d[0], vctr.d[0]
374-
ST5( hint 34 )
374+
ST5( bti c )
375375
ST5( mov v4.d[0], vctr.d[0] )
376376
1: b 2f
377377
.previous

arch/arm64/include/asm/assembler.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,16 @@ alternative_endif
790790
.Lnoyield_\@:
791791
.endm
792792

793+
/*
794+
* Branch Target Identifier (BTI)
795+
*/
796+
.macro bti, targets
797+
.equ .L__bti_targets_c, 34
798+
.equ .L__bti_targets_j, 36
799+
.equ .L__bti_targets_jc,38
800+
hint #.L__bti_targets_\targets
801+
.endm
802+
793803
/*
794804
* This macro emits a program property note section identifying
795805
* architecture features which require special handling, mainly for

arch/arm64/include/asm/linkage.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66

77
#if defined(CONFIG_ARM64_BTI_KERNEL) && defined(__aarch64__)
88

9-
/*
10-
* Since current versions of gas reject the BTI instruction unless we
11-
* set the architecture version to v8.5 we use the hint instruction
12-
* instead.
13-
*/
14-
#define BTI_C hint 34 ;
9+
#define BTI_C bti c ;
1510

1611
/*
1712
* When using in-kernel BTI we need to ensure that PCS-conformant assembly

0 commit comments

Comments
 (0)