aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-30 07:31:13 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:13 -0500
commit80fbb69a8d1268ef48dfe21da80e68cb01922f31 (patch)
tree6cc2d5d0fdc40eb53f74e36c5557fa24f89edce0
parent5af725026fe902bf81f1b90b1b9d9ee4b9e1eb6a (diff)
x86: introduce fill_ldt
This patch introduces fill_ldt(), which populates a ldt descriptor from a user_desc in once, instead of relying in the LDT_entry_a and LDT_entry_b macros Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/kernel/ldt.c3
-rw-r--r--arch/x86/kernel/process_64.c3
-rw-r--r--arch/x86/kernel/tls.c7
-rw-r--r--include/asm-x86/desc.h29
-rw-r--r--include/asm-x86/desc_32.h15
-rw-r--r--include/asm-x86/desc_64.h17
6 files changed, 34 insertions, 40 deletions
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 7eb0c8a45734..3e872b468533 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -223,8 +223,7 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
223 } 223 }
224 } 224 }
225 225
226 ldt.a = LDT_entry_a(&ldt_info); 226 fill_ldt(&ldt, &ldt_info);
227 ldt.b = LDT_entry_b(&ldt_info);
228 if (oldmode) 227 if (oldmode)
229 ldt.avl = 0; 228 ldt.avl = 0;
230 229
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 86c310acc989..f91521e26335 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -457,8 +457,7 @@ static inline void set_32bit_tls(struct task_struct *t, int tls, u32 addr)
457 }; 457 };
458 struct desc_struct *desc = (void *)t->thread.tls_array; 458 struct desc_struct *desc = (void *)t->thread.tls_array;
459 desc += tls; 459 desc += tls;
460 desc->a = LDT_entry_a(&ud); 460 fill_ldt(desc, &ud);
461 desc->b = LDT_entry_b(&ud);
462} 461}
463 462
464static inline u32 read_32bit_tls(struct task_struct *t, int tls) 463static inline u32 read_32bit_tls(struct task_struct *t, int tls)
diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 67a377621b12..74d2b65a82eb 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -67,10 +67,9 @@ int do_set_thread_area(struct task_struct *p, int idx,
67 if (LDT_empty(&info)) { 67 if (LDT_empty(&info)) {
68 desc[0] = 0; 68 desc[0] = 0;
69 desc[1] = 0; 69 desc[1] = 0;
70 } else { 70 } else
71 desc[0] = LDT_entry_a(&info); 71 fill_ldt((struct desc_struct *)desc, &info);
72 desc[1] = LDT_entry_b(&info); 72
73 }
74 if (t == &current->thread) 73 if (t == &current->thread)
75 load_TLS(t, cpu); 74 load_TLS(t, cpu);
76 75
diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h
index 6065c5092265..47086d2d9298 100644
--- a/include/asm-x86/desc.h
+++ b/include/asm-x86/desc.h
@@ -1,5 +1,34 @@
1#ifndef _ASM_DESC_H_
2#define _ASM_DESC_H_
3
4#ifndef __ASSEMBLY__
5#include <asm/desc_defs.h>
6#include <asm/ldt.h>
7
8static inline void fill_ldt(struct desc_struct *desc, struct user_desc *info)
9{
10 desc->limit0 = info->limit & 0x0ffff;
11 desc->base0 = info->base_addr & 0x0000ffff;
12
13 desc->base1 = (info->base_addr & 0x00ff0000) >> 16;
14 desc->type = (info->read_exec_only ^ 1) << 1;
15 desc->type |= info->contents << 2;
16 desc->s = 1;
17 desc->dpl = 0x3;
18 desc->p = info->seg_not_present ^ 1;
19 desc->limit = (info->limit & 0xf0000) >> 16;
20 desc->avl = info->useable;
21 desc->d = info->seg_32bit;
22 desc->g = info->limit_in_pages;
23 desc->base2 = (info->base_addr & 0xff000000) >> 24;
24}
25
26#endif
27
1#ifdef CONFIG_X86_32 28#ifdef CONFIG_X86_32
2# include "desc_32.h" 29# include "desc_32.h"
3#else 30#else
4# include "desc_64.h" 31# include "desc_64.h"
5#endif 32#endif
33
34#endif
diff --git a/include/asm-x86/desc_32.h b/include/asm-x86/desc_32.h
index 54b2314f2ddf..03700991c5db 100644
--- a/include/asm-x86/desc_32.h
+++ b/include/asm-x86/desc_32.h
@@ -163,21 +163,6 @@ static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const vo
163 163
164#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr) 164#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
165 165
166#define LDT_entry_a(info) \
167 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
168
169#define LDT_entry_b(info) \
170 (((info)->base_addr & 0xff000000) | \
171 (((info)->base_addr & 0x00ff0000) >> 16) | \
172 ((info)->limit & 0xf0000) | \
173 (((info)->read_exec_only ^ 1) << 9) | \
174 ((info)->contents << 10) | \
175 (((info)->seg_not_present ^ 1) << 15) | \
176 ((info)->seg_32bit << 22) | \
177 ((info)->limit_in_pages << 23) | \
178 ((info)->useable << 20) | \
179 0x7000)
180
181#define LDT_empty(info) (\ 166#define LDT_empty(info) (\
182 (info)->base_addr == 0 && \ 167 (info)->base_addr == 0 && \
183 (info)->limit == 0 && \ 168 (info)->limit == 0 && \
diff --git a/include/asm-x86/desc_64.h b/include/asm-x86/desc_64.h
index c49f928ed8b6..ba7fb87d10f3 100644
--- a/include/asm-x86/desc_64.h
+++ b/include/asm-x86/desc_64.h
@@ -147,23 +147,6 @@ static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
147 (unsigned long)addr, DESC_LDT, size * 8 - 1); 147 (unsigned long)addr, DESC_LDT, size * 8 - 1);
148} 148}
149 149
150#define LDT_entry_a(info) \
151 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
152/* Don't allow setting of the lm bit. It is useless anyways because
153 64bit system calls require __USER_CS. */
154#define LDT_entry_b(info) \
155 (((info)->base_addr & 0xff000000) | \
156 (((info)->base_addr & 0x00ff0000) >> 16) | \
157 ((info)->limit & 0xf0000) | \
158 (((info)->read_exec_only ^ 1) << 9) | \
159 ((info)->contents << 10) | \
160 (((info)->seg_not_present ^ 1) << 15) | \
161 ((info)->seg_32bit << 22) | \
162 ((info)->limit_in_pages << 23) | \
163 ((info)->useable << 20) | \
164 /* ((info)->lm << 21) | */ \
165 0x7000)
166
167#define LDT_empty(info) (\ 150#define LDT_empty(info) (\
168 (info)->base_addr == 0 && \ 151 (info)->base_addr == 0 && \
169 (info)->limit == 0 && \ 152 (info)->limit == 0 && \