summaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/compat_wrapper.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2019-01-16 14:15:22 +0100
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2019-01-18 09:33:19 +0100
commitaa0d6e70d3b34e710a6a57a53a3096cb2e0ea99f (patch)
treed89caa5e75f4e4c822e26f822208d87d1f0cf719 /arch/s390/kernel/compat_wrapper.c
parents390: use generic UID16 implementation (diff)
downloadlinux-aa0d6e70d3b34e710a6a57a53a3096cb2e0ea99f.tar.xz
linux-aa0d6e70d3b34e710a6a57a53a3096cb2e0ea99f.zip
s390: autogenerate compat syscall wrappers
Any system call that takes a pointer argument on s390 requires a wrapper function to do a 31-to-64 zero-extension, these are currently generated in arch/s390/kernel/compat_wrapper.c. On arm64 and x86, we already generate similar wrappers for all system calls in the place of their definition, just for a different purpose (they load the arguments from pt_regs). We can do the same thing here, by adding an asm/syscall_wrapper.h file with a copy of all the relevant macros to override the generic version. Besides the addition of the compat entry point, these also rename the entry points with a __s390_ or __s390x_ prefix, similar to what we do on arm64 and x86. This in turn requires renaming a few things, and adding a proper ni_syscall() entry point. In order to still compile system call definitions that pass an loff_t argument, the __SC_COMPAT_CAST() macro checks for that and forces an -ENOSYS error, which was the best I could come up with. Those functions must obviously not get called from user space, but instead require hand-written compat_sys_*() handlers, which fortunately already exist. Link: https://lore.kernel.org/lkml/20190116131527.2071570-5-arnd@arndb.de Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com> [heiko.carstens@de.ibm.com: compile fix for !CONFIG_COMPAT] Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/compat_wrapper.c')
-rw-r--r--arch/s390/kernel/compat_wrapper.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/arch/s390/kernel/compat_wrapper.c b/arch/s390/kernel/compat_wrapper.c
index f54b7b73f316..9d07cd553fc7 100644
--- a/arch/s390/kernel/compat_wrapper.c
+++ b/arch/s390/kernel/compat_wrapper.c
@@ -25,21 +25,6 @@
#define __SC_COMPAT_TYPE(t, a) \
__typeof(__builtin_choose_expr(sizeof(t) > 4, 0L, (t)0)) a
-#define __SC_COMPAT_CAST(t, a) \
-({ \
- long __ReS = a; \
- \
- BUILD_BUG_ON((sizeof(t) > 4) && !__TYPE_IS_L(t) && \
- !__TYPE_IS_UL(t) && !__TYPE_IS_PTR(t)); \
- if (__TYPE_IS_L(t)) \
- __ReS = (s32)a; \
- if (__TYPE_IS_UL(t)) \
- __ReS = (u32)a; \
- if (__TYPE_IS_PTR(t)) \
- __ReS = a & 0x7fffffff; \
- (t)__ReS; \
-})
-
/*
* The COMPAT_SYSCALL_WRAP macro generates system call wrappers to be used by
* compat tasks. These wrappers will only be used for system calls where only
@@ -53,11 +38,11 @@
* the regular system call wrappers.
*/
#define COMPAT_SYSCALL_WRAPx(x, name, ...) \
-asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
-asmlinkage long notrace compat_sys##name(__MAP(x,__SC_COMPAT_TYPE,__VA_ARGS__));\
-asmlinkage long notrace compat_sys##name(__MAP(x,__SC_COMPAT_TYPE,__VA_ARGS__)) \
+asmlinkage long __s390_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
+asmlinkage long notrace __s390_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
+asmlinkage long notrace __s390_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
{ \
- return sys##name(__MAP(x,__SC_COMPAT_CAST,__VA_ARGS__)); \
+ return __s390_sys##name(__MAP(x,__SC_ARGS,__VA_ARGS__)); \
}
COMPAT_SYSCALL_WRAP2(creat, const char __user *, pathname, umode_t, mode);