aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86
diff options
context:
space:
mode:
authorGlauber Costa <gcosta@redhat.com>2008-05-28 19:19:53 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-08 06:48:16 -0400
commita939098afcfa5f81d3474782ec15c6d114e57763 (patch)
tree62c21fb10d6b58dc8247c34e68ab5562e045b8d0 /include/asm-x86
parent736f12bff9d9e7b4e895c64f73b190c8383fc2a1 (diff)
x86: move x86_64 gdt closer to i386
i386 and x86_64 used two different schemes for maintaining the gdt. With this patch, x86_64 initial gdt table is defined in a .c file, same way as i386 is now. Also, we call it "gdt_page", and the descriptor, "early_gdt_descr". This way we achieve common naming, which can allow for more code integration. Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86')
-rw-r--r--include/asm-x86/desc.h24
-rw-r--r--include/asm-x86/segment.h23
2 files changed, 22 insertions, 25 deletions
diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h
index b3875d4b4fab..07f9f2b17be8 100644
--- a/include/asm-x86/desc.h
+++ b/include/asm-x86/desc.h
@@ -29,11 +29,17 @@ static inline void fill_ldt(struct desc_struct *desc,
29extern struct desc_ptr idt_descr; 29extern struct desc_ptr idt_descr;
30extern gate_desc idt_table[]; 30extern gate_desc idt_table[];
31 31
32struct gdt_page {
33 struct desc_struct gdt[GDT_ENTRIES];
34} __attribute__((aligned(PAGE_SIZE)));
35DECLARE_PER_CPU(struct gdt_page, gdt_page);
36
37static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
38{
39 return per_cpu(gdt_page, cpu).gdt;
40}
41
32#ifdef CONFIG_X86_64 42#ifdef CONFIG_X86_64
33extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
34extern struct desc_ptr cpu_gdt_descr[];
35/* the cpu gdt accessor */
36#define get_cpu_gdt_table(x) ((struct desc_struct *)cpu_gdt_descr[x].address)
37 43
38static inline void pack_gate(gate_desc *gate, unsigned type, unsigned long func, 44static inline void pack_gate(gate_desc *gate, unsigned type, unsigned long func,
39 unsigned dpl, unsigned ist, unsigned seg) 45 unsigned dpl, unsigned ist, unsigned seg)
@@ -51,16 +57,6 @@ static inline void pack_gate(gate_desc *gate, unsigned type, unsigned long func,
51} 57}
52 58
53#else 59#else
54struct gdt_page {
55 struct desc_struct gdt[GDT_ENTRIES];
56} __attribute__((aligned(PAGE_SIZE)));
57DECLARE_PER_CPU(struct gdt_page, gdt_page);
58
59static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
60{
61 return per_cpu(gdt_page, cpu).gdt;
62}
63
64static inline void pack_gate(gate_desc *gate, unsigned char type, 60static inline void pack_gate(gate_desc *gate, unsigned char type,
65 unsigned long base, unsigned dpl, unsigned flags, 61 unsigned long base, unsigned dpl, unsigned flags,
66 unsigned short seg) 62 unsigned short seg)
diff --git a/include/asm-x86/segment.h b/include/asm-x86/segment.h
index ed5131dd7d92..dfc8601c0892 100644
--- a/include/asm-x86/segment.h
+++ b/include/asm-x86/segment.h
@@ -61,18 +61,14 @@
61#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) 61#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
62 62
63#define GDT_ENTRY_DEFAULT_USER_CS 14 63#define GDT_ENTRY_DEFAULT_USER_CS 14
64#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
65 64
66#define GDT_ENTRY_DEFAULT_USER_DS 15 65#define GDT_ENTRY_DEFAULT_USER_DS 15
67#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
68 66
69#define GDT_ENTRY_KERNEL_BASE 12 67#define GDT_ENTRY_KERNEL_BASE 12
70 68
71#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0) 69#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)
72#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
73 70
74#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1) 71#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)
75#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
76 72
77#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4) 73#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)
78#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5) 74#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)
@@ -139,10 +135,11 @@
139#else 135#else
140#include <asm/cache.h> 136#include <asm/cache.h>
141 137
142#define __KERNEL_CS 0x10 138#define GDT_ENTRY_KERNEL32_CS 1
143#define __KERNEL_DS 0x18 139#define GDT_ENTRY_KERNEL_CS 2
140#define GDT_ENTRY_KERNEL_DS 3
144 141
145#define __KERNEL32_CS 0x08 142#define __KERNEL32_CS (GDT_ENTRY_KERNEL32_CS * 8)
146 143
147/* 144/*
148 * we cannot use the same code segment descriptor for user and kernel 145 * we cannot use the same code segment descriptor for user and kernel
@@ -150,10 +147,10 @@
150 * The segment offset needs to contain a RPL. Grr. -AK 147 * The segment offset needs to contain a RPL. Grr. -AK
151 * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets) 148 * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets)
152 */ 149 */
153 150#define GDT_ENTRY_DEFAULT_USER32_CS 4
154#define __USER32_CS 0x23 /* 4*8+3 */ 151#define GDT_ENTRY_DEFAULT_USER_DS 5
155#define __USER_DS 0x2b /* 5*8+3 */ 152#define GDT_ENTRY_DEFAULT_USER_CS 6
156#define __USER_CS 0x33 /* 6*8+3 */ 153#define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS * 8 + 3)
157#define __USER32_DS __USER_DS 154#define __USER32_DS __USER_DS
158 155
159#define GDT_ENTRY_TSS 8 /* needs two entries */ 156#define GDT_ENTRY_TSS 8 /* needs two entries */
@@ -175,6 +172,10 @@
175 172
176#endif 173#endif
177 174
175#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
176#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
177#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS* 8 + 3)
178#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS* 8 + 3)
178#ifndef CONFIG_PARAVIRT 179#ifndef CONFIG_PARAVIRT
179#define get_kernel_rpl() 0 180#define get_kernel_rpl() 0
180#endif 181#endif