* [PATCH 18/21] i386 Ldt cleanups 2
@ 2005-11-08 4:38 Zachary Amsden
0 siblings, 0 replies; only message in thread
From: Zachary Amsden @ 2005-11-08 4:38 UTC (permalink / raw)
To: Andrew Morton, Chris Wright, Linus Torvalds,
Linux Kernel Mailing List, Virtualization Mailing List,
H. Peter Anvin, Zwane Mwaikambo, Martin Bligh,
Pratap Subrahmanyam, Christopher Li, Eric W. Biederman,
Ingo Molnar, Zachary Amsden, Zachary Amsden
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@vmware.com>
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))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-11-08 4:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-08 4:38 [PATCH 18/21] i386 Ldt cleanups 2 Zachary Amsden
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®