Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
[sfrench/cifs-2.6.git] / arch / ia64 / ia32 / sys_ia32.c
index 5ea38286d8d5856dc5005a4f159295c834322f9c..70dba1f0e2ee916a7cd032080c96b69e0896ff04 100644 (file)
 #include <linux/ptrace.h>
 #include <linux/stat.h>
 #include <linux/ipc.h>
+#include <linux/capability.h>
 #include <linux/compat.h>
 #include <linux/vfs.h>
 #include <linux/mman.h>
+#include <linux/mutex.h>
 
 #include <asm/intrinsics.h>
-#include <asm/semaphore.h>
 #include <asm/types.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -85,7 +86,7 @@
  * while doing so.
  */
 /* XXX make per-mm: */
-static DECLARE_MUTEX(ia32_mmap_sem);
+static DEFINE_MUTEX(ia32_mmap_mutex);
 
 asmlinkage long
 sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __user *envp,
@@ -894,11 +895,11 @@ ia32_do_mmap (struct file *file, unsigned long addr, unsigned long len, int prot
        prot = get_prot32(prot);
 
 #if PAGE_SHIFT > IA32_PAGE_SHIFT
-       down(&ia32_mmap_sem);
+       mutex_lock(&ia32_mmap_mutex);
        {
                addr = emulate_mmap(file, addr, len, prot, flags, offset);
        }
-       up(&ia32_mmap_sem);
+       mutex_unlock(&ia32_mmap_mutex);
 #else
        down_write(&current->mm->mmap_sem);
        {
@@ -999,11 +1000,9 @@ sys32_munmap (unsigned int start, unsigned int len)
        if (start >= end)
                return 0;
 
-       down(&ia32_mmap_sem);
-       {
-               ret = sys_munmap(start, end - start);
-       }
-       up(&ia32_mmap_sem);
+       mutex_lock(&ia32_mmap_mutex);
+       ret = sys_munmap(start, end - start);
+       mutex_unlock(&ia32_mmap_mutex);
 #endif
        return ret;
 }
@@ -1055,7 +1054,7 @@ sys32_mprotect (unsigned int start, unsigned int len, int prot)
        if (retval < 0)
                return retval;
 
-       down(&ia32_mmap_sem);
+       mutex_lock(&ia32_mmap_mutex);
        {
                if (offset_in_page(start)) {
                        /* start address is 4KB aligned but not page aligned. */
@@ -1079,7 +1078,7 @@ sys32_mprotect (unsigned int start, unsigned int len, int prot)
                retval = sys_mprotect(start, end - start, prot);
        }
   out:
-       up(&ia32_mmap_sem);
+       mutex_unlock(&ia32_mmap_mutex);
        return retval;
 #endif
 }
@@ -1123,11 +1122,9 @@ sys32_mremap (unsigned int addr, unsigned int old_len, unsigned int new_len,
        old_len = PAGE_ALIGN(old_end) - addr;
        new_len = PAGE_ALIGN(new_end) - addr;
 
-       down(&ia32_mmap_sem);
-       {
-               ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
-       }
-       up(&ia32_mmap_sem);
+       mutex_lock(&ia32_mmap_mutex);
+       ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
+       mutex_unlock(&ia32_mmap_mutex);
 
        if ((ret >= 0) && (old_len < new_len)) {
                /* mremap expanded successfully */
@@ -1481,7 +1478,7 @@ getreg (struct task_struct *child, int regno)
 {
        struct pt_regs *child_regs;
 
-       child_regs = ia64_task_regs(child);
+       child_regs = task_pt_regs(child);
        switch (regno / sizeof(int)) {
              case PT_EBX: return child_regs->r11;
              case PT_ECX: return child_regs->r9;
@@ -1509,7 +1506,7 @@ putreg (struct task_struct *child, int regno, unsigned int value)
 {
        struct pt_regs *child_regs;
 
-       child_regs = ia64_task_regs(child);
+       child_regs = task_pt_regs(child);
        switch (regno / sizeof(int)) {
              case PT_EBX: child_regs->r11 = value; break;
              case PT_ECX: child_regs->r9 = value; break;
@@ -1625,7 +1622,7 @@ save_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __user
         *  Stack frames start with 16-bytes of temp space
         */
        swp = (struct switch_stack *)(tsk->thread.ksp + 16);
-       ptp = ia64_task_regs(tsk);
+       ptp = task_pt_regs(tsk);
        tos = (tsk->thread.fsr >> 11) & 7;
        for (i = 0; i < 8; i++)
                put_fpreg(i, &save->st_space[i], ptp, swp, tos);
@@ -1658,7 +1655,7 @@ restore_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __us
         *  Stack frames start with 16-bytes of temp space
         */
        swp = (struct switch_stack *)(tsk->thread.ksp + 16);
-       ptp = ia64_task_regs(tsk);
+       ptp = task_pt_regs(tsk);
        tos = (tsk->thread.fsr >> 11) & 7;
        for (i = 0; i < 8; i++)
                get_fpreg(i, &save->st_space[i], ptp, swp, tos);
@@ -1689,7 +1686,7 @@ save_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __user
          *  Stack frames start with 16-bytes of temp space
          */
         swp = (struct switch_stack *)(tsk->thread.ksp + 16);
-        ptp = ia64_task_regs(tsk);
+        ptp = task_pt_regs(tsk);
        tos = (tsk->thread.fsr >> 11) & 7;
         for (i = 0; i < 8; i++)
                put_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
@@ -1733,7 +1730,7 @@ restore_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __u
         *  Stack frames start with 16-bytes of temp space
         */
        swp = (struct switch_stack *)(tsk->thread.ksp + 16);
-       ptp = ia64_task_regs(tsk);
+       ptp = task_pt_regs(tsk);
        tos = (tsk->thread.fsr >> 11) & 7;
        for (i = 0; i < 8; i++)
        get_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);