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 /* SYM_FUNC_START -- use for global functions */ 47 #define SYM_FUNC_START(name) \ 48 SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) \ 49 ENDBR 50 51 /* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */ 52 #define SYM_FUNC_START_NOALIGN(name) \ 53 SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE) \ 54 ENDBR 55 56 /* SYM_FUNC_START_LOCAL -- use for local functions */ 57 #define SYM_FUNC_START_LOCAL(name) \ 58 SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN) \ 59 ENDBR 60 61 /* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */ 62 #define SYM_FUNC_START_LOCAL_NOALIGN(name) \ 63 SYM_START(name, SYM_L_LOCAL, SYM_A_NONE) \ 64 ENDBR 65 66 /* SYM_FUNC_START_WEAK -- use for weak functions */ 67 #define SYM_FUNC_START_WEAK(name) \ 68 SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN) \ 69 ENDBR 70 71 /* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */ 72 #define SYM_FUNC_START_WEAK_NOALIGN(name) \ 73 SYM_START(name, SYM_L_WEAK, SYM_A_NONE) \ 74 ENDBR 75 76 #endif /* _ASM_X86_LINKAGE_H */ 77 78