[PATCH 05/19] introduce gate_desc type.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Glauber de Oliveira Costa
Date: Thursday, December 13, 2007 - 6:57 am

To account for the differences in gate descriptor in i386 and x86_64
a gate_desc type is introduced.

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
---
 arch/x86/kernel/traps_32.c  |    3 ++-
 include/asm-x86/desc_32.h   |   15 ++++++++-------
 include/asm-x86/desc_64.h   |    4 ++--
 include/asm-x86/desc_defs.h |    8 +++++++-
 4 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 94c5aea..6b03d88 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -76,8 +76,8 @@ char ignore_fpu_irq = 0;
  * F0 0F bug workaround.. We have a special link segment
  * for this.
  */
-struct desc_struct idt_table[256]
-	__attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, };
+gate_desc idt_table[256]
+	__attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, };
 
 asmlinkage void divide_error(void);
 asmlinkage void debug(void);
diff --git a/include/asm-x86/desc_32.h b/include/asm-x86/desc_32.h
index bc5ca34..77f1e5a 100644
--- a/include/asm-x86/desc_32.h
+++ b/include/asm-x86/desc_32.h
@@ -3,6 +3,7 @@
 
 #include <asm/ldt.h>
 #include <asm/segment.h>
+#include <asm/desc_defs.h>
 
 #ifndef __ASSEMBLY__
 
@@ -24,7 +25,7 @@ static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
 }
 
 extern struct desc_ptr idt_descr;
-extern struct desc_struct idt_table[];
+extern gate_desc idt_table[];
 extern void set_intr_gate(unsigned int irq, void * addr);
 
 static inline void pack_descriptor(__u32 *a, __u32 *b,
@@ -35,11 +36,11 @@ static inline void pack_descriptor(__u32 *a, __u32 *b,
 		(limit & 0x000f0000) | ((type & 0xff) << 8) | ((flags & 0xf) << 20);
 }
 
-static inline void pack_gate(__u32 *a, __u32 *b,
+static inline void pack_gate(gate_desc *gate,
 	unsigned long base, unsigned short seg, unsigned char type, unsigned char flags)
 {
-	*a = (seg << 16) | (base & 0xffff);
-	*b = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff);
+	gate->a = (seg << 16) | (base & 0xffff);
+	gate->b = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff);
 }
 
 #define DESCTYPE_LDT 	0x82	/* present, system, DPL-0, LDT */
@@ -139,9 +140,9 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
 
 static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
 {
-	__u32 a, b;
-	pack_gate(&a, &b, (unsigned long)addr, seg, type, 0);
-	write_idt_entry(idt_table, gate, a, b);
+	gate_desc g;
+	pack_gate(&g, (unsigned long)addr, seg, type, 0);
+	write_idt_entry(idt_table, gate, g.a, g.b);
 }
 
 static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr)
diff --git a/include/asm-x86/desc_64.h b/include/asm-x86/desc_64.h
index 660cc84..ffc6c06 100644
--- a/include/asm-x86/desc_64.h
+++ b/include/asm-x86/desc_64.h
@@ -30,7 +30,7 @@ static inline unsigned long __store_tr(void)
 
 #define store_tr(tr) (tr) = __store_tr()
 
