vmparam.h revision 266204
133965Sjdp/*- 277298Sobrien * Copyright (c) 1990 The Regents of the University of California. 377298Sobrien * All rights reserved. 433965Sjdp * Copyright (c) 1994 John S. Dyson 533965Sjdp * All rights reserved. 633965Sjdp * Copyright (c) 2003 Peter Wemm 733965Sjdp * All rights reserved. 833965Sjdp * 933965Sjdp * This code is derived from software contributed to Berkeley by 1033965Sjdp * William Jolitz. 1133965Sjdp * 1233965Sjdp * Redistribution and use in source and binary forms, with or without 1333965Sjdp * modification, are permitted provided that the following conditions 1433965Sjdp * are met: 1533965Sjdp * 1. Redistributions of source code must retain the above copyright 1633965Sjdp * notice, this list of conditions and the following disclaimer. 1733965Sjdp * 2. Redistributions in binary form must reproduce the above copyright 1833965Sjdp * notice, this list of conditions and the following disclaimer in the 1933965Sjdp * documentation and/or other materials provided with the distribution. 2033965Sjdp * 3. All advertising materials mentioning features or use of this software 2133965Sjdp * must display the following acknowledgement: 2233965Sjdp * This product includes software developed by the University of 2377298Sobrien * California, Berkeley and its contributors. 2433965Sjdp * 4. Neither the name of the University nor the names of its contributors 2533965Sjdp * may be used to endorse or promote products derived from this software 2638889Sjdp * without specific prior written permission. 2738889Sjdp * 2838889Sjdp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2938889Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 3038889Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 3138889Sjdp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3238889Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3338889Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3438889Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3538889Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3638889Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3738889Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3838889Sjdp * SUCH DAMAGE. 3938889Sjdp * 4038889Sjdp * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 4138889Sjdp * $FreeBSD: stable/10/sys/amd64/include/vmparam.h 266204 2014-05-16 01:30:30Z ian $ 4238889Sjdp */ 4338889Sjdp 4438889Sjdp 4538889Sjdp#ifndef _MACHINE_VMPARAM_H_ 4638889Sjdp#define _MACHINE_VMPARAM_H_ 1 4738889Sjdp 4838889Sjdp/* 4938889Sjdp * Machine dependent constants for AMD64. 5038889Sjdp */ 5138889Sjdp 5238889Sjdp/* 5338889Sjdp * Virtual memory related constants, all in bytes 5433965Sjdp */ 5533965Sjdp#define MAXTSIZ (128UL*1024*1024) /* max text size */ 5633965Sjdp#ifndef DFLDSIZ 5733965Sjdp#define DFLDSIZ (32768UL*1024*1024) /* initial data size limit */ 5833965Sjdp#endif 5933965Sjdp#ifndef MAXDSIZ 6033965Sjdp#define MAXDSIZ (32768UL*1024*1024) /* max data size */ 6133965Sjdp#endif 6233965Sjdp#ifndef DFLSSIZ 6333965Sjdp#define DFLSSIZ (8UL*1024*1024) /* initial stack size limit */ 6433965Sjdp#endif 6533965Sjdp#ifndef MAXSSIZ 6633965Sjdp#define MAXSSIZ (512UL*1024*1024) /* max stack size */ 6733965Sjdp#endif 6833965Sjdp#ifndef SGROWSIZ 6960484Sobrien#define SGROWSIZ (128UL*1024) /* amount to grow stack */ 7060484Sobrien#endif 7133965Sjdp 7233965Sjdp/* 7333965Sjdp * We provide a machine specific single page allocator through the use 7433965Sjdp * of the direct mapped segment. This uses 2MB pages for reduced 7533965Sjdp * TLB pressure. 7633965Sjdp */ 7733965Sjdp#define UMA_MD_SMALL_ALLOC 7833965Sjdp 7933965Sjdp/* 8033965Sjdp * The physical address space is densely populated. 8133965Sjdp */ 8233965Sjdp#define VM_PHYSSEG_DENSE 8333965Sjdp 8433965Sjdp/* 8533965Sjdp * The number of PHYSSEG entries must be one greater than the number 8633965Sjdp * of phys_avail entries because the phys_avail entry that spans the 8733965Sjdp * largest physical address that is accessible by ISA DMA is split 8833965Sjdp * into two PHYSSEG entries. 8933965Sjdp */ 9033965Sjdp#define VM_PHYSSEG_MAX 31 9138889Sjdp 9238889Sjdp/* 9333965Sjdp * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool 9433965Sjdp * from which physical pages are allocated and VM_FREEPOOL_DIRECT is 9533965Sjdp * the pool from which physical pages for page tables and small UMA 9633965Sjdp * objects are allocated. 9733965Sjdp */ 9833965Sjdp#define VM_NFREEPOOL 3 9933965Sjdp#define VM_FREEPOOL_CACHE 2 10033965Sjdp#define VM_FREEPOOL_DEFAULT 0 10133965Sjdp#define VM_FREEPOOL_DIRECT 1 10233965Sjdp 10333965Sjdp/* 10433965Sjdp * Create two free page lists: VM_FREELIST_DEFAULT is for physical 10533965Sjdp * pages that are above the largest physical address that is 10633965Sjdp * accessible by ISA DMA and VM_FREELIST_ISADMA is for physical pages 10733965Sjdp * that are below that address. 10833965Sjdp */ 10933965Sjdp#define VM_NFREELIST 2 11033965Sjdp#define VM_FREELIST_DEFAULT 0 11133965Sjdp#define VM_FREELIST_ISADMA 1 11233965Sjdp 11333965Sjdp/* 11433965Sjdp * An allocation size of 16MB is supported in order to optimize the 11533965Sjdp * use of the direct map by UMA. Specifically, a cache line contains 11633965Sjdp * at most 8 PDEs, collectively mapping 16MB of physical memory. By 11733965Sjdp * reducing the number of distinct 16MB "pages" that are used by UMA, 11833965Sjdp * the physical memory allocator reduces the likelihood of both 2MB 11933965Sjdp * page TLB misses and cache misses caused by 2MB page TLB misses. 12033965Sjdp */ 12133965Sjdp#define VM_NFREEORDER 13 12233965Sjdp 12333965Sjdp/* 12433965Sjdp * Enable superpage reservations: 1 level. 12533965Sjdp */ 12633965Sjdp#ifndef VM_NRESERVLEVEL 12733965Sjdp#define VM_NRESERVLEVEL 1 12833965Sjdp#endif 12933965Sjdp 13033965Sjdp/* 13133965Sjdp * Level 0 reservations consist of 512 pages. 13233965Sjdp */ 13333965Sjdp#ifndef VM_LEVEL_0_ORDER 13433965Sjdp#define VM_LEVEL_0_ORDER 9 13533965Sjdp#endif 13633965Sjdp 13733965Sjdp#ifdef SMP 13833965Sjdp#define PA_LOCK_COUNT 256 13933965Sjdp#endif 14033965Sjdp 14133965Sjdp/* 14233965Sjdp * Virtual addresses of things. Derived from the page directory and 14333965Sjdp * page table indexes from pmap.h for precision. 14433965Sjdp * 14560484Sobrien * 0x0000000000000000 - 0x00007fffffffffff user map 14660484Sobrien * 0x0000800000000000 - 0xffff7fffffffffff does not exist (hole) 14760484Sobrien * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot) 14860484Sobrien * 0xffff804020101000 - 0xfffff7ffffffffff unused 14960484Sobrien * 0xfffff80000000000 - 0xfffffbffffffffff 4TB direct map 15060484Sobrien * 0xfffffc0000000000 - 0xfffffdffffffffff unused 15160484Sobrien * 0xfffffe0000000000 - 0xffffffffffffffff 2TB kernel map 15260484Sobrien * 15360484Sobrien * Within the kernel map: 15433965Sjdp * 15533965Sjdp * 0xffffffff80000000 KERNBASE 15633965Sjdp */ 15733965Sjdp 15833965Sjdp#define VM_MIN_KERNEL_ADDRESS KVADDR(KPML4BASE, 0, 0, 0) 15933965Sjdp#define VM_MAX_KERNEL_ADDRESS KVADDR(KPML4BASE + NKPML4E - 1, \ 16033965Sjdp NPDPEPG-1, NPDEPG-1, NPTEPG-1) 16133965Sjdp 16233965Sjdp#define DMAP_MIN_ADDRESS KVADDR(DMPML4I, 0, 0, 0) 16333965Sjdp#define DMAP_MAX_ADDRESS KVADDR(DMPML4I + NDMPML4E, 0, 0, 0) 16433965Sjdp 16533965Sjdp#define KERNBASE KVADDR(KPML4I, KPDPI, 0, 0) 16633965Sjdp 16733965Sjdp#define UPT_MAX_ADDRESS KVADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I) 16833965Sjdp#define UPT_MIN_ADDRESS KVADDR(PML4PML4I, 0, 0, 0) 16933965Sjdp 17033965Sjdp#define VM_MAXUSER_ADDRESS UVADDR(NUPML4E, 0, 0, 0) 17133965Sjdp 17233965Sjdp#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 17333965Sjdp#define USRSTACK SHAREDPAGE 17433965Sjdp 17533965Sjdp#define VM_MAX_ADDRESS UPT_MAX_ADDRESS 17677298Sobrien#define VM_MIN_ADDRESS (0) 17733965Sjdp 17833965Sjdp#define PHYS_TO_DMAP(x) ((x) | DMAP_MIN_ADDRESS) 17933965Sjdp#define DMAP_TO_PHYS(x) ((x) & ~DMAP_MIN_ADDRESS) 18033965Sjdp 18133965Sjdp/* 18233965Sjdp * How many physical pages per kmem arena virtual page. 18333965Sjdp */ 18477298Sobrien#ifndef VM_KMEM_SIZE_SCALE 18533965Sjdp#define VM_KMEM_SIZE_SCALE (1) 18677298Sobrien#endif 18733965Sjdp 18833965Sjdp/* 18933965Sjdp * Optional ceiling (in bytes) on the size of the kmem arena: 60% of the 19077298Sobrien * kernel map. 19133965Sjdp */ 19233965Sjdp#ifndef VM_KMEM_SIZE_MAX 19333965Sjdp#define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \ 19433965Sjdp VM_MIN_KERNEL_ADDRESS + 1) * 3 / 5) 19533965Sjdp#endif 19633965Sjdp 19777298Sobrien/* initial pagein size of beginning of executable file */ 19833965Sjdp#ifndef VM_INITIAL_PAGEIN 19933965Sjdp#define VM_INITIAL_PAGEIN 16 20033965Sjdp#endif 20133965Sjdp 20233965Sjdp#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ 20377298Sobrien 20433965Sjdp#endif /* _MACHINE_VMPARAM_H_ */ 20533965Sjdp