Commit 92ff2ecd authored by Jes Sorensen's avatar Jes Sorensen Committed by Tony Luck

[IA64] sem2mutex: arch/ia64/ia32/sys_ia32.c

Migrate arch/ia64/ia32/sys_ia32 to using a mutex for mmap protection.
Signed-off-by: default avatarJes Sorensen <jes@sgi.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent 4b16bfbf
...@@ -52,9 +52,9 @@ ...@@ -52,9 +52,9 @@
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/mutex.h>
#include <asm/intrinsics.h> #include <asm/intrinsics.h>
#include <asm/semaphore.h>
#include <asm/types.h> #include <asm/types.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/unistd.h> #include <asm/unistd.h>
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
* while doing so. * while doing so.
*/ */
/* XXX make per-mm: */ /* XXX make per-mm: */
static DECLARE_MUTEX(ia32_mmap_sem); static DEFINE_MUTEX(ia32_mmap_mutex);
asmlinkage long asmlinkage long
sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __user *envp, sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __user *envp,
...@@ -895,11 +895,11 @@ ia32_do_mmap (struct file *file, unsigned long addr, unsigned long len, int prot ...@@ -895,11 +895,11 @@ ia32_do_mmap (struct file *file, unsigned long addr, unsigned long len, int prot
prot = get_prot32(prot); prot = get_prot32(prot);
#if PAGE_SHIFT > IA32_PAGE_SHIFT #if PAGE_SHIFT > IA32_PAGE_SHIFT
down(&ia32_mmap_sem); mutex_lock(&ia32_mmap_mutex);
{ {
addr = emulate_mmap(file, addr, len, prot, flags, offset); addr = emulate_mmap(file, addr, len, prot, flags, offset);
} }
up(&ia32_mmap_sem); mutex_unlock(&ia32_mmap_mutex);
#else #else
down_write(&current->mm->mmap_sem); down_write(&current->mm->mmap_sem);
{ {
...@@ -1000,11 +1000,9 @@ sys32_munmap (unsigned int start, unsigned int len) ...@@ -1000,11 +1000,9 @@ sys32_munmap (unsigned int start, unsigned int len)
if (start >= end) if (start >= end)
return 0; return 0;
down(&ia32_mmap_sem); mutex_lock(&ia32_mmap_mutex);
{ ret = sys_munmap(start, end - start);
ret = sys_munmap(start, end - start); mutex_unlock(&ia32_mmap_mutex);
}
up(&ia32_mmap_sem);
#endif #endif
return ret; return ret;
} }
...@@ -1056,7 +1054,7 @@ sys32_mprotect (unsigned int start, unsigned int len, int prot) ...@@ -1056,7 +1054,7 @@ sys32_mprotect (unsigned int start, unsigned int len, int prot)
if (retval < 0) if (retval < 0)
return retval; return retval;
down(&ia32_mmap_sem); mutex_lock(&ia32_mmap_mutex);
{ {
if (offset_in_page(start)) { if (offset_in_page(start)) {
/* start address is 4KB aligned but not page aligned. */ /* start address is 4KB aligned but not page aligned. */
...@@ -1080,7 +1078,7 @@ sys32_mprotect (unsigned int start, unsigned int len, int prot) ...@@ -1080,7 +1078,7 @@ sys32_mprotect (unsigned int start, unsigned int len, int prot)
retval = sys_mprotect(start, end - start, prot); retval = sys_mprotect(start, end - start, prot);
} }
out: out:
up(&ia32_mmap_sem); mutex_unlock(&ia32_mmap_mutex);
return retval; return retval;
#endif #endif
} }
...@@ -1124,11 +1122,9 @@ sys32_mremap (unsigned int addr, unsigned int old_len, unsigned int new_len, ...@@ -1124,11 +1122,9 @@ sys32_mremap (unsigned int addr, unsigned int old_len, unsigned int new_len,
old_len = PAGE_ALIGN(old_end) - addr; old_len = PAGE_ALIGN(old_end) - addr;
new_len = PAGE_ALIGN(new_end) - addr; new_len = PAGE_ALIGN(new_end) - addr;
down(&ia32_mmap_sem); mutex_lock(&ia32_mmap_mutex);
{ ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
ret = sys_mremap(addr, old_len, new_len, flags, new_addr); mutex_unlock(&ia32_mmap_mutex);
}
up(&ia32_mmap_sem);
if ((ret >= 0) && (old_len < new_len)) { if ((ret >= 0) && (old_len < new_len)) {
/* mremap expanded successfully */ /* mremap expanded successfully */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment