xref: /illumos-gate/usr/src/uts/i86pc/sys/machparam.h (revision cab548c6523fe7fb0c3363124aeae784deb0fe99)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
541791439Sandrei  * Common Development and Distribution License (the "License").
641791439Sandrei  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2223d9e5acSMichael Corcoran  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
23af868f46SMatthew Ahrens  * Copyright (c) 2015 by Delphix. All rights reserved.
2474ecdb51SJohn Levon  * Copyright 2018 Joyent, Inc.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifndef _SYS_MACHPARAM_H
327c478bd9Sstevel@tonic-gate #define	_SYS_MACHPARAM_H
337c478bd9Sstevel@tonic-gate 
3404909c8cSJohn Levon #ifndef _ASM
3504909c8cSJohn Levon 
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
37843e1988Sjohnlev 
38843e1988Sjohnlev #if defined(__xpv)
39843e1988Sjohnlev #include <sys/xpv_impl.h>
40843e1988Sjohnlev #endif
41843e1988Sjohnlev 
4204909c8cSJohn Levon #endif /* !_ASM */
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifndef _ASM
497c478bd9Sstevel@tonic-gate #define	ADDRESS_C(c)    c ## ul
507c478bd9Sstevel@tonic-gate #else   /* _ASM */
517c478bd9Sstevel@tonic-gate #define	ADDRESS_C(c)    (c)
527c478bd9Sstevel@tonic-gate #endif  /* _ASM */
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
5541791439Sandrei  * Machine dependent parameters and limits.
567c478bd9Sstevel@tonic-gate  */
57ae115bc7Smrj 
582428aad8SPatrick Mooney /*
592428aad8SPatrick Mooney  * If NCPU grows beyond 256, sizing for the x86 comm page will require
602428aad8SPatrick Mooney  * adjustment.
612428aad8SPatrick Mooney  */
62a563a037Sbholler #define	NCPU	256
6323d9e5acSMichael Corcoran #define	NCPU_LOG2	8
647c478bd9Sstevel@tonic-gate 
65cb15d5d9SPeter Rival /* NCPU_P2 is NCPU rounded to a power of 2 */
66cb15d5d9SPeter Rival #define	NCPU_P2	(1 << NCPU_LOG2)
67cb15d5d9SPeter Rival 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * The value defined below could grow to 16. hat structure and
707c478bd9Sstevel@tonic-gate  * page_t have room for 16 nodes.
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate #define	MAXNODES	4
737c478bd9Sstevel@tonic-gate #define	NUMA_NODEMASK	0x0f
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate /*
767c478bd9Sstevel@tonic-gate  * Define the FPU symbol if we could run on a machine with an external
777c478bd9Sstevel@tonic-gate  * FPU (i.e. not integrated with the normal machine state like the vax).
787c478bd9Sstevel@tonic-gate  *
797c478bd9Sstevel@tonic-gate  * The fpu is defined in the architecture manual, and the kernel hides
807c478bd9Sstevel@tonic-gate  * its absence if it is not present, that's pretty integrated, no?
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /* supported page sizes */
8402bc52beSkchow #define	MMU_PAGE_SIZES	3
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * MMU_PAGES* describes the physical page size used by the mapping hardware.
887c478bd9Sstevel@tonic-gate  * PAGES* describes the logical page size used by the system.
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #define	MMU_PAGESIZE	0x1000		/* 4096 bytes */
927c478bd9Sstevel@tonic-gate #define	MMU_PAGESHIFT	12		/* log2(MMU_PAGESIZE) */
9341791439Sandrei 
9441791439Sandrei #if !defined(_ASM)
957c478bd9Sstevel@tonic-gate #define	MMU_PAGEOFFSET	(MMU_PAGESIZE-1) /* Mask of address bits in page */
96ae115bc7Smrj #else	/* _ASM */
9741791439Sandrei #define	MMU_PAGEOFFSET	_CONST(MMU_PAGESIZE-1)	/* assembler lameness */
98ae115bc7Smrj #endif	/* _ASM */
9941791439Sandrei 
1007c478bd9Sstevel@tonic-gate #define	MMU_PAGEMASK	(~MMU_PAGEOFFSET)
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate #define	PAGESIZE	0x1000		/* All of the above, for logical */
1037c478bd9Sstevel@tonic-gate #define	PAGESHIFT	12
1047c478bd9Sstevel@tonic-gate #define	PAGEOFFSET	(PAGESIZE - 1)
1057c478bd9Sstevel@tonic-gate #define	PAGEMASK	(~PAGEOFFSET)
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate  * DATA_ALIGN is used to define the alignment of the Unix data segment.
1097c478bd9Sstevel@tonic-gate  */
1107c478bd9Sstevel@tonic-gate #define	DATA_ALIGN	PAGESIZE
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /*
11341791439Sandrei  * DEFAULT KERNEL THREAD stack size (in pages).
1147c478bd9Sstevel@tonic-gate  */
11541791439Sandrei #define	DEFAULTSTKSZ_NPGS	5
1167c478bd9Sstevel@tonic-gate 
11741791439Sandrei #if !defined(_ASM)
11841791439Sandrei #define	DEFAULTSTKSZ	(DEFAULTSTKSZ_NPGS * PAGESIZE)
11941791439Sandrei #else	/* !_ASM */
12041791439Sandrei #define	DEFAULTSTKSZ	_MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */
12141791439Sandrei #endif	/* !_ASM */
122f1b92f9dSRobert Mustacchi 
123f1b92f9dSRobert Mustacchi /*
124f1b92f9dSRobert Mustacchi  * Use a slightly larger thread stack size for interrupt threads rather than
125f1b92f9dSRobert Mustacchi  * the default. This is useful for cases where the networking stack may do an
126f1b92f9dSRobert Mustacchi  * rx and a tx in the context of a single interrupt and when combined with
127f1b92f9dSRobert Mustacchi  * various promisc hooks that need memory, can cause us to get dangerously
128f1b92f9dSRobert Mustacchi  * close to the edge of the traditional stack sizes. This is only a few pages
129f1b92f9dSRobert Mustacchi  * more than a traditional stack and given that we don't have that many
130f1b92f9dSRobert Mustacchi  * interrupt threads, the memory costs end up being more than worthwhile.
131f1b92f9dSRobert Mustacchi  */
132f1b92f9dSRobert Mustacchi #define	LL_INTR_STKSZ_NPGS	8
133f1b92f9dSRobert Mustacchi #define	LL_INTR_STKSZ		(LL_INTR_STKSZ_NPGS * PAGESIZE)
13441791439Sandrei 
1357c478bd9Sstevel@tonic-gate /*
136ae115bc7Smrj  * During intial boot we limit heap to the top 4Gig.
1377c478bd9Sstevel@tonic-gate  */
138ae115bc7Smrj #define	BOOT_KERNELHEAP_BASE	ADDRESS_C(0xffffffff00000000)
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  * VMWare works best if we don't use the top 64Meg of memory for amd64.
1427c478bd9Sstevel@tonic-gate  * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages.
1437c478bd9Sstevel@tonic-gate  */
1447c478bd9Sstevel@tonic-gate #define	PROMSTART	ADDRESS_C(0xffc00000)
145ae115bc7Smrj 
146ae115bc7Smrj /*
147ae115bc7Smrj  * Virtual address range available to the debugger
148ae115bc7Smrj  */
149ae115bc7Smrj #define	SEGDEBUGBASE	ADDRESS_C(0xffffffffff800000)
150ae115bc7Smrj #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
1517c478bd9Sstevel@tonic-gate 
15204909c8cSJohn Levon #define	KERNEL_TEXT	UINT64_C(0xfffffffffb800000)
1537c478bd9Sstevel@tonic-gate 
154ae115bc7Smrj /*
15574ecdb51SJohn Levon  * Reserve pages just below KERNEL_TEXT for the GDT, IDT, LDT, TSS and debug
15674ecdb51SJohn Levon  * info.
15782664878Sjosephb  *
15882664878Sjosephb  * For now, DEBUG_INFO_VA must be first in this list for "xm" initiated dumps
15982664878Sjosephb  * of solaris domUs to be usable with mdb. Relying on a fixed VA is not viable
16082664878Sjosephb  * long term, but it's the best we've got for now.
161ae115bc7Smrj  */
162ae115bc7Smrj #if !defined(_ASM)
16382664878Sjosephb #define	DEBUG_INFO_VA	(KERNEL_TEXT - MMU_PAGESIZE)
16482664878Sjosephb #define	GDT_VA		(DEBUG_INFO_VA - MMU_PAGESIZE)
1650cfdb603Sjosephb #define	IDT_VA		(GDT_VA - MMU_PAGESIZE)
16674ecdb51SJohn Levon #define	LDT_VA		(IDT_VA - (16 * MMU_PAGESIZE))
1674c7b9a81SPatrick Mooney #define	KTSS_VA		(LDT_VA - MMU_PAGESIZE)
1680cfdb603Sjosephb #define	DFTSS_VA	(KTSS_VA - MMU_PAGESIZE)
16982664878Sjosephb #define	MISC_VA_BASE	(DFTSS_VA)
1700cfdb603Sjosephb #define	MISC_VA_SIZE	(KERNEL_TEXT - MISC_VA_BASE)
171ae115bc7Smrj #endif /* !_ASM */
172ae115bc7Smrj 
17304909c8cSJohn Levon /*
17404909c8cSJohn Levon  * Base of 'core' heap area, which is used for kernel and module text/data
17504909c8cSJohn Levon  * that must be within a 2GB range to allow for rip-relative addressing.
17604909c8cSJohn Levon  */
17704909c8cSJohn Levon #define	COREHEAP_BASE	ADDRESS_C(0xffffffffc0000000)
17804909c8cSJohn Levon 
17904909c8cSJohn Levon /*
18004909c8cSJohn Levon  * This is valloc_base, above seg_kpm, but below everything else.
18104909c8cSJohn Levon  * A lower value than this may be used if SEGKPM_BASE is adjusted.
18204909c8cSJohn Levon  * See i86pc/os/startup.c
18304909c8cSJohn Levon  */
18404909c8cSJohn Levon #define	VALLOC_BASE	ADDRESS_C(0xfffffe0000000000)
18504909c8cSJohn Levon 
18604909c8cSJohn Levon #define	SEGZIOMINSIZE	(400L * 1024 * 1024L)			/* 400M */
18704909c8cSJohn Levon #define	SEGVMMMINSIZE	(4096L * 1024 * 1024L)			/* 4G */
18804909c8cSJohn Levon 
18904909c8cSJohn Levon #define	SEGKPDEFSIZE	(2L * 1024L * 1024L * 1024L)		/*   2G */
19004909c8cSJohn Levon #define	SEGKPMAXSIZE	(8L * 1024L * 1024L * 1024L)		/*   8G */
19104909c8cSJohn Levon #define	SEGKPMINSIZE	(200L * 1024 * 1024L)			/* 200M */
19204909c8cSJohn Levon 
19304909c8cSJohn Levon #define	SEGKPM_BASE	ADDRESS_C(0xfffffd0000000000)
19404909c8cSJohn Levon 
19504909c8cSJohn Levon /*
19604909c8cSJohn Levon  * KERNELBASE is the virtual address at which the kernel segments start in
19704909c8cSJohn Levon  * all contexts.
19804909c8cSJohn Levon  *
19904909c8cSJohn Levon  * KERNELBASE is not fixed.  The value of KERNELBASE can change with
20004909c8cSJohn Levon  * installed memory size.
20104909c8cSJohn Levon  *
20204909c8cSJohn Levon  * common/conf/param.c requires a compile time defined value for KERNELBASE.
20304909c8cSJohn Levon  * This value is save in the variable _kernelbase.  _kernelbase may then be
20404909c8cSJohn Levon  * modified with to a different value in i86pc/os/startup.c.
20504909c8cSJohn Levon  *
20604909c8cSJohn Levon  * Most code should be using kernelbase, which resolves to a reference to
20704909c8cSJohn Levon  * _kernelbase.
20804909c8cSJohn Levon  */
20904909c8cSJohn Levon #define	KERNELBASE	ADDRESS_C(0xfffffc8000000000)
21004909c8cSJohn Levon 
21104909c8cSJohn Levon /*
21204909c8cSJohn Levon  * Size of the unmapped "red zone" at the very bottom of the kernel's
21304909c8cSJohn Levon  * address space.  Corresponds to 1 slot in the toplevel pagetable.
21404909c8cSJohn Levon  */
21504909c8cSJohn Levon #define	KERNEL_REDZONE_SIZE   ((uintptr_t)1 << 39)
21604909c8cSJohn Levon 
21704909c8cSJohn Levon /*
21804909c8cSJohn Levon  * Define upper limit on user address space
21904909c8cSJohn Levon  *
22004909c8cSJohn Levon  * The upper limit on a 64-bit user address space is 1 large page
22104909c8cSJohn Levon  * (2MB) below kernelbase.  The upper limit for a 32-bit user address space
22204909c8cSJohn Levon  * is 1 small page (4KB) below the top of the 32-bit range.  The 64-bit
22304909c8cSJohn Levon  * limit give dtrace the red zone it needs below kernelbase.  The 32-bit
22404909c8cSJohn Levon  * limit gives us a small red zone to detect address-space overruns in a
22504909c8cSJohn Levon  * user program.
22604909c8cSJohn Levon  *
22704909c8cSJohn Levon  * On the hypervisor, we limit the user to memory below the VA hole.
22804909c8cSJohn Levon  * Subtract 1 large page for a red zone.
22904909c8cSJohn Levon  */
23004909c8cSJohn Levon #if defined(__xpv)
23104909c8cSJohn Levon #define	USERLIMIT	ADDRESS_C(0x00007fffffe00000)
23204909c8cSJohn Levon #else
23304909c8cSJohn Levon #define	USERLIMIT	ADDRESS_C(0xfffffc7fffe00000)
23404909c8cSJohn Levon #endif
23504909c8cSJohn Levon 
23604909c8cSJohn Levon #ifdef bug_5074717_is_fixed
23704909c8cSJohn Levon #define	USERLIMIT32	ADDRESS_C(0xfffff000)
23804909c8cSJohn Levon #else
23904909c8cSJohn Levon #define	USERLIMIT32	ADDRESS_C(0xfefff000)
24004909c8cSJohn Levon #endif
24104909c8cSJohn Levon 
242ae115bc7Smrj #if !defined(_ASM) && !defined(_KMDB)
243ae115bc7Smrj extern uintptr_t kernelbase, segmap_start, segmapsize;
2447c478bd9Sstevel@tonic-gate #endif
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate /*
2477c478bd9Sstevel@tonic-gate  * ARGSBASE is the base virtual address of the range which
2487c478bd9Sstevel@tonic-gate  * the kernel uses to map the arguments for exec.
2497c478bd9Sstevel@tonic-gate  */
2507c478bd9Sstevel@tonic-gate #define	ARGSBASE	PROMSTART
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  * reserve space for modules
2547c478bd9Sstevel@tonic-gate  */
2557c478bd9Sstevel@tonic-gate #define	MODTEXT	(1024 * 1024 * 2)
2567c478bd9Sstevel@tonic-gate #define	MODDATA	(1024 * 300)
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate /*
2597c478bd9Sstevel@tonic-gate  * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
2607c478bd9Sstevel@tonic-gate  * for module text.
2617c478bd9Sstevel@tonic-gate  */
262*cab548c6SHans Rosenfeld #define	HEAPTEXT_SIZE		(128 * 1024 * 1024)	/* bytes */
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate /*
2657c478bd9Sstevel@tonic-gate  * Size of a kernel threads stack.  It must be a whole number of pages
2667c478bd9Sstevel@tonic-gate  * since the segment it comes from will only allocate space in pages.
2677c478bd9Sstevel@tonic-gate  */
2687c478bd9Sstevel@tonic-gate #define	T_STACKSZ	2*PAGESIZE
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate /*
2717c478bd9Sstevel@tonic-gate  * Size of a cpu startup thread stack.  (It must be a whole number of pages
2727c478bd9Sstevel@tonic-gate  * since the containing segment only allocates space in pages.)
2737c478bd9Sstevel@tonic-gate  */
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate #define	STARTUP_STKSZ	3*PAGESIZE
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate /*
2787c478bd9Sstevel@tonic-gate  * Bus types
2797c478bd9Sstevel@tonic-gate  */
2807c478bd9Sstevel@tonic-gate #define	BTISA		1
2817c478bd9Sstevel@tonic-gate #define	BTEISA		2
2827c478bd9Sstevel@tonic-gate #define	BTMCA		3
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2857c478bd9Sstevel@tonic-gate }
2867c478bd9Sstevel@tonic-gate #endif
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate #endif	/* _SYS_MACHPARAM_H */
289