aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2012-03-15 13:13:38 -0400
committerChris Metcalf <cmetcalf@tilera.com>2012-03-15 13:13:38 -0400
commit48b25c43e6eebb6c0edf72935e8720385beca76b (patch)
treed1c774a79ef5a8373b093479c3dabe9bf16aec07 /arch
parentfde7d9049e55ab85a390be7f415d74c9f62dd0f9 (diff)
[PATCH v3] ipc: provide generic compat versions of IPC syscalls
When using the "compat" APIs, architectures will generally want to be able to make direct syscalls to msgsnd(), shmctl(), etc., and in the kernel we would want them to be handled directly by compat_sys_xxx() functions, as is true for other compat syscalls. However, for historical reasons, several of the existing compat IPC syscalls do not do this. semctl() expects a pointer to the fourth argument, instead of the fourth argument itself. msgsnd(), msgrcv() and shmat() expect arguments in different order. This change adds an ARCH_WANT_OLD_COMPAT_IPC config option that can be set to preserve this behavior for ports that use it (x86, sparc, powerpc, s390, and mips). No actual semantics are changed for those architectures, and there is only a minimal amount of code refactoring in ipc/compat.c. Newer architectures like tile (and perhaps future architectures such as arm64 and unicore64) should not select this option, and thus can avoid having any IPC-specific code at all in their architecture-specific compat layer. In the same vein, if this option is not selected, IPC_64 mode is assumed, since that's what the <asm-generic> headers expect. The workaround code in "tile" for msgsnd() and msgrcv() is removed with this change; it also fixes the bug that shmat() and semctl() were not being properly handled. Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/Kconfig3
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/tile/include/asm/compat.h11
-rw-r--r--arch/tile/kernel/compat.c43
-rw-r--r--arch/x86/Kconfig1
8 files changed, 8 insertions, 54 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index 4f55c736be11..b37f8f3ffa54 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -199,4 +199,7 @@ config HAVE_CMPXCHG_LOCAL
199config HAVE_CMPXCHG_DOUBLE 199config HAVE_CMPXCHG_DOUBLE
200 bool 200 bool
201 201
202config ARCH_WANT_OLD_COMPAT_IPC
203 bool
204
202source "kernel/gcov/Kconfig" 205source "kernel/gcov/Kconfig"
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5ab6e89603c5..4bbbb40f352a 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2456,6 +2456,7 @@ config MIPS32_COMPAT
2456config COMPAT 2456config COMPAT
2457 bool 2457 bool
2458 depends on MIPS32_COMPAT 2458 depends on MIPS32_COMPAT
2459 select ARCH_WANT_OLD_COMPAT_IPC
2459 default y 2460 default y
2460 2461
2461config SYSVIPC_COMPAT 2462config SYSVIPC_COMPAT
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 1919634a9b32..48ab0bb38924 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -152,6 +152,7 @@ config COMPAT
152 bool 152 bool
153 default y if PPC64 153 default y if PPC64
154 select COMPAT_BINFMT_ELF 154 select COMPAT_BINFMT_ELF
155 select ARCH_WANT_OLD_COMPAT_IPC
155 156
156config SYSVIPC_COMPAT 157config SYSVIPC_COMPAT
157 bool 158 bool
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 6d99a5fcc090..0ff53e350092 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -218,6 +218,7 @@ config COMPAT
218 prompt "Kernel support for 31 bit emulation" 218 prompt "Kernel support for 31 bit emulation"
219 depends on 64BIT 219 depends on 64BIT
220 select COMPAT_BINFMT_ELF 220 select COMPAT_BINFMT_ELF
221 select ARCH_WANT_OLD_COMPAT_IPC
221 help 222 help
222 Select this option if you want to enable your system kernel to 223 Select this option if you want to enable your system kernel to
223 handle system-calls from ELF binaries for 31 bit ESA. This option 224 handle system-calls from ELF binaries for 31 bit ESA. This option
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index ca5580e4d813..64e1a8e7cab3 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -576,6 +576,7 @@ config COMPAT
576 depends on SPARC64 576 depends on SPARC64
577 default y 577 default y
578 select COMPAT_BINFMT_ELF 578 select COMPAT_BINFMT_ELF
579 select ARCH_WANT_OLD_COMPAT_IPC
579 580
580config SYSVIPC_COMPAT 581config SYSVIPC_COMPAT
581 bool 582 bool
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
index bf95f55b82b0..4b4b28969a65 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -242,17 +242,6 @@ long compat_sys_fallocate(int fd, int mode,
242long compat_sys_sched_rr_get_interval(compat_pid_t pid, 242long compat_sys_sched_rr_get_interval(compat_pid_t pid,
243 struct compat_timespec __user *interval); 243 struct compat_timespec __user *interval);
244 244
245/* Versions of compat functions that differ from generic Linux. */
246struct compat_msgbuf;
247long tile_compat_sys_msgsnd(int msqid,
248 struct compat_msgbuf __user *msgp,
249 size_t msgsz, int msgflg);
250long tile_compat_sys_msgrcv(int msqid,
251 struct compat_msgbuf __user *msgp,
252 size_t msgsz, long msgtyp, int msgflg);
253long tile_compat_sys_ptrace(compat_long_t request, compat_long_t pid,
254 compat_long_t addr, compat_long_t data);
255
256/* Tilera Linux syscalls that don't have "compat" versions. */ 245/* Tilera Linux syscalls that don't have "compat" versions. */
257#define compat_sys_flush_cache sys_flush_cache 246#define compat_sys_flush_cache sys_flush_cache
258 247
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c
index bf5e9d70266c..d67459b9ac2a 100644
--- a/arch/tile/kernel/compat.c
+++ b/arch/tile/kernel/compat.c
@@ -16,7 +16,6 @@
16#define __SYSCALL_COMPAT 16#define __SYSCALL_COMPAT
17 17
18#include <linux/compat.h> 18#include <linux/compat.h>
19#include <linux/msg.h>
20#include <linux/syscalls.h> 19#include <linux/syscalls.h>
21#include <linux/kdev_t.h> 20#include <linux/kdev_t.h>
22#include <linux/fs.h> 21#include <linux/fs.h>
@@ -95,52 +94,10 @@ long compat_sys_sched_rr_get_interval(compat_pid_t pid,
95 return ret; 94 return ret;
96} 95}
97 96
98/*
99 * The usual compat_sys_msgsnd() and _msgrcv() seem to be assuming
100 * some different calling convention than our normal 32-bit tile code.
101 */
102
103/* Already defined in ipc/compat.c, but we need it here. */
104struct compat_msgbuf {
105 compat_long_t mtype;
106 char mtext[1];
107};
108
109long tile_compat_sys_msgsnd(int msqid,
110 struct compat_msgbuf __user *msgp,
111 size_t msgsz, int msgflg)
112{
113 compat_long_t mtype;
114
115 if (get_user(mtype, &msgp->mtype))
116 return -EFAULT;
117 return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg);
118}
119
120long tile_compat_sys_msgrcv(int msqid,
121 struct compat_msgbuf __user *msgp,
122 size_t msgsz, long msgtyp, int msgflg)
123{
124 long err, mtype;
125
126 err = do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg);
127 if (err < 0)
128 goto out;
129
130 if (put_user(mtype, &msgp->mtype))
131 err = -EFAULT;
132 out:
133 return err;
134}
135
136/* Provide the compat syscall number to call mapping. */ 97/* Provide the compat syscall number to call mapping. */
137#undef __SYSCALL 98#undef __SYSCALL
138#define __SYSCALL(nr, call) [nr] = (call), 99#define __SYSCALL(nr, call) [nr] = (call),
139 100
140/* The generic versions of these don't work for Tile. */
141#define compat_sys_msgrcv tile_compat_sys_msgrcv
142#define compat_sys_msgsnd tile_compat_sys_msgsnd
143
144/* See comments in sys.c */ 101/* See comments in sys.c */
145#define compat_sys_fadvise64_64 sys32_fadvise64_64 102#define compat_sys_fadvise64_64 sys32_fadvise64_64
146#define compat_sys_readahead sys32_readahead 103#define compat_sys_readahead sys32_readahead
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5bed94e189fa..cde163dc6058 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2178,6 +2178,7 @@ config IA32_AOUT
2178config COMPAT 2178config COMPAT
2179 def_bool y 2179 def_bool y
2180 depends on IA32_EMULATION 2180 depends on IA32_EMULATION
2181 select ARCH_WANT_OLD_COMPAT_IPC
2181 2182
2182config COMPAT_FOR_U64_ALIGNMENT 2183config COMPAT_FOR_U64_ALIGNMENT
2183 def_bool COMPAT 2184 def_bool COMPAT