kernel - Lower VM_MAX_USER_ADDRESS to finalize work-around for Ryzen bug
[dragonfly.git] / sys / platform / pc64 / include / vmparam.h
blobeeae0e71cbe84ab3e9e1ccc1e1f4105af68d07ec
1 /*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * Copyright (c) 1994 John S. Dyson
4 * Copyright (c) 2003 Peter Wemm
5 * Copyright (c) 2008 The DragonFly Project.
6 * All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
39 * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
40 * $FreeBSD: src/sys/amd64/include/vmparam.h,v 1.44 2003/12/07 04:51:04 alc Exp $
41 * $DragonFly: src/sys/platform/pc64/include/vmparam.h,v 1.2 2008/08/29 17:07:17 dillon Exp $
45 #ifndef _MACHINE_VMPARAM_H_
46 #define _MACHINE_VMPARAM_H_
49 * Machine dependent constants for x86_64.
53 * Virtual memory related constants, all in bytes
55 #define MAXTSIZ (256UL*1024*1024) /* max text size */
56 #ifndef DFLDSIZ
57 #define DFLDSIZ (128UL*1024*1024) /* initial data size limit */
58 #endif
59 #ifndef MAXDSIZ
60 #define MAXDSIZ (32768UL*1024*1024) /* max data size */
61 #endif
62 #ifndef DFLSSIZ
63 #define DFLSSIZ (8UL*1024*1024) /* initial stack size limit */
64 #endif
65 #ifndef MAXSSIZ
66 #define MAXSSIZ (512UL*1024*1024) /* max stack size */
67 #endif
68 #ifndef SGROWSIZ
69 #define SGROWSIZ (128UL*1024) /* amount to grow stack */
70 #endif
73 * The time for a process to be blocked before being very swappable.
74 * This is a number of seconds which the system takes as being a non-trivial
75 * amount of real time. You probably shouldn't change this;
76 * it is used in subtle ways (fractions and multiples of it are, that is, like
77 * half of a ``long time'', almost a long time, etc.)
78 * It is related to human patience and other factors which don't really
79 * change over time.
81 #define MAXSLP 20
84 * We provide a machine specific single page allocator through the use
85 * of the direct mapped segment. This uses 2MB pages for reduced
86 * TLB pressure.
88 #define UMA_MD_SMALL_ALLOC
91 * The number of PHYSSEG entries must be one greater than the number
92 * of phys_avail entries because the phys_avail entry that spans the
93 * largest physical address that is accessible by ISA DMA is split
94 * into two PHYSSEG entries.
96 #define VM_PHYSSEG_MAX 127
99 * Virtual addresses of things. Derived from the page directory and
100 * page table indexes from pmap.h for precision.
101 * Because of the page that is both a PD and PT, it looks a little
102 * messy at times, but hey, we'll do anything to save a page :-)
104 * The kernel address space can be up to (I think) 511 page directory
105 * pages. Each one represents 1G. NKPDPE defines the size of the kernel
106 * address space. The recommended value is between 128 and 511.
108 * The ending address is non-inclusive of the per-cpu data array
109 * which starts at MPPTDI (-16MB mark). MPPTDI is the page directory
110 * index in the last PD of the kernel address space and is typically
111 * set to (NPDEPG - 8) = (512 - 8).
113 #define NKPDPE 511
114 #define VM_MIN_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG - NKPDPE, 0, 0)
115 #define VM_MAX_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG - 1, MPPTDI, NPTEPG - 1)
117 #define DMAP_MIN_ADDRESS KVADDR(DMPML4I, 0, 0, 0)
118 #define DMAP_MAX_ADDRESS KVADDR(DMPML4I+NDMPML4E, 0, 0, 0)
120 #define KERNBASE KVADDR(KPML4I, KPDPI, 0, 0)
121 #define PTOV_OFFSET KERNBASE
123 #define UPT_MAX_ADDRESS KVADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I)
124 #define UPT_MIN_ADDRESS KVADDR(PML4PML4I, 0, 0, 0)
127 * Do not allow the top 2MB of the user stack to be mapped to work around
128 * an AMD bug wherein the cpu can lockup or destabilize if the instruction
129 * prefetcher crosses over into non-canonical address space. Only the top
130 * 4KB needs to be disallowed, but taking out the whole 2MB allows potential
131 * 2MB PTE optimizations to be retained.
133 #define VM_MIN_USER_ADDRESS ((vm_offset_t)0)
134 #define VM_MAX_USER_ADDRESS UVADDR(NUPDP_USER - 1, NPDPEPG - 1, \
135 NPDEPG - 1, 0)
137 #define USRSTACK VM_MAX_USER_ADDRESS
139 #define VM_MAX_ADDRESS UPT_MAX_ADDRESS
140 #define VM_MIN_ADDRESS (0)
142 #define PHYS_TO_DMAP(x) ((vm_offset_t)(x) | DMAP_MIN_ADDRESS)
143 #define DMAP_TO_PHYS(x) ((vm_paddr_t)(x) & ~DMAP_MIN_ADDRESS)
145 /* initial pagein size of beginning of executable file */
146 #ifndef VM_INITIAL_PAGEIN
147 #define VM_INITIAL_PAGEIN 16
148 #endif
150 #endif /* _MACHINE_VMPARAM_H_ */