diff options
author | Christoph Hellwig <hch@lst.de> | 2010-03-10 18:21:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 18:52:32 -0500 |
commit | baed7fc9b580bd3fb8252ff1d9b36eaf1f86b670 (patch) | |
tree | 38f23cd9888b92de3f73ed1f4ce48cd83e940e0e /arch/sparc | |
parent | a4679373cf4ee0e7792dc56205365732b725c2c1 (diff) |
Add generic sys_ipc wrapper
Add a generic implementation of the ipc demultiplexer syscall. Except for
s390 and sparc64 all implementations of the sys_ipc are nearly identical.
There are slight differences in the types of the parameters, where mips
and powerpc as the only 64-bit architectures with sys_ipc use unsigned
long for the "third" argument as it gets casted to a pointer later, while
it traditionally is an "int" like most other paramters. frv goes even
further and uses unsigned long for all parameters execept for "ptr" which
is a pointer type everywhere. The change from int to unsigned long for
"third" and back to "int" for the others on frv should be fine due to the
in-register calling conventions for syscalls (we already had a similar
issue with the generic sys_ptrace), but I'd prefer to have the arch
maintainers looks over this in details.
Except for that h8300, m68k and m68knommu lack an impplementation of the
semtimedop sub call which this patch adds, and various architectures have
gets used - at least on i386 it seems superflous as the compat code on
x86-64 and ia64 doesn't even bother to implement it.
[akpm@linux-foundation.org: add sys_ipc to sys_ni.c]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Reviewed-by: H. Peter Anvin <hpa@zytor.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: James Morris <jmorris@namei.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Kyle McMartin <kyle@mcmartin.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/include/asm/unistd.h | 4 | ||||
-rw-r--r-- | arch/sparc/kernel/sys_sparc_32.c | 113 | ||||
-rw-r--r-- | arch/sparc/kernel/sys_sparc_64.c | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/systbls.h | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/systbls_64.S | 2 |
5 files changed, 6 insertions, 117 deletions
diff --git a/arch/sparc/include/asm/unistd.h b/arch/sparc/include/asm/unistd.h index cb4b9bfd0d87..d0b3b01ac9d4 100644 --- a/arch/sparc/include/asm/unistd.h +++ b/arch/sparc/include/asm/unistd.h | |||
@@ -432,7 +432,9 @@ | |||
432 | #define __ARCH_WANT_SYS_SIGPENDING | 432 | #define __ARCH_WANT_SYS_SIGPENDING |
433 | #define __ARCH_WANT_SYS_SIGPROCMASK | 433 | #define __ARCH_WANT_SYS_SIGPROCMASK |
434 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND | 434 | #define __ARCH_WANT_SYS_RT_SIGSUSPEND |
435 | #ifndef __32bit_syscall_numbers__ | 435 | #ifdef __32bit_syscall_numbers__ |
436 | #define __ARCH_WANT_SYS_IPC | ||
437 | #else | ||
436 | #define __ARCH_WANT_COMPAT_SYS_TIME | 438 | #define __ARCH_WANT_COMPAT_SYS_TIME |
437 | #define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND | 439 | #define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND |
438 | #endif | 440 | #endif |
diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c index 3a82e65d8db2..ee995b7dae7e 100644 --- a/arch/sparc/kernel/sys_sparc_32.c +++ b/arch/sparc/kernel/sys_sparc_32.c | |||
@@ -98,119 +98,6 @@ out: | |||
98 | return error; | 98 | return error; |
99 | } | 99 | } |
100 | 100 | ||
101 | /* | ||
102 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. | ||
103 | * | ||
104 | * This is really horribly ugly. | ||
105 | */ | ||
106 | |||
107 | asmlinkage int sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fifth) | ||
108 | { | ||
109 | int version, err; | ||
110 | |||
111 | version = call >> 16; /* hack for backward compatibility */ | ||
112 | call &= 0xffff; | ||
113 | |||
114 | if (call <= SEMCTL) | ||
115 | switch (call) { | ||
116 | case SEMOP: | ||
117 | err = sys_semtimedop (first, (struct sembuf __user *)ptr, second, NULL); | ||
118 | goto out; | ||
119 | case SEMTIMEDOP: | ||
120 | err = sys_semtimedop (first, (struct sembuf __user *)ptr, second, (const struct timespec __user *) fifth); | ||
121 | goto out; | ||
122 | case SEMGET: | ||
123 | err = sys_semget (first, second, third); | ||
124 | goto out; | ||
125 | case SEMCTL: { | ||
126 | union semun fourth; | ||
127 | err = -EINVAL; | ||
128 | if (!ptr) | ||
129 | goto out; | ||
130 | err = -EFAULT; | ||
131 | if (get_user(fourth.__pad, | ||
132 | (void __user * __user *)ptr)) | ||
133 | goto out; | ||
134 | err = sys_semctl (first, second, third, fourth); | ||
135 | goto out; | ||
136 | } | ||
137 | default: | ||
138 | err = -ENOSYS; | ||
139 | goto out; | ||
140 | } | ||
141 | if (call <= MSGCTL) | ||
142 | switch (call) { | ||
143 | case MSGSND: | ||
144 | err = sys_msgsnd (first, (struct msgbuf __user *) ptr, | ||
145 | second, third); | ||
146 | goto out; | ||
147 | case MSGRCV: | ||
148 | switch (version) { | ||
149 | case 0: { | ||
150 | struct ipc_kludge tmp; | ||
151 | err = -EINVAL; | ||
152 | if (!ptr) | ||
153 | goto out; | ||
154 | err = -EFAULT; | ||
155 | if (copy_from_user(&tmp, (struct ipc_kludge __user *) ptr, sizeof (tmp))) | ||
156 | goto out; | ||
157 | err = sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, third); | ||
158 | goto out; | ||
159 | } | ||
160 | case 1: default: | ||
161 | err = sys_msgrcv (first, | ||
162 | (struct msgbuf __user *) ptr, | ||
163 | second, fifth, third); | ||
164 | goto out; | ||
165 | } | ||
166 | case MSGGET: | ||
167 | err = sys_msgget ((key_t) first, second); | ||
168 | goto out; | ||
169 | case MSGCTL: | ||
170 | err = sys_msgctl (first, second, (struct msqid_ds __user *) ptr); | ||
171 | goto out; | ||
172 | default: | ||
173 | err = -ENOSYS; | ||
174 | goto out; | ||
175 | } | ||
176 | if (call <= SHMCTL) | ||
177 | switch (call) { | ||
178 | case SHMAT: | ||
179 | switch (version) { | ||
180 | case 0: default: { | ||
181 | ulong raddr; | ||
182 | err = do_shmat (first, (char __user *) ptr, second, &raddr); | ||
183 | if (err) | ||
184 | goto out; | ||
185 | err = -EFAULT; | ||
186 | if (put_user (raddr, (ulong __user *) third)) | ||
187 | goto out; | ||
188 | err = 0; | ||
189 | goto out; | ||
190 | } | ||
191 | case 1: /* iBCS2 emulator entry point */ | ||
192 | err = -EINVAL; | ||
193 | goto out; | ||
194 | } | ||
195 | case SHMDT: | ||
196 | err = sys_shmdt ((char __user *)ptr); | ||
197 | goto out; | ||
198 | case SHMGET: | ||
199 | err = sys_shmget (first, second, third); | ||
200 | goto out; | ||
201 | case SHMCTL: | ||
202 | err = sys_shmctl (first, second, (struct shmid_ds __user *) ptr); | ||
203 | goto out; | ||
204 | default: | ||
205 | err = -ENOSYS; | ||
206 | goto out; | ||
207 | } | ||
208 | else | ||
209 | err = -ENOSYS; | ||
210 | out: | ||
211 | return err; | ||
212 | } | ||
213 | |||
214 | int sparc_mmap_check(unsigned long addr, unsigned long len) | 101 | int sparc_mmap_check(unsigned long addr, unsigned long len) |
215 | { | 102 | { |
216 | if (ARCH_SUN4C && | 103 | if (ARCH_SUN4C && |
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index cb1bef6f14b7..45410e939628 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c | |||
@@ -426,7 +426,7 @@ out: | |||
426 | * This is really horribly ugly. | 426 | * This is really horribly ugly. |
427 | */ | 427 | */ |
428 | 428 | ||
429 | SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second, | 429 | SYSCALL_DEFINE6(sparc_ipc, unsigned int, call, int, first, unsigned long, second, |
430 | unsigned long, third, void __user *, ptr, long, fifth) | 430 | unsigned long, third, void __user *, ptr, long, fifth) |
431 | { | 431 | { |
432 | long err; | 432 | long err; |
diff --git a/arch/sparc/kernel/systbls.h b/arch/sparc/kernel/systbls.h index 68312fe8da74..2c331c37e748 100644 --- a/arch/sparc/kernel/systbls.h +++ b/arch/sparc/kernel/systbls.h | |||
@@ -10,7 +10,7 @@ struct new_utsname; | |||
10 | 10 | ||
11 | extern asmlinkage unsigned long sys_getpagesize(void); | 11 | extern asmlinkage unsigned long sys_getpagesize(void); |
12 | extern asmlinkage long sparc_pipe(struct pt_regs *regs); | 12 | extern asmlinkage long sparc_pipe(struct pt_regs *regs); |
13 | extern asmlinkage long sys_ipc(unsigned int call, int first, | 13 | extern asmlinkage long sys_sparc_ipc(unsigned int call, int first, |
14 | unsigned long second, | 14 | unsigned long second, |
15 | unsigned long third, | 15 | unsigned long third, |
16 | void __user *ptr, long fifth); | 16 | void __user *ptr, long fifth); |
diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S index 17614251fb6d..30ca2b1d3a17 100644 --- a/arch/sparc/kernel/systbls_64.S +++ b/arch/sparc/kernel/systbls_64.S | |||
@@ -136,7 +136,7 @@ sys_call_table: | |||
136 | /*200*/ .word sys_ssetmask, sys_nis_syscall, sys_newlstat, sys_uselib, sys_nis_syscall | 136 | /*200*/ .word sys_ssetmask, sys_nis_syscall, sys_newlstat, sys_uselib, sys_nis_syscall |
137 | .word sys_readahead, sys_socketcall, sys_syslog, sys_lookup_dcookie, sys_fadvise64 | 137 | .word sys_readahead, sys_socketcall, sys_syslog, sys_lookup_dcookie, sys_fadvise64 |
138 | /*210*/ .word sys_fadvise64_64, sys_tgkill, sys_waitpid, sys_swapoff, sys_sysinfo | 138 | /*210*/ .word sys_fadvise64_64, sys_tgkill, sys_waitpid, sys_swapoff, sys_sysinfo |
139 | .word sys_ipc, sys_nis_syscall, sys_clone, sys_ioprio_get, sys_adjtimex | 139 | .word sys_sparc_ipc, sys_nis_syscall, sys_clone, sys_ioprio_get, sys_adjtimex |
140 | /*220*/ .word sys_nis_syscall, sys_ni_syscall, sys_delete_module, sys_ni_syscall, sys_getpgid | 140 | /*220*/ .word sys_nis_syscall, sys_ni_syscall, sys_delete_module, sys_ni_syscall, sys_getpgid |
141 | .word sys_bdflush, sys_sysfs, sys_nis_syscall, sys_setfsuid, sys_setfsgid | 141 | .word sys_bdflush, sys_sysfs, sys_nis_syscall, sys_setfsuid, sys_setfsgid |
142 | /*230*/ .word sys_select, sys_nis_syscall, sys_splice, sys_stime, sys_statfs64 | 142 | /*230*/ .word sys_select, sys_nis_syscall, sys_splice, sys_stime, sys_statfs64 |