Add an acessor function to get a pointer to an LDT descriptor. Add one for the GDT too, while we are here, and a function to tell the difference. Turns out on some GCC versions, converting to char * and back gives better code output than gdt[seg >> 3]. Lets keep that trick in the header file so the C-code can be clean. Not used yet, but soon. Signed-off-by: Zachary Amsden <zach@xxxxxxxxxx> Index: linux-2.6.14-zach-work/include/asm-i386/desc.h =================================================================== --- linux-2.6.14-zach-work.orig/include/asm-i386/desc.h 2005-11-04 18:10:53.000000000 -0800 +++ linux-2.6.14-zach-work/include/asm-i386/desc.h 2005-11-05 00:28:03.000000000 -0800 @@ -30,7 +30,24 @@ static inline struct desc_struct *get_cp { return ((struct desc_struct *)cpu_gdt_descr[cpu].address); } - + +static inline int segment_from_ldt(unsigned int segment) +{ + return segment & LDT_SEGMENT; +} + +static inline struct desc_struct *get_gdt_desc(int cpu, unsigned int segment) +{ + char *gdt = (char *)get_cpu_gdt_table(cpu); + return (struct desc_struct *)&gdt[segment & ~7]; +} + +static inline struct desc_struct *get_ldt_desc(mm_context_t *ctx, unsigned int segment) +{ + char *ldt = (char *)ctx->ldt; + return (struct desc_struct *)&ldt[segment & ~7]; +} + #define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8)) #define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8))