1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * syscall_wrapper.h - arm64 specific wrappers to syscall definitions 4 * 5 * Based on arch/x86/include/asm_syscall_wrapper.h 6 */ 7 8 #ifndef __ASM_SYSCALL_WRAPPER_H 9 #define __ASM_SYSCALL_WRAPPER_H 10 11 #include <asm/ptrace.h> 12 13 #define SC_ARM64_REGS_TO_ARGS(x, ...) \ 14 __MAP(x,__SC_ARGS \ 15 ,,regs->regs[0],,regs->regs[1],,regs->regs[2] \ 16 ,,regs->regs[3],,regs->regs[4],,regs->regs[5]) 17 18 #ifdef CONFIG_COMPAT 19 20 #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ 21 asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs); \ 22 ALLOW_ERROR_INJECTION(__arm64_compat_sys##name, ERRNO); \ 23 static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ 24 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ 25 asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs) \ 26 { \ 27 return __se_compat_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ 28 } \ 29 static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ 30 { \ 31 return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ 32 } \ 33 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 34 35 #define COMPAT_SYSCALL_DEFINE0(sname) \ 36 asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused); \ 37 ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \ 38 asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused) 39 40 #define COND_SYSCALL_COMPAT(name) \ 41 asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs) \ 42 { \ 43 return sys_ni_syscall(); \ 44 } 45 46 #define COMPAT_SYS_NI(name) \ 47 SYSCALL_ALIAS(__arm64_compat_sys_##name, sys_ni_posix_timers); 48 49 #endif /* CONFIG_COMPAT */ 50 51 #define __SYSCALL_DEFINEx(x, name, ...) \ 52 asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \ 53 ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \ 54 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ 55 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ 56 asmlinkage long __arm64_sys##name(const struct pt_regs *regs) \ 57 { \ 58 return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ 59 } \ 60 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ 61 { \ 62 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ 63 __MAP(x,__SC_TEST,__VA_ARGS__); \ 64 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ 65 return ret; \ 66 } \ 67 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 68 69 #ifndef SYSCALL_DEFINE0 70 #define SYSCALL_DEFINE0(sname) \ 71 SYSCALL_METADATA(_##sname, 0); \ 72 asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \ 73 ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \ 74 asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused) 75 #endif 76 77 #ifndef COND_SYSCALL 78 #define COND_SYSCALL(name) \ 79 asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \ 80 { \ 81 return sys_ni_syscall(); \ 82 } 83 #endif 84 85 #ifndef SYS_NI 86 #define SYS_NI(name) SYSCALL_ALIAS(__arm64_sys_##name, sys_ni_posix_timers); 87 #endif 88 89 #endif /* __ASM_SYSCALL_WRAPPER_H */ 90