1 /* SPDX-License-Identifier: GPL-2.0 */
3 * syscall_wrapper.h - arm64 specific wrappers to syscall definitions
5 * Based on arch/x86/include/asm_syscall_wrapper.h
8 #ifndef __ASM_SYSCALL_WRAPPER_H
9 #define __ASM_SYSCALL_WRAPPER_H
11 #define SC_ARM64_REGS_TO_ARGS(x, ...) \
13 ,,regs->regs[0],,regs->regs[1],,regs->regs[2] \
14 ,,regs->regs[3],,regs->regs[4],,regs->regs[5])
18 #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
19 asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs); \
20 ALLOW_ERROR_INJECTION(__arm64_compat_sys##name, ERRNO); \
21 static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
22 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
23 asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs) \
25 return __se_compat_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \
27 static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
29 return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
31 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
33 #define COMPAT_SYSCALL_DEFINE0(sname) \
34 asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused); \
35 ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \
36 asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused)
38 #define COND_SYSCALL_COMPAT(name) \
39 cond_syscall(__arm64_compat_sys_##name);
41 #define COMPAT_SYS_NI(name) \
42 SYSCALL_ALIAS(__arm64_compat_sys_##name, sys_ni_posix_timers);
44 #endif /* CONFIG_COMPAT */
46 #define __SYSCALL_DEFINEx(x, name, ...) \
47 asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \
48 ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \
49 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
50 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
51 asmlinkage long __arm64_sys##name(const struct pt_regs *regs) \
53 return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \
55 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
57 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
58 __MAP(x,__SC_TEST,__VA_ARGS__); \
59 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
62 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
64 #ifndef SYSCALL_DEFINE0
65 #define SYSCALL_DEFINE0(sname) \
66 SYSCALL_METADATA(_##sname, 0); \
67 asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \
68 ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \
69 asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused)
73 #define COND_SYSCALL(name) cond_syscall(__arm64_sys_##name)
77 #define SYS_NI(name) SYSCALL_ALIAS(__arm64_sys_##name, sys_ni_posix_timers);
80 #endif /* __ASM_SYSCALL_WRAPPER_H */