param.h revision 1.37 1 /* $NetBSD: param.h,v 1.37 2020/03/17 17:18:49 maxv Exp $ */
2
3 #ifdef __x86_64__
4
5 #ifndef XENPV
6 /* Must be defined before cpu.h */
7 #define MAXCPUS 256
8 #endif
9
10 #ifdef _KERNEL
11 #include <machine/cpu.h>
12 #if defined(_KERNEL_OPT)
13 #include "opt_kasan.h"
14 #include "opt_kmsan.h"
15 #endif
16 #endif
17
18 #define _MACHINE amd64
19 #define MACHINE "amd64"
20 #define _MACHINE_ARCH x86_64
21 #define MACHINE_ARCH "x86_64"
22 #define MID_MACHINE MID_X86_64
23
24 #define ALIGNED_POINTER(p,t) 1
25 #define ALIGNED_POINTER_LOAD(q,p,t) memcpy((q), (p), sizeof(t))
26
27 /*
28 * Align stack as required by AMD64 System V ABI. This is because
29 * (1) we want to bypass libc/csu in LLDB, and
30 * (2) rtld in glibc >= 2.23 for Linux/x86_64 requires it.
31 */
32 #define STACK_ALIGNBYTES (16 - 1)
33
34 #define ALIGNBYTES32 (sizeof(int) - 1)
35 #define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
36
37 #define PGSHIFT 12 /* LOG2(NBPG) */
38 #define NBPG (1 << PGSHIFT) /* bytes/page */
39 #define PGOFSET (NBPG-1) /* byte offset into page */
40 #define NPTEPG (NBPG/(sizeof (pt_entry_t)))
41
42 #define MAXIOMEM 0xffffffffffff
43
44 /*
45 * Maximum physical memory supported by the implementation.
46 */
47 #if defined(KMSAN)
48 #define MAXPHYSMEM 0x008000000000ULL /* 512GB */
49 #else
50 #define MAXPHYSMEM 0x100000000000ULL /* 16TB */
51 #endif
52
53 /*
54 * XXXfvdl change this (after bootstrap) to take # of bits from
55 * config info into account.
56 */
57 #define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */
58 #define KERNTEXTOFF 0xffffffff80200000 /* start of kernel text */
59 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
60
61 #define KERNTEXTOFF_HI 0xffffffff
62 #define KERNTEXTOFF_LO 0x80200000
63
64 #define KERNBASE_HI 0xffffffff
65 #define KERNBASE_LO 0x80000000
66
67 #define SSIZE 1 /* initial stack size/NBPG */
68 #define SINCR 1 /* increment of stack/NBPG */
69
70 #if defined(KASAN) || defined(KMSAN)
71 #define UPAGES 8
72 #else
73 #define UPAGES 5 /* pages of u-area (1 for redzone) */
74 #endif
75 #define USPACE (UPAGES * NBPG) /* total size of u-area */
76
77 #ifndef MSGBUFSIZE
78 #define MSGBUFSIZE (16*NBPG) /* default message buffer size */
79 #endif
80
81 /*
82 * Constants related to network buffer management.
83 * MCLBYTES must be no larger than NBPG (the software page size), and,
84 * on machines that exchange pages of input or output buffers with mbuf
85 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
86 * of the hardware page size.
87 */
88 #define MSIZE 512 /* size of an mbuf */
89
90 #ifndef MCLSHIFT
91 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
92 /* 2K cluster can hold Ether frame */
93 #endif /* MCLSHIFT */
94
95 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
96
97 #ifndef NFS_RSIZE
98 #define NFS_RSIZE 32768
99 #endif
100 #ifndef NFS_WSIZE
101 #define NFS_WSIZE 32768
102 #endif
103
104 /*
105 * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized
106 * logical pages.
107 * No enforced maximum on amd64.
108 */
109 #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT)
110 #define NKMEMPAGES_MAX_UNLIMITED 1
111
112 /*
113 * XXXfvdl the PD* stuff is different from i386.
114 */
115 /*
116 * Mach derived conversion macros
117 */
118 #define x86_round_pdr(x) \
119 ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1))
120 #define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1))
121 #define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT)
122 #define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT)
123 #define x86_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET)
124 #define x86_trunc_page(x) ((unsigned long)(x) & ~PGOFSET)
125 #define x86_btop(x) ((unsigned long)(x) >> PGSHIFT)
126 #define x86_ptob(x) ((unsigned long)(x) << PGSHIFT)
127
128 #define btop(x) x86_btop(x)
129 #define ptob(x) x86_ptob(x)
130
131 #else /* __x86_64__ */
132
133 #include <i386/param.h>
134
135 #endif /* __x86_64__ */
136