[PATCH] rcu: Mention rcu_bh in description of rcutorture's torture_type parameter
[linux-2.6.git] / kernel / compat.c
index b9bdd12..75573e5 100644 (file)
 #include <linux/time.h>
 #include <linux/signal.h>
 #include <linux/sched.h>       /* for MAX_SCHEDULE_TIMEOUT */
-#include <linux/futex.h>       /* for FUTEX_WAIT */
 #include <linux/syscalls.h>
 #include <linux/unistd.h>
 #include <linux/security.h>
 #include <linux/timex.h>
+#include <linux/migrate.h>
+#include <linux/posix-timers.h>
 
 #include <asm/uaccess.h>
 
@@ -239,28 +240,6 @@ asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *set,
        return ret;
 }
 
-#ifdef CONFIG_FUTEX
-asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, int val,
-               struct compat_timespec __user *utime, u32 __user *uaddr2,
-               int val3)
-{
-       struct timespec t;
-       unsigned long timeout = MAX_SCHEDULE_TIMEOUT;
-       int val2 = 0;
-
-       if ((op == FUTEX_WAIT) && utime) {
-               if (get_compat_timespec(&t, utime))
-                       return -EFAULT;
-               timeout = timespec_to_jiffies(&t) + 1;
-       }
-       if (op >= FUTEX_REQUEUE)
-               val2 = (int) (unsigned long) utime;
-
-       return do_futex((unsigned long)uaddr, op, val, timeout,
-                       (unsigned long)uaddr2, val2, val3);
-}
-#endif
-
 asmlinkage long compat_sys_setrlimit(unsigned int resource,
                struct compat_rlimit __user *rlim)
 {
@@ -623,6 +602,30 @@ long compat_sys_clock_getres(clockid_t which_clock,
        return err;
 } 
 
+static long compat_clock_nanosleep_restart(struct restart_block *restart)
+{
+       long err;
+       mm_segment_t oldfs;
+       struct timespec tu;
+       struct compat_timespec *rmtp = (struct compat_timespec *)(restart->arg1);
+
+       restart->arg1 = (unsigned long) &tu;
+       oldfs = get_fs();
+       set_fs(KERNEL_DS);
+       err = clock_nanosleep_restart(restart);
+       set_fs(oldfs);
+
+       if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
+           put_compat_timespec(&tu, rmtp))
+               return -EFAULT;
+
+       if (err == -ERESTART_RESTARTBLOCK) {
+               restart->fn = compat_clock_nanosleep_restart;
+               restart->arg1 = (unsigned long) rmtp;
+       }
+       return err;
+}
+
 long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
                            struct compat_timespec __user *rqtp,
                            struct compat_timespec __user *rmtp)
@@ -630,6 +633,7 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
        long err;
        mm_segment_t oldfs;
        struct timespec in, out; 
+       struct restart_block *restart;
 
        if (get_compat_timespec(&in, rqtp)) 
                return -EFAULT;
@@ -640,9 +644,16 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
                                  (struct timespec __user *) &in,
                                  (struct timespec __user *) &out);
        set_fs(oldfs);
+
        if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
            put_compat_timespec(&out, rmtp))
                return -EFAULT;
+
+       if (err == -ERESTART_RESTARTBLOCK) {
+               restart = &current_thread_info()->restart_block;
+               restart->fn = compat_clock_nanosleep_restart;
+               restart->arg1 = (unsigned long) rmtp;
+       }
        return err;     
 } 
 
@@ -752,17 +763,10 @@ void
 sigset_from_compat (sigset_t *set, compat_sigset_t *compat)
 {
        switch (_NSIG_WORDS) {
-#if defined (__COMPAT_ENDIAN_SWAP__)
-       case 4: set->sig[3] = compat->sig[7] | (((long)compat->sig[6]) << 32 );
-       case 3: set->sig[2] = compat->sig[5] | (((long)compat->sig[4]) << 32 );
-       case 2: set->sig[1] = compat->sig[3] | (((long)compat->sig[2]) << 32 );
-       case 1: set->sig[0] = compat->sig[1] | (((long)compat->sig[0]) << 32 );
-#else
        case 4: set->sig[3] = compat->sig[6] | (((long)compat->sig[7]) << 32 );
        case 3: set->sig[2] = compat->sig[4] | (((long)compat->sig[5]) << 32 );
        case 2: set->sig[1] = compat->sig[2] | (((long)compat->sig[3]) << 32 );
        case 1: set->sig[0] = compat->sig[0] | (((long)compat->sig[1]) << 32 );
-#endif
        }
 }
 
@@ -957,3 +961,25 @@ asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp)
 
        return ret;
 }
+
+#ifdef CONFIG_NUMA
+asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_pages,
+               compat_uptr_t __user *pages32,
+               const int __user *nodes,
+               int __user *status,
+               int flags)
+{
+       const void __user * __user *pages;
+       int i;
+
+       pages = compat_alloc_user_space(nr_pages * sizeof(void *));
+       for (i = 0; i < nr_pages; i++) {
+               compat_uptr_t p;
+
+               if (get_user(p, pages32 + i) ||
+                       put_user(compat_ptr(p), pages + i))
+                       return -EFAULT;
+       }
+       return sys_move_pages(pid, nr_pages, pages, nodes, status, flags);
+}
+#endif