1 /* SPDX-License-Identifier: GPL-2.0 */
3 * syscall_wrapper.h - s390 specific wrappers to syscall definitions
7 #ifndef _ASM_S390_SYSCALL_WRAPPER_H
8 #define _ASM_S390_SYSCALL_WRAPPER_H
11 #define __SC_COMPAT_TYPE(t, a) \
12 __typeof(__builtin_choose_expr(sizeof(t) > 4, 0L, (t)0)) a
14 #define __SC_COMPAT_CAST(t, a) \
18 BUILD_BUG_ON((sizeof(t) > 4) && !__TYPE_IS_L(t) && \
19 !__TYPE_IS_UL(t) && !__TYPE_IS_PTR(t) && \
23 if (__TYPE_IS_UL(t)) \
25 if (__TYPE_IS_PTR(t)) \
26 __ReS = a & 0x7fffffff; \
27 if (__TYPE_IS_LL(t)) \
32 #define __S390_SYS_STUBx(x, name, ...) \
33 asmlinkage long __s390_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__));\
34 ALLOW_ERROR_INJECTION(__s390_sys##name, ERRNO); \
35 asmlinkage long __s390_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
37 long ret = __s390x_sys##name(__MAP(x,__SC_COMPAT_CAST,__VA_ARGS__));\
38 __MAP(x,__SC_TEST,__VA_ARGS__); \
43 * To keep the naming coherent, re-define SYSCALL_DEFINE0 to create an alias
44 * named __s390x_sys_*()
46 #define COMPAT_SYSCALL_DEFINE0(sname) \
47 SYSCALL_METADATA(_##sname, 0); \
48 asmlinkage long __s390_compat_sys_##sname(void); \
49 ALLOW_ERROR_INJECTION(__s390_compat_sys_##sname, ERRNO); \
50 asmlinkage long __s390_compat_sys_##sname(void)
52 #define SYSCALL_DEFINE0(sname) \
53 SYSCALL_METADATA(_##sname, 0); \
54 asmlinkage long __s390x_sys_##sname(void); \
55 ALLOW_ERROR_INJECTION(__s390x_sys_##sname, ERRNO); \
56 asmlinkage long __s390_sys_##sname(void) \
57 __attribute__((alias(__stringify(__s390x_sys_##sname)))); \
58 asmlinkage long __s390x_sys_##sname(void)
60 #define COND_SYSCALL(name) \
61 cond_syscall(__s390x_sys_##name); \
62 cond_syscall(__s390_sys_##name)
64 #define SYS_NI(name) \
65 SYSCALL_ALIAS(__s390x_sys_##name, sys_ni_posix_timers); \
66 SYSCALL_ALIAS(__s390_sys_##name, sys_ni_posix_timers)
68 #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
70 __diag_ignore(GCC, 8, "-Wattribute-alias", \
71 "Type aliasing is used to sanitize syscall arguments");\
72 asmlinkage long __s390_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
73 asmlinkage long __s390_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
74 __attribute__((alias(__stringify(__se_compat_sys##name)))); \
75 ALLOW_ERROR_INJECTION(__s390_compat_sys##name, ERRNO); \
76 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
77 asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
78 asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
80 long ret = __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
81 __MAP(x,__SC_TEST,__VA_ARGS__); \
85 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
88 * As some compat syscalls may not be implemented, we need to expand
89 * COND_SYSCALL_COMPAT in kernel/sys_ni.c and COMPAT_SYS_NI in
90 * kernel/time/posix-stubs.c to cover this case as well.
92 #define COND_SYSCALL_COMPAT(name) \
93 cond_syscall(__s390_compat_sys_##name)
95 #define COMPAT_SYS_NI(name) \
96 SYSCALL_ALIAS(__s390_compat_sys_##name, sys_ni_posix_timers)
98 #else /* CONFIG_COMPAT */
100 #define __S390_SYS_STUBx(x, fullname, name, ...)
102 #define SYSCALL_DEFINE0(sname) \
103 SYSCALL_METADATA(_##sname, 0); \
104 asmlinkage long __s390x_sys_##sname(void); \
105 ALLOW_ERROR_INJECTION(__s390x_sys_##sname, ERRNO); \
106 asmlinkage long __s390x_sys_##sname(void)
108 #define COND_SYSCALL(name) \
109 cond_syscall(__s390x_sys_##name)
111 #define SYS_NI(name) \
112 SYSCALL_ALIAS(__s390x_sys_##name, sys_ni_posix_timers);
114 #endif /* CONFIG_COMPAT */
116 #define __SYSCALL_DEFINEx(x, name, ...) \
118 __diag_ignore(GCC, 8, "-Wattribute-alias", \
119 "Type aliasing is used to sanitize syscall arguments");\
120 asmlinkage long __s390x_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
121 __attribute__((alias(__stringify(__se_sys##name)))); \
122 ALLOW_ERROR_INJECTION(__s390x_sys##name, ERRNO); \
123 long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
124 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
125 __S390_SYS_STUBx(x, name, __VA_ARGS__) \
126 asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
128 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
129 __MAP(x,__SC_TEST,__VA_ARGS__); \
133 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
135 #endif /* _ASM_X86_SYSCALL_WRAPPER_H */