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