xref: /illumos-gate/usr/src/uts/i86pc/sys/machparam.h (revision 044da6e1a8d008f558b8a0a17f173f2483276900)
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 
74 /* supported page sizes */
75 #define	MMU_PAGE_SIZES	3
76 
77 /*
78  * MMU_PAGES* describes the physical page size used by the mapping hardware.
79  * PAGES* describes the logical page size used by the system.
80  */
81 
82 #define	MMU_PAGESIZE	0x1000		/* 4096 bytes */
83 #define	MMU_PAGESHIFT	12		/* log2(MMU_PAGESIZE) */
84 
85 #if !defined(_ASM)
86 #define	MMU_PAGEOFFSET	(MMU_PAGESIZE-1) /* Mask of address bits in page */
87 #else	/* _ASM */
88 #define	MMU_PAGEOFFSET	_CONST(MMU_PAGESIZE-1)	/* assembler lameness */
89 #endif	/* _ASM */
90 
91 #define	MMU_PAGEMASK	(~MMU_PAGEOFFSET)
92 
93 #define	PAGESIZE	0x1000		/* All of the above, for logical */
94 #define	PAGESHIFT	12
95 #define	PAGEOFFSET	(PAGESIZE - 1)
96 #define	PAGEMASK	(~PAGEOFFSET)
97 
98 /*
99  * DATA_ALIGN is used to define the alignment of the Unix data segment.
100  */
101 #define	DATA_ALIGN	PAGESIZE
102 
103 /*
104  * DEFAULT KERNEL THREAD stack size (in pages).
105  */
106 #define	DEFAULTSTKSZ_NPGS	5
107 
108 #if !defined(_ASM)
109 #define	DEFAULTSTKSZ	(DEFAULTSTKSZ_NPGS * PAGESIZE)
110 #else	/* !_ASM */
111 #define	DEFAULTSTKSZ	_MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */
112 #endif	/* !_ASM */
113 
114 /*
115  * Use a slightly larger thread stack size for interrupt threads rather than
116  * the default. This is useful for cases where the networking stack may do an
117  * rx and a tx in the context of a single interrupt and when combined with
118  * various promisc hooks that need memory, can cause us to get dangerously
119  * close to the edge of the traditional stack sizes. This is only a few pages
120  * more than a traditional stack and given that we don't have that many
121  * interrupt threads, the memory costs end up being more than worthwhile.
122  */
123 #define	LL_INTR_STKSZ_NPGS	8
124 #define	LL_INTR_STKSZ		(LL_INTR_STKSZ_NPGS * PAGESIZE)
125 
126 /*
127  * Virtual address range available to the debugger
128  */
129 #define	SEGDEBUGBASE	ADDRESS_C(0xffffffffff800000)
130 #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
131 
132 #define	KERNEL_TEXT	UINT64_C(0xfffffffffb800000)
133 
134 /*
135  * Reserve pages just below KERNEL_TEXT for the GDT, IDT, LDT, TSS and debug
136  * info.
137  *
138  * For now, DEBUG_INFO_VA must be first in this list for "xm" initiated dumps
139  * of solaris domUs to be usable with mdb. Relying on a fixed VA is not viable
140  * long term, but it's the best we've got for now.
141  */
142 #if !defined(_ASM)
143 #define	DEBUG_INFO_VA	(KERNEL_TEXT - MMU_PAGESIZE)
144 #define	GDT_VA		(DEBUG_INFO_VA - MMU_PAGESIZE)
145 #define	IDT_VA		(GDT_VA - MMU_PAGESIZE)
146 #define	LDT_VA		(IDT_VA - (16 * MMU_PAGESIZE))
147 #define	KTSS_VA		(LDT_VA - MMU_PAGESIZE)
148 #define	DFTSS_VA	(KTSS_VA - MMU_PAGESIZE)
149 #define	MISC_VA_BASE	(DFTSS_VA)
150 #define	MISC_VA_SIZE	(KERNEL_TEXT - MISC_VA_BASE)
151 #endif /* !_ASM */
152 
153 /*
154  * Base of 'core' heap area, which is used for kernel and module text/data
155  * that must be within a 2GB range to allow for rip-relative addressing.
156  */
157 #define	COREHEAP_BASE	ADDRESS_C(0xffffffffc0000000)
158 
159 /*
160  * This is valloc_base, above seg_kpm, but below everything else.
161  * A lower value than this may be used if SEGKPM_BASE is adjusted.
162  * See i86pc/os/startup.c
163  */
164 #define	VALLOC_BASE	ADDRESS_C(0xfffffe0000000000)
165 
166 #define	SEGZIOMINSIZE	(400L * 1024 * 1024L)			/* 400M */
167 #define	SEGVMMMINSIZE	(4096L * 1024 * 1024L)			/* 4G */
168 
169 #define	SEGKPDEFSIZE	(2L * 1024L * 1024L * 1024L)		/*   2G */
170 #define	SEGKPMAXSIZE	(8L * 1024L * 1024L * 1024L)		/*   8G */
171 #define	SEGKPMINSIZE	(200L * 1024 * 1024L)			/* 200M */
172 
173 #define	SEGKPM_BASE	ADDRESS_C(0xfffffd0000000000)
174 
175 /*
176  * KERNELBASE is the virtual address at which the kernel segments start in
177  * all contexts.
178  *
179  * KERNELBASE is not fixed.  The value of KERNELBASE can change with
180  * installed memory size.
181  *
182  * common/conf/param.c requires a compile time defined value for KERNELBASE.
183  * This value is save in the variable _kernelbase.  _kernelbase may then be
184  * modified with to a different value in i86pc/os/startup.c.
185  *
186  * Most code should be using kernelbase, which resolves to a reference to
187  * _kernelbase.
188  */
189 #define	KERNELBASE	ADDRESS_C(0xfffffc8000000000)
190 
191 /*
192  * Size of the unmapped "red zone" at the very bottom of the kernel's
193  * address space.  Corresponds to 1 slot in the toplevel pagetable.
194  */
195 #define	KERNEL_REDZONE_SIZE   ((uintptr_t)1 << 39)
196 
197 /*
198  * Define upper limit on user address space
199  *
200  * The upper limit on a 64-bit user address space is 1 large page
201  * (2MB) below kernelbase.  The upper limit for a 32-bit user address space
202  * is 1 small page (4KB) below the top of the 32-bit range.  The 64-bit
203  * limit give dtrace the red zone it needs below kernelbase.  The 32-bit
204  * limit gives us a small red zone to detect address-space overruns in a
205  * user program.
206  *
207  * On the hypervisor, we limit the user to memory below the VA hole.
208  * Subtract 1 large page for a red zone.
209  */
210 #if defined(__xpv)
211 #define	USERLIMIT	ADDRESS_C(0x00007fffffe00000)
212 #else
213 #define	USERLIMIT	ADDRESS_C(0xfffffc7fffe00000)
214 #endif
215 
216 #ifdef bug_5074717_is_fixed
217 #define	USERLIMIT32	ADDRESS_C(0xfffff000)
218 #else
219 #define	USERLIMIT32	ADDRESS_C(0xfefff000)
220 #endif
221 
222 #if !defined(_ASM) && !defined(_KMDB)
223 extern uintptr_t kernelbase, segmap_start, segmapsize;
224 #endif
225 
226 /*
227  * reserve space for modules
228  */
229 #define	MODTEXT	(1024 * 1024 * 2)
230 #define	MODDATA	(1024 * 300)
231 
232 /*
233  * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
234  * for module text.
235  */
236 #define	HEAPTEXT_SIZE		(128 * 1024 * 1024)	/* bytes */
237 
238 /*
239  * Bus types
240  */
241 #define	BTISA		1
242 #define	BTEISA		2
243 
244 #ifdef	__cplusplus
245 }
246 #endif
247 
248 #endif	/* _SYS_MACHPARAM_H */
249