xref: /netbsd-src/sys/arch/arm/include/arm32/vmparam.h (revision 8469df929f4af7108beb12d564f7f89318e711ff)
1*8469df92Sandvar /*	$NetBSD: vmparam.h,v 1.58 2024/09/07 06:17:37 andvar Exp $	*/
2c653a0eeSthorpej 
3c653a0eeSthorpej /*
4a92da3d4Sthorpej  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
5c653a0eeSthorpej  * All rights reserved.
6c653a0eeSthorpej  *
7c653a0eeSthorpej  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8c653a0eeSthorpej  *
9c653a0eeSthorpej  * Redistribution and use in source and binary forms, with or without
10c653a0eeSthorpej  * modification, are permitted provided that the following conditions
11c653a0eeSthorpej  * are met:
12c653a0eeSthorpej  * 1. Redistributions of source code must retain the above copyright
13c653a0eeSthorpej  *    notice, this list of conditions and the following disclaimer.
14c653a0eeSthorpej  * 2. Redistributions in binary form must reproduce the above copyright
15c653a0eeSthorpej  *    notice, this list of conditions and the following disclaimer in the
16c653a0eeSthorpej  *    documentation and/or other materials provided with the distribution.
17c653a0eeSthorpej  * 3. All advertising materials mentioning features or use of this software
18c653a0eeSthorpej  *    must display the following acknowledgement:
19c653a0eeSthorpej  *	This product includes software developed for the NetBSD Project by
20c653a0eeSthorpej  *	Wasabi Systems, Inc.
21c653a0eeSthorpej  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22c653a0eeSthorpej  *    or promote products derived from this software without specific prior
23c653a0eeSthorpej  *    written permission.
24c653a0eeSthorpej  *
25c653a0eeSthorpej  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26c653a0eeSthorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27c653a0eeSthorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28c653a0eeSthorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29c653a0eeSthorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30c653a0eeSthorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31c653a0eeSthorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32c653a0eeSthorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33c653a0eeSthorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34c653a0eeSthorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35c653a0eeSthorpej  * POSSIBILITY OF SUCH DAMAGE.
36c653a0eeSthorpej  */
37c653a0eeSthorpej 
38c653a0eeSthorpej #ifndef _ARM_ARM32_VMPARAM_H_
39c653a0eeSthorpej #define	_ARM_ARM32_VMPARAM_H_
40c653a0eeSthorpej 
41ce8bb56eSskrll #if defined(_KERNEL_OPT)
42d329adb0Sskrll #include "opt_kasan.h"
43ce8bb56eSskrll #endif
4415c76e3cSthorpej 
45c653a0eeSthorpej /*
46c653a0eeSthorpej  * Virtual Memory parameters common to all arm32 platforms.
47c653a0eeSthorpej  */
48c653a0eeSthorpej 
4984e1f959Schristos #include <sys/cdefs.h>
50aaedf760Sskrll #include <arm/cpuconf.h>
51fd2979f3Sjmcneill #include <arm/arm32/param.h>
5215c76e3cSthorpej 
538638b0baSskrll #define	__USE_TOPDOWN_VM
545101f01dSthorpej #define	USRSTACK	VM_MAXUSER_ADDRESS
555101f01dSthorpej 
565101f01dSthorpej /*
57*8469df92Sandvar  * ARMv4 systems are normally configured for 256MB KVA only, so restrict
585e02b3cbSjoerg  * the size of the pager map to 4MB.
595e02b3cbSjoerg  */
605e02b3cbSjoerg #ifndef _ARM_ARCH_5
615e02b3cbSjoerg #define PAGER_MAP_DEFAULT_SIZE          (4 * 1024 * 1024)
625e02b3cbSjoerg #endif
635e02b3cbSjoerg 
645e02b3cbSjoerg /*
655101f01dSthorpej  * Note that MAXTSIZ can't be larger than 32M, otherwise the compiler
665101f01dSthorpej  * would have to be changed to not generate "bl" instructions.
675101f01dSthorpej  */
682ac93693Smatt #define	MAXTSIZ		(128*1024*1024)		/* max text size */
695101f01dSthorpej #ifndef	DFLDSIZ
702ac93693Smatt #define	DFLDSIZ		(384*1024*1024)		/* initial data size limit */
715101f01dSthorpej #endif
725101f01dSthorpej #ifndef	MAXDSIZ
73d41493b1She #define	MAXDSIZ		(1856*1024*1024)	/* max data size */
745101f01dSthorpej #endif
755101f01dSthorpej #ifndef	DFLSSIZ
762ac93693Smatt #define	DFLSSIZ		(4*1024*1024)		/* initial stack size limit */
775101f01dSthorpej #endif
785101f01dSthorpej #ifndef	MAXSSIZ
792ac93693Smatt #define	MAXSSIZ		(64*1024*1024)		/* max stack size */
805101f01dSthorpej #endif
815101f01dSthorpej 
825101f01dSthorpej /*
83c653a0eeSthorpej  * While the ARM architecture defines Section mappings, large pages,
8497e1fde8Sskrll  * and small pages, the standard MMU page size is (and will always be) 4K.
85c653a0eeSthorpej  */
862f4dafd1Smatt #define	PAGE_SHIFT	PGSHIFT
87c653a0eeSthorpej #define	PAGE_SIZE	(1 << PAGE_SHIFT)
88c653a0eeSthorpej #define	PAGE_MASK	(PAGE_SIZE - 1)
89c653a0eeSthorpej 
904eeee795Sthorpej /*
914eeee795Sthorpej  * Mach derived constants
924eeee795Sthorpej  */
93a644e638Smatt #define	VM_MIN_ADDRESS		((vaddr_t) PAGE_SIZE)
94d329adb0Sskrll 
95a644e638Smatt #define	VM_MAXUSER_ADDRESS	((vaddr_t) KERNEL_BASE - PAGE_SIZE)
964eeee795Sthorpej #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
9746ffc57aSthorpej 
98bbba90a2Sthorpej #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t) KERNEL_BASE)
99a644e638Smatt #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t) -(PAGE_SIZE+1))
1005101f01dSthorpej 
101ce8bb56eSskrll #if defined(_KERNEL)
102d329adb0Sskrll // AddressSanitizer dedicates 1/8 of kernel memory to its shadow memory (e.g.
103d329adb0Sskrll // 128MB to cover 1GB for ARM) and uses a special KVA range for the shadow
104d329adb0Sskrll // address corresponding to a kernel memory address.
105d329adb0Sskrll 
1066cbab208Sskrll /*
1076cbab208Sskrll  * kernel virtual space layout without direct map (common case)
1086cbab208Sskrll  *
1096cbab208Sskrll  *   0x8000_0000 -  256MB kernel text/data/bss
1106cbab208Sskrll  *   0x9000_0000 - 1536MB Kernel VM Space
1116cbab208Sskrll  *   0xf000_0000 -  256MB IO
1126cbab208Sskrll  *
113d329adb0Sskrll  * kernel virtual space layout with KASAN
114d329adb0Sskrll  *
115d329adb0Sskrll  *   0x8000_0000 -  256MB kernel text/data/bss
116d329adb0Sskrll  *   0x9000_0000 -  768MB Kernel VM Space
117d329adb0Sskrll  *   0xc000_0000 -  128MB (KASAN SHADOW MAP)
118d329adb0Sskrll  *   0xc800_0000 -  640MB (spare)
119d329adb0Sskrll  *   0xf000_0000 -  256MB IO
120d329adb0Sskrll  *
1216cbab208Sskrll  * kernel virtual space layout with direct map (1GB limited)
1226cbab208Sskrll  *   0x8000_0000 - 1024MB kernel text/data/bss and direct map start
1236cbab208Sskrll  *   0xc000_0000 -  768MB Kernel VM Space
1246cbab208Sskrll  *   0xf000_0000 -  256MB IO
1256cbab208Sskrll  *
1266cbab208Sskrll  */
1276cbab208Sskrll 
128d329adb0Sskrll #ifdef KASAN
129d329adb0Sskrll #define VM_KERNEL_KASAN_BASE	0xc0000000
13025b9b3dcSskrll #define VM_KERNEL_KASAN_SIZE	(VM_KERNEL_ADDR_SIZE >> KASAN_SHADOW_SCALE_SHIFT)
131d329adb0Sskrll #define VM_KERNEL_KASAN_END	(VM_KERNEL_KASAN_BASE + VM_KERNEL_KASAN_SIZE)
132d329adb0Sskrll #define VM_KERNEL_VM_END	VM_KERNEL_KASAN_BASE
133d329adb0Sskrll #else
1344def9d8bSskrll #define VM_KERNEL_VM_END	VM_KERNEL_IO_BASE
135d329adb0Sskrll #endif
136d329adb0Sskrll 
1376cbab208Sskrll #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
138d329adb0Sskrll #ifdef KASAN
139d329adb0Sskrll #error KASAN and __HAVE_MM_MD_DIRECT_MAPPED_PHYS is unsupported
140d329adb0Sskrll #endif
1416652c005Sskrll #define VM_KERNEL_VM_BASE	0xc0000000
1426cbab208Sskrll #else
1436652c005Sskrll #define VM_KERNEL_VM_BASE	0x90000000
1446cbab208Sskrll #endif
1456cbab208Sskrll 
14625b9b3dcSskrll #define VM_KERNEL_ADDR_SIZE	(VM_KERNEL_VM_END - KERNEL_BASE)
147d329adb0Sskrll #define VM_KERNEL_VM_SIZE	(VM_KERNEL_VM_END - VM_KERNEL_VM_BASE)
1486cbab208Sskrll 
1494def9d8bSskrll #define VM_KERNEL_IO_BASE	0xf0000000
1504def9d8bSskrll #define VM_KERNEL_IO_SIZE	(VM_MAX_KERNEL_ADDRESS - VM_KERNEL_IO_BASE)
151ce8bb56eSskrll #endif
1526cbab208Sskrll 
153c653a0eeSthorpej #endif /* _ARM_ARM32_VMPARAM_H_ */
154