aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-30 07:31:11 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:11 -0500
commit6842ef0e85a9cc1295f3ef933a230f863b01eb0f (patch)
treedfee4feb74f15ea3819b57848e59fb29ebb10750
parent746ef0cd0c7190d570c65b8e39a4ac67550ae43a (diff)
x86: unify desc_struct
This patch aims to make the access of struct desc_struct variables equal across architectures. In this patch, I unify the i386 and x86_64 versions under an anonymous union, keeping the way they are accessed untouched (a and b for 32-bit code, individual bit-fields for 64-bit). This solution is not beautiful, but will allow us to integrate common code that differed by the way descriptors were used. This is to be viewed incrementally. There's simply too much code to be fixed at once. In the future, goal is to set up in a single way of acessing the desc_struct fields. 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/apm_32.c2
-rw-r--r--arch/x86/kernel/cpu/common.c35
-rw-r--r--arch/x86/kernel/process_64.c2
-rw-r--r--arch/x86/kernel/traps_32.c3
-rw-r--r--include/asm-x86/desc_defs.h25
-rw-r--r--include/asm-x86/lguest.h4
-rw-r--r--include/asm-x86/processor_32.h5
7 files changed, 45 insertions, 31 deletions
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 7496c2e4b6ae..e32f6c37db9b 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -405,7 +405,7 @@ static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
405static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); 405static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
406static struct apm_user * user_list; 406static struct apm_user * user_list;
407static DEFINE_SPINLOCK(user_list_lock); 407static DEFINE_SPINLOCK(user_list_lock);
408static const struct desc_struct bad_bios_desc = { 0, 0x00409200 }; 408static const struct desc_struct bad_bios_desc = { { { 0, 0x00409200 } } };
409 409
410static const char driver_version[] = "1.16ac"; /* no spaces */ 410static const char driver_version[] = "1.16ac"; /* no spaces */
411 411
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 235cd615b89d..4f9e31912a25 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -22,31 +22,38 @@
22#include "cpu.h" 22#include "cpu.h"
23 23
24DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = { 24DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = {
25 [GDT_ENTRY_KERNEL_CS] = { 0x0000ffff, 0x00cf9a00 }, 25 [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00cf9a00 } } },
26 [GDT_ENTRY_KERNEL_DS] = { 0x0000ffff, 0x00cf9200 }, 26 [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9200 } } },
27 [GDT_ENTRY_DEFAULT_USER_CS] = { 0x0000ffff, 0x00cffa00 }, 27 [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00cffa00 } } },
28 [GDT_ENTRY_DEFAULT_USER_DS] = { 0x0000ffff, 0x00cff200 }, 28 [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff200 } } },
29 /* 29 /*
30 * Segments used for calling PnP BIOS have byte granularity. 30 * Segments used for calling PnP BIOS have byte granularity.
31 * They code segments and data segments have fixed 64k limits, 31 * They code segments and data segments have fixed 64k limits,
32 * the transfer segment sizes are set at run time. 32 * the transfer segment sizes are set at run time.
33 */ 33 */
34 [GDT_ENTRY_PNPBIOS_CS32] = { 0x0000ffff, 0x00409a00 },/* 32-bit code */ 34 /* 32-bit code */
35 [GDT_ENTRY_PNPBIOS_CS16] = { 0x0000ffff, 0x00009a00 },/* 16-bit code */ 35 [GDT_ENTRY_PNPBIOS_CS32] = { { { 0x0000ffff, 0x00409a00 } } },
36 [GDT_ENTRY_PNPBIOS_DS] = { 0x0000ffff, 0x00009200 }, /* 16-bit data */ 36 /* 16-bit code */
37 [GDT_ENTRY_PNPBIOS_TS1] = { 0x00000000, 0x00009200 },/* 16-bit data */ 37 [GDT_ENTRY_PNPBIOS_CS16] = { { { 0x0000ffff, 0x00009a00 } } },
38 [GDT_ENTRY_PNPBIOS_TS2] = { 0x00000000, 0x00009200 },/* 16-bit data */ 38 /* 16-bit data */
39 [GDT_ENTRY_PNPBIOS_DS] = { { { 0x0000ffff, 0x00009200 } } },
40 /* 16-bit data */
41 [GDT_ENTRY_PNPBIOS_TS1] = { { { 0x00000000, 0x00009200 } } },
42 /* 16-bit data */
43 [GDT_ENTRY_PNPBIOS_TS2] = { { { 0x00000000, 0x00009200 } } },
39 /* 44 /*
40 * The APM segments have byte granularity and their bases 45 * The APM segments have byte granularity and their bases
41 * are set at run time. All have 64k limits. 46 * are set at run time. All have 64k limits.
42 */ 47 */
43 [GDT_ENTRY_APMBIOS_BASE] = { 0x0000ffff, 0x00409a00 },/* 32-bit code */ 48 /* 32-bit code */
49 [GDT_ENTRY_APMBIOS_BASE] = { { { 0x0000ffff, 0x00409a00 } } },
44 /* 16-bit code */ 50 /* 16-bit code */
45 [GDT_ENTRY_APMBIOS_BASE+1] = { 0x0000ffff, 0x00009a00 }, 51 [GDT_ENTRY_APMBIOS_BASE+1] = { { { 0x0000ffff, 0x00009a00 } } },
46 [GDT_ENTRY_APMBIOS_BASE+2] = { 0x0000ffff, 0x00409200 }, /* data */ 52 /* data */
53 [GDT_ENTRY_APMBIOS_BASE+2] = { { { 0x0000ffff, 0x00409200 } } },
47 54
48 [GDT_ENTRY_ESPFIX_SS] = { 0x00000000, 0x00c09200 }, 55 [GDT_ENTRY_ESPFIX_SS] = { { { 0x00000000, 0x00c09200 } } },
49 [GDT_ENTRY_PERCPU] = { 0x00000000, 0x00000000 }, 56 [GDT_ENTRY_PERCPU] = { { { 0x00000000, 0x00000000 } } },
50} }; 57} };
51EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); 58EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
52 59
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 843bf0c978a4..86c310acc989 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -455,7 +455,7 @@ static inline void set_32bit_tls(struct task_struct *t, int tls, u32 addr)
455 .limit_in_pages = 1, 455 .limit_in_pages = 1,
456 .useable = 1, 456 .useable = 1,
457 }; 457 };
458 struct n_desc_struct *desc = (void *)t->thread.tls_array; 458 struct desc_struct *desc = (void *)t->thread.tls_array;
459 desc += tls; 459 desc += tls;
460 desc->a = LDT_entry_a(&ud); 460 desc->a = LDT_entry_a(&ud);
461 desc->b = LDT_entry_b(&ud); 461 desc->b = LDT_entry_b(&ud);
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 57491942cc4e..0d45017ed824 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -76,7 +76,8 @@ char ignore_fpu_irq = 0;
76 * F0 0F bug workaround.. We have a special link segment 76 * F0 0F bug workaround.. We have a special link segment
77 * for this. 77 * for this.
78 */ 78 */
79struct desc_struct idt_table[256] __attribute__((__section__(".data.idt"))) = { {0, 0}, }; 79struct desc_struct idt_table[256]
80 __attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, };
80 81
81asmlinkage void divide_error(void); 82asmlinkage void divide_error(void);
82asmlinkage void debug(void); 83asmlinkage void debug(void);
diff --git a/include/asm-x86/desc_defs.h b/include/asm-x86/desc_defs.h
index 089004070099..de47eb0a23aa 100644
--- a/include/asm-x86/desc_defs.h
+++ b/include/asm-x86/desc_defs.h
@@ -11,17 +11,26 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14/*
15 * FIXME: Acessing the desc_struct through its fields is more elegant,
16 * and should be the one valid thing to do. However, a lot of open code
17 * still touches the a and b acessors, and doing this allow us to do it
18 * incrementally. We keep the signature as a struct, rather than an union,
19 * so we can get rid of it transparently in the future -- glommer
20 */
14// 8 byte segment descriptor 21// 8 byte segment descriptor
15struct desc_struct { 22struct desc_struct {
16 u16 limit0; 23 union {
17 u16 base0; 24 struct { unsigned int a, b; };
18 unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1; 25 struct {
19 unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8; 26 u16 limit0;
20} __attribute__((packed)); 27 u16 base0;
28 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
29 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
30 };
21 31
22struct n_desc_struct { 32 };
23 unsigned int a,b; 33} __attribute__((packed));
24};
25 34
26enum { 35enum {
27 GATE_INTERRUPT = 0xE, 36 GATE_INTERRUPT = 0xE,
diff --git a/include/asm-x86/lguest.h b/include/asm-x86/lguest.h
index ccd338460811..17c908c0ef1c 100644
--- a/include/asm-x86/lguest.h
+++ b/include/asm-x86/lguest.h
@@ -78,8 +78,8 @@ static inline void lguest_set_ts(void)
78} 78}
79 79
80/* Full 4G segment descriptors, suitable for CS and DS. */ 80/* Full 4G segment descriptors, suitable for CS and DS. */
81#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00}) 81#define FULL_EXEC_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9b00} } })
82#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300}) 82#define FULL_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9300} } })
83 83
84#endif /* __ASSEMBLY__ */ 84#endif /* __ASSEMBLY__ */
85 85
diff --git a/include/asm-x86/processor_32.h b/include/asm-x86/processor_32.h
index 9c0ab7f26bd9..bc48ad64de47 100644
--- a/include/asm-x86/processor_32.h
+++ b/include/asm-x86/processor_32.h
@@ -20,14 +20,11 @@
20#include <linux/cpumask.h> 20#include <linux/cpumask.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <asm/processor-flags.h> 22#include <asm/processor-flags.h>
23#include <asm/desc_defs.h>
23 24
24/* flag for disabling the tsc */ 25/* flag for disabling the tsc */
25extern int tsc_disable; 26extern int tsc_disable;
26 27
27struct desc_struct {
28 unsigned long a,b;
29};
30
31static inline int desc_empty(const void *ptr) 28static inline int desc_empty(const void *ptr)
32{ 29{
33 const u32 *desc = ptr; 30 const u32 *desc = ptr;