10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52006Sandrei * Common Development and Distribution License (the "License"). 62006Sandrei * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 2212173SMichael.Corcoran@Sun.COM * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 260Sstevel@tonic-gate /* All Rights Reserved */ 270Sstevel@tonic-gate 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifndef _SYS_MACHPARAM_H 300Sstevel@tonic-gate #define _SYS_MACHPARAM_H 310Sstevel@tonic-gate 322006Sandrei #if !defined(_ASM) 330Sstevel@tonic-gate #include <sys/types.h> 345084Sjohnlev 355084Sjohnlev #if defined(__xpv) 365084Sjohnlev #include <sys/xpv_impl.h> 375084Sjohnlev #endif 385084Sjohnlev 392006Sandrei #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifdef __cplusplus 420Sstevel@tonic-gate extern "C" { 430Sstevel@tonic-gate #endif 440Sstevel@tonic-gate 450Sstevel@tonic-gate #ifndef _ASM 460Sstevel@tonic-gate #define ADDRESS_C(c) c ## ul 470Sstevel@tonic-gate #else /* _ASM */ 480Sstevel@tonic-gate #define ADDRESS_C(c) (c) 490Sstevel@tonic-gate #endif /* _ASM */ 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* 522006Sandrei * Machine dependent parameters and limits. 530Sstevel@tonic-gate */ 543446Smrj 552006Sandrei #if defined(__amd64) 566336Sbholler #define NCPU 256 5712173SMichael.Corcoran@Sun.COM #define NCPU_LOG2 8 582006Sandrei #elif defined(__i386) 592006Sandrei #define NCPU 32 6012173SMichael.Corcoran@Sun.COM #define NCPU_LOG2 5 612006Sandrei #endif 620Sstevel@tonic-gate 63*12230SFrank.Rival@oracle.com /* NCPU_P2 is NCPU rounded to a power of 2 */ 64*12230SFrank.Rival@oracle.com #define NCPU_P2 (1 << NCPU_LOG2) 65*12230SFrank.Rival@oracle.com 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * The value defined below could grow to 16. hat structure and 680Sstevel@tonic-gate * page_t have room for 16 nodes. 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate #define MAXNODES 4 710Sstevel@tonic-gate #define NUMA_NODEMASK 0x0f 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 740Sstevel@tonic-gate * Define the FPU symbol if we could run on a machine with an external 750Sstevel@tonic-gate * FPU (i.e. not integrated with the normal machine state like the vax). 760Sstevel@tonic-gate * 770Sstevel@tonic-gate * The fpu is defined in the architecture manual, and the kernel hides 780Sstevel@tonic-gate * its absence if it is not present, that's pretty integrated, no? 790Sstevel@tonic-gate */ 800Sstevel@tonic-gate 810Sstevel@tonic-gate /* supported page sizes */ 825349Skchow #define MMU_PAGE_SIZES 3 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * MMU_PAGES* describes the physical page size used by the mapping hardware. 860Sstevel@tonic-gate * PAGES* describes the logical page size used by the system. 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate 890Sstevel@tonic-gate #define MMU_PAGESIZE 0x1000 /* 4096 bytes */ 900Sstevel@tonic-gate #define MMU_PAGESHIFT 12 /* log2(MMU_PAGESIZE) */ 912006Sandrei 922006Sandrei #if !defined(_ASM) 930Sstevel@tonic-gate #define MMU_PAGEOFFSET (MMU_PAGESIZE-1) /* Mask of address bits in page */ 943446Smrj #else /* _ASM */ 953446Smrj #define MMU_PAGEOFFSET _CONST(MMU_PAGESIZE-1) /* assembler lameness */ 963446Smrj #endif /* _ASM */ 972006Sandrei 980Sstevel@tonic-gate #define MMU_PAGEMASK (~MMU_PAGEOFFSET) 990Sstevel@tonic-gate 1000Sstevel@tonic-gate #define PAGESIZE 0x1000 /* All of the above, for logical */ 1010Sstevel@tonic-gate #define PAGESHIFT 12 1020Sstevel@tonic-gate #define PAGEOFFSET (PAGESIZE - 1) 1030Sstevel@tonic-gate #define PAGEMASK (~PAGEOFFSET) 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * DATA_ALIGN is used to define the alignment of the Unix data segment. 1070Sstevel@tonic-gate */ 1080Sstevel@tonic-gate #define DATA_ALIGN PAGESIZE 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate /* 1112006Sandrei * DEFAULT KERNEL THREAD stack size (in pages). 1120Sstevel@tonic-gate */ 1130Sstevel@tonic-gate #if defined(__amd64) 1142006Sandrei #define DEFAULTSTKSZ_NPGS 5 1150Sstevel@tonic-gate #elif defined(__i386) 1168282SSherry.Moore@Sun.COM #define DEFAULTSTKSZ_NPGS 3 1170Sstevel@tonic-gate #endif 1180Sstevel@tonic-gate 1192006Sandrei #if !defined(_ASM) 1202006Sandrei #define DEFAULTSTKSZ (DEFAULTSTKSZ_NPGS * PAGESIZE) 1212006Sandrei #else /* !_ASM */ 1222006Sandrei #define DEFAULTSTKSZ _MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */ 1232006Sandrei #endif /* !_ASM */ 1242006Sandrei 1250Sstevel@tonic-gate /* 1260Sstevel@tonic-gate * KERNELBASE is the virtual address at which the kernel segments start in 1270Sstevel@tonic-gate * all contexts. 1280Sstevel@tonic-gate * 1294828Sjosephb * KERNELBASE is not fixed. The value of KERNELBASE can change with 1304828Sjosephb * installed memory or on 32 bit systems the eprom variable 'eprom_kernelbase'. 1310Sstevel@tonic-gate * 1324828Sjosephb * common/conf/param.c requires a compile time defined value for KERNELBASE. 1334828Sjosephb * This value is save in the variable _kernelbase. _kernelbase may then be 1344828Sjosephb * modified with to a different value in i86pc/os/startup.c. 1350Sstevel@tonic-gate * 1364828Sjosephb * Most code should be using kernelbase, which resolves to a reference to 1374828Sjosephb * _kernelbase. 1380Sstevel@tonic-gate */ 1393446Smrj #define KERNEL_TEXT_amd64 UINT64_C(0xfffffffffb800000) 1405084Sjohnlev 1415084Sjohnlev #ifdef __i386 1425084Sjohnlev 1433446Smrj #define KERNEL_TEXT_i386 ADDRESS_C(0xfe800000) 1440Sstevel@tonic-gate 1455084Sjohnlev /* 1465084Sjohnlev * We don't use HYPERVISOR_VIRT_START, as we need both the PAE and non-PAE 1475084Sjohnlev * versions in our code. We always compile based on the lower PAE address. 1485084Sjohnlev */ 1495084Sjohnlev #define KERNEL_TEXT_i386_xpv \ 1505084Sjohnlev (HYPERVISOR_VIRT_START_PAE - 3 * ADDRESS_C(0x400000)) 1515084Sjohnlev 1525084Sjohnlev #endif /* __i386 */ 1535084Sjohnlev 1540Sstevel@tonic-gate #if defined(__amd64) 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate #define KERNELBASE ADDRESS_C(0xfffffd8000000000) 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate /* 1590Sstevel@tonic-gate * Size of the unmapped "red zone" at the very bottom of the kernel's 1600Sstevel@tonic-gate * address space. Corresponds to 1 slot in the toplevel pagetable. 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate #define KERNEL_REDZONE_SIZE ((uintptr_t)1 << 39) 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * Base of 'core' heap area, which is used for kernel and module text/data 1660Sstevel@tonic-gate * that must be within a 2GB range to allow for rip-relative addressing. 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate #define COREHEAP_BASE ADDRESS_C(0xffffffffc0000000) 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate /* 1714828Sjosephb * Beginning of the segkpm window. A lower value than this is used if 1724828Sjosephb * physical addresses exceed 1TB. See i86pc/os/startup.c 1730Sstevel@tonic-gate */ 1740Sstevel@tonic-gate #define SEGKPM_BASE ADDRESS_C(0xfffffe0000000000) 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate /* 1774828Sjosephb * This is valloc_base, above seg_kpm, but below everything else. 1784828Sjosephb * A lower value than this may be used if SEGKPM_BASE is adjusted. 1794828Sjosephb * See i86pc/os/startup.c 1803446Smrj */ 1813446Smrj #define VALLOC_BASE ADDRESS_C(0xffffff0000000000) 1823446Smrj 1833446Smrj /* 1840Sstevel@tonic-gate * default and boundary sizes for segkp 1850Sstevel@tonic-gate */ 1860Sstevel@tonic-gate #define SEGKPDEFSIZE (2L * 1024L * 1024L * 1024L) /* 2G */ 1870Sstevel@tonic-gate #define SEGKPMAXSIZE (8L * 1024L * 1024L * 1024L) /* 8G */ 1880Sstevel@tonic-gate #define SEGKPMINSIZE (200L * 1024 * 1024L) /* 200M */ 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate /* 1913290Sjohansen * minimum size for segzio 1923290Sjohansen */ 1933290Sjohansen #define SEGZIOMINSIZE (400L * 1024 * 1024L) /* 400M */ 1943552Sjohansen #define SEGZIOMAXSIZE (512L * 1024L * 1024L * 1024L) /* 512G */ 1953290Sjohansen 1963290Sjohansen /* 1973446Smrj * During intial boot we limit heap to the top 4Gig. 1980Sstevel@tonic-gate */ 1993446Smrj #define BOOT_KERNELHEAP_BASE ADDRESS_C(0xffffffff00000000) 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate /* 2020Sstevel@tonic-gate * VMWare works best if we don't use the top 64Meg of memory for amd64. 2030Sstevel@tonic-gate * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages. 2040Sstevel@tonic-gate */ 2050Sstevel@tonic-gate #define PROMSTART ADDRESS_C(0xffc00000) 2063446Smrj #define KERNEL_TEXT KERNEL_TEXT_amd64 2073446Smrj 2083446Smrj /* 2093446Smrj * Virtual address range available to the debugger 2103446Smrj */ 2113446Smrj #define SEGDEBUGBASE ADDRESS_C(0xffffffffff800000) 2123446Smrj #define SEGDEBUGSIZE ADDRESS_C(0x400000) 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate /* 2150Sstevel@tonic-gate * Define upper limit on user address space 2160Sstevel@tonic-gate * 2170Sstevel@tonic-gate * In amd64, the upper limit on a 64-bit user address space is 1 large page 2180Sstevel@tonic-gate * (2MB) below kernelbase. The upper limit for a 32-bit user address space 2190Sstevel@tonic-gate * is 1 small page (4KB) below the top of the 32-bit range. The 64-bit 2200Sstevel@tonic-gate * limit give dtrace the red zone it needs below kernelbase. The 32-bit 2210Sstevel@tonic-gate * limit gives us a small red zone to detect address-space overruns in a 2220Sstevel@tonic-gate * user program. 2235084Sjohnlev * 2245084Sjohnlev * On the hypervisor, we limit the user to memory below the VA hole. 2255084Sjohnlev * Subtract 1 large page for a red zone. 2260Sstevel@tonic-gate */ 2275084Sjohnlev #if defined(__xpv) 2285084Sjohnlev #define USERLIMIT ADDRESS_C(0x00007fffffe00000) 2295084Sjohnlev #else 2300Sstevel@tonic-gate #define USERLIMIT ADDRESS_C(0xfffffd7fffe00000) 2315084Sjohnlev #endif 2325084Sjohnlev 2330Sstevel@tonic-gate #ifdef bug_5074717_is_fixed 2340Sstevel@tonic-gate #define USERLIMIT32 ADDRESS_C(0xfffff000) 2350Sstevel@tonic-gate #else 2360Sstevel@tonic-gate #define USERLIMIT32 ADDRESS_C(0xfefff000) 2370Sstevel@tonic-gate #endif 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate #elif defined(__i386) 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate #ifdef DEBUG 2420Sstevel@tonic-gate #define KERNELBASE ADDRESS_C(0xc8000000) 2430Sstevel@tonic-gate #else 2440Sstevel@tonic-gate #define KERNELBASE ADDRESS_C(0xd4000000) 2450Sstevel@tonic-gate #endif 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate #define KERNELBASE_MAX ADDRESS_C(0xe0000000) 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate /* 2500Sstevel@tonic-gate * The i386 ABI requires that the user address space be at least 3Gb 2510Sstevel@tonic-gate * in size. KERNELBASE_ABI_MIN is used as the default KERNELBASE for 2520Sstevel@tonic-gate * physical memory configurations > 4gb. 2530Sstevel@tonic-gate */ 2540Sstevel@tonic-gate #define KERNELBASE_ABI_MIN ADDRESS_C(0xc0000000) 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate /* 2570Sstevel@tonic-gate * Size of the unmapped "red zone" at the very bottom of the kernel's 2580Sstevel@tonic-gate * address space. Since segmap start immediately above the red zone, this 2590Sstevel@tonic-gate * needs to be MAXBSIZE aligned. 2600Sstevel@tonic-gate */ 2610Sstevel@tonic-gate #define KERNEL_REDZONE_SIZE MAXBSIZE 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate /* 2640Sstevel@tonic-gate * This is the last 4MB of the 4G address space. Some psm modules 2650Sstevel@tonic-gate * need this region of virtual address space mapped 1-1 2665084Sjohnlev * The top 64MB of the address space is reserved for the hypervisor. 2670Sstevel@tonic-gate */ 2680Sstevel@tonic-gate #define PROMSTART ADDRESS_C(0xffc00000) 2695084Sjohnlev #ifdef __xpv 2705084Sjohnlev #define KERNEL_TEXT KERNEL_TEXT_i386_xpv 2715084Sjohnlev #else 2723446Smrj #define KERNEL_TEXT KERNEL_TEXT_i386 2735084Sjohnlev #endif 2743446Smrj 2753446Smrj /* 2763446Smrj * Virtual address range available to the debugger 2773446Smrj * We place it just above the kernel text (4M) and kernel data (4M). 2783446Smrj */ 2793446Smrj #define SEGDEBUGBASE (KERNEL_TEXT + ADDRESS_C(0x800000)) 2803446Smrj #define SEGDEBUGSIZE ADDRESS_C(0x400000) 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate /* 2830Sstevel@tonic-gate * Define upper limit on user address space 2840Sstevel@tonic-gate */ 2850Sstevel@tonic-gate #define USERLIMIT KERNELBASE 2860Sstevel@tonic-gate #define USERLIMIT32 USERLIMIT 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate #endif /* __i386 */ 2890Sstevel@tonic-gate 2903446Smrj /* 2915460Sjosephb * Reserve pages just below KERNEL_TEXT for the GDT, IDT, TSS and debug info. 2925564Sjosephb * 2935564Sjosephb * For now, DEBUG_INFO_VA must be first in this list for "xm" initiated dumps 2945564Sjosephb * of solaris domUs to be usable with mdb. Relying on a fixed VA is not viable 2955564Sjosephb * long term, but it's the best we've got for now. 2963446Smrj */ 2973446Smrj #if !defined(_ASM) 2985564Sjosephb #define DEBUG_INFO_VA (KERNEL_TEXT - MMU_PAGESIZE) 2995564Sjosephb #define GDT_VA (DEBUG_INFO_VA - MMU_PAGESIZE) 3005460Sjosephb #define IDT_VA (GDT_VA - MMU_PAGESIZE) 3015460Sjosephb #define KTSS_VA (IDT_VA - MMU_PAGESIZE) 3025460Sjosephb #define DFTSS_VA (KTSS_VA - MMU_PAGESIZE) 3035564Sjosephb #define MISC_VA_BASE (DFTSS_VA) 3045460Sjosephb #define MISC_VA_SIZE (KERNEL_TEXT - MISC_VA_BASE) 3053446Smrj #endif /* !_ASM */ 3063446Smrj 3073446Smrj #if !defined(_ASM) && !defined(_KMDB) 3083446Smrj extern uintptr_t kernelbase, segmap_start, segmapsize; 3090Sstevel@tonic-gate #endif 3100Sstevel@tonic-gate 3110Sstevel@tonic-gate /* 3120Sstevel@tonic-gate * ARGSBASE is the base virtual address of the range which 3130Sstevel@tonic-gate * the kernel uses to map the arguments for exec. 3140Sstevel@tonic-gate */ 3150Sstevel@tonic-gate #define ARGSBASE PROMSTART 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate /* 3180Sstevel@tonic-gate * reserve space for modules 3190Sstevel@tonic-gate */ 3200Sstevel@tonic-gate #define MODTEXT (1024 * 1024 * 2) 3210Sstevel@tonic-gate #define MODDATA (1024 * 300) 3220Sstevel@tonic-gate 3230Sstevel@tonic-gate /* 3240Sstevel@tonic-gate * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically 3250Sstevel@tonic-gate * for module text. 3260Sstevel@tonic-gate */ 3270Sstevel@tonic-gate #define HEAPTEXT_SIZE (64 * 1024 * 1024) /* bytes */ 3280Sstevel@tonic-gate 3290Sstevel@tonic-gate /* 3300Sstevel@tonic-gate * Size of a kernel threads stack. It must be a whole number of pages 3310Sstevel@tonic-gate * since the segment it comes from will only allocate space in pages. 3320Sstevel@tonic-gate */ 3330Sstevel@tonic-gate #define T_STACKSZ 2*PAGESIZE 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate /* 3360Sstevel@tonic-gate * Size of a cpu startup thread stack. (It must be a whole number of pages 3370Sstevel@tonic-gate * since the containing segment only allocates space in pages.) 3380Sstevel@tonic-gate */ 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate #define STARTUP_STKSZ 3*PAGESIZE 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate /* 3430Sstevel@tonic-gate * Bus types 3440Sstevel@tonic-gate */ 3450Sstevel@tonic-gate #define BTISA 1 3460Sstevel@tonic-gate #define BTEISA 2 3470Sstevel@tonic-gate #define BTMCA 3 3480Sstevel@tonic-gate 3490Sstevel@tonic-gate #ifdef __cplusplus 3500Sstevel@tonic-gate } 3510Sstevel@tonic-gate #endif 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate #endif /* _SYS_MACHPARAM_H */ 354