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