Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1965aae3 PA |
2 | #ifndef _ASM_X86_LINKAGE_H |
3 | #define _ASM_X86_LINKAGE_H | |
82f74e71 | 4 | |
bb7f5f6c | 5 | #include <linux/stringify.h> |
c4691712 | 6 | #include <asm/ibt.h> |
bb7f5f6c | 7 | |
78a9909a IM |
8 | #undef notrace |
9 | #define notrace __attribute__((no_instrument_function)) | |
10 | ||
96a388de | 11 | #ifdef CONFIG_X86_32 |
82f74e71 | 12 | #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0))) |
7ab15247 CG |
13 | #endif /* CONFIG_X86_32 */ |
14 | ||
d49a0626 | 15 | #define __ALIGN .balign CONFIG_FUNCTION_ALIGNMENT, 0x90; |
bb7f5f6c | 16 | #define __ALIGN_STR __stringify(__ALIGN) |
82f74e71 | 17 | |
931ab636 | 18 | #if defined(CONFIG_CALL_PADDING) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO) |
bea75b33 TG |
19 | #define FUNCTION_PADDING .skip CONFIG_FUNCTION_ALIGNMENT, 0x90; |
20 | #else | |
21 | #define FUNCTION_PADDING | |
22 | #endif | |
23 | ||
7324f74d | 24 | #if (CONFIG_FUNCTION_ALIGNMENT > 8) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO) |
bea75b33 TG |
25 | # define __FUNC_ALIGN __ALIGN; FUNCTION_PADDING |
26 | #else | |
27 | # define __FUNC_ALIGN __ALIGN | |
28 | #endif | |
29 | ||
30 | #define ASM_FUNC_ALIGN __stringify(__FUNC_ALIGN) | |
8eb5d34e TG |
31 | #define SYM_F_ALIGN __FUNC_ALIGN |
32 | ||
33 | #ifdef __ASSEMBLY__ | |
34 | ||
f43b9876 | 35 | #if defined(CONFIG_RETHUNK) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO) |
aa3d4803 PZ |
36 | #define RET jmp __x86_return_thunk |
37 | #else /* CONFIG_RETPOLINE */ | |
e463a09a PZ |
38 | #ifdef CONFIG_SLS |
39 | #define RET ret; int3 | |
40 | #else | |
41 | #define RET ret | |
42 | #endif | |
aa3d4803 | 43 | #endif /* CONFIG_RETPOLINE */ |
e463a09a | 44 | |
b17c2baa PZ |
45 | #else /* __ASSEMBLY__ */ |
46 | ||
f43b9876 | 47 | #if defined(CONFIG_RETHUNK) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO) |
aa3d4803 PZ |
48 | #define ASM_RET "jmp __x86_return_thunk\n\t" |
49 | #else /* CONFIG_RETPOLINE */ | |
e463a09a PZ |
50 | #ifdef CONFIG_SLS |
51 | #define ASM_RET "ret; int3\n\t" | |
52 | #else | |
b17c2baa | 53 | #define ASM_RET "ret\n\t" |
e463a09a | 54 | #endif |
aa3d4803 | 55 | #endif /* CONFIG_RETPOLINE */ |
b17c2baa | 56 | |
7ab15247 CG |
57 | #endif /* __ASSEMBLY__ */ |
58 | ||
bea75b33 | 59 | /* |
931ab636 | 60 | * Depending on -fpatchable-function-entry=N,N usage (CONFIG_CALL_PADDING) the |
bea75b33 TG |
61 | * CFI symbol layout changes. |
62 | * | |
63 | * Without CALL_THUNKS: | |
64 | * | |
65 | * .align FUNCTION_ALIGNMENT | |
66 | * __cfi_##name: | |
67 | * .skip FUNCTION_PADDING, 0x90 | |
68 | * .byte 0xb8 | |
69 | * .long __kcfi_typeid_##name | |
70 | * name: | |
71 | * | |
72 | * With CALL_THUNKS: | |
73 | * | |
74 | * .align FUNCTION_ALIGNMENT | |
75 | * __cfi_##name: | |
76 | * .byte 0xb8 | |
77 | * .long __kcfi_typeid_##name | |
78 | * .skip FUNCTION_PADDING, 0x90 | |
79 | * name: | |
80 | * | |
81 | * In both cases the whole thing is FUNCTION_ALIGNMENT aligned and sized. | |
82 | */ | |
83 | ||
931ab636 | 84 | #ifdef CONFIG_CALL_PADDING |
bea75b33 TG |
85 | #define CFI_PRE_PADDING |
86 | #define CFI_POST_PADDING .skip CONFIG_FUNCTION_PADDING_BYTES, 0x90; | |
87 | #else | |
88 | #define CFI_PRE_PADDING .skip CONFIG_FUNCTION_PADDING_BYTES, 0x90; | |
89 | #define CFI_POST_PADDING | |
90 | #endif | |
91 | ||
ccace936 ST |
92 | #define __CFI_TYPE(name) \ |
93 | SYM_START(__cfi_##name, SYM_L_LOCAL, SYM_A_NONE) \ | |
bea75b33 | 94 | CFI_PRE_PADDING \ |
ccace936 ST |
95 | .byte 0xb8 ASM_NL \ |
96 | .long __kcfi_typeid_##name ASM_NL \ | |
bea75b33 | 97 | CFI_POST_PADDING \ |
ccace936 ST |
98 | SYM_FUNC_END(__cfi_##name) |
99 | ||
100 | /* SYM_TYPED_FUNC_START -- use for indirectly called globals, w/ CFI type */ | |
101 | #define SYM_TYPED_FUNC_START(name) \ | |
4a2c3448 | 102 | SYM_TYPED_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) \ |
ccace936 ST |
103 | ENDBR |
104 | ||
c4691712 PZ |
105 | /* SYM_FUNC_START -- use for global functions */ |
106 | #define SYM_FUNC_START(name) \ | |
8eb5d34e | 107 | SYM_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) \ |
c4691712 PZ |
108 | ENDBR |
109 | ||
110 | /* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */ | |
111 | #define SYM_FUNC_START_NOALIGN(name) \ | |
112 | SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE) \ | |
113 | ENDBR | |
114 | ||
115 | /* SYM_FUNC_START_LOCAL -- use for local functions */ | |
116 | #define SYM_FUNC_START_LOCAL(name) \ | |
8eb5d34e | 117 | SYM_START(name, SYM_L_LOCAL, SYM_F_ALIGN) \ |
c4691712 PZ |
118 | ENDBR |
119 | ||
120 | /* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */ | |
121 | #define SYM_FUNC_START_LOCAL_NOALIGN(name) \ | |
122 | SYM_START(name, SYM_L_LOCAL, SYM_A_NONE) \ | |
123 | ENDBR | |
124 | ||
125 | /* SYM_FUNC_START_WEAK -- use for weak functions */ | |
126 | #define SYM_FUNC_START_WEAK(name) \ | |
8eb5d34e | 127 | SYM_START(name, SYM_L_WEAK, SYM_F_ALIGN) \ |
c4691712 PZ |
128 | ENDBR |
129 | ||
130 | /* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */ | |
131 | #define SYM_FUNC_START_WEAK_NOALIGN(name) \ | |
132 | SYM_START(name, SYM_L_WEAK, SYM_A_NONE) \ | |
133 | ENDBR | |
134 | ||
1965aae3 | 135 | #endif /* _ASM_X86_LINKAGE_H */ |
82f74e71 | 136 |