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 * Use a slightly larger thread stack size for interrupt threads rather than 125 * the default. This is useful for cases where the networking stack may do an 126 * rx and a tx in the context of a single interrupt and when combined with 127 * various promisc hooks that need memory, can cause us to get dangerously 128 * close to the edge of the traditional stack sizes. This is only a few pages 129 * more than a traditional stack and given that we don't have that many 130 * interrupt threads, the memory costs end up being more than worthwhile. 131 */ 132 #define LL_INTR_STKSZ_NPGS 8 133 #define LL_INTR_STKSZ (LL_INTR_STKSZ_NPGS * PAGESIZE) 134 135 /* 136 * During intial boot we limit heap to the top 4Gig. 137 */ 138 #define BOOT_KERNELHEAP_BASE ADDRESS_C(0xffffffff00000000) 139 140 /* 141 * VMWare works best if we don't use the top 64Meg of memory for amd64. 142 * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages. 143 */ 144 #define PROMSTART ADDRESS_C(0xffc00000) 145 146 /* 147 * Virtual address range available to the debugger 148 */ 149 #define SEGDEBUGBASE ADDRESS_C(0xffffffffff800000) 150 #define SEGDEBUGSIZE ADDRESS_C(0x400000) 151 152 #define KERNEL_TEXT UINT64_C(0xfffffffffb800000) 153 154 /* 155 * Reserve pages just below KERNEL_TEXT for the GDT, IDT, LDT, TSS and debug 156 * info. 157 * 158 * For now, DEBUG_INFO_VA must be first in this list for "xm" initiated dumps 159 * of solaris domUs to be usable with mdb. Relying on a fixed VA is not viable 160 * long term, but it's the best we've got for now. 161 */ 162 #if !defined(_ASM) 163 #define DEBUG_INFO_VA (KERNEL_TEXT - MMU_PAGESIZE) 164 #define GDT_VA (DEBUG_INFO_VA - MMU_PAGESIZE) 165 #define IDT_VA (GDT_VA - MMU_PAGESIZE) 166 #define LDT_VA (IDT_VA - (16 * MMU_PAGESIZE)) 167 #define KTSS_VA (LDT_VA - MMU_PAGESIZE) 168 #define DFTSS_VA (KTSS_VA - MMU_PAGESIZE) 169 #define MISC_VA_BASE (DFTSS_VA) 170 #define MISC_VA_SIZE (KERNEL_TEXT - MISC_VA_BASE) 171 #endif /* !_ASM */ 172 173 /* 174 * Base of 'core' heap area, which is used for kernel and module text/data 175 * that must be within a 2GB range to allow for rip-relative addressing. 176 */ 177 #define COREHEAP_BASE ADDRESS_C(0xffffffffc0000000) 178 179 /* 180 * This is valloc_base, above seg_kpm, but below everything else. 181 * A lower value than this may be used if SEGKPM_BASE is adjusted. 182 * See i86pc/os/startup.c 183 */ 184 #define VALLOC_BASE ADDRESS_C(0xfffffe0000000000) 185 186 #define SEGZIOMINSIZE (400L * 1024 * 1024L) /* 400M */ 187 #define SEGVMMMINSIZE (4096L * 1024 * 1024L) /* 4G */ 188 189 #define SEGKPDEFSIZE (2L * 1024L * 1024L * 1024L) /* 2G */ 190 #define SEGKPMAXSIZE (8L * 1024L * 1024L * 1024L) /* 8G */ 191 #define SEGKPMINSIZE (200L * 1024 * 1024L) /* 200M */ 192 193 #define SEGKPM_BASE ADDRESS_C(0xfffffd0000000000) 194 195 /* 196 * KERNELBASE is the virtual address at which the kernel segments start in 197 * all contexts. 198 * 199 * KERNELBASE is not fixed. The value of KERNELBASE can change with 200 * installed memory size. 201 * 202 * common/conf/param.c requires a compile time defined value for KERNELBASE. 203 * This value is save in the variable _kernelbase. _kernelbase may then be 204 * modified with to a different value in i86pc/os/startup.c. 205 * 206 * Most code should be using kernelbase, which resolves to a reference to 207 * _kernelbase. 208 */ 209 #define KERNELBASE ADDRESS_C(0xfffffc8000000000) 210 211 /* 212 * Size of the unmapped "red zone" at the very bottom of the kernel's 213 * address space. Corresponds to 1 slot in the toplevel pagetable. 214 */ 215 #define KERNEL_REDZONE_SIZE ((uintptr_t)1 << 39) 216 217 /* 218 * Define upper limit on user address space 219 * 220 * The upper limit on a 64-bit user address space is 1 large page 221 * (2MB) below kernelbase. The upper limit for a 32-bit user address space 222 * is 1 small page (4KB) below the top of the 32-bit range. The 64-bit 223 * limit give dtrace the red zone it needs below kernelbase. The 32-bit 224 * limit gives us a small red zone to detect address-space overruns in a 225 * user program. 226 * 227 * On the hypervisor, we limit the user to memory below the VA hole. 228 * Subtract 1 large page for a red zone. 229 */ 230 #if defined(__xpv) 231 #define USERLIMIT ADDRESS_C(0x00007fffffe00000) 232 #else 233 #define USERLIMIT ADDRESS_C(0xfffffc7fffe00000) 234 #endif 235 236 #ifdef bug_5074717_is_fixed 237 #define USERLIMIT32 ADDRESS_C(0xfffff000) 238 #else 239 #define USERLIMIT32 ADDRESS_C(0xfefff000) 240 #endif 241 242 #if !defined(_ASM) && !defined(_KMDB) 243 extern uintptr_t kernelbase, segmap_start, segmapsize; 244 #endif 245 246 /* 247 * ARGSBASE is the base virtual address of the range which 248 * the kernel uses to map the arguments for exec. 249 */ 250 #define ARGSBASE PROMSTART 251 252 /* 253 * reserve space for modules 254 */ 255 #define MODTEXT (1024 * 1024 * 2) 256 #define MODDATA (1024 * 300) 257 258 /* 259 * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically 260 * for module text. 261 */ 262 #define HEAPTEXT_SIZE (128 * 1024 * 1024) /* bytes */ 263 264 /* 265 * Size of a kernel threads stack. It must be a whole number of pages 266 * since the segment it comes from will only allocate space in pages. 267 */ 268 #define T_STACKSZ 2*PAGESIZE 269 270 /* 271 * Size of a cpu startup thread stack. (It must be a whole number of pages 272 * since the containing segment only allocates space in pages.) 273 */ 274 275 #define STARTUP_STKSZ 3*PAGESIZE 276 277 /* 278 * Bus types 279 */ 280 #define BTISA 1 281 #define BTEISA 2 282 #define BTMCA 3 283 284 #ifdef __cplusplus 285 } 286 #endif 287 288 #endif /* _SYS_MACHPARAM_H */ 289