-extern struct gate_struct idt_table[];
+extern gate_desc idt_table[];
 extern struct desc_ptr cpu_gdt_descr[];
 
 static inline void write_ldt_entry(struct desc_struct *ldt,
@@ -58,7 +58,7 @@ static inline void store_gdt(struct desc_ptr *ptr)
 static inline void _set_gate(void *adr, unsigned type, unsigned long func,
 			     unsigned dpl, unsigned ist)
 {
-	struct gate_struct s;
+	gate_desc s;
 
 	s.offset_low = PTR_LOW(func);
 	s.segment = __KERNEL_CS;
diff --git a/include/asm-x86/desc_defs.h b/include/asm-x86/desc_defs.h
index f37b44c..05eff93 100644
--- a/include/asm-x86/desc_defs.h
+++ b/include/asm-x86/desc_defs.h
@@ -39,7 +39,7 @@ enum {
 };
 
 // 16byte gate
-struct gate_struct {
+struct gate_struct64 {
 	u16 offset_low;
 	u16 segment;
 	unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
@@ -67,6 +67,12 @@ struct ldttss_desc {
 	u32 zero1;
 } __attribute__((packed));
 
+#ifdef CONFIG_X86_64
+typedef struct gate_struct64 gate_desc;
+#else
+typedef struct desc_struct gate_desc;
+#endif
+
 struct desc_ptr {
 	unsigned short size;
 	unsigned long address;
-- 
1.5.0.6

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/19] desc_struct integration, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 1/19] unify desc_struct, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 2/19] unify struct desc_ptr, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 4/19] removed unused variable, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 5/19] introduce gate_desc type., Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 6/19] change write_idt_entry signature, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 7/19] introduce ldt_desc type., Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 8/19] modify write_ldt function, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 9/19] introduce fill_ldt, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 10/19] change write_gdt_entry signature., Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 11/19] change write_ldt_entry signature, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 12/19] move constants to desc_defs.h, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 14/19] use the same data type for tls_array., Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 15/19] modify get_desc_base, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 16/19] provide tss_desc, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 17/19] unify paravirt pieces of descriptor handling, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 18/19] move _set_gate and its users to a common loc ..., Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
[PATCH 19/19] unify set_tss_desc, Glauber de Oliveira ..., (Thu Dec 6, 9:16 am)
Re: [PATCH 1/19] unify desc_struct, Jeremy Fitzhardinge, (Thu Dec 6, 12:24 pm)
Re: [PATCH 1/19] unify desc_struct, Glauber de Oliveira ..., (Thu Dec 6, 12:37 pm)
Re: [PATCH 1/19] unify desc_struct, Glauber de Oliveira ..., (Thu Dec 6, 2:20 pm)
Re: [PATCH 1/19] unify desc_struct, Jeremy Fitzhardinge, (Thu Dec 6, 3:03 pm)
[PATCH 0/19] desc_struct integration, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 01/19] unify desc_struct, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 02/19] unify struct desc_ptr, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 03/19] change gdt acessor macro name, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 04/19] removed unused variable, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 05/19] introduce gate_desc type., Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 07/19] introduce ldt_desc type., Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 08/19] modify write_ldt function, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 09/19] introduce fill_ldt, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 10/19] provide tss_desc, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 11/19] change write_gdt_entry signature., Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 12/19] change write_ldt_entry signature, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 13/19] move constants to desc_defs.h, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 14/19] unify non-paravirt parts of desc.h, Glauber de Oliveira ..., (Wed Dec 12, 5:53 am)
[PATCH 15/19] use the same data type for tls_array., Glauber de Oliveira ..., (Wed Dec 12, 5:54 am)
[PATCH 16/19] modify get_desc_base, Glauber de Oliveira ..., (Wed Dec 12, 5:54 am)
[PATCH 17/19] unify paravirt pieces of descriptor handling, Glauber de Oliveira ..., (Wed Dec 12, 5:54 am)
[PATCH 18/19] move _set_gate and its users to a common loc ..., Glauber de Oliveira ..., (Wed Dec 12, 5:54 am)
[PATCH 19/19] unify set_tss_desc, Glauber de Oliveira ..., (Wed Dec 12, 5:54 am)
Re: [PATCH 0/19] desc_struct integration, Ingo Molnar, (Wed Dec 12, 10:20 am)
Re: [PATCH 09/19] introduce fill_ldt, Ingo Molnar, (Wed Dec 12, 10:56 am)
Re: [PATCH 0/19] desc_struct integration, Ingo Molnar, (Wed Dec 12, 11:11 am)
Re: [PATCH 0/19] desc_struct integration, Ingo Molnar, (Wed Dec 12, 11:20 am)
Re: [PATCH 0/19] desc_struct integration, Glauber de Oliveira ..., (Wed Dec 12, 11:27 am)
Re: [PATCH 0/19] desc_struct integration, Ingo Molnar, (Wed Dec 12, 11:33 am)
Re: [PATCH 0/19] desc_struct integration, Ingo Molnar, (Wed Dec 12, 11:34 am)
Re: [PATCH 0/19] desc_struct integration, Glauber de Oliveira ..., (Wed Dec 12, 12:05 pm)
Re: [PATCH 0/19] desc_struct integration, H. Peter Anvin, (Wed Dec 12, 4:39 pm)
[PATCH 0/19 - v3] desc_struct integration, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 02/19] unify struct desc_ptr, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 03/19] change gdt acessor macro name, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 04/19] removed unused variable, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 05/19] introduce gate_desc type., Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 06/19] change write_idt_entry signature, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 07/19] introduce ldt_desc type., Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 08/19] modify write_ldt function, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 09/19] introduce fill_ldt, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 10/19] provide tss_desc, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 11/19] change write_gdt_entry signature., Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 12/19] change write_ldt_entry signature, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 13/19] move constants to desc_defs.h, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 15/19] use the same data type for tls_array., Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 16/19] modify get_desc_base, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 17/19] unify paravirt pieces of descriptor handling, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 18/19] move _set_gate and its users to a common loc ..., Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
[PATCH 19/19] unify set_tss_desc, Glauber de Oliveira ..., (Wed Dec 12, 7:01 pm)
Re: [PATCH 19/19] unify set_tss_desc, Andi Kleen, (Thu Dec 13, 5:46 am)
[PATCH 0/19 -v4] desc_struct integration, Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 01/19] unify desc_struct, Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 02/19] unify struct desc_ptr, Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 03/19] change gdt acessor macro name, Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 04/19] removed unused variable, Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 05/19] introduce gate_desc type., Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 06/19] change write_idt_entry signature, Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 07/19] introduce ldt_desc type., Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 09/19] introduce fill_ldt, Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 10/19] provide tss_desc, Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 11/19] change write_gdt_entry signature., Glauber de Oliveira ..., (Thu Dec 13, 6:57 am)
[PATCH 12/19] change write_ldt_entry signature, Glauber de Oliveira ..., (Thu Dec 13, 6:58 am)
[PATCH 13/19] move constants to desc_defs.h, Glauber de Oliveira ..., (Thu Dec 13, 6:58 am)
[PATCH 14/19] unify non-paravirt parts of desc.h, Glauber de Oliveira ..., (Thu Dec 13, 6:58 am)
[PATCH 15/19] use the same data type for tls_array., Glauber de Oliveira ..., (Thu Dec 13, 6:58 am)
[PATCH 16/19] modify get_desc_base, Glauber de Oliveira ..., (Thu Dec 13, 6:58 am)
[PATCH 17/19] unify paravirt pieces of descriptor handling, Glauber de Oliveira ..., (Thu Dec 13, 6:58 am)
[PATCH 18/19] move _set_gate and its users to a common loc ..., Glauber de Oliveira ..., (Thu Dec 13, 6:58 am)
[PATCH 19/19] unify set_tss_desc, Glauber de Oliveira ..., (Thu Dec 13, 6:58 am)
Re: [PATCH 19/19] unify set_tss_desc, Glauber de Oliveira ..., (Thu Dec 13, 7:50 am)
Re: [PATCH 0/19 -v4] desc_struct integration, Ingo Molnar, (Thu Dec 13, 9:47 am)
Re: [PATCH 0/19 -v4] desc_struct integration, Glauber de Oliveira ..., (Thu Dec 13, 10:06 am)