aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86
diff options
context:
space:
mode:
authorGlauber de Oliveira Costa <gcosta@redhat.com>2008-01-30 07:31:09 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:09 -0500
commitb23be399da88a5008b1db4db06f03146b25cdc52 (patch)
treed54acf84d3999dc957b2c5c2a23b117468c2efc2 /include/asm-x86
parent15ee09b40831ae88eb8a804a647b6935eb8b7114 (diff)
x86: remove arch specific segment headers
This file puts the remainder of the arch specificic segment headers in segment.h. 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>
Diffstat (limited to 'include/asm-x86')
-rw-r--r--include/asm-x86/segment.h177
-rw-r--r--include/asm-x86/segment_32.h122
-rw-r--r--include/asm-x86/segment_64.h47
3 files changed, 175 insertions, 171 deletions
diff --git a/include/asm-x86/segment.h b/include/asm-x86/segment.h
index 3c9b306bc4bf..c7509df79141 100644
--- a/include/asm-x86/segment.h
+++ b/include/asm-x86/segment.h
@@ -2,9 +2,182 @@
2#define _ASM_X86_SEGMENT_H_ 2#define _ASM_X86_SEGMENT_H_
3 3
4#ifdef CONFIG_X86_32 4#ifdef CONFIG_X86_32
5# include "segment_32.h" 5/*
6 * The layout of the per-CPU GDT under Linux:
7 *
8 * 0 - null
9 * 1 - reserved
10 * 2 - reserved
11 * 3 - reserved
12 *
13 * 4 - unused <==== new cacheline
14 * 5 - unused
15 *
16 * ------- start of TLS (Thread-Local Storage) segments:
17 *
18 * 6 - TLS segment #1 [ glibc's TLS segment ]
19 * 7 - TLS segment #2 [ Wine's %fs Win32 segment ]
20 * 8 - TLS segment #3
21 * 9 - reserved
22 * 10 - reserved
23 * 11 - reserved
24 *
25 * ------- start of kernel segments:
26 *
27 * 12 - kernel code segment <==== new cacheline
28 * 13 - kernel data segment
29 * 14 - default user CS
30 * 15 - default user DS
31 * 16 - TSS
32 * 17 - LDT
33 * 18 - PNPBIOS support (16->32 gate)
34 * 19 - PNPBIOS support
35 * 20 - PNPBIOS support
36 * 21 - PNPBIOS support
37 * 22 - PNPBIOS support
38 * 23 - APM BIOS support
39 * 24 - APM BIOS support
40 * 25 - APM BIOS support
41 *
42 * 26 - ESPFIX small SS
43 * 27 - per-cpu [ offset to per-cpu data area ]
44 * 28 - unused
45 * 29 - unused
46 * 30 - unused
47 * 31 - TSS for double fault handler
48 */
49#define GDT_ENTRY_TLS_MIN 6
50#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
51
52#define GDT_ENTRY_DEFAULT_USER_CS 14
53#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
54
55#define GDT_ENTRY_DEFAULT_USER_DS 15
56#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
57
58#define GDT_ENTRY_KERNEL_BASE 12
59
60#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)
61#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
62
63#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)
64#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
65
66#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)
67#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)
68
69#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6)
70#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11)
71
72#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)
73#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
74
75#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15)
76#ifdef CONFIG_SMP
77#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
78#else
79#define __KERNEL_PERCPU 0
80#endif
81
82#define GDT_ENTRY_DOUBLEFAULT_TSS 31
83
84/*
85 * The GDT has 32 entries
86 */
87#define GDT_ENTRIES 32
88
89/* Simple and small GDT entries for booting only */
90
91#define GDT_ENTRY_BOOT_CS 2
92#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
93
94#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
95#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
96
97/* The PnP BIOS entries in the GDT */
98#define GDT_ENTRY_PNPBIOS_CS32 (GDT_ENTRY_PNPBIOS_BASE + 0)
99#define GDT_ENTRY_PNPBIOS_CS16 (GDT_ENTRY_PNPBIOS_BASE + 1)
100#define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2)
101#define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3)
102#define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4)
103
104/* The PnP BIOS selectors */
105#define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8) /* segment for calling fn */
106#define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8) /* code segment for BIOS */
107#define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8) /* data segment for BIOS */
108#define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8) /* transfer data segment */
109#define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8) /* another data segment */
110
111/* Bottom two bits of selector give the ring privilege level */
112#define SEGMENT_RPL_MASK 0x3
113/* Bit 2 is table indicator (LDT/GDT) */
114#define SEGMENT_TI_MASK 0x4
115
116/* User mode is privilege level 3 */
117#define USER_RPL 0x3
118/* LDT segment has TI set, GDT has it cleared */
119#define SEGMENT_LDT 0x4
120#define SEGMENT_GDT 0x0
121
122/*
123 * Matching rules for certain types of segments.
124 */
125
126/* Matches only __KERNEL_CS, ignoring PnP / USER / APM segments */
127#define SEGMENT_IS_KERNEL_CODE(x) (((x) & 0xfc) == GDT_ENTRY_KERNEL_CS * 8)
128
129/* Matches __KERNEL_CS and __USER_CS (they must be 2 entries apart) */
130#define SEGMENT_IS_FLAT_CODE(x) (((x) & 0xec) == GDT_ENTRY_KERNEL_CS * 8)
131
132/* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
133#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
134
135
6#else 136#else
7# include "segment_64.h" 137#include <asm/cache.h>
138
139/* Simple and small GDT entries for booting only */
140
141#define GDT_ENTRY_BOOT_CS 2
142#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
143
144#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
145#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
146
147#define __KERNEL_CS 0x10
148#define __KERNEL_DS 0x18
149
150#define __KERNEL32_CS 0x08
151
152/*
153 * we cannot use the same code segment descriptor for user and kernel
154 * -- not even in the long flat mode, because of different DPL /kkeil
155 * The segment offset needs to contain a RPL. Grr. -AK
156 * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets)
157 */
158
159#define __USER32_CS 0x23 /* 4*8+3 */
160#define __USER_DS 0x2b /* 5*8+3 */
161#define __USER_CS 0x33 /* 6*8+3 */
162#define __USER32_DS __USER_DS
163
164#define GDT_ENTRY_TSS 8 /* needs two entries */
165#define GDT_ENTRY_LDT 10 /* needs two entries */
166#define GDT_ENTRY_TLS_MIN 12
167#define GDT_ENTRY_TLS_MAX 14
168
169#define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
170#define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
171
172/* TLS indexes for 64bit - hardcoded in arch_prctl */
173#define FS_TLS 0
174#define GS_TLS 1
175
176#define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
177#define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
178
179#define GDT_ENTRIES 16
180
8#endif 181#endif
9 182
10#ifndef CONFIG_PARAVIRT 183#ifndef CONFIG_PARAVIRT
diff --git a/include/asm-x86/segment_32.h b/include/asm-x86/segment_32.h
index 3e133ad4252d..8b137891791f 100644
--- a/include/asm-x86/segment_32.h
+++ b/include/asm-x86/segment_32.h
@@ -1,123 +1 @@
1#ifndef _ASM_SEGMENT_H
2#define _ASM_SEGMENT_H
3
4/*
5 * The layout of the per-CPU GDT under Linux:
6 *
7 * 0 - null
8 * 1 - reserved
9 * 2 - reserved
10 * 3 - reserved
11 *
12 * 4 - unused <==== new cacheline
13 * 5 - unused
14 *
15 * ------- start of TLS (Thread-Local Storage) segments:
16 *
17 * 6 - TLS segment #1 [ glibc's TLS segment ]
18 * 7 - TLS segment #2 [ Wine's %fs Win32 segment ]
19 * 8 - TLS segment #3
20 * 9 - reserved
21 * 10 - reserved
22 * 11 - reserved
23 *
24 * ------- start of kernel segments:
25 *
26 * 12 - kernel code segment <==== new cacheline
27 * 13 - kernel data segment
28 * 14 - default user CS
29 * 15 - default user DS
30 * 16 - TSS
31 * 17 - LDT
32 * 18 - PNPBIOS support (16->32 gate)
33 * 19 - PNPBIOS support
34 * 20 - PNPBIOS support
35 * 21 - PNPBIOS support
36 * 22 - PNPBIOS support
37 * 23 - APM BIOS support
38 * 24 - APM BIOS support
39 * 25 - APM BIOS support
40 *
41 * 26 - ESPFIX small SS
42 * 27 - per-cpu [ offset to per-cpu data area ]
43 * 28 - unused
44 * 29 - unused
45 * 30 - unused
46 * 31 - TSS for double fault handler
47 */
48#define GDT_ENTRY_TLS_MIN 6
49#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
50
51#define GDT_ENTRY_DEFAULT_USER_CS 14
52#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
53
54#define GDT_ENTRY_DEFAULT_USER_DS 15
55#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
56
57#define GDT_ENTRY_KERNEL_BASE 12
58
59#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)
60#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
61
62#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)
63#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
64
65#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)
66#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)
67
68#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6)
69#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11)
70
71#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)
72#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
73
74#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15)
75#ifdef CONFIG_SMP
76#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
77#else
78#define __KERNEL_PERCPU 0
79#endif
80
81#define GDT_ENTRY_DOUBLEFAULT_TSS 31
82
83/*
84 * The GDT has 32 entries
85 */
86#define GDT_ENTRIES 32
87
88/* Simple and small GDT entries for booting only */
89
90#define GDT_ENTRY_BOOT_CS 2
91#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
92
93#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
94#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
95
96/* The PnP BIOS entries in the GDT */
97#define GDT_ENTRY_PNPBIOS_CS32 (GDT_ENTRY_PNPBIOS_BASE + 0)
98#define GDT_ENTRY_PNPBIOS_CS16 (GDT_ENTRY_PNPBIOS_BASE + 1)
99#define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2)
100#define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3)
101#define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4)
102
103/* The PnP BIOS selectors */
104#define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8) /* segment for calling fn */
105#define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8) /* code segment for BIOS */
106#define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8) /* data segment for BIOS */
107#define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8) /* transfer data segment */
108#define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8) /* another data segment */
109
110/*
111 * Matching rules for certain types of segments.
112 */
113
114/* Matches only __KERNEL_CS, ignoring PnP / USER / APM segments */
115#define SEGMENT_IS_KERNEL_CODE(x) (((x) & 0xfc) == GDT_ENTRY_KERNEL_CS * 8)
116
117/* Matches __KERNEL_CS and __USER_CS (they must be 2 entries apart) */
118#define SEGMENT_IS_FLAT_CODE(x) (((x) & 0xec) == GDT_ENTRY_KERNEL_CS * 8)
119
120/* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
121#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
122
123#endif
diff --git a/include/asm-x86/segment_64.h b/include/asm-x86/segment_64.h
deleted file mode 100644
index 5cc7deb8b034..000000000000
--- a/include/asm-x86/segment_64.h
+++ /dev/null
@@ -1,47 +0,0 @@
1#ifndef _ASM_SEGMENT_H
2#define _ASM_SEGMENT_H
3
4#include <asm/cache.h>
5
6/* Simple and small GDT entries for booting only */
7
8#define GDT_ENTRY_BOOT_CS 2
9#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
10
11#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
12#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
13
14#define __KERNEL_CS 0x10
15#define __KERNEL_DS 0x18
16
17#define __KERNEL32_CS 0x08
18
19/*
20 * we cannot use the same code segment descriptor for user and kernel
21 * -- not even in the long flat mode, because of different DPL /kkeil
22 * The segment offset needs to contain a RPL. Grr. -AK
23 * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets)
24 */
25
26#define __USER32_CS 0x23 /* 4*8+3 */
27#define __USER_DS 0x2b /* 5*8+3 */
28#define __USER_CS 0x33 /* 6*8+3 */
29#define __USER32_DS __USER_DS
30
31#define GDT_ENTRY_TSS 8 /* needs two entries */
32#define GDT_ENTRY_LDT 10 /* needs two entries */
33#define GDT_ENTRY_TLS_MIN 12
34#define GDT_ENTRY_TLS_MAX 14
35
36#define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
37#define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
38
39/* TLS indexes for 64bit - hardcoded in arch_prctl */
40#define FS_TLS 0
41#define GS_TLS 1
42
43#define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
44#define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
45
46#define GDT_ENTRIES 16
47#endif