139923942SSimon Schubert /*- 239923942SSimon Schubert * Copyright (c) 1990 The Regents of the University of California. 339923942SSimon Schubert * Copyright (c) 1994 John S. Dyson 439923942SSimon Schubert * Copyright (c) 2003 Peter Wemm 5c8fe38aeSMatthew Dillon * Copyright (c) 2008 The DragonFly Project. 639923942SSimon Schubert * All rights reserved. 739923942SSimon Schubert * 839923942SSimon Schubert * This code is derived from software contributed to Berkeley by 939923942SSimon Schubert * William Jolitz. 1039923942SSimon Schubert * 1139923942SSimon Schubert * Redistribution and use in source and binary forms, with or without 1239923942SSimon Schubert * modification, are permitted provided that the following conditions 1339923942SSimon Schubert * are met: 1439923942SSimon Schubert * 1. Redistributions of source code must retain the above copyright 1539923942SSimon Schubert * notice, this list of conditions and the following disclaimer. 1639923942SSimon Schubert * 2. Redistributions in binary form must reproduce the above copyright 1739923942SSimon Schubert * notice, this list of conditions and the following disclaimer in the 1839923942SSimon Schubert * documentation and/or other materials provided with the distribution. 1939923942SSimon Schubert * 3. All advertising materials mentioning features or use of this software 2039923942SSimon Schubert * must display the following acknowledgement: 2139923942SSimon Schubert * This product includes software developed by the University of 2239923942SSimon Schubert * California, Berkeley and its contributors. 2339923942SSimon Schubert * 4. Neither the name of the University nor the names of its contributors 2439923942SSimon Schubert * may be used to endorse or promote products derived from this software 2539923942SSimon Schubert * without specific prior written permission. 2639923942SSimon Schubert * 2739923942SSimon Schubert * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2839923942SSimon Schubert * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2939923942SSimon Schubert * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 3039923942SSimon Schubert * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3139923942SSimon Schubert * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3239923942SSimon Schubert * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3339923942SSimon Schubert * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3439923942SSimon Schubert * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3539923942SSimon Schubert * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3639923942SSimon Schubert * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3739923942SSimon Schubert * SUCH DAMAGE. 3839923942SSimon Schubert * 3939923942SSimon Schubert * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 4039923942SSimon Schubert * $FreeBSD: src/sys/amd64/include/vmparam.h,v 1.44 2003/12/07 04:51:04 alc Exp $ 41c8fe38aeSMatthew Dillon * $DragonFly: src/sys/platform/pc64/include/vmparam.h,v 1.2 2008/08/29 17:07:17 dillon Exp $ 4239923942SSimon Schubert */ 4339923942SSimon Schubert 4439923942SSimon Schubert 4539923942SSimon Schubert #ifndef _MACHINE_VMPARAM_H_ 4639923942SSimon Schubert #define _MACHINE_VMPARAM_H_ 4739923942SSimon Schubert 4839923942SSimon Schubert /* 49b2b3ffcdSSimon Schubert * Machine dependent constants for x86_64. 5039923942SSimon Schubert */ 5139923942SSimon Schubert 5239923942SSimon Schubert /* 5339923942SSimon Schubert * Virtual memory related constants, all in bytes 5439923942SSimon Schubert */ 55*3206d887SMatthew Dillon #define MAXTSIZ (32UL*1024*1024*1024) /* max text size */ 5639923942SSimon Schubert #ifndef DFLDSIZ 5739923942SSimon Schubert #define DFLDSIZ (128UL*1024*1024) /* initial data size limit */ 5839923942SSimon Schubert #endif 5939923942SSimon Schubert #ifndef MAXDSIZ 60*3206d887SMatthew Dillon #define MAXDSIZ (32UL*1024*1024*1024) /* max data size */ 6139923942SSimon Schubert #endif 6239923942SSimon Schubert #ifndef DFLSSIZ 6339923942SSimon Schubert #define DFLSSIZ (8UL*1024*1024) /* initial stack size limit */ 6439923942SSimon Schubert #endif 6539923942SSimon Schubert #ifndef MAXSSIZ 66a2a636ccSMatthew Dillon #define MAXSSIZ (512UL*1024*1024) /* max stack size */ 6739923942SSimon Schubert #endif 684837705eSMatthew Dillon #ifndef MAXTHRSSIZ 69*3206d887SMatthew Dillon #define MAXTHRSSIZ (128UL*1024*1024*1024) /* thread stack area */ 704837705eSMatthew Dillon #endif 7139923942SSimon Schubert #ifndef SGROWSIZ 7239923942SSimon Schubert #define SGROWSIZ (128UL*1024) /* amount to grow stack */ 7339923942SSimon Schubert #endif 7439923942SSimon Schubert 7539923942SSimon Schubert /* 7639923942SSimon Schubert * The time for a process to be blocked before being very swappable. 7739923942SSimon Schubert * This is a number of seconds which the system takes as being a non-trivial 7839923942SSimon Schubert * amount of real time. You probably shouldn't change this; 7939923942SSimon Schubert * it is used in subtle ways (fractions and multiples of it are, that is, like 8039923942SSimon Schubert * half of a ``long time'', almost a long time, etc.) 8139923942SSimon Schubert * It is related to human patience and other factors which don't really 8239923942SSimon Schubert * change over time. 8339923942SSimon Schubert */ 8439923942SSimon Schubert #define MAXSLP 20 8539923942SSimon Schubert 8639923942SSimon Schubert /* 8739923942SSimon Schubert * We provide a machine specific single page allocator through the use 8839923942SSimon Schubert * of the direct mapped segment. This uses 2MB pages for reduced 8939923942SSimon Schubert * TLB pressure. 9039923942SSimon Schubert */ 9139923942SSimon Schubert #define UMA_MD_SMALL_ALLOC 9239923942SSimon Schubert 9339923942SSimon Schubert /* 94c8fe38aeSMatthew Dillon * The number of PHYSSEG entries must be one greater than the number 95c8fe38aeSMatthew Dillon * of phys_avail entries because the phys_avail entry that spans the 96c8fe38aeSMatthew Dillon * largest physical address that is accessible by ISA DMA is split 97c8fe38aeSMatthew Dillon * into two PHYSSEG entries. 98c8fe38aeSMatthew Dillon */ 9977c48adbSMatthew Dillon #define VM_PHYSSEG_MAX 127 100c8fe38aeSMatthew Dillon 101c8fe38aeSMatthew Dillon /* 10239923942SSimon Schubert * Virtual addresses of things. Derived from the page directory and 10339923942SSimon Schubert * page table indexes from pmap.h for precision. 10439923942SSimon Schubert * Because of the page that is both a PD and PT, it looks a little 10539923942SSimon Schubert * messy at times, but hey, we'll do anything to save a page :-) 106791c6551SMatthew Dillon * 1078ff9866bSMatthew Dillon * NKPDPE is the number of PD's representing KVM. Not all are immediately 1088ff9866bSMatthew Dillon * populated. There are 512 PD's per PDP and the value is calculated from 1098ff9866bSMatthew Dillon * NKPML4E (see pmap.h). 110da23a592SMatthew Dillon * 111da23a592SMatthew Dillon * The ending address is non-inclusive of the per-cpu data array 112da23a592SMatthew Dillon * which starts at MPPTDI (-16MB mark). MPPTDI is the page directory 113da23a592SMatthew Dillon * index in the last PD of the kernel address space and is typically 114da23a592SMatthew Dillon * set to (NPDEPG - 8) = (512 - 8). 11539923942SSimon Schubert */ 1168ff9866bSMatthew Dillon #define NKPDPE (NKPML4E*NPDPEPG-1) 117d30a28ddSMatthew Dillon #define KPDPPHYS_KVA KVADDR(KPML4I, 0, 0, 0) 1188ff9866bSMatthew Dillon #define VM_MIN_KERNEL_ADDRESS KVADDR(KPML4I, NKPML4E*NPDPEPG - NKPDPE, 0, 0) 1198ff9866bSMatthew Dillon #define VM_MAX_KERNEL_ADDRESS KVADDR(KPML4I + NKPML4E - 1, \ 1208ff9866bSMatthew Dillon NPDPEPG - 1, MPPTDI, NPTEPG - 1) 12139923942SSimon Schubert 12239923942SSimon Schubert #define DMAP_MIN_ADDRESS KVADDR(DMPML4I, 0, 0, 0) 12333fb3ba1SMatthew Dillon #define DMAP_MAX_ADDRESS KVADDR(DMPML4I+NDMPML4E, 0, 0, 0) 12439923942SSimon Schubert 1258ff9866bSMatthew Dillon #define KERNBASE KVADDR(KPML4I + NKPML4E - 1, KPDPI, 0, 0) 126c8fe38aeSMatthew Dillon #define PTOV_OFFSET KERNBASE 12739923942SSimon Schubert 12867553e72SJordan Gordeev #define UPT_MAX_ADDRESS KVADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I) 12967553e72SJordan Gordeev #define UPT_MIN_ADDRESS KVADDR(PML4PML4I, 0, 0, 0) 13039923942SSimon Schubert 13111ba7f73SMatthew Dillon /* 13211ba7f73SMatthew Dillon * Do not allow the top 2MB of the user stack to be mapped to work around 13311ba7f73SMatthew Dillon * an AMD bug wherein the cpu can lockup or destabilize if the instruction 13411ba7f73SMatthew Dillon * prefetcher crosses over into non-canonical address space. Only the top 13511ba7f73SMatthew Dillon * 4KB needs to be disallowed, but taking out the whole 2MB allows potential 13611ba7f73SMatthew Dillon * 2MB PTE optimizations to be retained. 13711ba7f73SMatthew Dillon */ 13839923942SSimon Schubert #define VM_MIN_USER_ADDRESS ((vm_offset_t)0) 13911ba7f73SMatthew Dillon #define VM_MAX_USER_ADDRESS UVADDR(NUPDP_USER - 1, NPDPEPG - 1, \ 14011ba7f73SMatthew Dillon NPDEPG - 1, 0) 14167553e72SJordan Gordeev 14267553e72SJordan Gordeev #define USRSTACK VM_MAX_USER_ADDRESS 14339923942SSimon Schubert 1448cd7f47bSFrançois Tigeot #define VM_MAX_ADDRESS UPT_MAX_ADDRESS 1458cd7f47bSFrançois Tigeot #define VM_MIN_ADDRESS (0) 1468cd7f47bSFrançois Tigeot 147f70051b1SMatthew Dillon #define PHYS_TO_DMAP(x) ((vm_offset_t)(x) + DMAP_MIN_ADDRESS) 148f70051b1SMatthew Dillon #define DMAP_TO_PHYS(x) ((vm_paddr_t)(x) - DMAP_MIN_ADDRESS) 14939923942SSimon Schubert 15039923942SSimon Schubert /* initial pagein size of beginning of executable file */ 15139923942SSimon Schubert #ifndef VM_INITIAL_PAGEIN 15239923942SSimon Schubert #define VM_INITIAL_PAGEIN 16 15339923942SSimon Schubert #endif 15439923942SSimon Schubert 15539923942SSimon Schubert #endif /* _MACHINE_VMPARAM_H_ */ 156