x86: convert mm_context_t semaphore to a mutex
authorLuiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Wed, 17 Oct 2007 16:04:41 +0000 (18:04 +0200)
committerThomas Gleixner <tglx@inhelltoy.tec.linutronix.de>
Wed, 17 Oct 2007 18:17:05 +0000 (20:17 +0200)
convert mm_context_t semaphore to a mutex.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/i386_ksyms_32.c
arch/x86/kernel/ldt_32.c
arch/x86/kernel/ptrace_32.c
arch/x86/mm/fault_32.c
include/asm-x86/mmu_32.h

index e3d4b73bfdb0334e6cfb0ccc54a7615acd337ace..edd39ccf139e0f9586a48fb17e75f453b3b8a4ee 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/module.h>
+#include <asm/semaphore.h>
 #include <asm/checksum.h>
 #include <asm/desc.h>
 
index a8b18421863a78fa4231bcf089fcff820002ef87..9ff90a27c45f75eee7423f5caaf66a2348f4d5a8 100644 (file)
@@ -92,13 +92,13 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
        struct mm_struct * old_mm;
        int retval = 0;
 
-       init_MUTEX(&mm->context.sem);
+       mutex_init(&mm->context.lock);
        mm->context.size = 0;
        old_mm = current->mm;
        if (old_mm && old_mm->context.size > 0) {
-               down(&old_mm->context.sem);
+               mutex_lock(&old_mm->context.lock);
                retval = copy_ldt(&mm->context, &old_mm->context);
-               up(&old_mm->context.sem);
+               mutex_unlock(&old_mm->context.lock);
        }
        return retval;
 }
@@ -130,7 +130,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
        if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
                bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES;
 
-       down(&mm->context.sem);
+       mutex_lock(&mm->context.lock);
        size = mm->context.size*LDT_ENTRY_SIZE;
        if (size > bytecount)
                size = bytecount;
@@ -138,7 +138,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
        err = 0;
        if (copy_to_user(ptr, mm->context.ldt, size))
                err = -EFAULT;
-       up(&mm->context.sem);
+       mutex_unlock(&mm->context.lock);
        if (err < 0)
                goto error_return;
        if (size != bytecount) {
@@ -194,7 +194,7 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
                        goto out;
        }
 
-       down(&mm->context.sem);
+       mutex_lock(&mm->context.lock);
        if (ldt_info.entry_number >= mm->context.size) {
                error = alloc_ldt(&current->mm->context, ldt_info.entry_number+1, 1);
                if (error < 0)
@@ -221,7 +221,7 @@ install:
        error = 0;
 
 out_unlock:
-       up(&mm->context.sem);
+       mutex_unlock(&mm->context.lock);
 out:
        return error;
 }
index 8622b9cd3e383eb259ec4101dac98464dc1bd9ce..99102ec5fade9dc79ff01fde4469ef10a39cff33 100644 (file)
@@ -165,7 +165,7 @@ static unsigned long convert_eip_to_linear(struct task_struct *child, struct pt_
 
                seg &= ~7UL;
 
-               down(&child->mm->context.sem);
+               mutex_lock(&child->mm->context.lock);
                if (unlikely((seg >> 3) >= child->mm->context.size))
                        addr = -1L; /* bogus selector, access would fault */
                else {
@@ -179,7 +179,7 @@ static unsigned long convert_eip_to_linear(struct task_struct *child, struct pt_
                                addr &= 0xffff;
                        addr += base;
                }
-               up(&child->mm->context.sem);
+               mutex_unlock(&child->mm->context.lock);
        }
        return addr;
 }
index d84314ce22bb0f7b3189b43aade379c380a2eeab..6555c3d143716c74dc97d466ffafd1baf1399f35 100644 (file)
@@ -105,7 +105,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
           LDT and other horrors are only used in user space. */
        if (seg & (1<<2)) {
                /* Must lock the LDT while reading it. */
-               down(&current->mm->context.sem);
+               mutex_lock(&current->mm->context.lock);
                desc = current->mm->context.ldt;
                desc = (void *)desc + (seg & ~7);
        } else {
@@ -118,7 +118,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
        base = get_desc_base((unsigned long *)desc);
 
        if (seg & (1<<2)) { 
-               up(&current->mm->context.sem);
+               mutex_unlock(&current->mm->context.lock);
        } else
                put_cpu();
 
index 8358dd3df7aa22c1eb5bd4637f68b47b5509cd76..5e249c51ef56bf8b28ee1ca29d05167152dab424 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __i386_MMU_H
 #define __i386_MMU_H
 
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 /*
  * The i386 doesn't have a mmu context, but
  * we put the segment information here.
@@ -10,7 +10,7 @@
  */
 typedef struct { 
        int size;
-       struct semaphore sem;
+       struct mutex lock;
        void *ldt;
        void *vdso;
 } mm_context_t;