x86: convert mm_context_t semaphore to a mutex
[ tglx: arch/x86 adaptation ] Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
committed by
Thomas Gleixner
parent
99741faa34
commit
c7537ab234
@@ -96,13 +96,13 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
|
|||||||
struct mm_struct * old_mm;
|
struct mm_struct * old_mm;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
init_MUTEX(&mm->context.sem);
|
mutex_init(&mm->context.lock);
|
||||||
mm->context.size = 0;
|
mm->context.size = 0;
|
||||||
old_mm = current->mm;
|
old_mm = current->mm;
|
||||||
if (old_mm && old_mm->context.size > 0) {
|
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);
|
retval = copy_ldt(&mm->context, &old_mm->context);
|
||||||
up(&old_mm->context.sem);
|
mutex_unlock(&old_mm->context.lock);
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
|
|||||||
if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
|
if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
|
||||||
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;
|
size = mm->context.size*LDT_ENTRY_SIZE;
|
||||||
if (size > bytecount)
|
if (size > bytecount)
|
||||||
size = bytecount;
|
size = bytecount;
|
||||||
@@ -141,7 +141,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
|
|||||||
err = 0;
|
err = 0;
|
||||||
if (copy_to_user(ptr, mm->context.ldt, size))
|
if (copy_to_user(ptr, mm->context.ldt, size))
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
up(&mm->context.sem);
|
mutex_unlock(&mm->context.lock);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error_return;
|
goto error_return;
|
||||||
if (size != bytecount) {
|
if (size != bytecount) {
|
||||||
@@ -193,7 +193,7 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
down(&mm->context.sem);
|
mutex_lock(&mm->context.lock);
|
||||||
if (ldt_info.entry_number >= (unsigned)mm->context.size) {
|
if (ldt_info.entry_number >= (unsigned)mm->context.size) {
|
||||||
error = alloc_ldt(¤t->mm->context, ldt_info.entry_number+1, 1);
|
error = alloc_ldt(¤t->mm->context, ldt_info.entry_number+1, 1);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
@@ -223,7 +223,7 @@ install:
|
|||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
out_unlock:
|
out_unlock:
|
||||||
up(&mm->context.sem);
|
mutex_unlock(&mm->context.lock);
|
||||||
out:
|
out:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@@ -103,7 +103,7 @@ unsigned long convert_rip_to_linear(struct task_struct *child, struct pt_regs *r
|
|||||||
|
|
||||||
seg &= ~7UL;
|
seg &= ~7UL;
|
||||||
|
|
||||||
down(&child->mm->context.sem);
|
mutex_lock(&child->mm->context.lock);
|
||||||
if (unlikely((seg >> 3) >= child->mm->context.size))
|
if (unlikely((seg >> 3) >= child->mm->context.size))
|
||||||
addr = -1L; /* bogus selector, access would fault */
|
addr = -1L; /* bogus selector, access would fault */
|
||||||
else {
|
else {
|
||||||
@@ -117,7 +117,7 @@ unsigned long convert_rip_to_linear(struct task_struct *child, struct pt_regs *r
|
|||||||
addr &= 0xffff;
|
addr &= 0xffff;
|
||||||
addr += base;
|
addr += base;
|
||||||
}
|
}
|
||||||
up(&child->mm->context.sem);
|
mutex_unlock(&child->mm->context.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return addr;
|
return addr;
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#define __x86_64_MMU_H
|
#define __x86_64_MMU_H
|
||||||
|
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <asm/semaphore.h>
|
#include <linux/mutex.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The x86_64 doesn't have a mmu context, but
|
* The x86_64 doesn't have a mmu context, but
|
||||||
@@ -14,7 +14,7 @@ typedef struct {
|
|||||||
void *ldt;
|
void *ldt;
|
||||||
rwlock_t ldtlock;
|
rwlock_t ldtlock;
|
||||||
int size;
|
int size;
|
||||||
struct semaphore sem;
|
struct mutex lock;
|
||||||
void *vdso;
|
void *vdso;
|
||||||
} mm_context_t;
|
} mm_context_t;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user