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 __arm64_compat_sys_##name(const struct pt_regs *regs); \ 42 asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs) \ 43 { \ 44 return sys_ni_syscall(); \ 45 } 46 47 #define COMPAT_SYS_NI(name) \ 48 SYSCALL_ALIAS(__arm64_compat_sys_##name, sys_ni_posix_timers); 49 50 #endif /* CONFIG_COMPAT */ 51 52 #define __SYSCALL_DEFINEx(x, name, ...) \ 53 asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \ 54 ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \ 55 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ 56 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ 57 asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \ 58 asmlinkage long __arm64_sys##name(const struct pt_regs *regs) \ 59 { \ 60 return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ 61 } \ 62 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ 63 { \ 64 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ 65 __MAP(x,__SC_TEST,__VA_ARGS__); \ 66 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ 67 return ret; \ 68 } \ 69 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 70 71 #define SYSCALL_DEFINE0(sname) \ 72 SYSCALL_METADATA(_##sname, 0); \ 73 asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \ 74 ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \ 75 asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused) 76 77 #define COND_SYSCALL(name) \ 78 asmlinkage long __arm64_sys_##name(const struct pt_regs *regs); \ 79 asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \ 80 { \ 81 return sys_ni_syscall(); \ 82 } 83 84 asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused); 85 #define SYS_NI(name) SYSCALL_ALIAS(__arm64_sys_##name, sys_ni_posix_timers); 86 87 #endif /* __ASM_SYSCALL_WRAPPER_H */ 88