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