aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/desc.h
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-30 07:31:20 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:20 -0500
commitf6e0eba1b133192e298052d616e9e17356d32517 (patch)
tree190b1c2085af0194bd160983fba5164f6cc6f1ac /include/asm-x86/desc.h
parent2215e69d2cf5024647f9a034807990590d25dd4e (diff)
x86: avoid ifdefs in desc.h, getting rid of pack_ldt and pack_tss
By Andi Kleen's suggestion, this patch removes pack_ldt() and pack_tss() wrappers in favour of a general wrapper. It saves us an ifdef and some lines of code, but more importantly, it's more elegant. No functional change is made, although the object code is expected to be different. 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.h')
-rw-r--r--include/asm-x86/desc.h58
1 files changed, 18 insertions, 40 deletions
diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h
index c31715cf221..e9356a85202 100644
--- a/include/asm-x86/desc.h
+++ b/include/asm-x86/desc.h
@@ -125,21 +125,6 @@ static inline void native_write_gdt_entry(struct desc_struct *gdt, int entry,
125 memcpy(&gdt[entry], desc, size); 125 memcpy(&gdt[entry], desc, size);
126} 126}
127 127
128static inline void set_tssldt_descriptor(struct ldttss_desc64 *d,
129 unsigned long tss, unsigned type,
130 unsigned size)
131{
132 memset(d, 0, sizeof(*d));
133 d->limit0 = size & 0xFFFF;
134 d->base0 = PTR_LOW(tss);
135 d->base1 = PTR_MIDDLE(tss) & 0xFF;
136 d->type = type;
137 d->p = 1;
138 d->limit1 = (size >> 16) & 0xF;
139 d->base2 = (PTR_MIDDLE(tss) >> 8) & 0xFF;
140 d->base3 = PTR_HIGH(tss);
141}
142
143static inline void pack_descriptor(struct desc_struct *desc, unsigned long base, 128static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
144 unsigned long limit, unsigned char type, 129 unsigned long limit, unsigned char type,
145 unsigned char flags) 130 unsigned char flags)
@@ -151,30 +136,24 @@ static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
151 desc->p = 1; 136 desc->p = 1;
152} 137}
153 138
154static inline void pack_ldt(ldt_desc *ldt, unsigned long addr,
155 unsigned size)
156{
157 139
158#ifdef CONFIG_X86_64 140static inline void set_tssldt_descriptor(void *d, unsigned long addr,
159 set_tssldt_descriptor(ldt, 141 unsigned type, unsigned size)
160 addr, DESC_LDT, size);
161#else
162 pack_descriptor(ldt, (unsigned long)addr,
163 size,
164 0x80 | DESC_LDT, 0);
165#endif
166}
167
168static inline void pack_tss(tss_desc *tss, unsigned long addr,
169 unsigned size, unsigned entry)
170{ 142{
171#ifdef CONFIG_X86_64 143#ifdef CONFIG_X86_64
172 set_tssldt_descriptor(tss, 144 struct ldttss_desc64 *desc = d;
173 addr, entry, size); 145 memset(desc, 0, sizeof(*desc));
146 desc->limit0 = size & 0xFFFF;
147 desc->base0 = PTR_LOW(addr);
148 desc->base1 = PTR_MIDDLE(addr) & 0xFF;
149 desc->type = type;
150 desc->p = 1;
151 desc->limit1 = (size >> 16) & 0xF;
152 desc->base2 = (PTR_MIDDLE(addr) >> 8) & 0xFF;
153 desc->base3 = PTR_HIGH(addr);
174#else 154#else
175 pack_descriptor(tss, (unsigned long)addr, 155
176 size, 156 pack_descriptor((struct desc_struct *)d, addr, size, 0x80 | type, 0);
177 0x80 | entry, 0);
178#endif 157#endif
179} 158}
180 159
@@ -190,9 +169,8 @@ static inline void __set_tss_desc(unsigned cpu, unsigned int entry, void *addr)
190 * -1? seg base+limit should be pointing to the address of the 169 * -1? seg base+limit should be pointing to the address of the
191 * last valid byte 170 * last valid byte
192 */ 171 */
193 pack_tss(&tss, (unsigned long)addr, 172 set_tssldt_descriptor(&tss, (unsigned long)addr, DESC_TSS,
194 IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1, 173 IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
195 DESC_TSS);
196 write_gdt_entry(d, entry, &tss, DESC_TSS); 174 write_gdt_entry(d, entry, &tss, DESC_TSS);
197} 175}
198 176
@@ -206,8 +184,8 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
206 unsigned cpu = smp_processor_id(); 184 unsigned cpu = smp_processor_id();
207 ldt_desc ldt; 185 ldt_desc ldt;
208 186
209 pack_ldt(&ldt, (unsigned long)addr, 187 set_tssldt_descriptor(&ldt, (unsigned long)addr,
210 entries * sizeof(ldt) - 1); 188 DESC_LDT, entries * sizeof(ldt) - 1);
211 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, 189 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT,
212 &ldt, DESC_LDT); 190 &ldt, DESC_LDT);
213 __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8)); 191 __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));