diff options
| author | Stephen Rothwell <sfr@canb.auug.org.au> | 2003-02-14 20:38:11 -0800 |
|---|---|---|
| committer | Jens Axboe <axboe@suse.de> | 2003-02-14 20:38:11 -0800 |
| commit | 424706ad4e048c933773cfabf0244cb80bbc8e64 (patch) | |
| tree | b4069ad4daf4578349912d7bcf1ab3a31f813465 | |
| parent | fcc21ee29a39fd47d119e12997d2b09d97083e28 (diff) | |
[PATCH] compat_sys_futex 1/3 generic, parisc, ppc64, s390x and x86_64
This is the generic part of the patch and the architecture specific parts
I have been asked to forward directly to you.
| -rw-r--r-- | arch/parisc/kernel/syscall.S | 5 | ||||
| -rw-r--r-- | arch/ppc64/kernel/misc.S | 2 | ||||
| -rw-r--r-- | arch/s390x/kernel/entry.S | 2 | ||||
| -rw-r--r-- | arch/s390x/kernel/linux32.c | 22 | ||||
| -rw-r--r-- | arch/s390x/kernel/wrapper32.S | 10 | ||||
| -rw-r--r-- | arch/x86_64/ia32/ia32entry.S | 2 | ||||
| -rw-r--r-- | arch/x86_64/ia32/sys_ia32.c | 20 | ||||
| -rw-r--r-- | include/linux/futex.h | 2 | ||||
| -rw-r--r-- | kernel/compat.c | 17 | ||||
| -rw-r--r-- | kernel/futex.c | 37 |
10 files changed, 46 insertions, 73 deletions
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S index acde743c0fb0..1f8ecc14ac36 100644 --- a/arch/parisc/kernel/syscall.S +++ b/arch/parisc/kernel/syscall.S @@ -320,7 +320,8 @@ tracesys_sigexit: #ifdef __LP64__ /* Use ENTRY_SAME for 32-bit syscalls which are the same on wide and * narrow palinux. Use ENTRY_DIFF for those where a 32-bit specific - * implementation is required on wide palinux. + * implementation is required on wide palinux. Use ENTRY_COMP where + * the compatability layer has a useful 32-bit implementation. */ #define ENTRY_SAME(_name_) .dword sys_##_name_ #define ENTRY_DIFF(_name_) .dword sys32_##_name_ @@ -597,7 +598,7 @@ sys_call_table: ENTRY_SAME(ni_syscall) /* tkill */ ENTRY_SAME(sendfile64) - ENTRY_SAME(futex) /* 210 */ + ENTRY_COMP(futex) /* 210 */ ENTRY_SAME(sched_setaffinity) ENTRY_SAME(sched_getaffinity) ENTRY_SAME(set_thread_area) diff --git a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S index ff99745b764f..677250300f23 100644 --- a/arch/ppc64/kernel/misc.S +++ b/arch/ppc64/kernel/misc.S @@ -724,7 +724,7 @@ _GLOBAL(sys_call_table32) .llong .sys_removexattr .llong .sys_lremovexattr .llong .sys_fremovexattr /* 220 */ - .llong .sys_futex + .llong .compat_sys_futex .llong .sys32_sched_setaffinity .llong .sys32_sched_getaffinity .llong .sys_ni_syscall diff --git a/arch/s390x/kernel/entry.S b/arch/s390x/kernel/entry.S index 2fa970cba546..484f840571db 100644 --- a/arch/s390x/kernel/entry.S +++ b/arch/s390x/kernel/entry.S @@ -629,7 +629,7 @@ sys_call_table: .long SYSCALL(sys_fremovexattr,sys32_fremovexattr_wrapper) /* 235 */ .long SYSCALL(sys_gettid,sys_gettid) .long SYSCALL(sys_tkill,sys_tkill) - .long SYSCALL(sys_futex,sys32_futex_wrapper) + .long SYSCALL(sys_futex,compat_sys_futex_wrapper) .long SYSCALL(sys_sched_setaffinity,sys32_sched_setaffinity_wrapper) .long SYSCALL(sys_sched_getaffinity,sys32_sched_getaffinity_wrapper) /* 240 */ .long SYSCALL(sys_ni_syscall,sys_ni_syscall) diff --git a/arch/s390x/kernel/linux32.c b/arch/s390x/kernel/linux32.c index a26632e3dd9a..fce07ff5aae3 100644 --- a/arch/s390x/kernel/linux32.c +++ b/arch/s390x/kernel/linux32.c @@ -4049,28 +4049,6 @@ asmlinkage int sys32_sched_getaffinity(compat_pid_t pid, unsigned int len, return ret; } -asmlinkage int -sys_futex(void *uaddr, int op, int val, struct timespec *utime); - -asmlinkage int -sys32_futex(void *uaddr, int op, int val, - struct compat_timespec *timeout32) -{ - struct timespec tmp; - mm_segment_t old_fs; - int ret; - - if (timeout32 && get_compat_timespec(&tmp, timeout32)) - return -EINVAL; - - old_fs = get_fs(); - set_fs(KERNEL_DS); - ret = sys_futex(uaddr, op, val, timeout32 ? &tmp : NULL); - set_fs(old_fs); - - return ret; -} - asmlinkage ssize_t sys_read(unsigned int fd, char * buf, size_t count); asmlinkage compat_ssize_t sys32_read(unsigned int fd, char * buf, size_t count) diff --git a/arch/s390x/kernel/wrapper32.S b/arch/s390x/kernel/wrapper32.S index 68612324ece5..d255576722b0 100644 --- a/arch/s390x/kernel/wrapper32.S +++ b/arch/s390x/kernel/wrapper32.S @@ -1088,13 +1088,13 @@ sys32_fstat64_wrapper: llgfr %r4,%r4 # long jg sys32_fstat64 # branch to system call - .globl sys32_futex_wrapper -sys32_futex_wrapper: - llgtr %r2,%r2 # void * + .globl compat_sys_futex_wrapper +compat_sys_futex_wrapper: + llgtr %r2,%r2 # u32 * lgfr %r3,%r3 # int lgfr %r4,%r4 # int - llgtr %r5,%r5 # struct timespec * - jg sys32_futex # branch to system call + llgtr %r5,%r5 # struct compat_timespec * + jg compat_sys_futex # branch to system call .globl sys32_setxattr_wrapper sys32_setxattr_wrapper: diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S index ae59a84040a5..a2eb4c13f023 100644 --- a/arch/x86_64/ia32/ia32entry.S +++ b/arch/x86_64/ia32/ia32entry.S @@ -440,7 +440,7 @@ ia32_sys_call_table: .quad sys_fremovexattr .quad sys_tkill /* 238 */ .quad sys_sendfile64 - .quad sys32_futex /* 240 */ + .quad compat_sys_futex /* 240 */ .quad sys32_sched_setaffinity .quad sys32_sched_getaffinity .quad sys_set_thread_area diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c index ee12fd5a8847..3849c0ad3ec0 100644 --- a/arch/x86_64/ia32/sys_ia32.c +++ b/arch/x86_64/ia32/sys_ia32.c @@ -2199,26 +2199,6 @@ long sys32_sched_getaffinity(pid_t pid, unsigned int len, return err; } -extern int sys_futex(unsigned long uaddr, int op, int val, struct timespec *t); - -asmlinkage long -sys32_futex(unsigned long uaddr, int op, int val, struct compat_timespec *utime32) -{ - struct timespec t; - mm_segment_t oldfs = get_fs(); - int err; - - if (utime32 && get_compat_timespec(&t, utime32)) - return -EFAULT; - - /* the set_fs is safe because futex doesn't use the seg limit - for valid page checking of uaddr. */ - set_fs(KERNEL_DS); - err = sys_futex(uaddr, op, val, utime32 ? &t : NULL); - set_fs(oldfs); - return err; -} - extern long sys_io_setup(unsigned nr_reqs, aio_context_t *ctx); long sys32_io_setup(unsigned nr_reqs, u32 *ctx32p) diff --git a/include/linux/futex.h b/include/linux/futex.h index 415946df03d4..5120f5fb84cd 100644 --- a/include/linux/futex.h +++ b/include/linux/futex.h @@ -6,6 +6,6 @@ #define FUTEX_WAKE (1) #define FUTEX_FD (2) -extern asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec *utime); +extern asmlinkage long sys_futex(u32 *uaddr, int op, int val, struct timespec *utime); #endif diff --git a/kernel/compat.c b/kernel/compat.c index 0c51a4de67a8..892b49f14f5f 100644 --- a/kernel/compat.c +++ b/kernel/compat.c @@ -16,6 +16,7 @@ #include <linux/errno.h> #include <linux/time.h> #include <linux/signal.h> +#include <linux/sched.h> /* for MAX_SCHEDULE_TIMEOUT */ #include <asm/uaccess.h> @@ -208,3 +209,19 @@ asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t *set, ret = put_user(s, oset); return ret; } + +extern long do_futex(u32 *, int, int, unsigned long); + +asmlinkage long compat_sys_futex(u32 *uaddr, int op, int val, + struct compat_timespec *utime) +{ + struct timespec t; + unsigned long timeout = MAX_SCHEDULE_TIMEOUT; + + if ((op == FUTEX_WAIT) && utime) { + if (get_compat_timespec(&t, utime)) + return -EFAULT; + timeout = timespec_to_jiffies(t) + 1; + } + return do_futex((unsigned long)uaddr, op, val, timeout); +} diff --git a/kernel/futex.c b/kernel/futex.c index 16775292bdc4..9813932a6a0a 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -315,23 +315,6 @@ out: return ret; } -static inline int futex_wait_utime(unsigned long uaddr, - int offset, - int val, - struct timespec* utime) -{ - unsigned long time = MAX_SCHEDULE_TIMEOUT; - - if (utime) { - struct timespec t; - if (copy_from_user(&t, utime, sizeof(t)) != 0) - return -EFAULT; - time = timespec_to_jiffies(&t) + 1; - } - - return futex_wait(uaddr, offset, val, time); -} - static int futex_close(struct inode *inode, struct file *filp) { struct futex_q *q = filp->private_data; @@ -437,7 +420,7 @@ out: return ret; } -asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec *utime) +long do_futex(unsigned long uaddr, int op, int val, unsinged long timeout) { unsigned long pos_in_page; int ret; @@ -445,12 +428,12 @@ asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec * pos_in_page = uaddr % PAGE_SIZE; /* Must be "naturally" aligned */ - if (pos_in_page % sizeof(int)) + if (pos_in_page % sizeof(u32)) return -EINVAL; switch (op) { case FUTEX_WAIT: - ret = futex_wait_utime(uaddr, pos_in_page, val, utime); + ret = futex_wait(uaddr, pos_in_page, val, timeout); break; case FUTEX_WAKE: ret = futex_wake(uaddr, pos_in_page, val); @@ -465,6 +448,20 @@ asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec * return ret; } +asmlinkage long sys_futex(u32 *uaddr, int op, int val, struct timespec *utime) +{ + struct timespec t; + unsigned long timeout = MAX_SCHEDULE_TIMEOUT; + + + if ((op == FUTEX_WAIT) && utime) { + if (copy_from_user(&t, utime, sizeof(t)) != 0) + return -EFAULT; + timeout = timespec_to_jiffies(t) + 1; + } + return do_futex((unsigned long)uaddr, op, val, timeout); +} + static struct super_block * futexfs_get_sb(struct file_system_type *fs_type, int flags, char *dev_name, void *data) |
