aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/segment.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-x86/segment.h')
-rw-r--r--include/asm-x86/segment.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/include/asm-x86/segment.h b/include/asm-x86/segment.h
index ed5131dd7d9..646452ea9ea 100644
--- a/include/asm-x86/segment.h
+++ b/include/asm-x86/segment.h
@@ -1,6 +1,15 @@
1#ifndef _ASM_X86_SEGMENT_H_ 1#ifndef _ASM_X86_SEGMENT_H_
2#define _ASM_X86_SEGMENT_H_ 2#define _ASM_X86_SEGMENT_H_
3 3
4/* Constructor for a conventional segment GDT (or LDT) entry */
5/* This is a macro so it can be used in initializers */
6#define GDT_ENTRY(flags, base, limit) \
7 ((((base) & 0xff000000ULL) << (56-24)) | \
8 (((flags) & 0x0000f0ffULL) << 40) | \
9 (((limit) & 0x000f0000ULL) << (48-16)) | \
10 (((base) & 0x00ffffffULL) << 16) | \
11 (((limit) & 0x0000ffffULL)))
12
4/* Simple and small GDT entries for booting only */ 13/* Simple and small GDT entries for booting only */
5 14
6#define GDT_ENTRY_BOOT_CS 2 15#define GDT_ENTRY_BOOT_CS 2
@@ -61,18 +70,14 @@
61#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) 70#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
62 71
63#define GDT_ENTRY_DEFAULT_USER_CS 14 72#define GDT_ENTRY_DEFAULT_USER_CS 14
64#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
65 73
66#define GDT_ENTRY_DEFAULT_USER_DS 15 74#define GDT_ENTRY_DEFAULT_USER_DS 15
67#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
68 75
69#define GDT_ENTRY_KERNEL_BASE 12 76#define GDT_ENTRY_KERNEL_BASE 12
70 77
71#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0) 78#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)
72#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
73 79
74#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1) 80#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)
75#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
76 81
77#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4) 82#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)
78#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5) 83#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)
@@ -139,10 +144,11 @@
139#else 144#else
140#include <asm/cache.h> 145#include <asm/cache.h>
141 146
142#define __KERNEL_CS 0x10 147#define GDT_ENTRY_KERNEL32_CS 1
143#define __KERNEL_DS 0x18 148#define GDT_ENTRY_KERNEL_CS 2
149#define GDT_ENTRY_KERNEL_DS 3
144 150
145#define __KERNEL32_CS 0x08 151#define __KERNEL32_CS (GDT_ENTRY_KERNEL32_CS * 8)
146 152
147/* 153/*
148 * we cannot use the same code segment descriptor for user and kernel 154 * we cannot use the same code segment descriptor for user and kernel
@@ -150,10 +156,10 @@
150 * The segment offset needs to contain a RPL. Grr. -AK 156 * The segment offset needs to contain a RPL. Grr. -AK
151 * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets) 157 * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets)
152 */ 158 */
153 159#define GDT_ENTRY_DEFAULT_USER32_CS 4
154#define __USER32_CS 0x23 /* 4*8+3 */ 160#define GDT_ENTRY_DEFAULT_USER_DS 5
155#define __USER_DS 0x2b /* 5*8+3 */ 161#define GDT_ENTRY_DEFAULT_USER_CS 6
156#define __USER_CS 0x33 /* 6*8+3 */ 162#define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS * 8 + 3)
157#define __USER32_DS __USER_DS 163#define __USER32_DS __USER_DS
158 164
159#define GDT_ENTRY_TSS 8 /* needs two entries */ 165#define GDT_ENTRY_TSS 8 /* needs two entries */
@@ -175,6 +181,10 @@
175 181
176#endif 182#endif
177 183
184#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
185#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
186#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS* 8 + 3)
187#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS* 8 + 3)
178#ifndef CONFIG_PARAVIRT 188#ifndef CONFIG_PARAVIRT
179#define get_kernel_rpl() 0 189#define get_kernel_rpl() 0
180#endif 190#endif