H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_SEGMENT_H |
| 2 | #define _ASM_X86_SEGMENT_H |
Glauber de Oliveira Costa | cef1895 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 3 | |
H. Peter Anvin | 014eea5 | 2011-02-14 18:33:55 -0800 | [diff] [blame] | 4 | #include <linux/const.h> |
| 5 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 6 | /* |
| 7 | * Constructor for a conventional segment GDT (or LDT) entry. |
| 8 | * This is a macro so it can be used in initializers. |
| 9 | */ |
H. Peter Anvin | 4fdf08b | 2008-07-17 11:29:24 -0700 | [diff] [blame] | 10 | #define GDT_ENTRY(flags, base, limit) \ |
H. Peter Anvin | 014eea5 | 2011-02-14 18:33:55 -0800 | [diff] [blame] | 11 | ((((base) & _AC(0xff000000,ULL)) << (56-24)) | \ |
| 12 | (((flags) & _AC(0x0000f0ff,ULL)) << 40) | \ |
| 13 | (((limit) & _AC(0x000f0000,ULL)) << (48-16)) | \ |
| 14 | (((base) & _AC(0x00ffffff,ULL)) << 16) | \ |
| 15 | (((limit) & _AC(0x0000ffff,ULL)))) |
H. Peter Anvin | 4fdf08b | 2008-07-17 11:29:24 -0700 | [diff] [blame] | 16 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 17 | /* Simple and small GDT entries for booting only: */ |
H. Peter Anvin | 2a6648e | 2008-01-30 13:33:01 +0100 | [diff] [blame] | 18 | |
| 19 | #define GDT_ENTRY_BOOT_CS 2 |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 20 | #define GDT_ENTRY_BOOT_DS 3 |
| 21 | #define GDT_ENTRY_BOOT_TSS 4 |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 22 | #define __BOOT_CS (GDT_ENTRY_BOOT_CS*8) |
| 23 | #define __BOOT_DS (GDT_ENTRY_BOOT_DS*8) |
| 24 | #define __BOOT_TSS (GDT_ENTRY_BOOT_TSS*8) |
H. Peter Anvin | 8808951 | 2008-01-30 13:33:02 +0100 | [diff] [blame] | 25 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 26 | /* |
| 27 | * Bottom two bits of selector give the ring |
| 28 | * privilege level |
| 29 | */ |
| 30 | #define SEGMENT_RPL_MASK 0x3 |
| 31 | |
| 32 | /* User mode is privilege level 3: */ |
| 33 | #define USER_RPL 0x3 |
| 34 | |
| 35 | /* Bit 2 is Table Indicator (TI): selects between LDT or GDT */ |
| 36 | #define SEGMENT_TI_MASK 0x4 |
| 37 | /* LDT segment has TI set ... */ |
| 38 | #define SEGMENT_LDT 0x4 |
| 39 | /* ... GDT has it cleared */ |
| 40 | #define SEGMENT_GDT 0x0 |
Borislav Petkov | be9d173 | 2014-12-09 13:25:59 +0100 | [diff] [blame] | 41 | |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 42 | #ifdef CONFIG_X86_32 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 43 | /* |
| 44 | * The layout of the per-CPU GDT under Linux: |
| 45 | * |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 46 | * 0 - null <=== cacheline #1 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 47 | * 1 - reserved |
| 48 | * 2 - reserved |
| 49 | * 3 - reserved |
| 50 | * |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 51 | * 4 - unused <=== cacheline #2 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 52 | * 5 - unused |
| 53 | * |
| 54 | * ------- start of TLS (Thread-Local Storage) segments: |
| 55 | * |
| 56 | * 6 - TLS segment #1 [ glibc's TLS segment ] |
| 57 | * 7 - TLS segment #2 [ Wine's %fs Win32 segment ] |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 58 | * 8 - TLS segment #3 <=== cacheline #3 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 59 | * 9 - reserved |
| 60 | * 10 - reserved |
| 61 | * 11 - reserved |
| 62 | * |
| 63 | * ------- start of kernel segments: |
| 64 | * |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 65 | * 12 - kernel code segment <=== cacheline #4 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 66 | * 13 - kernel data segment |
| 67 | * 14 - default user CS |
| 68 | * 15 - default user DS |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 69 | * 16 - TSS <=== cacheline #5 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 70 | * 17 - LDT |
| 71 | * 18 - PNPBIOS support (16->32 gate) |
| 72 | * 19 - PNPBIOS support |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 73 | * 20 - PNPBIOS support <=== cacheline #6 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 74 | * 21 - PNPBIOS support |
| 75 | * 22 - PNPBIOS support |
| 76 | * 23 - APM BIOS support |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 77 | * 24 - APM BIOS support <=== cacheline #7 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 78 | * 25 - APM BIOS support |
| 79 | * |
| 80 | * 26 - ESPFIX small SS |
| 81 | * 27 - per-cpu [ offset to per-cpu data area ] |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 82 | * 28 - stack_canary-20 [ for stack protector ] <=== cacheline #8 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 83 | * 29 - unused |
| 84 | * 30 - unused |
| 85 | * 31 - TSS for double fault handler |
| 86 | */ |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 87 | #define GDT_ENTRY_TLS_MIN 6 |
| 88 | #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 89 | |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 90 | #define GDT_ENTRY_KERNEL_CS 12 |
| 91 | #define GDT_ENTRY_KERNEL_DS 13 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 92 | #define GDT_ENTRY_DEFAULT_USER_CS 14 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 93 | #define GDT_ENTRY_DEFAULT_USER_DS 15 |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 94 | #define GDT_ENTRY_TSS 16 |
| 95 | #define GDT_ENTRY_LDT 17 |
| 96 | #define GDT_ENTRY_PNPBIOS_CS32 18 |
| 97 | #define GDT_ENTRY_PNPBIOS_CS16 19 |
| 98 | #define GDT_ENTRY_PNPBIOS_DS 20 |
| 99 | #define GDT_ENTRY_PNPBIOS_TS1 21 |
| 100 | #define GDT_ENTRY_PNPBIOS_TS2 22 |
| 101 | #define GDT_ENTRY_APMBIOS_BASE 23 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 102 | |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 103 | #define GDT_ENTRY_ESPFIX_SS 26 |
| 104 | #define GDT_ENTRY_PERCPU 27 |
| 105 | #define GDT_ENTRY_STACK_CANARY 28 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 106 | |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 107 | #define GDT_ENTRY_DOUBLEFAULT_TSS 31 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 108 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 109 | /* |
| 110 | * Number of entries in the GDT table: |
| 111 | */ |
| 112 | #define GDT_ENTRIES 32 |
| 113 | |
| 114 | /* |
| 115 | * Segment selector values corresponding to the above entries: |
| 116 | */ |
| 117 | |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 118 | #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8) |
| 119 | #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8) |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 120 | #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3) |
| 121 | #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8 + 3) |
Jan Beulich | 3234282 | 2010-10-19 14:52:26 +0100 | [diff] [blame] | 122 | #define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS*8) |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 123 | |
| 124 | /* segment for calling fn: */ |
| 125 | #define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32*8) |
| 126 | /* code segment for BIOS: */ |
| 127 | #define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16*8) |
| 128 | |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 129 | /* "Is this PNP code selector (PNP_CS32 or PNP_CS16)?" */ |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 130 | #define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == PNP_CS32) |
| 131 | |
| 132 | /* data segment for BIOS: */ |
| 133 | #define PNP_DS (GDT_ENTRY_PNPBIOS_DS*8) |
| 134 | /* transfer data segment: */ |
| 135 | #define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1*8) |
| 136 | /* another data segment: */ |
| 137 | #define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2*8) |
| 138 | |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 139 | #ifdef CONFIG_SMP |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 140 | # define __KERNEL_PERCPU (GDT_ENTRY_PERCPU*8) |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 141 | #else |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 142 | # define __KERNEL_PERCPU 0 |
Tejun Heo | 60a5317 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 143 | #endif |
| 144 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 145 | #ifdef CONFIG_CC_STACKPROTECTOR |
| 146 | # define __KERNEL_STACK_CANARY (GDT_ENTRY_STACK_CANARY*8) |
| 147 | #else |
| 148 | # define __KERNEL_STACK_CANARY 0 |
| 149 | #endif |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 150 | |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 151 | #else /* 64-bit: */ |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 152 | |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 153 | #include <asm/cache.h> |
| 154 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 155 | #define GDT_ENTRY_KERNEL32_CS 1 |
| 156 | #define GDT_ENTRY_KERNEL_CS 2 |
| 157 | #define GDT_ENTRY_KERNEL_DS 3 |
| 158 | |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 159 | /* |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 160 | * We cannot use the same code segment descriptor for user and kernel mode, |
| 161 | * not even in long flat mode, because of different DPL. |
| 162 | * |
| 163 | * GDT layout to get 64-bit SYSCALL/SYSRET support right. SYSRET hardcodes |
| 164 | * selectors: |
| 165 | * |
| 166 | * if returning to 32-bit userspace: cs = STAR.SYSRET_CS, |
| 167 | * if returning to 64-bit userspace: cs = STAR.SYSRET_CS+16, |
| 168 | * |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 169 | * ss = STAR.SYSRET_CS+8 (in either case) |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 170 | * |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 171 | * thus USER_DS should be between 32-bit and 64-bit code selectors: |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 172 | */ |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 173 | #define GDT_ENTRY_DEFAULT_USER32_CS 4 |
| 174 | #define GDT_ENTRY_DEFAULT_USER_DS 5 |
| 175 | #define GDT_ENTRY_DEFAULT_USER_CS 6 |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 176 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 177 | /* Needs two entries */ |
| 178 | #define GDT_ENTRY_TSS 8 |
| 179 | /* Needs two entries */ |
| 180 | #define GDT_ENTRY_LDT 10 |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 181 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 182 | #define GDT_ENTRY_TLS_MIN 12 |
| 183 | #define GDT_ENTRY_TLS_MAX 14 |
Denys Vlasenko | 84f5378 | 2015-03-22 22:01:12 +0100 | [diff] [blame] | 184 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 185 | /* Abused to load per CPU data from limit */ |
| 186 | #define GDT_ENTRY_PER_CPU 15 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 187 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 188 | /* |
| 189 | * Number of entries in the GDT table: |
| 190 | */ |
| 191 | #define GDT_ENTRIES 16 |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 192 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 193 | /* |
| 194 | * Segment selector values corresponding to the above entries: |
| 195 | * |
| 196 | * Note, selectors also need to have a correct RPL, |
| 197 | * expressed with the +3 value for user-space selectors: |
| 198 | */ |
| 199 | #define __KERNEL32_CS (GDT_ENTRY_KERNEL32_CS*8) |
| 200 | #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8) |
| 201 | #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8) |
| 202 | #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8 + 3) |
| 203 | #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3) |
| 204 | #define __USER32_DS __USER_DS |
| 205 | #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8 + 3) |
| 206 | #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU*8 + 3) |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 207 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 208 | /* TLS indexes for 64-bit - hardcoded in arch_prctl(): */ |
| 209 | #define FS_TLS 0 |
| 210 | #define GS_TLS 1 |
| 211 | |
| 212 | #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3) |
| 213 | #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3) |
Glauber de Oliveira Costa | b23be39 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 214 | |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 215 | #endif |
Glauber de Oliveira Costa | cef1895 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 216 | |
| 217 | #ifndef CONFIG_PARAVIRT |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 218 | # define get_kernel_rpl() 0 |
Glauber de Oliveira Costa | cef1895 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 219 | #endif |
| 220 | |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 221 | #define IDT_ENTRIES 256 |
| 222 | #define NUM_EXCEPTION_VECTORS 32 |
| 223 | |
| 224 | /* Bitmask of exception vectors which push an error code on the stack: */ |
| 225 | #define EXCEPTION_ERRCODE_MASK 0x00027d00 |
| 226 | |
| 227 | #define GDT_SIZE (GDT_ENTRIES*8) |
| 228 | #define GDT_ENTRY_TLS_ENTRIES 3 |
| 229 | #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES* 8) |
Glauber de Oliveira Costa | 15ee09b | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 230 | |
Roland McGrath | 8866cd9 | 2008-01-30 13:33:06 +0100 | [diff] [blame] | 231 | #ifdef __KERNEL__ |
| 232 | #ifndef __ASSEMBLY__ |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 233 | |
H. Peter Anvin | 9900aa2 | 2012-04-18 17:16:49 -0700 | [diff] [blame] | 234 | extern const char early_idt_handlers[NUM_EXCEPTION_VECTORS][2+2+5]; |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 235 | #ifdef CONFIG_TRACING |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 236 | # define trace_early_idt_handlers early_idt_handlers |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 237 | #endif |
David Howells | f05e798 | 2012-03-28 18:11:12 +0100 | [diff] [blame] | 238 | |
| 239 | /* |
| 240 | * Load a segment. Fall back on loading the zero |
| 241 | * segment if something goes wrong.. |
| 242 | */ |
| 243 | #define loadsegment(seg, value) \ |
| 244 | do { \ |
| 245 | unsigned short __val = (value); \ |
| 246 | \ |
| 247 | asm volatile(" \n" \ |
| 248 | "1: movl %k0,%%" #seg " \n" \ |
| 249 | \ |
| 250 | ".section .fixup,\"ax\" \n" \ |
| 251 | "2: xorl %k0,%k0 \n" \ |
| 252 | " jmp 1b \n" \ |
| 253 | ".previous \n" \ |
| 254 | \ |
| 255 | _ASM_EXTABLE(1b, 2b) \ |
| 256 | \ |
| 257 | : "+r" (__val) : : "memory"); \ |
| 258 | } while (0) |
| 259 | |
| 260 | /* |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 261 | * Save a segment register away: |
David Howells | f05e798 | 2012-03-28 18:11:12 +0100 | [diff] [blame] | 262 | */ |
| 263 | #define savesegment(seg, value) \ |
| 264 | asm("mov %%" #seg ",%0":"=r" (value) : : "memory") |
| 265 | |
| 266 | /* |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 267 | * x86-32 user GS accessors: |
David Howells | f05e798 | 2012-03-28 18:11:12 +0100 | [diff] [blame] | 268 | */ |
| 269 | #ifdef CONFIG_X86_32 |
Ingo Molnar | 72d64cc | 2015-03-24 20:45:42 +0100 | [diff] [blame^] | 270 | # ifdef CONFIG_X86_32_LAZY_GS |
| 271 | # define get_user_gs(regs) (u16)({ unsigned long v; savesegment(gs, v); v; }) |
| 272 | # define set_user_gs(regs, v) loadsegment(gs, (unsigned long)(v)) |
| 273 | # define task_user_gs(tsk) ((tsk)->thread.gs) |
| 274 | # define lazy_save_gs(v) savesegment(gs, (v)) |
| 275 | # define lazy_load_gs(v) loadsegment(gs, (v)) |
| 276 | # else /* X86_32_LAZY_GS */ |
| 277 | # define get_user_gs(regs) (u16)((regs)->gs) |
| 278 | # define set_user_gs(regs, v) do { (regs)->gs = (v); } while (0) |
| 279 | # define task_user_gs(tsk) (task_pt_regs(tsk)->gs) |
| 280 | # define lazy_save_gs(v) do { } while (0) |
| 281 | # define lazy_load_gs(v) do { } while (0) |
| 282 | # endif /* X86_32_LAZY_GS */ |
David Howells | f05e798 | 2012-03-28 18:11:12 +0100 | [diff] [blame] | 283 | #endif /* X86_32 */ |
| 284 | |
David Howells | f05e798 | 2012-03-28 18:11:12 +0100 | [diff] [blame] | 285 | #endif /* !__ASSEMBLY__ */ |
| 286 | #endif /* __KERNEL__ */ |
Roland McGrath | 8866cd9 | 2008-01-30 13:33:06 +0100 | [diff] [blame] | 287 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 288 | #endif /* _ASM_X86_SEGMENT_H */ |