1*8f18579dSriastradh /* $NetBSD: vmparam.h,v 1.55 2022/08/20 23:48:50 riastradh Exp $ */ 281918bf8Sfvdl 381918bf8Sfvdl /*- 481918bf8Sfvdl * Copyright (c) 1990 The Regents of the University of California. 581918bf8Sfvdl * All rights reserved. 681918bf8Sfvdl * 781918bf8Sfvdl * This code is derived from software contributed to Berkeley by 881918bf8Sfvdl * William Jolitz. 981918bf8Sfvdl * 1081918bf8Sfvdl * Redistribution and use in source and binary forms, with or without 1181918bf8Sfvdl * modification, are permitted provided that the following conditions 1281918bf8Sfvdl * are met: 1381918bf8Sfvdl * 1. Redistributions of source code must retain the above copyright 1481918bf8Sfvdl * notice, this list of conditions and the following disclaimer. 1581918bf8Sfvdl * 2. Redistributions in binary form must reproduce the above copyright 1681918bf8Sfvdl * notice, this list of conditions and the following disclaimer in the 1781918bf8Sfvdl * documentation and/or other materials provided with the distribution. 18aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 1981918bf8Sfvdl * may be used to endorse or promote products derived from this software 2081918bf8Sfvdl * without specific prior written permission. 2181918bf8Sfvdl * 2281918bf8Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2381918bf8Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2481918bf8Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2581918bf8Sfvdl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2681918bf8Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2781918bf8Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2881918bf8Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2981918bf8Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3081918bf8Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3181918bf8Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3281918bf8Sfvdl * SUCH DAMAGE. 3381918bf8Sfvdl * 3481918bf8Sfvdl * @(#)vmparam.h 5.9 (Berkeley) 5/12/91 3581918bf8Sfvdl */ 3681918bf8Sfvdl 3729f99fffSpooka #ifndef _X86_64_VMPARAM_H_ 3829f99fffSpooka #define _X86_64_VMPARAM_H_ 3981918bf8Sfvdl 405e4ac102Spooka #ifdef __x86_64__ 415e4ac102Spooka 4280f35befSad #include <sys/mutex.h> 434e541343Sbouyer #ifdef _KERNEL_OPT 444e541343Sbouyer #include "opt_xen.h" 454e541343Sbouyer #endif 46f7212a9aSsekiya 4781918bf8Sfvdl /* 4881918bf8Sfvdl * Machine dependent constants for 386. 4981918bf8Sfvdl */ 5081918bf8Sfvdl 5181918bf8Sfvdl /* 5281918bf8Sfvdl * Page size on the amd64 s not variable in the traditional sense. 5381918bf8Sfvdl * We override the PAGE_* definitions to compile-time constants. 5481918bf8Sfvdl */ 5581918bf8Sfvdl #define PAGE_SHIFT 12 5681918bf8Sfvdl #define PAGE_SIZE (1 << PAGE_SHIFT) 5781918bf8Sfvdl #define PAGE_MASK (PAGE_SIZE - 1) 5881918bf8Sfvdl 5981918bf8Sfvdl /* 6080759ca0Swiz * Default pager_map of 16MB is awfully small. There is plenty 6133448d9fSmrg * of VA so use it. 6233448d9fSmrg */ 6333448d9fSmrg #define PAGER_MAP_DEFAULT_SIZE (512 * 1024 * 1024) 6433448d9fSmrg 6533448d9fSmrg /* 66e5b2948dSad * Defaults for Unified Buffer Cache parameters. 67e5b2948dSad */ 68e5b2948dSad 69e5b2948dSad #ifndef UBC_WINSHIFT 70e5b2948dSad #define UBC_WINSHIFT 16 /* 64kB */ 71e5b2948dSad #endif 72e5b2948dSad #ifndef UBC_NWINS 73e5b2948dSad #define UBC_NWINS 4096 /* 256MB */ 74e5b2948dSad #endif 75e5b2948dSad 76e5b2948dSad /* 7781918bf8Sfvdl * USRSTACK is the top (end) of the user stack. Immediately above the 7881918bf8Sfvdl * user stack resides the user structure, which is UPAGES long and contains 7981918bf8Sfvdl * the kernel stack. 8081918bf8Sfvdl * 8181918bf8Sfvdl * Immediately after the user structure is the page table map, and then 82ed1153a3Swiz * kernel address space. 8381918bf8Sfvdl */ 8481918bf8Sfvdl #define USRSTACK VM_MAXUSER_ADDRESS 8581918bf8Sfvdl 8681918bf8Sfvdl #define USRSTACK32 VM_MAXUSER_ADDRESS32 8781918bf8Sfvdl 8881918bf8Sfvdl /* 8981918bf8Sfvdl * Virtual memory related constants, all in bytes 9081918bf8Sfvdl */ 912617b55bSchristos #define MAXTSIZ (8L*1024*1024*1024) /* max text size */ 9281918bf8Sfvdl #ifndef DFLDSIZ 93ea5ee473Sdrochner #define DFLDSIZ (256*1024*1024) /* initial data size limit */ 9481918bf8Sfvdl #endif 9581918bf8Sfvdl #ifndef MAXDSIZ 96b2bdc388Sws #define MAXDSIZ (8L*1024*1024*1024) /* max data size */ 9781918bf8Sfvdl #endif 9881918bf8Sfvdl #ifndef DFLSSIZ 99fbd59be9Sdrochner #define DFLSSIZ (4*1024*1024) /* initial stack size limit */ 10081918bf8Sfvdl #endif 10181918bf8Sfvdl #ifndef MAXSSIZ 1027fcafe3aSchristos #define MAXSSIZ (128*1024*1024) /* max stack size */ 10381918bf8Sfvdl #endif 10481918bf8Sfvdl 10581918bf8Sfvdl /* 106c487efe4Sfvdl * 32bit memory related constants. 107c487efe4Sfvdl */ 108c487efe4Sfvdl 109c487efe4Sfvdl #ifndef DFLDSIZ32 110c487efe4Sfvdl #define DFLDSIZ32 (256*1024*1024) /* initial data size limit */ 111c487efe4Sfvdl #endif 112c487efe4Sfvdl #ifndef MAXDSIZ32 1130ea99faeScube #define MAXDSIZ32 (3U*1024*1024*1024) /* max data size */ 114c487efe4Sfvdl #endif 115c487efe4Sfvdl #ifndef DFLSSIZ32 116c487efe4Sfvdl #define DFLSSIZ32 (2*1024*1024) /* initial stack size limit */ 117c487efe4Sfvdl #endif 118c487efe4Sfvdl #ifndef MAXSSIZ32 1190ea99faeScube #define MAXSSIZ32 (64*1024*1024) /* max stack size */ 120c487efe4Sfvdl #endif 121c487efe4Sfvdl 122c487efe4Sfvdl /* 12381918bf8Sfvdl * Size of User Raw I/O map 12481918bf8Sfvdl */ 12581918bf8Sfvdl #define USRIOSIZE 300 12681918bf8Sfvdl 12772349b9cSmaxv /* User map constants */ 12881918bf8Sfvdl #define VM_MIN_ADDRESS 0 129f228a924Smaxv #define VM_MAXUSER_ADDRESS (0x00007f8000000000 - PAGE_SIZE) 13072349b9cSmaxv #define VM_MAXUSER_ADDRESS32 0xfffff000 13181918bf8Sfvdl #define VM_MAX_ADDRESS 0x00007fbfdfeff000 13272349b9cSmaxv 13372349b9cSmaxv /* 13472349b9cSmaxv * Kernel map constants. 13572349b9cSmaxv * MIN = VA_SIGN_NEG(L4_SLOT_KERN * NBPD_L4) 13672349b9cSmaxv * MAX = MIN + NKL4_MAX_ENTRIES * NBPD_L4 13772349b9cSmaxv */ 138427af037Scherry #ifndef XENPV 13931588fa0Smaxv #define VM_MIN_KERNEL_ADDRESS_DEFAULT 0xffff800000000000 14031588fa0Smaxv #define VM_MAX_KERNEL_ADDRESS_DEFAULT 0xffffa00000000000 1419c9be108Smaxv #else 1429c9be108Smaxv #define VM_MIN_KERNEL_ADDRESS_DEFAULT 0xffffa00000000000 1439c9be108Smaxv #define VM_MAX_KERNEL_ADDRESS_DEFAULT 0xffffc00000000000 1449c9be108Smaxv #endif 1459c9be108Smaxv 146d3aa9156Smaya #if defined(_KMEMUSER) || defined(_KERNEL) 14731588fa0Smaxv extern vaddr_t vm_min_kernel_address; 14831588fa0Smaxv extern vaddr_t vm_max_kernel_address; 14931588fa0Smaxv #define VM_MIN_KERNEL_ADDRESS vm_min_kernel_address 15031588fa0Smaxv #define VM_MAX_KERNEL_ADDRESS vm_max_kernel_address 1512c044026Smaxv #endif 15281918bf8Sfvdl 153*8f18579dSriastradh #define PDP_SIZE 1 154*8f18579dSriastradh 15581918bf8Sfvdl /* 1560ea99faeScube * The address to which unspecified mapping requests default 1570ea99faeScube */ 1580ea99faeScube #ifdef _KERNEL_OPT 1590ea99faeScube #include "opt_uvm.h" 1600ea99faeScube #endif 1610ea99faeScube #define __USE_TOPDOWN_VM 162b07f3fe2Schristos 1634e88c910Schristos #define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ 1644e88c910Schristos round_page((vaddr_t)(da) + (vsize_t)maxdmap) 165b07f3fe2Schristos 1664e88c910Schristos #define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \ 1670bc4a2daSjoerg trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size) 1684e88c910Schristos #define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \ 1694e88c910Schristos round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32) 1700ea99faeScube 17181918bf8Sfvdl /* virtual sizes (bytes) for various kernel submaps */ 17281918bf8Sfvdl #define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) 17381918bf8Sfvdl 1743b6bd9f0Smaxv #define VM_PHYSSEG_MAX 64 /* 1 "hole" + 63 free lists */ 17581918bf8Sfvdl #define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST 17681918bf8Sfvdl 177c5f3dfcfSriastradh #define VM_NFREELIST 6 17881918bf8Sfvdl #define VM_FREELIST_DEFAULT 0 179cd2156f4Sriastradh #define VM_FREELIST_FIRST1T 1 180cd2156f4Sriastradh #define VM_FREELIST_FIRST64G 2 181cd2156f4Sriastradh #define VM_FREELIST_FIRST4G 3 182c5f3dfcfSriastradh #define VM_FREELIST_FIRST1G 4 183c5f3dfcfSriastradh #define VM_FREELIST_FIRST16 5 18481918bf8Sfvdl 1855e4ac102Spooka #else /* !__x86_64__ */ 1865e4ac102Spooka 1875e4ac102Spooka #include <i386/vmparam.h> 1885e4ac102Spooka 1895e4ac102Spooka #endif /* __x86_64__ */ 1905e4ac102Spooka 19129f99fffSpooka #endif /* _X86_64_VMPARAM_H_ */ 192