aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLuiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>2007-10-17 12:04:41 -0400
committerThomas Gleixner <tglx@inhelltoy.tec.linutronix.de>2007-10-17 14:17:05 -0400
commitde8aacbe6a3f3dd7104da09a5535232cd385fdd6 (patch)
tree89c6dc0070ab30b4e6ecaa6269bfd54320a400c7 /arch
parent32c464f5d9701db45bc1673288594e664065388e (diff)
x86: convert mm_context_t semaphore to a mutex
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/i386_ksyms_32.c1
-rw-r--r--arch/x86/kernel/ldt_32.c14
-rw-r--r--arch/x86/kernel/ptrace_32.c4
-rw-r--r--arch/x86/mm/fault_32.c4
4 files changed, 12 insertions, 11 deletions
diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
index e3d4b73bfdb0..edd39ccf139e 100644
--- a/arch/x86/kernel/i386_ksyms_32.c
+++ b/arch/x86/kernel/i386_ksyms_32.c
@@ -1,4 +1,5 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <asm/semaphore.h>
2#include <asm/checksum.h> 3#include <asm/checksum.h>
3#include <asm/desc.h> 4#include <asm/desc.h>
4 5
diff --git a/arch/x86/kernel/ldt_32.c b/arch/x86/kernel/ldt_32.c
index a8b18421863a..9ff90a27c45f 100644
--- a/arch/x86/kernel/ldt_32.c
+++ b/arch/x86/kernel/ldt_32.c
@@ -92,13 +92,13 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
92 struct mm_struct * old_mm; 92 struct mm_struct * old_mm;
93 int retval = 0; 93 int retval = 0;
94 94
95 init_MUTEX(&mm->context.sem); 95 mutex_init(&mm->context.lock);
96 mm->context.size = 0; 96 mm->context.size = 0;
97 old_mm = current->mm; 97 old_mm = current->mm;
98 if (old_mm && old_mm->context.size > 0) { 98 if (old_mm && old_mm->context.size > 0) {
99 down(&old_mm->context.sem); 99 mutex_lock(&old_mm->context.lock);
100 retval = copy_ldt(&mm->context, &old_mm->context); 100 retval = copy_ldt(&mm->context, &old_mm->context);
101 up(&old_mm->context.sem); 101 mutex_unlock(&old_mm->context.lock);
102 } 102 }
103 return retval; 103 return retval;
104} 104}
@@ -130,7 +130,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
130 if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES) 130 if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
131 bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES; 131 bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES;
132 132
133 down(&mm->context.sem); 133 mutex_lock(&mm->context.lock);
134 size = mm->context.size*LDT_ENTRY_SIZE; 134 size = mm->context.size*LDT_ENTRY_SIZE;
135 if (size > bytecount) 135 if (size > bytecount)
136 size = bytecount; 136 size = bytecount;
@@ -138,7 +138,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
138 err = 0; 138 err = 0;
139 if (copy_to_user(ptr, mm->context.ldt, size)) 139 if (copy_to_user(ptr, mm->context.ldt, size))
140 err = -EFAULT; 140 err = -EFAULT;
141 up(&mm->context.sem); 141 mutex_unlock(&mm->context.lock);
142 if (err < 0) 142 if (err < 0)
143 goto error_return; 143 goto error_return;
144 if (size != bytecount) { 144 if (size != bytecount) {
@@ -194,7 +194,7 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
194 goto out; 194 goto out;
195 } 195 }
196 196
197 down(&mm->context.sem); 197 mutex_lock(&mm->context.lock);
198 if (ldt_info.entry_number >= mm->context.size) { 198 if (ldt_info.entry_number >= mm->context.size) {
199 error = alloc_ldt(&current->mm->context, ldt_info.entry_number+1, 1); 199 error = alloc_ldt(&current->mm->context, ldt_info.entry_number+1, 1);
200 if (error < 0) 200 if (error < 0)
@@ -221,7 +221,7 @@ install:
221 error = 0; 221 error = 0;
222 222
223out_unlock: 223out_unlock:
224 up(&mm->context.sem); 224 mutex_unlock(&mm->context.lock);
225out: 225out:
226 return error; 226 return error;
227} 227}
diff --git a/arch/x86/kernel/ptrace_32.c b/arch/x86/kernel/ptrace_32.c
index 8622b9cd3e38..99102ec5fade 100644
--- a/arch/x86/kernel/ptrace_32.c
+++ b/arch/x86/kernel/ptrace_32.c
@@ -165,7 +165,7 @@ static unsigned long convert_eip_to_linear(struct task_struct *child, struct pt_
165 165
166 seg &= ~7UL; 166 seg &= ~7UL;
167 167
168 down(&child->mm->context.sem); 168 mutex_lock(&child->mm->context.lock);
169 if (unlikely((seg >> 3) >= child->mm->context.size)) 169 if (unlikely((seg >> 3) >= child->mm->context.size))
170 addr = -1L; /* bogus selector, access would fault */ 170 addr = -1L; /* bogus selector, access would fault */
171 else { 171 else {
@@ -179,7 +179,7 @@ static unsigned long convert_eip_to_linear(struct task_struct *child, struct pt_
179 addr &= 0xffff; 179 addr &= 0xffff;
180 addr += base; 180 addr += base;
181 } 181 }
182 up(&child->mm->context.sem); 182 mutex_unlock(&child->mm->context.lock);
183 } 183 }
184 return addr; 184 return addr;
185} 185}
diff --git a/arch/x86/mm/fault_32.c b/arch/x86/mm/fault_32.c
index d84314ce22bb..6555c3d14371 100644
--- a/arch/x86/mm/fault_32.c
+++ b/arch/x86/mm/fault_32.c
@@ -105,7 +105,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
105 LDT and other horrors are only used in user space. */ 105 LDT and other horrors are only used in user space. */
106 if (seg & (1<<2)) { 106 if (seg & (1<<2)) {
107 /* Must lock the LDT while reading it. */ 107 /* Must lock the LDT while reading it. */
108 down(&current->mm->context.sem); 108 mutex_lock(&current->mm->context.lock);
109 desc = current->mm->context.ldt; 109 desc = current->mm->context.ldt;
110 desc = (void *)desc + (seg & ~7); 110 desc = (void *)desc + (seg & ~7);
111 } else { 111 } else {
@@ -118,7 +118,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
118 base = get_desc_base((unsigned long *)desc); 118 base = get_desc_base((unsigned long *)desc);
119 119
120 if (seg & (1<<2)) { 120 if (seg & (1<<2)) {
121 up(&current->mm->context.sem); 121 mutex_unlock(&current->mm->context.lock);
122 } else 122 } else
123 put_cpu(); 123 put_cpu();
124 124