diff options
author | Glauber de Oliveira Costa <gcosta@redhat.com> | 2008-01-30 07:31:14 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:31:14 -0500 |
commit | 881c2975d02b6575c417a6eee40868d60a9ecba9 (patch) | |
tree | 402785bef46e3051aca5d006eaddbf0b99aff502 /include/asm-x86/desc_64.h | |
parent | 59fbed775aa5a6f352bfbde6b40508b541086b7e (diff) |
x86: unify non-paravirt parts of desc.h
This patch unifies the non-paravirt part of desc_{32,64}.h into
desc.h. Most of it, is simply common code, that is moved to
the shared header. The only exception is the set_ldt_desc in desc_64.h,
which is changed - included its name - to accomodate for the way
the ldt is set up in i386.
Also, constant definitions used in desc_32.h are moved to desc_defs.h
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>
Diffstat (limited to 'include/asm-x86/desc_64.h')
-rw-r--r-- | include/asm-x86/desc_64.h | 55 |
1 files changed, 10 insertions, 45 deletions
diff --git a/include/asm-x86/desc_64.h b/include/asm-x86/desc_64.h index 7cdd3f0420fd..c037c7d55b92 100644 --- a/include/asm-x86/desc_64.h +++ b/include/asm-x86/desc_64.h | |||
@@ -9,16 +9,13 @@ | |||
9 | 9 | ||
10 | #include <linux/string.h> | 10 | #include <linux/string.h> |
11 | #include <linux/smp.h> | 11 | #include <linux/smp.h> |
12 | #include <asm/desc_defs.h> | ||
13 | 12 | ||
14 | #include <asm/segment.h> | 13 | #include <asm/segment.h> |
15 | #include <asm/mmu.h> | ||
16 | 14 | ||
17 | extern struct desc_struct cpu_gdt_table[GDT_ENTRIES]; | 15 | extern struct desc_struct cpu_gdt_table[GDT_ENTRIES]; |
18 | 16 | ||
19 | #define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8)) | 17 | #define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8)) |
20 | #define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8)) | 18 | #define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8)) |
21 | #define clear_LDT() asm volatile("lldt %w0"::"r" (0)) | ||
22 | 19 | ||
23 | static inline unsigned long __store_tr(void) | 20 | static inline unsigned long __store_tr(void) |
24 | { | 21 | { |
@@ -30,7 +27,6 @@ static inline unsigned long __store_tr(void) | |||
30 | 27 | ||
31 | #define store_tr(tr) (tr) = __store_tr() | 28 | #define store_tr(tr) (tr) = __store_tr() |
32 | 29 | ||
33 | extern gate_desc idt_table[]; | ||
34 | extern struct desc_ptr cpu_gdt_descr[]; | 30 | extern struct desc_ptr cpu_gdt_descr[]; |
35 | 31 | ||
36 | static inline void write_ldt_entry(struct desc_struct *ldt, | 32 | static inline void write_ldt_entry(struct desc_struct *ldt, |
@@ -138,22 +134,18 @@ static inline void set_tss_desc(unsigned cpu, void *addr) | |||
138 | IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1); | 134 | IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1); |
139 | } | 135 | } |
140 | 136 | ||
141 | static inline void set_ldt_desc(unsigned cpu, void *addr, int size) | 137 | static inline void set_ldt(void *addr, int entries) |
142 | { | 138 | { |
143 | set_tssldt_descriptor(&get_cpu_gdt_table(cpu)[GDT_ENTRY_LDT], | 139 | if (likely(entries == 0)) |
144 | (unsigned long)addr, DESC_LDT, size * 8 - 1); | 140 | __asm__ __volatile__("lldt %w0"::"q" (0)); |
145 | } | 141 | else { |
142 | unsigned cpu = smp_processor_id(); | ||
146 | 143 | ||
147 | #define LDT_empty(info) (\ | 144 | set_tssldt_descriptor(&get_cpu_gdt_table(cpu)[GDT_ENTRY_LDT], |
148 | (info)->base_addr == 0 && \ | 145 | (unsigned long)addr, DESC_LDT, entries * 8 - 1); |
149 | (info)->limit == 0 && \ | 146 | __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8)); |
150 | (info)->contents == 0 && \ | 147 | } |
151 | (info)->read_exec_only == 1 && \ | 148 | } |
152 | (info)->seg_32bit == 0 && \ | ||
153 | (info)->limit_in_pages == 0 && \ | ||
154 | (info)->seg_not_present == 1 && \ | ||
155 | (info)->useable == 0 && \ | ||
156 | (info)->lm == 0) | ||
157 | 149 | ||
158 | static inline void load_TLS(struct thread_struct *t, unsigned int cpu) | 150 | static inline void load_TLS(struct thread_struct *t, unsigned int cpu) |
159 | { | 151 | { |
@@ -164,32 +156,6 @@ static inline void load_TLS(struct thread_struct *t, unsigned int cpu) | |||
164 | gdt[i] = t->tls_array[i]; | 156 | gdt[i] = t->tls_array[i]; |
165 | } | 157 | } |
166 | 158 | ||
167 | /* | ||
168 | * load one particular LDT into the current CPU | ||
169 | */ | ||
170 | static inline void load_LDT_nolock(mm_context_t *pc, int cpu) | ||
171 | { | ||
172 | int count = pc->size; | ||
173 | |||
174 | if (likely(!count)) { | ||
175 | clear_LDT(); | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | set_ldt_desc(cpu, pc->ldt, count); | ||
180 | load_LDT_desc(); | ||
181 | } | ||
182 | |||
183 | static inline void load_LDT(mm_context_t *pc) | ||
184 | { | ||
185 | int cpu = get_cpu(); | ||
186 | |||
187 | load_LDT_nolock(pc, cpu); | ||
188 | put_cpu(); | ||
189 | } | ||
190 | |||
191 | extern struct desc_ptr idt_descr; | ||
192 | |||
193 | static inline unsigned long get_desc_base(const void *ptr) | 159 | static inline unsigned long get_desc_base(const void *ptr) |
194 | { | 160 | { |
195 | const u32 *desc = ptr; | 161 | const u32 *desc = ptr; |
@@ -199,7 +165,6 @@ static inline unsigned long get_desc_base(const void *ptr) | |||
199 | (desc[1] & 0xff000000); | 165 | (desc[1] & 0xff000000); |
200 | return base; | 166 | return base; |
201 | } | 167 | } |
202 | |||
203 | #endif /* !__ASSEMBLY__ */ | 168 | #endif /* !__ASSEMBLY__ */ |
204 | 169 | ||
205 | #endif | 170 | #endif |