aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-30 07:31:12 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:12 -0500
commit6b68f01baa810e9f63fbf39e9d5c3ef1d94a966f (patch)
treedc7f50673d72677d24dbe9ac8217b832f8d5cb02
parent6842ef0e85a9cc1295f3ef933a230f863b01eb0f (diff)
x86: unify struct desc_ptr
This patch unifies struct desc_ptr between i386 and x86_64. They can be expressed in the exact same way in C code, only having to change the name of one of them. As Xgt_desc_struct is ugly and big, this is the one that goes away. There's also a padding field in i386, but it is not really needed in the C structure definition. 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>
-rw-r--r--arch/x86/kernel/asm-offsets_32.c5
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/doublefault_32.c2
-rw-r--r--arch/x86/kernel/efi_32.c4
-rw-r--r--arch/x86/kernel/machine_kexec_32.c4
-rw-r--r--arch/x86/kernel/reboot_32.c2
-rw-r--r--arch/x86/lguest/boot.c4
-rw-r--r--arch/x86/xen/enlighten.c10
-rw-r--r--drivers/kvm/svm.c2
-rw-r--r--include/asm-x86/desc_32.h16
-rw-r--r--include/asm-x86/lguest.h8
-rw-r--r--include/asm-x86/paravirt.h18
-rw-r--r--include/asm-x86/processor_32.h2
-rw-r--r--include/asm-x86/suspend_32.h4
14 files changed, 38 insertions, 45 deletions
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index 415313556708..afd84463b712 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -70,9 +70,8 @@ void foo(void)
70 OFFSET(TI_cpu, thread_info, cpu); 70 OFFSET(TI_cpu, thread_info, cpu);
71 BLANK(); 71 BLANK();
72 72
73 OFFSET(GDS_size, Xgt_desc_struct, size); 73 OFFSET(GDS_size, desc_ptr, size);
74 OFFSET(GDS_address, Xgt_desc_struct, address); 74 OFFSET(GDS_address, desc_ptr, address);
75 OFFSET(GDS_pad, Xgt_desc_struct, pad);
76 BLANK(); 75 BLANK();
77 76
78 OFFSET(PT_EBX, pt_regs, bx); 77 OFFSET(PT_EBX, pt_regs, bx);
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 4f9e31912a25..69507ae8a65b 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -649,7 +649,7 @@ struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
649 * it's on the real one. */ 649 * it's on the real one. */
650void switch_to_new_gdt(void) 650void switch_to_new_gdt(void)
651{ 651{
652 struct Xgt_desc_struct gdt_descr; 652 struct desc_ptr gdt_descr;
653 653
654 gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id()); 654 gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id());
655 gdt_descr.size = GDT_SIZE - 1; 655 gdt_descr.size = GDT_SIZE - 1;
diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
index cc19a3ea403a..d16122a8e4eb 100644
--- a/arch/x86/kernel/doublefault_32.c
+++ b/arch/x86/kernel/doublefault_32.c
@@ -17,7 +17,7 @@ static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17 17
18static void doublefault_fn(void) 18static void doublefault_fn(void)
19{ 19{
20 struct Xgt_desc_struct gdt_desc = {0, 0}; 20 struct desc_ptr gdt_desc = {0, 0};
21 unsigned long gdt, tss; 21 unsigned long gdt, tss;
22 22
23 store_gdt(&gdt_desc); 23 store_gdt(&gdt_desc);
diff --git a/arch/x86/kernel/efi_32.c b/arch/x86/kernel/efi_32.c
index e2be78f49399..863e8926f2bb 100644
--- a/arch/x86/kernel/efi_32.c
+++ b/arch/x86/kernel/efi_32.c
@@ -69,7 +69,7 @@ static void efi_call_phys_prelog(void) __acquires(efi_rt_lock)
69{ 69{
70 unsigned long cr4; 70 unsigned long cr4;
71 unsigned long temp; 71 unsigned long temp;
72 struct Xgt_desc_struct gdt_descr; 72 struct desc_ptr gdt_descr;
73 73
74 spin_lock(&efi_rt_lock); 74 spin_lock(&efi_rt_lock);
75 local_irq_save(efi_rt_eflags); 75 local_irq_save(efi_rt_eflags);
@@ -111,7 +111,7 @@ static void efi_call_phys_prelog(void) __acquires(efi_rt_lock)
111static void efi_call_phys_epilog(void) __releases(efi_rt_lock) 111static void efi_call_phys_epilog(void) __releases(efi_rt_lock)
112{ 112{
113 unsigned long cr4; 113 unsigned long cr4;
114 struct Xgt_desc_struct gdt_descr; 114 struct desc_ptr gdt_descr;
115 115
116 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0); 116 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
117 gdt_descr.size = GDT_SIZE - 1; 117 gdt_descr.size = GDT_SIZE - 1;
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
index 11b935f4f886..c1cfd60639d4 100644
--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -32,7 +32,7 @@ static u32 kexec_pte1[1024] PAGE_ALIGNED;
32 32
33static void set_idt(void *newidt, __u16 limit) 33static void set_idt(void *newidt, __u16 limit)
34{ 34{
35 struct Xgt_desc_struct curidt; 35 struct desc_ptr curidt;
36 36
37 /* ia32 supports unaliged loads & stores */ 37 /* ia32 supports unaliged loads & stores */
38 curidt.size = limit; 38 curidt.size = limit;
@@ -44,7 +44,7 @@ static void set_idt(void *newidt, __u16 limit)
44 44
45static void set_gdt(void *newgdt, __u16 limit) 45static void set_gdt(void *newgdt, __u16 limit)
46{ 46{
47 struct Xgt_desc_struct curgdt; 47 struct desc_ptr curgdt;
48 48
49 /* ia32 supports unaligned loads & stores */ 49 /* ia32 supports unaligned loads & stores */
50 curgdt.size = limit; 50 curgdt.size = limit;
diff --git a/arch/x86/kernel/reboot_32.c b/arch/x86/kernel/reboot_32.c
index bb1a0f889c5e..c3376fae639d 100644
--- a/arch/x86/kernel/reboot_32.c
+++ b/arch/x86/kernel/reboot_32.c
@@ -161,7 +161,7 @@ real_mode_gdt_entries [3] =
161 0x000092000100ffffULL /* 16-bit real-mode 64k data at 0x00000100 */ 161 0x000092000100ffffULL /* 16-bit real-mode 64k data at 0x00000100 */
162}; 162};
163 163
164static struct Xgt_desc_struct 164static struct desc_ptr
165real_mode_gdt = { sizeof (real_mode_gdt_entries) - 1, (long)real_mode_gdt_entries }, 165real_mode_gdt = { sizeof (real_mode_gdt_entries) - 1, (long)real_mode_gdt_entries },
166real_mode_idt = { 0x3ff, 0 }, 166real_mode_idt = { 0x3ff, 0 },
167no_idt = { 0, 0 }; 167no_idt = { 0, 0 };
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index c751e3c03e85..aa0bdd5fc4bb 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -229,7 +229,7 @@ static void lguest_write_idt_entry(struct desc_struct *dt,
229/* Changing to a different IDT is very rare: we keep the IDT up-to-date every 229/* Changing to a different IDT is very rare: we keep the IDT up-to-date every
230 * time it is written, so we can simply loop through all entries and tell the 230 * time it is written, so we can simply loop through all entries and tell the
231 * Host about them. */ 231 * Host about them. */
232static void lguest_load_idt(const struct Xgt_desc_struct *desc) 232static void lguest_load_idt(const struct desc_ptr *desc)
233{ 233{
234 unsigned int i; 234 unsigned int i;
235 struct desc_struct *idt = (void *)desc->address; 235 struct desc_struct *idt = (void *)desc->address;
@@ -252,7 +252,7 @@ static void lguest_load_idt(const struct Xgt_desc_struct *desc)
252 * hypercall and use that repeatedly to load a new IDT. I don't think it 252 * hypercall and use that repeatedly to load a new IDT. I don't think it
253 * really matters, but wouldn't it be nice if they were the same? 253 * really matters, but wouldn't it be nice if they were the same?
254 */ 254 */
255static void lguest_load_gdt(const struct Xgt_desc_struct *desc) 255static void lguest_load_gdt(const struct desc_ptr *desc)
256{ 256{
257 BUG_ON((desc->size+1)/8 != GDT_ENTRIES); 257 BUG_ON((desc->size+1)/8 != GDT_ENTRIES);
258 hcall(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES, 0); 258 hcall(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES, 0);
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index d81e8d709102..c32e0fd0f838 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -295,7 +295,7 @@ static void xen_set_ldt(const void *addr, unsigned entries)
295 xen_mc_issue(PARAVIRT_LAZY_CPU); 295 xen_mc_issue(PARAVIRT_LAZY_CPU);
296} 296}
297 297
298static void xen_load_gdt(const struct Xgt_desc_struct *dtr) 298static void xen_load_gdt(const struct desc_ptr *dtr)
299{ 299{
300 unsigned long *frames; 300 unsigned long *frames;
301 unsigned long va = dtr->address; 301 unsigned long va = dtr->address;
@@ -395,7 +395,7 @@ static int cvt_gate_to_trap(int vector, u32 low, u32 high,
395} 395}
396 396
397/* Locations of each CPU's IDT */ 397/* Locations of each CPU's IDT */
398static DEFINE_PER_CPU(struct Xgt_desc_struct, idt_desc); 398static DEFINE_PER_CPU(struct desc_ptr, idt_desc);
399 399
400/* Set an IDT entry. If the entry is part of the current IDT, then 400/* Set an IDT entry. If the entry is part of the current IDT, then
401 also update Xen. */ 401 also update Xen. */
@@ -427,7 +427,7 @@ static void xen_write_idt_entry(struct desc_struct *dt, int entrynum,
427 preempt_enable(); 427 preempt_enable();
428} 428}
429 429
430static void xen_convert_trap_info(const struct Xgt_desc_struct *desc, 430static void xen_convert_trap_info(const struct desc_ptr *desc,
431 struct trap_info *traps) 431 struct trap_info *traps)
432{ 432{
433 unsigned in, out, count; 433 unsigned in, out, count;
@@ -446,7 +446,7 @@ static void xen_convert_trap_info(const struct Xgt_desc_struct *desc,
446 446
447void xen_copy_trap_info(struct trap_info *traps) 447void xen_copy_trap_info(struct trap_info *traps)
448{ 448{
449 const struct Xgt_desc_struct *desc = &__get_cpu_var(idt_desc); 449 const struct desc_ptr *desc = &__get_cpu_var(idt_desc);
450 450
451 xen_convert_trap_info(desc, traps); 451 xen_convert_trap_info(desc, traps);
452} 452}
@@ -454,7 +454,7 @@ void xen_copy_trap_info(struct trap_info *traps)
454/* Load a new IDT into Xen. In principle this can be per-CPU, so we 454/* Load a new IDT into Xen. In principle this can be per-CPU, so we
455 hold a spinlock to protect the static traps[] array (static because 455 hold a spinlock to protect the static traps[] array (static because
456 it avoids allocation, and saves stack space). */ 456 it avoids allocation, and saves stack space). */
457static void xen_load_idt(const struct Xgt_desc_struct *desc) 457static void xen_load_idt(const struct desc_ptr *desc)
458{ 458{
459 static DEFINE_SPINLOCK(lock); 459 static DEFINE_SPINLOCK(lock);
460 static struct trap_info traps[257]; 460 static struct trap_info traps[257];
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 4e04e49a2f1c..ced4ac1955db 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -290,7 +290,7 @@ static void svm_hardware_enable(void *garbage)
290#ifdef CONFIG_X86_64 290#ifdef CONFIG_X86_64
291 struct desc_ptr gdt_descr; 291 struct desc_ptr gdt_descr;
292#else 292#else
293 struct Xgt_desc_struct gdt_descr; 293 struct desc_ptr gdt_descr;
294#endif 294#endif
295 struct desc_struct *gdt; 295 struct desc_struct *gdt;
296 int me = raw_smp_processor_id(); 296 int me = raw_smp_processor_id();
diff --git a/include/asm-x86/desc_32.h b/include/asm-x86/desc_32.h
index c547403f341d..bc5ca3453466 100644
--- a/include/asm-x86/desc_32.h
+++ b/include/asm-x86/desc_32.h
@@ -12,12 +12,6 @@
12 12
13#include <asm/mmu.h> 13#include <asm/mmu.h>
14 14
15struct Xgt_desc_struct {
16 unsigned short size;
17 unsigned long address __attribute__((packed));
18 unsigned short pad;
19} __attribute__ ((packed));
20
21struct gdt_page 15struct gdt_page
22{ 16{
23 struct desc_struct gdt[GDT_ENTRIES]; 17 struct desc_struct gdt[GDT_ENTRIES];
@@ -29,7 +23,7 @@ static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
29 return per_cpu(gdt_page, cpu).gdt; 23 return per_cpu(gdt_page, cpu).gdt;
30} 24}
31 25
32extern struct Xgt_desc_struct idt_descr; 26extern struct desc_ptr idt_descr;
33extern struct desc_struct idt_table[]; 27extern struct desc_struct idt_table[];
34extern void set_intr_gate(unsigned int irq, void * addr); 28extern void set_intr_gate(unsigned int irq, void * addr);
35 29
@@ -107,22 +101,22 @@ static inline void native_load_tr_desc(void)
107 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8)); 101 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
108} 102}
109 103
110static inline void native_load_gdt(const struct Xgt_desc_struct *dtr) 104static inline void native_load_gdt(const struct desc_ptr *dtr)
111{ 105{
112 asm volatile("lgdt %0"::"m" (*dtr)); 106 asm volatile("lgdt %0"::"m" (*dtr));
113} 107}
114 108
115static inline void native_load_idt(const struct Xgt_desc_struct *dtr) 109static inline void native_load_idt(const struct desc_ptr *dtr)
116{ 110{
117 asm volatile("lidt %0"::"m" (*dtr)); 111 asm volatile("lidt %0"::"m" (*dtr));
118} 112}
119 113
120static inline void native_store_gdt(struct Xgt_desc_struct *dtr) 114static inline void native_store_gdt(struct desc_ptr *dtr)
121{ 115{
122 asm ("sgdt %0":"=m" (*dtr)); 116 asm ("sgdt %0":"=m" (*dtr));
123} 117}
124 118
125static inline void native_store_idt(struct Xgt_desc_struct *dtr) 119static inline void native_store_idt(struct desc_ptr *dtr)
126{ 120{
127 asm ("sidt %0":"=m" (*dtr)); 121 asm ("sidt %0":"=m" (*dtr));
128} 122}
diff --git a/include/asm-x86/lguest.h b/include/asm-x86/lguest.h
index 17c908c0ef1c..3585a1628b59 100644
--- a/include/asm-x86/lguest.h
+++ b/include/asm-x86/lguest.h
@@ -44,13 +44,13 @@ struct lguest_ro_state
44{ 44{
45 /* Host information we need to restore when we switch back. */ 45 /* Host information we need to restore when we switch back. */
46 u32 host_cr3; 46 u32 host_cr3;
47 struct Xgt_desc_struct host_idt_desc; 47 struct desc_ptr host_idt_desc;
48 struct Xgt_desc_struct host_gdt_desc; 48 struct desc_ptr host_gdt_desc;
49 u32 host_sp; 49 u32 host_sp;
50 50
51 /* Fields which are used when guest is running. */ 51 /* Fields which are used when guest is running. */
52 struct Xgt_desc_struct guest_idt_desc; 52 struct desc_ptr guest_idt_desc;
53 struct Xgt_desc_struct guest_gdt_desc; 53 struct desc_ptr guest_gdt_desc;
54 struct i386_hw_tss guest_tss; 54 struct i386_hw_tss guest_tss;
55 struct desc_struct guest_idt[IDT_ENTRIES]; 55 struct desc_struct guest_idt[IDT_ENTRIES];
56 struct desc_struct guest_gdt[GDT_ENTRIES]; 56 struct desc_struct guest_gdt[GDT_ENTRIES];
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index e95c2a655165..0333fb6988b5 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -20,7 +20,7 @@
20 20
21struct page; 21struct page;
22struct thread_struct; 22struct thread_struct;
23struct Xgt_desc_struct; 23struct desc_ptr;
24struct tss_struct; 24struct tss_struct;
25struct mm_struct; 25struct mm_struct;
26struct desc_struct; 26struct desc_struct;
@@ -88,10 +88,10 @@ struct pv_cpu_ops {
88 88
89 /* Segment descriptor handling */ 89 /* Segment descriptor handling */
90 void (*load_tr_desc)(void); 90 void (*load_tr_desc)(void);
91 void (*load_gdt)(const struct Xgt_desc_struct *); 91 void (*load_gdt)(const struct desc_ptr *);
92 void (*load_idt)(const struct Xgt_desc_struct *); 92 void (*load_idt)(const struct desc_ptr *);
93 void (*store_gdt)(struct Xgt_desc_struct *); 93 void (*store_gdt)(struct desc_ptr *);
94 void (*store_idt)(struct Xgt_desc_struct *); 94 void (*store_idt)(struct desc_ptr *);
95 void (*set_ldt)(const void *desc, unsigned entries); 95 void (*set_ldt)(const void *desc, unsigned entries);
96 unsigned long (*store_tr)(void); 96 unsigned long (*store_tr)(void);
97 void (*load_tls)(struct thread_struct *t, unsigned int cpu); 97 void (*load_tls)(struct thread_struct *t, unsigned int cpu);
@@ -630,11 +630,11 @@ static inline void load_TR_desc(void)
630{ 630{
631 PVOP_VCALL0(pv_cpu_ops.load_tr_desc); 631 PVOP_VCALL0(pv_cpu_ops.load_tr_desc);
632} 632}
633static inline void load_gdt(const struct Xgt_desc_struct *dtr) 633static inline void load_gdt(const struct desc_ptr *dtr)
634{ 634{
635 PVOP_VCALL1(pv_cpu_ops.load_gdt, dtr); 635 PVOP_VCALL1(pv_cpu_ops.load_gdt, dtr);
636} 636}
637static inline void load_idt(const struct Xgt_desc_struct *dtr) 637static inline void load_idt(const struct desc_ptr *dtr)
638{ 638{
639 PVOP_VCALL1(pv_cpu_ops.load_idt, dtr); 639 PVOP_VCALL1(pv_cpu_ops.load_idt, dtr);
640} 640}
@@ -642,11 +642,11 @@ static inline void set_ldt(const void *addr, unsigned entries)
642{ 642{
643 PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries); 643 PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries);
644} 644}
645static inline void store_gdt(struct Xgt_desc_struct *dtr) 645static inline void store_gdt(struct desc_ptr *dtr)
646{ 646{
647 PVOP_VCALL1(pv_cpu_ops.store_gdt, dtr); 647 PVOP_VCALL1(pv_cpu_ops.store_gdt, dtr);
648} 648}
649static inline void store_idt(struct Xgt_desc_struct *dtr) 649static inline void store_idt(struct desc_ptr *dtr)
650{ 650{
651 PVOP_VCALL1(pv_cpu_ops.store_idt, dtr); 651 PVOP_VCALL1(pv_cpu_ops.store_idt, dtr);
652} 652}
diff --git a/include/asm-x86/processor_32.h b/include/asm-x86/processor_32.h
index bc48ad64de47..e5056ab9dd9f 100644
--- a/include/asm-x86/processor_32.h
+++ b/include/asm-x86/processor_32.h
@@ -707,7 +707,7 @@ extern void enable_sep_cpu(void);
707extern int sysenter_setup(void); 707extern int sysenter_setup(void);
708 708
709/* Defined in head.S */ 709/* Defined in head.S */
710extern struct Xgt_desc_struct early_gdt_descr; 710extern struct desc_ptr early_gdt_descr;
711 711
712extern void cpu_set_gdt(int); 712extern void cpu_set_gdt(int);
713extern void switch_to_new_gdt(void); 713extern void switch_to_new_gdt(void);
diff --git a/include/asm-x86/suspend_32.h b/include/asm-x86/suspend_32.h
index a2520732ffd6..1bbda3ad7796 100644
--- a/include/asm-x86/suspend_32.h
+++ b/include/asm-x86/suspend_32.h
@@ -12,8 +12,8 @@ static inline int arch_prepare_suspend(void) { return 0; }
12struct saved_context { 12struct saved_context {
13 u16 es, fs, gs, ss; 13 u16 es, fs, gs, ss;
14 unsigned long cr0, cr2, cr3, cr4; 14 unsigned long cr0, cr2, cr3, cr4;
15 struct Xgt_desc_struct gdt; 15 struct desc_ptr gdt;
16 struct Xgt_desc_struct idt; 16 struct desc_ptr idt;
17 u16 ldt; 17 u16 ldt;
18 u16 tss; 18 u16 tss;
19 unsigned long tr; 19 unsigned long tr;