xref: /linux/arch/s390/include/asm/syscall_wrapper.h (revision 7fc2cd2e4b398c57c9cf961cfea05eadbf34c05c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * syscall_wrapper.h - s390 specific wrappers to syscall definitions
4  *
5  */
6 
7 #ifndef _ASM_S390_SYSCALL_WRAPPER_H
8 #define _ASM_S390_SYSCALL_WRAPPER_H
9 
10 /* Mapping of registers to parameters for syscalls */
11 #define SC_S390_REGS_TO_ARGS(x, ...)					\
12 	__MAP(x, __SC_ARGS						\
13 	      ,, regs->orig_gpr2,, regs->gprs[3],, regs->gprs[4]	\
14 	      ,, regs->gprs[5],, regs->gprs[6],, regs->gprs[7])
15 
16 #define SYSCALL_DEFINE0(sname)						\
17 	SYSCALL_METADATA(_##sname, 0);					\
18 	long __s390x_sys_##sname(struct pt_regs *__unused);		\
19 	ALLOW_ERROR_INJECTION(__s390x_sys_##sname, ERRNO);		\
20 	static inline long __do_sys_##sname(void);			\
21 	long __s390x_sys_##sname(struct pt_regs *__unused)		\
22 	{								\
23 		return __do_sys_##sname();				\
24 	}								\
25 	static inline long __do_sys_##sname(void)
26 
27 #define COND_SYSCALL(name)						\
28 	cond_syscall(__s390x_sys_##name)
29 
30 #define __S390_SYS_STUBx(x, fullname, name, ...)
31 
32 #define __SYSCALL_DEFINEx(x, name, ...)						\
33 	long __s390x_sys##name(struct pt_regs *regs);				\
34 	ALLOW_ERROR_INJECTION(__s390x_sys##name, ERRNO);			\
35 	static inline long __se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__));	\
36 	static inline long __do_sys##name(__MAP(x, __SC_DECL, __VA_ARGS__));	\
37 	__S390_SYS_STUBx(x, name, __VA_ARGS__);					\
38 	long __s390x_sys##name(struct pt_regs *regs)				\
39 	{									\
40 		return __se_sys##name(SC_S390_REGS_TO_ARGS(x, __VA_ARGS__));	\
41 	}									\
42 	static inline long __se_sys##name(__MAP(x, __SC_LONG, __VA_ARGS__))	\
43 	{									\
44 		__MAP(x, __SC_TEST, __VA_ARGS__);				\
45 		return __do_sys##name(__MAP(x, __SC_CAST, __VA_ARGS__));	\
46 	}									\
47 	static inline long __do_sys##name(__MAP(x, __SC_DECL, __VA_ARGS__))
48 
49 #endif /* _ASM_S390_SYSCALL_WRAPPER_H */
50