diff options
Diffstat (limited to 'arch/mips/kernel/syscall.c')
-rw-r--r-- | arch/mips/kernel/syscall.c | 170 |
1 files changed, 10 insertions, 160 deletions
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c index fe0d79805603..dd81b0f87518 100644 --- a/arch/mips/kernel/syscall.c +++ b/arch/mips/kernel/syscall.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/syscalls.h> | 20 | #include <linux/syscalls.h> |
21 | #include <linux/file.h> | 21 | #include <linux/file.h> |
22 | #include <linux/slab.h> | ||
23 | #include <linux/utsname.h> | 22 | #include <linux/utsname.h> |
24 | #include <linux/unistd.h> | 23 | #include <linux/unistd.h> |
25 | #include <linux/sem.h> | 24 | #include <linux/sem.h> |
@@ -29,6 +28,7 @@ | |||
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/ipc.h> | 29 | #include <linux/ipc.h> |
31 | #include <linux/uaccess.h> | 30 | #include <linux/uaccess.h> |
31 | #include <linux/slab.h> | ||
32 | 32 | ||
33 | #include <asm/asm.h> | 33 | #include <asm/asm.h> |
34 | #include <asm/branch.h> | 34 | #include <asm/branch.h> |
@@ -79,7 +79,11 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, | |||
79 | int do_color_align; | 79 | int do_color_align; |
80 | unsigned long task_size; | 80 | unsigned long task_size; |
81 | 81 | ||
82 | task_size = STACK_TOP; | 82 | #ifdef CONFIG_32BIT |
83 | task_size = TASK_SIZE; | ||
84 | #else /* Must be CONFIG_64BIT*/ | ||
85 | task_size = test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE; | ||
86 | #endif | ||
83 | 87 | ||
84 | if (len > task_size) | 88 | if (len > task_size) |
85 | return -ENOMEM; | 89 | return -ENOMEM; |
@@ -93,7 +97,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, | |||
93 | * We do not accept a shared mapping if it would violate | 97 | * We do not accept a shared mapping if it would violate |
94 | * cache aliasing constraints. | 98 | * cache aliasing constraints. |
95 | */ | 99 | */ |
96 | if ((flags & MAP_SHARED) && (addr & shm_align_mask)) | 100 | if ((flags & MAP_SHARED) && |
101 | ((addr - (pgoff << PAGE_SHIFT)) & shm_align_mask)) | ||
97 | return -EINVAL; | 102 | return -EINVAL; |
98 | return addr; | 103 | return addr; |
99 | } | 104 | } |
@@ -129,31 +134,6 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, | |||
129 | } | 134 | } |
130 | } | 135 | } |
131 | 136 | ||
132 | /* common code for old and new mmaps */ | ||
133 | static inline unsigned long | ||
134 | do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, | ||
135 | unsigned long flags, unsigned long fd, unsigned long pgoff) | ||
136 | { | ||
137 | unsigned long error = -EBADF; | ||
138 | struct file * file = NULL; | ||
139 | |||
140 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | ||
141 | if (!(flags & MAP_ANONYMOUS)) { | ||
142 | file = fget(fd); | ||
143 | if (!file) | ||
144 | goto out; | ||
145 | } | ||
146 | |||
147 | down_write(¤t->mm->mmap_sem); | ||
148 | error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
149 | up_write(¤t->mm->mmap_sem); | ||
150 | |||
151 | if (file) | ||
152 | fput(file); | ||
153 | out: | ||
154 | return error; | ||
155 | } | ||
156 | |||
157 | SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len, | 137 | SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len, |
158 | unsigned long, prot, unsigned long, flags, unsigned long, | 138 | unsigned long, prot, unsigned long, flags, unsigned long, |
159 | fd, off_t, offset) | 139 | fd, off_t, offset) |
@@ -164,7 +144,7 @@ SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len, | |||
164 | if (offset & ~PAGE_MASK) | 144 | if (offset & ~PAGE_MASK) |
165 | goto out; | 145 | goto out; |
166 | 146 | ||
167 | result = do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT); | 147 | result = sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT); |
168 | 148 | ||
169 | out: | 149 | out: |
170 | return result; | 150 | return result; |
@@ -177,7 +157,7 @@ SYSCALL_DEFINE6(mips_mmap2, unsigned long, addr, unsigned long, len, | |||
177 | if (pgoff & (~PAGE_MASK >> 12)) | 157 | if (pgoff & (~PAGE_MASK >> 12)) |
178 | return -EINVAL; | 158 | return -EINVAL; |
179 | 159 | ||
180 | return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT-12)); | 160 | return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT-12)); |
181 | } | 161 | } |
182 | 162 | ||
183 | save_static_function(sys_fork); | 163 | save_static_function(sys_fork); |
@@ -239,48 +219,6 @@ out: | |||
239 | return error; | 219 | return error; |
240 | } | 220 | } |
241 | 221 | ||
242 | /* | ||
243 | * Compacrapability ... | ||
244 | */ | ||
245 | SYSCALL_DEFINE1(uname, struct old_utsname __user *, name) | ||
246 | { | ||
247 | if (name && !copy_to_user(name, utsname(), sizeof (*name))) | ||
248 | return 0; | ||
249 | return -EFAULT; | ||
250 | } | ||
251 | |||
252 | /* | ||
253 | * Compacrapability ... | ||
254 | */ | ||
255 | SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name) | ||
256 | { | ||
257 | int error; | ||
258 | |||
259 | if (!name) | ||
260 | return -EFAULT; | ||
261 | if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname))) | ||
262 | return -EFAULT; | ||
263 | |||
264 | error = __copy_to_user(&name->sysname, &utsname()->sysname, | ||
265 | __OLD_UTS_LEN); | ||
266 | error -= __put_user(0, name->sysname + __OLD_UTS_LEN); | ||
267 | error -= __copy_to_user(&name->nodename, &utsname()->nodename, | ||
268 | __OLD_UTS_LEN); | ||
269 | error -= __put_user(0, name->nodename + __OLD_UTS_LEN); | ||
270 | error -= __copy_to_user(&name->release, &utsname()->release, | ||
271 | __OLD_UTS_LEN); | ||
272 | error -= __put_user(0, name->release + __OLD_UTS_LEN); | ||
273 | error -= __copy_to_user(&name->version, &utsname()->version, | ||
274 | __OLD_UTS_LEN); | ||
275 | error -= __put_user(0, name->version + __OLD_UTS_LEN); | ||
276 | error -= __copy_to_user(&name->machine, &utsname()->machine, | ||
277 | __OLD_UTS_LEN); | ||
278 | error = __put_user(0, name->machine + __OLD_UTS_LEN); | ||
279 | error = error ? -EFAULT : 0; | ||
280 | |||
281 | return error; | ||
282 | } | ||
283 | |||
284 | SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) | 222 | SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) |
285 | { | 223 | { |
286 | struct thread_info *ti = task_thread_info(current); | 224 | struct thread_info *ti = task_thread_info(current); |
@@ -431,94 +369,6 @@ _sys_sysmips(nabi_no_regargs struct pt_regs regs) | |||
431 | } | 369 | } |
432 | 370 | ||
433 | /* | 371 | /* |
434 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. | ||
435 | * | ||
436 | * This is really horribly ugly. | ||
437 | */ | ||
438 | SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, int, second, | ||
439 | unsigned long, third, void __user *, ptr, long, fifth) | ||
440 | { | ||
441 | int version, ret; | ||
442 | |||
443 | version = call >> 16; /* hack for backward compatibility */ | ||
444 | call &= 0xffff; | ||
445 | |||
446 | switch (call) { | ||
447 | case SEMOP: | ||
448 | return sys_semtimedop(first, (struct sembuf __user *)ptr, | ||
449 | second, NULL); | ||
450 | case SEMTIMEDOP: | ||
451 | return sys_semtimedop(first, (struct sembuf __user *)ptr, | ||
452 | second, | ||
453 | (const struct timespec __user *)fifth); | ||
454 | case SEMGET: | ||
455 | return sys_semget(first, second, third); | ||
456 | case SEMCTL: { | ||
457 | union semun fourth; | ||
458 | if (!ptr) | ||
459 | return -EINVAL; | ||
460 | if (get_user(fourth.__pad, (void __user *__user *) ptr)) | ||
461 | return -EFAULT; | ||
462 | return sys_semctl(first, second, third, fourth); | ||
463 | } | ||
464 | |||
465 | case MSGSND: | ||
466 | return sys_msgsnd(first, (struct msgbuf __user *) ptr, | ||
467 | second, third); | ||
468 | case MSGRCV: | ||
469 | switch (version) { | ||
470 | case 0: { | ||
471 | struct ipc_kludge tmp; | ||
472 | if (!ptr) | ||
473 | return -EINVAL; | ||
474 | |||
475 | if (copy_from_user(&tmp, | ||
476 | (struct ipc_kludge __user *) ptr, | ||
477 | sizeof(tmp))) | ||
478 | return -EFAULT; | ||
479 | return sys_msgrcv(first, tmp.msgp, second, | ||
480 | tmp.msgtyp, third); | ||
481 | } | ||
482 | default: | ||
483 | return sys_msgrcv(first, | ||
484 | (struct msgbuf __user *) ptr, | ||
485 | second, fifth, third); | ||
486 | } | ||
487 | case MSGGET: | ||
488 | return sys_msgget((key_t) first, second); | ||
489 | case MSGCTL: | ||
490 | return sys_msgctl(first, second, | ||
491 | (struct msqid_ds __user *) ptr); | ||
492 | |||
493 | case SHMAT: | ||
494 | switch (version) { | ||
495 | default: { | ||
496 | unsigned long raddr; | ||
497 | ret = do_shmat(first, (char __user *) ptr, second, | ||
498 | &raddr); | ||
499 | if (ret) | ||
500 | return ret; | ||
501 | return put_user(raddr, (unsigned long __user *) third); | ||
502 | } | ||
503 | case 1: /* iBCS2 emulator entry point */ | ||
504 | if (!segment_eq(get_fs(), get_ds())) | ||
505 | return -EINVAL; | ||
506 | return do_shmat(first, (char __user *) ptr, second, | ||
507 | (unsigned long *) third); | ||
508 | } | ||
509 | case SHMDT: | ||
510 | return sys_shmdt((char __user *)ptr); | ||
511 | case SHMGET: | ||
512 | return sys_shmget(first, second, third); | ||
513 | case SHMCTL: | ||
514 | return sys_shmctl(first, second, | ||
515 | (struct shmid_ds __user *) ptr); | ||
516 | default: | ||
517 | return -ENOSYS; | ||
518 | } | ||
519 | } | ||
520 | |||
521 | /* | ||
522 | * No implemented yet ... | 372 | * No implemented yet ... |
523 | */ | 373 | */ |
524 | SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op) | 374 | SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op) |