xref: /illumos-gate/usr/src/uts/i86pc/sys/machparam.h (revision a92282e44f968185a6bba094d1e5fece2da819cf)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
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.
25  */
26 
27 /*	Copyright (c) 1988 AT&T	*/
28 /*	  All Rights Reserved	*/
29 
30 
31 #ifndef _SYS_MACHPARAM_H
32 #define	_SYS_MACHPARAM_H
33 
34 #ifndef _ASM
35 
36 #include <sys/types.h>
37 
38 #if defined(__xpv)
39 #include <sys/xpv_impl.h>
40 #endif
41 
42 #endif /* !_ASM */
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 #ifndef _ASM
49 #define	ADDRESS_C(c)    c ## ul
50 #else   /* _ASM */
51 #define	ADDRESS_C(c)    (c)
52 #endif  /* _ASM */
53 
54 /*
55  * Machine dependent parameters and limits.
56  */
57 
58 /*
59  * If NCPU grows beyond 256, sizing for the x86 comm page will require
60  * adjustment.
61  */
62 #define	NCPU	256
63 #define	NCPU_LOG2	8
64 
65 /* NCPU_P2 is NCPU rounded to a power of 2 */
66 #define	NCPU_P2	(1 << NCPU_LOG2)
67 
68 /*
69  * The value defined below could grow to 16. hat structure and
70  * page_t have room for 16 nodes.
71  */
72 #define	MAXNODES 	4
73 #define	NUMA_NODEMASK	0x0f
74 
75 /*
76  * Define the FPU symbol if we could run on a machine with an external
77  * FPU (i.e. not integrated with the normal machine state like the vax).
78  *
79  * The fpu is defined in the architecture manual, and the kernel hides
80  * its absence if it is not present, that's pretty integrated, no?
81  */
82 
83 /* supported page sizes */
84 #define	MMU_PAGE_SIZES	3
85 
86 /*
87  * MMU_PAGES* describes the physical page size used by the mapping hardware.
88  * PAGES* describes the logical page size used by the system.
89  */
90 
91 #define	MMU_PAGESIZE	0x1000		/* 4096 bytes */
92 #define	MMU_PAGESHIFT	12		/* log2(MMU_PAGESIZE) */
93 
94 #if !defined(_ASM)
95 #define	MMU_PAGEOFFSET	(MMU_PAGESIZE-1) /* Mask of address bits in page */
96 #else	/* _ASM */
97 #define	MMU_PAGEOFFSET	_CONST(MMU_PAGESIZE-1)	/* assembler lameness */
98 #endif	/* _ASM */
99 
100 #define	MMU_PAGEMASK	(~MMU_PAGEOFFSET)
101 
102 #define	PAGESIZE	0x1000		/* All of the above, for logical */
103 #define	PAGESHIFT	12
104 #define	PAGEOFFSET	(PAGESIZE - 1)
105 #define	PAGEMASK	(~PAGEOFFSET)
106 
107 /*
108  * DATA_ALIGN is used to define the alignment of the Unix data segment.
109  */
110 #define	DATA_ALIGN	PAGESIZE
111 
112 /*
113  * DEFAULT KERNEL THREAD stack size (in pages).
114  */
115 #define	DEFAULTSTKSZ_NPGS	5
116 
117 #if !defined(_ASM)
118 #define	DEFAULTSTKSZ	(DEFAULTSTKSZ_NPGS * PAGESIZE)
119 #else	/* !_ASM */
120 #define	DEFAULTSTKSZ	_MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */
121 #endif	/* !_ASM */
122 
123 /*
124  * During intial boot we limit heap to the top 4Gig.
125  */
126 #define	BOOT_KERNELHEAP_BASE	ADDRESS_C(0xffffffff00000000)
127 
128 /*
129  * VMWare works best if we don't use the top 64Meg of memory for amd64.
130  * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages.
131  */
132 #define	PROMSTART	ADDRESS_C(0xffc00000)
133 
134 /*
135  * Virtual address range available to the debugger
136  */
137 #define	SEGDEBUGBASE	ADDRESS_C(0xffffffffff800000)
138 #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
139 
140 #define	KERNEL_TEXT	UINT64_C(0xfffffffffb800000)
141 
142 /*
143  * Reserve pages just below KERNEL_TEXT for the GDT, IDT, LDT, TSS and debug
144  * info.
145  *
146  * For now, DEBUG_INFO_VA must be first in this list for "xm" initiated dumps
147  * of solaris domUs to be usable with mdb. Relying on a fixed VA is not viable
148  * long term, but it's the best we've got for now.
149  */
150 #if !defined(_ASM)
151 #define	DEBUG_INFO_VA	(KERNEL_TEXT - MMU_PAGESIZE)
152 #define	GDT_VA		(DEBUG_INFO_VA - MMU_PAGESIZE)
153 #define	IDT_VA		(GDT_VA - MMU_PAGESIZE)
154 #define	LDT_VA		(IDT_VA - (16 * MMU_PAGESIZE))
155 #define	KTSS_VA		(LDT_VA - MMU_PAGESIZE)
156 #define	DFTSS_VA	(KTSS_VA - MMU_PAGESIZE)
157 #define	MISC_VA_BASE	(DFTSS_VA)
158 #define	MISC_VA_SIZE	(KERNEL_TEXT - MISC_VA_BASE)
159 #endif /* !_ASM */
160 
161 /*
162  * Base of 'core' heap area, which is used for kernel and module text/data
163  * that must be within a 2GB range to allow for rip-relative addressing.
164  */
165 #define	COREHEAP_BASE	ADDRESS_C(0xffffffffc0000000)
166 
167 /*
168  * This is valloc_base, above seg_kpm, but below everything else.
169  * A lower value than this may be used if SEGKPM_BASE is adjusted.
170  * See i86pc/os/startup.c
171  */
172 #define	VALLOC_BASE	ADDRESS_C(0xfffffe0000000000)
173 
174 #define	SEGZIOMINSIZE	(400L * 1024 * 1024L)			/* 400M */
175 #define	SEGVMMMINSIZE	(4096L * 1024 * 1024L)			/* 4G */
176 
177 #define	SEGKPDEFSIZE	(2L * 1024L * 1024L * 1024L)		/*   2G */
178 #define	SEGKPMAXSIZE	(8L * 1024L * 1024L * 1024L)		/*   8G */
179 #define	SEGKPMINSIZE	(200L * 1024 * 1024L)			/* 200M */
180 
181 #define	SEGKPM_BASE	ADDRESS_C(0xfffffd0000000000)
182 
183 /*
184  * KERNELBASE is the virtual address at which the kernel segments start in
185  * all contexts.
186  *
187  * KERNELBASE is not fixed.  The value of KERNELBASE can change with
188  * installed memory size.
189  *
190  * common/conf/param.c requires a compile time defined value for KERNELBASE.
191  * This value is save in the variable _kernelbase.  _kernelbase may then be
192  * modified with to a different value in i86pc/os/startup.c.
193  *
194  * Most code should be using kernelbase, which resolves to a reference to
195  * _kernelbase.
196  */
197 #define	KERNELBASE	ADDRESS_C(0xfffffc8000000000)
198 
199 /*
200  * Size of the unmapped "red zone" at the very bottom of the kernel's
201  * address space.  Corresponds to 1 slot in the toplevel pagetable.
202  */
203 #define	KERNEL_REDZONE_SIZE   ((uintptr_t)1 << 39)
204 
205 /*
206  * Define upper limit on user address space
207  *
208  * The upper limit on a 64-bit user address space is 1 large page
209  * (2MB) below kernelbase.  The upper limit for a 32-bit user address space
210  * is 1 small page (4KB) below the top of the 32-bit range.  The 64-bit
211  * limit give dtrace the red zone it needs below kernelbase.  The 32-bit
212  * limit gives us a small red zone to detect address-space overruns in a
213  * user program.
214  *
215  * On the hypervisor, we limit the user to memory below the VA hole.
216  * Subtract 1 large page for a red zone.
217  */
218 #if defined(__xpv)
219 #define	USERLIMIT	ADDRESS_C(0x00007fffffe00000)
220 #else
221 #define	USERLIMIT	ADDRESS_C(0xfffffc7fffe00000)
222 #endif
223 
224 #ifdef bug_5074717_is_fixed
225 #define	USERLIMIT32	ADDRESS_C(0xfffff000)
226 #else
227 #define	USERLIMIT32	ADDRESS_C(0xfefff000)
228 #endif
229 
230 #if !defined(_ASM) && !defined(_KMDB)
231 extern uintptr_t kernelbase, segmap_start, segmapsize;
232 #endif
233 
234 /*
235  * ARGSBASE is the base virtual address of the range which
236  * the kernel uses to map the arguments for exec.
237  */
238 #define	ARGSBASE	PROMSTART
239 
240 /*
241  * reserve space for modules
242  */
243 #define	MODTEXT	(1024 * 1024 * 2)
244 #define	MODDATA	(1024 * 300)
245 
246 /*
247  * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
248  * for module text.
249  */
250 #define	HEAPTEXT_SIZE		(64 * 1024 * 1024)	/* bytes */
251 
252 /*
253  * Size of a kernel threads stack.  It must be a whole number of pages
254  * since the segment it comes from will only allocate space in pages.
255  */
256 #define	T_STACKSZ	2*PAGESIZE
257 
258 /*
259  * Size of a cpu startup thread stack.  (It must be a whole number of pages
260  * since the containing segment only allocates space in pages.)
261  */
262 
263 #define	STARTUP_STKSZ	3*PAGESIZE
264 
265 /*
266  * Bus types
267  */
268 #define	BTISA		1
269 #define	BTEISA		2
270 #define	BTMCA		3
271 
272 #ifdef	__cplusplus
273 }
274 #endif
275 
276 #endif	/* _SYS_MACHPARAM_H */
277