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