1*ff2d91f1Sjdolecek /* $NetBSD: param.h,v 1.38 2020/06/29 09:56:51 jdolecek Exp $ */ 2433b5ddeSmrg 3433b5ddeSmrg #ifdef __x86_64__ 481918bf8Sfvdl 5427af037Scherry #ifndef XENPV 60c794722Srmind /* Must be defined before cpu.h */ 70c794722Srmind #define MAXCPUS 256 80c794722Srmind #endif 90c794722Srmind 1081918bf8Sfvdl #ifdef _KERNEL 1181918bf8Sfvdl #include <machine/cpu.h> 127c492317Smaxv #if defined(_KERNEL_OPT) 137c492317Smaxv #include "opt_kasan.h" 1410c5b023Smaxv #include "opt_kmsan.h" 15*ff2d91f1Sjdolecek #include "opt_svs.h" 167c492317Smaxv #endif 1781918bf8Sfvdl #endif 1881918bf8Sfvdl 1981918bf8Sfvdl #define _MACHINE amd64 2081918bf8Sfvdl #define MACHINE "amd64" 2181918bf8Sfvdl #define _MACHINE_ARCH x86_64 2281918bf8Sfvdl #define MACHINE_ARCH "x86_64" 2381918bf8Sfvdl #define MID_MACHINE MID_X86_64 2481918bf8Sfvdl 2581918bf8Sfvdl #define ALIGNED_POINTER(p,t) 1 26001c9b0eSriastradh #define ALIGNED_POINTER_LOAD(q,p,t) memcpy((q), (p), sizeof(t)) 2781918bf8Sfvdl 28573f65caSrin /* 29573f65caSrin * Align stack as required by AMD64 System V ABI. This is because 30573f65caSrin * (1) we want to bypass libc/csu in LLDB, and 31573f65caSrin * (2) rtld in glibc >= 2.23 for Linux/x86_64 requires it. 32573f65caSrin */ 33573f65caSrin #define STACK_ALIGNBYTES (16 - 1) 34573f65caSrin 3581918bf8Sfvdl #define ALIGNBYTES32 (sizeof(int) - 1) 3681918bf8Sfvdl #define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32) 3781918bf8Sfvdl 3881918bf8Sfvdl #define PGSHIFT 12 /* LOG2(NBPG) */ 3981918bf8Sfvdl #define NBPG (1 << PGSHIFT) /* bytes/page */ 4081918bf8Sfvdl #define PGOFSET (NBPG-1) /* byte offset into page */ 4181918bf8Sfvdl #define NPTEPG (NBPG/(sizeof (pt_entry_t))) 4281918bf8Sfvdl 4315149c9aSmaya #define MAXIOMEM 0xffffffffffff 4415149c9aSmaya 4581918bf8Sfvdl /* 46b58f1fcbSmaxv * Maximum physical memory supported by the implementation. 47b58f1fcbSmaxv */ 4810c5b023Smaxv #if defined(KMSAN) 4910c5b023Smaxv #define MAXPHYSMEM 0x008000000000ULL /* 512GB */ 5010c5b023Smaxv #else 51b58f1fcbSmaxv #define MAXPHYSMEM 0x100000000000ULL /* 16TB */ 5210c5b023Smaxv #endif 53b58f1fcbSmaxv 54b58f1fcbSmaxv /* 5581918bf8Sfvdl * XXXfvdl change this (after bootstrap) to take # of bits from 5681918bf8Sfvdl * config info into account. 5781918bf8Sfvdl */ 5881918bf8Sfvdl #define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */ 592b265831Smaxv #define KERNTEXTOFF 0xffffffff80200000 /* start of kernel text */ 6081918bf8Sfvdl #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 6181918bf8Sfvdl 6281918bf8Sfvdl #define KERNTEXTOFF_HI 0xffffffff 632b265831Smaxv #define KERNTEXTOFF_LO 0x80200000 6481918bf8Sfvdl 6581918bf8Sfvdl #define KERNBASE_HI 0xffffffff 6681918bf8Sfvdl #define KERNBASE_LO 0x80000000 6781918bf8Sfvdl 68dd6f356cShaad #define SSIZE 1 /* initial stack size/NBPG */ 69dd6f356cShaad #define SINCR 1 /* increment of stack/NBPG */ 707c492317Smaxv 71081da2e4Smaxv #if defined(KASAN) || defined(KMSAN) 727c492317Smaxv #define UPAGES 8 73*ff2d91f1Sjdolecek #elif defined(SVS) 74*ff2d91f1Sjdolecek #define UPAGES 6 /* 1 page used internally by SVS */ 755e34fbf9Sad #else 765d43782cSmaxv #define UPAGES 5 /* pages of u-area (1 for redzone) */ 775e34fbf9Sad #endif 7881918bf8Sfvdl #define USPACE (UPAGES * NBPG) /* total size of u-area */ 7981918bf8Sfvdl 8081918bf8Sfvdl #ifndef MSGBUFSIZE 81a96590afSsborrill #define MSGBUFSIZE (16*NBPG) /* default message buffer size */ 8281918bf8Sfvdl #endif 8381918bf8Sfvdl 8481918bf8Sfvdl /* 8581918bf8Sfvdl * Constants related to network buffer management. 8681918bf8Sfvdl * MCLBYTES must be no larger than NBPG (the software page size), and, 8781918bf8Sfvdl * on machines that exchange pages of input or output buffers with mbuf 8881918bf8Sfvdl * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 8981918bf8Sfvdl * of the hardware page size. 9081918bf8Sfvdl */ 9181918bf8Sfvdl #define MSIZE 512 /* size of an mbuf */ 9281918bf8Sfvdl 9381918bf8Sfvdl #ifndef MCLSHIFT 9481918bf8Sfvdl #define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 9581918bf8Sfvdl /* 2K cluster can hold Ether frame */ 9681918bf8Sfvdl #endif /* MCLSHIFT */ 9781918bf8Sfvdl 9881918bf8Sfvdl #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ 9981918bf8Sfvdl 10081918bf8Sfvdl #ifndef NFS_RSIZE 10181918bf8Sfvdl #define NFS_RSIZE 32768 10281918bf8Sfvdl #endif 10381918bf8Sfvdl #ifndef NFS_WSIZE 10481918bf8Sfvdl #define NFS_WSIZE 32768 10581918bf8Sfvdl #endif 10681918bf8Sfvdl 10781918bf8Sfvdl /* 1085f319369Spara * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized 10981918bf8Sfvdl * logical pages. 1105f319369Spara * No enforced maximum on amd64. 11181918bf8Sfvdl */ 11281918bf8Sfvdl #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) 1135f319369Spara #define NKMEMPAGES_MAX_UNLIMITED 1 11481918bf8Sfvdl 11581918bf8Sfvdl /* 11681918bf8Sfvdl * XXXfvdl the PD* stuff is different from i386. 11781918bf8Sfvdl */ 11881918bf8Sfvdl /* 11981918bf8Sfvdl * Mach derived conversion macros 12081918bf8Sfvdl */ 12181918bf8Sfvdl #define x86_round_pdr(x) \ 12281918bf8Sfvdl ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1)) 12381918bf8Sfvdl #define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1)) 12481918bf8Sfvdl #define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT) 12581918bf8Sfvdl #define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT) 12681918bf8Sfvdl #define x86_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET) 12781918bf8Sfvdl #define x86_trunc_page(x) ((unsigned long)(x) & ~PGOFSET) 12881918bf8Sfvdl #define x86_btop(x) ((unsigned long)(x) >> PGSHIFT) 12981918bf8Sfvdl #define x86_ptob(x) ((unsigned long)(x) << PGSHIFT) 13081918bf8Sfvdl 13181918bf8Sfvdl #define btop(x) x86_btop(x) 13281918bf8Sfvdl #define ptob(x) x86_ptob(x) 13381918bf8Sfvdl 134433b5ddeSmrg #else /* __x86_64__ */ 135433b5ddeSmrg 136433b5ddeSmrg #include <i386/param.h> 137433b5ddeSmrg 138433b5ddeSmrg #endif /* __x86_64__ */ 139