xref: /openbmc/linux/arch/x86/include/asm/linkage.h (revision 6c8c1406)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_LINKAGE_H
3 #define _ASM_X86_LINKAGE_H
4 
5 #include <linux/stringify.h>
6 #include <asm/ibt.h>
7 
8 #undef notrace
9 #define notrace __attribute__((no_instrument_function))
10 
11 #ifdef CONFIG_X86_32
12 #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
13 #endif /* CONFIG_X86_32 */
14 
15 #ifdef __ASSEMBLY__
16 
17 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_ALIGNMENT_16)
18 #define __ALIGN		.p2align 4, 0x90
19 #define __ALIGN_STR	__stringify(__ALIGN)
20 #endif
21 
22 #if defined(CONFIG_RETHUNK) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO)
23 #define RET	jmp __x86_return_thunk
24 #else /* CONFIG_RETPOLINE */
25 #ifdef CONFIG_SLS
26 #define RET	ret; int3
27 #else
28 #define RET	ret
29 #endif
30 #endif /* CONFIG_RETPOLINE */
31 
32 #else /* __ASSEMBLY__ */
33 
34 #if defined(CONFIG_RETHUNK) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO)
35 #define ASM_RET	"jmp __x86_return_thunk\n\t"
36 #else /* CONFIG_RETPOLINE */
37 #ifdef CONFIG_SLS
38 #define ASM_RET	"ret; int3\n\t"
39 #else
40 #define ASM_RET	"ret\n\t"
41 #endif
42 #endif /* CONFIG_RETPOLINE */
43 
44 #endif /* __ASSEMBLY__ */
45 
46 #define __CFI_TYPE(name)					\
47 	SYM_START(__cfi_##name, SYM_L_LOCAL, SYM_A_NONE)	\
48 	.fill 11, 1, 0x90 ASM_NL				\
49 	.byte 0xb8 ASM_NL					\
50 	.long __kcfi_typeid_##name ASM_NL			\
51 	SYM_FUNC_END(__cfi_##name)
52 
53 /* SYM_TYPED_FUNC_START -- use for indirectly called globals, w/ CFI type */
54 #define SYM_TYPED_FUNC_START(name)				\
55 	SYM_TYPED_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)	\
56 	ENDBR
57 
58 /* SYM_FUNC_START -- use for global functions */
59 #define SYM_FUNC_START(name)				\
60 	SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)	\
61 	ENDBR
62 
63 /* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */
64 #define SYM_FUNC_START_NOALIGN(name)			\
65 	SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)	\
66 	ENDBR
67 
68 /* SYM_FUNC_START_LOCAL -- use for local functions */
69 #define SYM_FUNC_START_LOCAL(name)			\
70 	SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)	\
71 	ENDBR
72 
73 /* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */
74 #define SYM_FUNC_START_LOCAL_NOALIGN(name)		\
75 	SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)	\
76 	ENDBR
77 
78 /* SYM_FUNC_START_WEAK -- use for weak functions */
79 #define SYM_FUNC_START_WEAK(name)			\
80 	SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN)	\
81 	ENDBR
82 
83 /* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */
84 #define SYM_FUNC_START_WEAK_NOALIGN(name)		\
85 	SYM_START(name, SYM_L_WEAK, SYM_A_NONE)		\
86 	ENDBR
87 
88 #endif /* _ASM_X86_LINKAGE_H */
89 
90