diff options
author | Chris Metcalf <cmetcalf@tilera.com> | 2012-03-15 13:13:38 -0400 |
---|---|---|
committer | Chris Metcalf <cmetcalf@tilera.com> | 2012-03-15 13:13:38 -0400 |
commit | 48b25c43e6eebb6c0edf72935e8720385beca76b (patch) | |
tree | d1c774a79ef5a8373b093479c3dabe9bf16aec07 /arch/tile/kernel | |
parent | fde7d9049e55ab85a390be7f415d74c9f62dd0f9 (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/tile/kernel')
-rw-r--r-- | arch/tile/kernel/compat.c | 43 |
1 files changed, 0 insertions, 43 deletions
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. */ | ||
104 | struct compat_msgbuf { | ||
105 | compat_long_t mtype; | ||
106 | char mtext[1]; | ||
107 | }; | ||
108 | |||
109 | long 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 | |||
120 | long 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 |