vserver 1.9.5.x5
[linux-2.6.git] / arch / ppc64 / kernel / sys_ppc32.c
index b518b9a..979f79d 100644 (file)
@@ -60,7 +60,6 @@
 #include <linux/ptrace.h>
 #include <linux/aio_abi.h>
 #include <linux/elf.h>
-#include <linux/vs_cvirt.h>
 
 #include <net/scm.h>
 #include <net/sock.h>
@@ -73,8 +72,8 @@
 #include <asm/semaphore.h>
 #include <asm/ppcdebug.h>
 #include <asm/time.h>
-#include <asm/ppc32.h>
 #include <asm/mmu_context.h>
+#include <asm/systemcfg.h>
 
 #include "pci.h"
 
@@ -493,6 +492,7 @@ asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv, struct time
        return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
 }
 
+#ifdef CONFIG_SYSVIPC
 long sys32_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr,
               u32 fifth)
 {
@@ -557,6 +557,7 @@ long sys32_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr,
 
        return -ENOSYS;
 }
+#endif
 
 /* Note: it is necessary to treat out_fd and in_fd as unsigned ints, 
  * with the corresponding cast to a signed int to insure that the 
@@ -618,17 +619,16 @@ long sys32_execve(unsigned long a0, unsigned long a1, unsigned long a2,
        error = PTR_ERR(filename);
        if (IS_ERR(filename))
                goto out;
-       if (regs->msr & MSR_FP)
-               giveup_fpu(current);
-#ifdef CONFIG_ALTIVEC
-       if (regs->msr & MSR_VEC)
-               giveup_altivec(current);
-#endif /* CONFIG_ALTIVEC */
+       flush_fp_to_thread(current);
+       flush_altivec_to_thread(current);
 
        error = compat_do_execve(filename, compat_ptr(a1), compat_ptr(a2), regs);
 
-       if (error == 0)
+       if (error == 0) {
+               task_lock(current);
                current->ptrace &= ~PT_DTRACE;
+               task_unlock(current);
+       }
        putname(filename);
 
 out:
@@ -639,8 +639,24 @@ out:
 void start_thread32(struct pt_regs* regs, unsigned long nip, unsigned long sp)
 {
        set_fs(USER_DS);
-       memset(regs->gpr, 0, sizeof(regs->gpr));
-       memset(&regs->ctr, 0, 4 * sizeof(regs->ctr));
+
+       /*
+        * If we exec out of a kernel thread then thread.regs will not be
+        * set. Do it now.
+        */
+       if (!current->thread.regs) {
+               unsigned long childregs = (unsigned long)current->thread_info +
+                                               THREAD_SIZE;
+               childregs -= sizeof(struct pt_regs);
+               current->thread.regs = (struct pt_regs *)childregs;
+       }
+
+       /*
+        * ELF_PLAT_INIT already clears all registers but it also sets r2.
+        * So just clear r2 here.
+        */
+       regs->gpr[2] = 0;
+
        regs->nip = nip;
        regs->gpr[1] = sp;
        regs->msr = MSR_USER32;
@@ -705,7 +721,7 @@ asmlinkage int sys32_pciconfig_read(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf
                                  (unsigned long) dfn,
                                  (unsigned long) off,
                                  (unsigned long) len,
-                                 (unsigned char __user *)AA(ubuf));
+                                 compat_ptr(ubuf));
 }
 
 asmlinkage int sys32_pciconfig_write(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf)
@@ -714,7 +730,7 @@ asmlinkage int sys32_pciconfig_write(u32 bus, u32 dfn, u32 off, u32 len, u32 ubu
                                   (unsigned long) dfn,
                                   (unsigned long) off,
                                   (unsigned long) len,
-                                  (unsigned char __user *)AA(ubuf));
+                                  compat_ptr(ubuf));
 }
 
 #define IOBASE_BRIDGE_NUMBER   0
@@ -1090,6 +1106,7 @@ asmlinkage long sys32_umask(u32 mask)
        return sys_umask((int)mask);
 }
 
+#ifdef CONFIG_SYSCTL
 struct __sysctl_args32 {
        u32 name;
        int nlen;
@@ -1100,7 +1117,7 @@ struct __sysctl_args32 {
        u32 __unused[4];
 };
 
-extern asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
+asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
 {
        struct __sysctl_args32 tmp;
        int error;
@@ -1119,42 +1136,27 @@ extern asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
                   glibc's __sysctl uses rw memory for the structure
                   anyway.  */
                oldlenp = (size_t __user *)addr;
-               if (get_user(oldlen, (u32 __user *)A(tmp.oldlenp)) ||
+               if (get_user(oldlen, (compat_size_t __user *)compat_ptr(tmp.oldlenp)) ||
                    put_user(oldlen, oldlenp))
                        return -EFAULT;
        }
 
        lock_kernel();
-       error = do_sysctl((int __user *)A(tmp.name), tmp.nlen, (void __user *)A(tmp.oldval),
-                         oldlenp, (void __user *)A(tmp.newval), tmp.newlen);
+       error = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
+                         compat_ptr(tmp.oldval), oldlenp,
+                         compat_ptr(tmp.newval), tmp.newlen);
        unlock_kernel();
        if (oldlenp) {
                if (!error) {
                        if (get_user(oldlen, oldlenp) ||
-                           put_user(oldlen, (u32 __user *)A(tmp.oldlenp)))
+                           put_user(oldlen, (compat_size_t __user *)compat_ptr(tmp.oldlenp)))
                                error = -EFAULT;
                }
                copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused));
        }
        return error;
 }
-
-asmlinkage long sys32_time(compat_time_t __user * tloc)
-{
-       compat_time_t secs;
-
-       struct timeval tv;
-
-       do_gettimeofday( &tv );
-       secs = tv.tv_sec;
-
-       if (tloc) {
-               if (put_user(secs,tloc))
-                       secs = -EFAULT;
-       }
-
-       return secs;
-}
+#endif
 
 asmlinkage int sys32_olduname(struct oldold_utsname __user * name)
 {
@@ -1316,3 +1318,21 @@ long ppc32_timer_create(clockid_t clock,
 
        return err;
 }
+
+asmlinkage long sys32_add_key(const char __user *_type,
+                             const char __user *_description,
+                             const void __user *_payload,
+                             u32 plen,
+                             u32 ringid)
+{
+       return sys_add_key(_type, _description, _payload, plen, ringid);
+}
+
+asmlinkage long sys32_request_key(const char __user *_type,
+                                 const char __user *_description,
+                                 const char __user *_callout_info,
+                                 u32 destringid)
+{
+       return sys_request_key(_type, _description, _callout_info, destringid);
+}
+