Print this page
8956 Implement KPTI
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/i86pc/sys/machparam.h
+++ new/usr/src/uts/i86pc/sys/machparam.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 2015 by Delphix. All rights reserved.
24 - * Copyright 2016 Joyent, Inc.
24 + * Copyright 2018 Joyent, Inc.
25 25 */
26 26
27 27 /* Copyright (c) 1988 AT&T */
28 28 /* All Rights Reserved */
29 29
30 30
31 31 #ifndef _SYS_MACHPARAM_H
32 32 #define _SYS_MACHPARAM_H
33 33
34 34 #if !defined(_ASM)
35 35 #include <sys/types.h>
36 36
37 37 #if defined(__xpv)
38 38 #include <sys/xpv_impl.h>
39 39 #endif
40 40
41 41 #endif
42 42
43 43 #ifdef __cplusplus
44 44 extern "C" {
45 45 #endif
46 46
47 47 #ifndef _ASM
48 48 #define ADDRESS_C(c) c ## ul
49 49 #else /* _ASM */
50 50 #define ADDRESS_C(c) (c)
51 51 #endif /* _ASM */
52 52
53 53 /*
54 54 * Machine dependent parameters and limits.
55 55 */
56 56
57 57 #if defined(__amd64)
58 58 /*
59 59 * If NCPU grows beyond 256, sizing for the x86 comm page will require
60 60 * adjustment.
61 61 */
62 62 #define NCPU 256
63 63 #define NCPU_LOG2 8
64 64 #elif defined(__i386)
65 65 #define NCPU 32
66 66 #define NCPU_LOG2 5
67 67 #endif
68 68
69 69 /* NCPU_P2 is NCPU rounded to a power of 2 */
70 70 #define NCPU_P2 (1 << NCPU_LOG2)
71 71
72 72 /*
73 73 * The value defined below could grow to 16. hat structure and
74 74 * page_t have room for 16 nodes.
75 75 */
76 76 #define MAXNODES 4
77 77 #define NUMA_NODEMASK 0x0f
78 78
79 79 /*
80 80 * Define the FPU symbol if we could run on a machine with an external
81 81 * FPU (i.e. not integrated with the normal machine state like the vax).
82 82 *
83 83 * The fpu is defined in the architecture manual, and the kernel hides
84 84 * its absence if it is not present, that's pretty integrated, no?
85 85 */
86 86
87 87 /* supported page sizes */
88 88 #define MMU_PAGE_SIZES 3
89 89
90 90 /*
91 91 * MMU_PAGES* describes the physical page size used by the mapping hardware.
92 92 * PAGES* describes the logical page size used by the system.
93 93 */
94 94
95 95 #define MMU_PAGESIZE 0x1000 /* 4096 bytes */
96 96 #define MMU_PAGESHIFT 12 /* log2(MMU_PAGESIZE) */
97 97
98 98 #if !defined(_ASM)
99 99 #define MMU_PAGEOFFSET (MMU_PAGESIZE-1) /* Mask of address bits in page */
100 100 #else /* _ASM */
101 101 #define MMU_PAGEOFFSET _CONST(MMU_PAGESIZE-1) /* assembler lameness */
102 102 #endif /* _ASM */
103 103
104 104 #define MMU_PAGEMASK (~MMU_PAGEOFFSET)
105 105
106 106 #define PAGESIZE 0x1000 /* All of the above, for logical */
107 107 #define PAGESHIFT 12
108 108 #define PAGEOFFSET (PAGESIZE - 1)
109 109 #define PAGEMASK (~PAGEOFFSET)
110 110
111 111 /*
112 112 * DATA_ALIGN is used to define the alignment of the Unix data segment.
113 113 */
114 114 #define DATA_ALIGN PAGESIZE
115 115
116 116 /*
117 117 * DEFAULT KERNEL THREAD stack size (in pages).
118 118 */
119 119 #if defined(__amd64)
120 120 #define DEFAULTSTKSZ_NPGS 5
121 121 #elif defined(__i386)
122 122 #define DEFAULTSTKSZ_NPGS 3
123 123 #endif
124 124
125 125 #if !defined(_ASM)
126 126 #define DEFAULTSTKSZ (DEFAULTSTKSZ_NPGS * PAGESIZE)
127 127 #else /* !_ASM */
128 128 #define DEFAULTSTKSZ _MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */
129 129 #endif /* !_ASM */
130 130
131 131 /*
132 132 * KERNELBASE is the virtual address at which the kernel segments start in
133 133 * all contexts.
134 134 *
135 135 * KERNELBASE is not fixed. The value of KERNELBASE can change with
136 136 * installed memory or on 32 bit systems the eprom variable 'eprom_kernelbase'.
137 137 *
138 138 * common/conf/param.c requires a compile time defined value for KERNELBASE.
139 139 * This value is save in the variable _kernelbase. _kernelbase may then be
140 140 * modified with to a different value in i86pc/os/startup.c.
141 141 *
142 142 * Most code should be using kernelbase, which resolves to a reference to
143 143 * _kernelbase.
144 144 */
145 145 #define KERNEL_TEXT_amd64 UINT64_C(0xfffffffffb800000)
146 146
147 147 #ifdef __i386
148 148
149 149 #define KERNEL_TEXT_i386 ADDRESS_C(0xfe800000)
150 150
151 151 /*
152 152 * We don't use HYPERVISOR_VIRT_START, as we need both the PAE and non-PAE
153 153 * versions in our code. We always compile based on the lower PAE address.
154 154 */
155 155 #define KERNEL_TEXT_i386_xpv \
156 156 (HYPERVISOR_VIRT_START_PAE - 3 * ADDRESS_C(0x400000))
157 157
158 158 #endif /* __i386 */
159 159
160 160 #if defined(__amd64)
161 161
162 162 #define KERNELBASE ADDRESS_C(0xfffffd8000000000)
163 163
164 164 /*
165 165 * Size of the unmapped "red zone" at the very bottom of the kernel's
166 166 * address space. Corresponds to 1 slot in the toplevel pagetable.
167 167 */
168 168 #define KERNEL_REDZONE_SIZE ((uintptr_t)1 << 39)
169 169
170 170 /*
171 171 * Base of 'core' heap area, which is used for kernel and module text/data
172 172 * that must be within a 2GB range to allow for rip-relative addressing.
173 173 */
174 174 #define COREHEAP_BASE ADDRESS_C(0xffffffffc0000000)
175 175
176 176 /*
177 177 * Beginning of the segkpm window. A lower value than this is used if
178 178 * physical addresses exceed 1TB. See i86pc/os/startup.c
179 179 */
180 180 #define SEGKPM_BASE ADDRESS_C(0xfffffe0000000000)
181 181
182 182 /*
183 183 * This is valloc_base, above seg_kpm, but below everything else.
184 184 * A lower value than this may be used if SEGKPM_BASE is adjusted.
185 185 * See i86pc/os/startup.c
186 186 */
187 187 #define VALLOC_BASE ADDRESS_C(0xffffff0000000000)
188 188
189 189 /*
190 190 * default and boundary sizes for segkp
191 191 */
192 192 #define SEGKPDEFSIZE (2L * 1024L * 1024L * 1024L) /* 2G */
193 193 #define SEGKPMAXSIZE (8L * 1024L * 1024L * 1024L) /* 8G */
194 194 #define SEGKPMINSIZE (200L * 1024 * 1024L) /* 200M */
195 195
196 196 /*
197 197 * minimum size for segzio
198 198 */
199 199 #define SEGZIOMINSIZE (400L * 1024 * 1024L) /* 400M */
200 200
201 201 /*
202 202 * During intial boot we limit heap to the top 4Gig.
203 203 */
204 204 #define BOOT_KERNELHEAP_BASE ADDRESS_C(0xffffffff00000000)
205 205
206 206 /*
207 207 * VMWare works best if we don't use the top 64Meg of memory for amd64.
208 208 * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages.
209 209 */
210 210 #define PROMSTART ADDRESS_C(0xffc00000)
211 211 #define KERNEL_TEXT KERNEL_TEXT_amd64
212 212
213 213 /*
214 214 * Virtual address range available to the debugger
215 215 */
216 216 #define SEGDEBUGBASE ADDRESS_C(0xffffffffff800000)
217 217 #define SEGDEBUGSIZE ADDRESS_C(0x400000)
218 218
219 219 /*
220 220 * Define upper limit on user address space
221 221 *
222 222 * In amd64, the upper limit on a 64-bit user address space is 1 large page
223 223 * (2MB) below kernelbase. The upper limit for a 32-bit user address space
224 224 * is 1 small page (4KB) below the top of the 32-bit range. The 64-bit
225 225 * limit give dtrace the red zone it needs below kernelbase. The 32-bit
226 226 * limit gives us a small red zone to detect address-space overruns in a
227 227 * user program.
228 228 *
229 229 * On the hypervisor, we limit the user to memory below the VA hole.
230 230 * Subtract 1 large page for a red zone.
231 231 */
232 232 #if defined(__xpv)
233 233 #define USERLIMIT ADDRESS_C(0x00007fffffe00000)
234 234 #else
235 235 #define USERLIMIT ADDRESS_C(0xfffffd7fffe00000)
236 236 #endif
237 237
238 238 #ifdef bug_5074717_is_fixed
239 239 #define USERLIMIT32 ADDRESS_C(0xfffff000)
240 240 #else
241 241 #define USERLIMIT32 ADDRESS_C(0xfefff000)
242 242 #endif
243 243
244 244 #elif defined(__i386)
245 245
246 246 #ifdef DEBUG
247 247 #define KERNELBASE ADDRESS_C(0xc8000000)
248 248 #else
249 249 #define KERNELBASE ADDRESS_C(0xd4000000)
250 250 #endif
251 251
252 252 #define KERNELBASE_MAX ADDRESS_C(0xe0000000)
253 253
254 254 /*
255 255 * The i386 ABI requires that the user address space be at least 3Gb
256 256 * in size. KERNELBASE_ABI_MIN is used as the default KERNELBASE for
257 257 * physical memory configurations > 4gb.
258 258 */
259 259 #define KERNELBASE_ABI_MIN ADDRESS_C(0xc0000000)
260 260
261 261 /*
262 262 * Size of the unmapped "red zone" at the very bottom of the kernel's
263 263 * address space. Since segmap start immediately above the red zone, this
264 264 * needs to be MAXBSIZE aligned.
265 265 */
266 266 #define KERNEL_REDZONE_SIZE MAXBSIZE
267 267
268 268 /*
269 269 * This is the last 4MB of the 4G address space. Some psm modules
270 270 * need this region of virtual address space mapped 1-1
271 271 * The top 64MB of the address space is reserved for the hypervisor.
272 272 */
273 273 #define PROMSTART ADDRESS_C(0xffc00000)
274 274 #ifdef __xpv
275 275 #define KERNEL_TEXT KERNEL_TEXT_i386_xpv
276 276 #else
277 277 #define KERNEL_TEXT KERNEL_TEXT_i386
278 278 #endif
279 279
280 280 /*
281 281 * Virtual address range available to the debugger
282 282 * We place it just above the kernel text (4M) and kernel data (4M).
283 283 */
284 284 #define SEGDEBUGBASE (KERNEL_TEXT + ADDRESS_C(0x800000))
285 285 #define SEGDEBUGSIZE ADDRESS_C(0x400000)
↓ open down ↓ |
251 lines elided |
↑ open up ↑ |
286 286
287 287 /*
288 288 * Define upper limit on user address space
289 289 */
290 290 #define USERLIMIT KERNELBASE
291 291 #define USERLIMIT32 USERLIMIT
292 292
293 293 #endif /* __i386 */
294 294
295 295 /*
296 - * Reserve pages just below KERNEL_TEXT for the GDT, IDT, TSS and debug info.
296 + * Reserve pages just below KERNEL_TEXT for the GDT, IDT, LDT, TSS and debug
297 + * info.
297 298 *
298 299 * For now, DEBUG_INFO_VA must be first in this list for "xm" initiated dumps
299 300 * of solaris domUs to be usable with mdb. Relying on a fixed VA is not viable
300 301 * long term, but it's the best we've got for now.
301 302 */
302 303 #if !defined(_ASM)
303 304 #define DEBUG_INFO_VA (KERNEL_TEXT - MMU_PAGESIZE)
304 305 #define GDT_VA (DEBUG_INFO_VA - MMU_PAGESIZE)
305 306 #define IDT_VA (GDT_VA - MMU_PAGESIZE)
306 -#define KTSS_VA (IDT_VA - MMU_PAGESIZE)
307 +#define LDT_VA (IDT_VA - (16 * MMU_PAGESIZE))
308 +#define KTSS_VA (LDT_VA - MMU_PAGESIZE)
307 309 #define DFTSS_VA (KTSS_VA - MMU_PAGESIZE)
308 310 #define MISC_VA_BASE (DFTSS_VA)
309 311 #define MISC_VA_SIZE (KERNEL_TEXT - MISC_VA_BASE)
310 312 #endif /* !_ASM */
311 313
312 314 #if !defined(_ASM) && !defined(_KMDB)
313 315 extern uintptr_t kernelbase, segmap_start, segmapsize;
314 316 #endif
315 317
316 318 /*
317 319 * ARGSBASE is the base virtual address of the range which
318 320 * the kernel uses to map the arguments for exec.
319 321 */
320 322 #define ARGSBASE PROMSTART
321 323
322 324 /*
323 325 * reserve space for modules
324 326 */
325 327 #define MODTEXT (1024 * 1024 * 2)
326 328 #define MODDATA (1024 * 300)
327 329
328 330 /*
329 331 * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
330 332 * for module text.
331 333 */
332 334 #define HEAPTEXT_SIZE (64 * 1024 * 1024) /* bytes */
333 335
334 336 /*
335 337 * Size of a kernel threads stack. It must be a whole number of pages
336 338 * since the segment it comes from will only allocate space in pages.
337 339 */
338 340 #define T_STACKSZ 2*PAGESIZE
339 341
340 342 /*
341 343 * Size of a cpu startup thread stack. (It must be a whole number of pages
342 344 * since the containing segment only allocates space in pages.)
343 345 */
344 346
345 347 #define STARTUP_STKSZ 3*PAGESIZE
346 348
347 349 /*
348 350 * Bus types
349 351 */
350 352 #define BTISA 1
351 353 #define BTEISA 2
352 354 #define BTMCA 3
353 355
354 356 #ifdef __cplusplus
355 357 }
356 358 #endif
357 359
358 360 #endif /* _SYS_MACHPARAM_H */
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX