Skip to content

Commit 742a15b

Browse files
brooniectmarinas
authored andcommitted
arm64: Use BTI C directly and unconditionally
Now we have a macro for BTI C that looks like a regular instruction change all the users of the current BTI_C macro to just emit a BTI C directly and remove the macro. This does mean that we now unconditionally BTI annotate all assembly functions, meaning that they are worse in this respect than code generated by the compiler. The overhead should be minimal for implementations with a reasonable HINT implementation. Signed-off-by: Mark Brown <[email protected]> Reviewed-by: Ard Biesheuvel <[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 481ee45 commit 742a15b

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

arch/arm64/include/asm/linkage.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@
44
#define __ALIGN .align 2
55
#define __ALIGN_STR ".align 2"
66

7-
#if defined(CONFIG_ARM64_BTI_KERNEL) && defined(__aarch64__)
8-
9-
#define BTI_C bti c ;
10-
11-
#else
12-
13-
#define BTI_C
14-
15-
#endif
16-
177
/*
188
* When using in-kernel BTI we need to ensure that PCS-conformant
199
* assembly functions have suitable annotations. Override
@@ -23,27 +13,27 @@
2313
*/
2414
#define SYM_FUNC_START(name) \
2515
SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) \
26-
BTI_C
16+
bti c ;
2717

2818
#define SYM_FUNC_START_NOALIGN(name) \
2919
SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE) \
30-
BTI_C
20+
bti c ;
3121

3222
#define SYM_FUNC_START_LOCAL(name) \
3323
SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN) \
34-
BTI_C
24+
bti c ;
3525

3626
#define SYM_FUNC_START_LOCAL_NOALIGN(name) \
3727
SYM_START(name, SYM_L_LOCAL, SYM_A_NONE) \
38-
BTI_C
28+
bti c ;
3929

4030
#define SYM_FUNC_START_WEAK(name) \
4131
SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN) \
42-
BTI_C
32+
bti c ;
4333

4434
#define SYM_FUNC_START_WEAK_NOALIGN(name) \
4535
SYM_START(name, SYM_L_WEAK, SYM_A_NONE) \
46-
BTI_C
36+
bti c ;
4737

4838
/*
4939
* Annotate a function as position independent, i.e., safe to be called before

arch/arm64/kernel/entry-ftrace.S

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,13 @@
7777
.endm
7878

7979
SYM_CODE_START(ftrace_regs_caller)
80-
#ifdef BTI_C
81-
BTI_C
82-
#endif
80+
bti c
8381
ftrace_regs_entry 1
8482
b ftrace_common
8583
SYM_CODE_END(ftrace_regs_caller)
8684

8785
SYM_CODE_START(ftrace_caller)
88-
#ifdef BTI_C
89-
BTI_C
90-
#endif
86+
bti c
9187
ftrace_regs_entry 0
9288
b ftrace_common
9389
SYM_CODE_END(ftrace_caller)

arch/arm64/lib/kasan_sw_tags.S

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
* incremented by 256 prior to return).
3939
*/
4040
SYM_CODE_START(__hwasan_tag_mismatch)
41-
#ifdef BTI_C
42-
BTI_C
43-
#endif
41+
bti c
4442
add x29, sp, #232
4543
stp x2, x3, [sp, #8 * 2]
4644
stp x4, x5, [sp, #8 * 4]

0 commit comments

Comments
 (0)