xref: /openbmc/linux/arch/arm64/include/asm/linkage.h (revision c8ed9fc9)
1 #ifndef __ASM_LINKAGE_H
2 #define __ASM_LINKAGE_H
3 
4 #define __ALIGN		.align 2
5 #define __ALIGN_STR	".align 2"
6 
7 #if defined(CONFIG_ARM64_BTI_KERNEL) && defined(__aarch64__)
8 
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 ;
15 #define BTI_J hint 36 ;
16 
17 /*
18  * When using in-kernel BTI we need to ensure that PCS-conformant assembly
19  * functions have suitable annotations.  Override SYM_FUNC_START to insert
20  * a BTI landing pad at the start of everything.
21  */
22 #define SYM_FUNC_START(name)				\
23 	SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)	\
24 	BTI_C
25 
26 #define SYM_FUNC_START_NOALIGN(name)			\
27 	SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)	\
28 	BTI_C
29 
30 #define SYM_FUNC_START_LOCAL(name)			\
31 	SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)	\
32 	BTI_C
33 
34 #define SYM_FUNC_START_LOCAL_NOALIGN(name)		\
35 	SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)	\
36 	BTI_C
37 
38 #define SYM_FUNC_START_WEAK(name)			\
39 	SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN)	\
40 	BTI_C
41 
42 #define SYM_FUNC_START_WEAK_NOALIGN(name)		\
43 	SYM_START(name, SYM_L_WEAK, SYM_A_NONE)		\
44 	BTI_C
45 
46 #define SYM_INNER_LABEL(name, linkage)			\
47 	.type name SYM_T_NONE ASM_NL			\
48 	SYM_ENTRY(name, linkage, SYM_A_NONE)		\
49 	BTI_J
50 
51 #endif
52 
53 /*
54  * Annotate a function as position independent, i.e., safe to be called before
55  * the kernel virtual mapping is activated.
56  */
57 #define SYM_FUNC_START_PI(x)			\
58 		SYM_FUNC_START_ALIAS(__pi_##x);	\
59 		SYM_FUNC_START(x)
60 
61 #define SYM_FUNC_START_WEAK_PI(x)		\
62 		SYM_FUNC_START_ALIAS(__pi_##x);	\
63 		SYM_FUNC_START_WEAK(x)
64 
65 #define SYM_FUNC_END_PI(x)			\
66 		SYM_FUNC_END(x);		\
67 		SYM_FUNC_END_ALIAS(__pi_##x)
68 
69 #endif
70