Index: sys/amd64/amd64/machdep.c =================================================================== --- sys/amd64/amd64/machdep.c +++ sys/amd64/amd64/machdep.c @@ -210,21 +210,6 @@ long Maxmem = 0; long realmem = 0; -/* - * The number of PHYSMAP entries must be one less than the number of - * PHYSSEG entries because the PHYSMAP entry that spans the largest - * physical address that is accessible by ISA DMA is split into two - * PHYSSEG entries. - */ -#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1)) - -vm_paddr_t phys_avail[PHYSMAP_SIZE + 2]; -vm_paddr_t dump_avail[PHYSMAP_SIZE + 2]; - -/* must be 2 less so 0 0 can signal end of chunks */ -#define PHYS_AVAIL_ARRAY_END (nitems(phys_avail) - 2) -#define DUMP_AVAIL_ARRAY_END (nitems(dump_avail) - 2) - struct kva_md_info kmi; static struct trapframe proc0_tf; @@ -1036,7 +1021,7 @@ physmap_idx += 2; *physmap_idxp = physmap_idx; - if (physmap_idx == PHYSMAP_SIZE) { + if (physmap_idx == PHYS_AVAIL_ENTRIES) { printf( "Too many segments in the physical address map, giving up\n"); return (0); @@ -1229,7 +1214,7 @@ getmemsize(caddr_t kmdp, u_int64_t first) { int i, physmap_idx, pa_indx, da_indx; - vm_paddr_t pa, physmap[PHYSMAP_SIZE]; + vm_paddr_t pa, physmap[PHYS_AVAIL_ENTRIES]; u_long physmem_start, physmem_tunable, memtest; pt_entry_t *pte; quad_t dcons_addr, dcons_size; @@ -1446,7 +1431,7 @@ phys_avail[pa_indx] += PAGE_SIZE; } else { pa_indx++; - if (pa_indx == PHYS_AVAIL_ARRAY_END) { + if (pa_indx == PHYS_AVAIL_ENTRIES) { printf( "Too many holes in the physical address space, giving up\n"); pa_indx--; @@ -1462,7 +1447,7 @@ dump_avail[da_indx] += PAGE_SIZE; } else { da_indx++; - if (da_indx == DUMP_AVAIL_ARRAY_END) { + if (da_indx == PHYS_AVAIL_ENTRIES) { da_indx--; goto do_next; } Index: sys/amd64/include/pmap.h =================================================================== --- sys/amd64/include/pmap.h +++ sys/amd64/include/pmap.h @@ -226,7 +226,7 @@ /* Large map: index of the first and max last pml4 entry */ #define LMSPML4I (PML4PML4I + 1) -#define LMEPML4I (DMPML4I - 1) +#define LMEPML4I (PAPML4I - 1) /* * XXX doesn't really belong here I guess... @@ -408,8 +408,6 @@ extern caddr_t CADDR1; extern pt_entry_t *CMAP1; -extern vm_paddr_t phys_avail[]; -extern vm_paddr_t dump_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; extern vm_paddr_t dmaplimit; Index: sys/arm/arm/busdma_machdep-v4.c =================================================================== --- sys/arm/arm/busdma_machdep-v4.c +++ sys/arm/arm/busdma_machdep-v4.c @@ -70,7 +70,9 @@ #include #include +#include #include +#include #include #include #include Index: sys/arm/arm/busdma_machdep-v6.c =================================================================== --- sys/arm/arm/busdma_machdep-v6.c +++ sys/arm/arm/busdma_machdep-v6.c @@ -52,7 +52,9 @@ #include #include +#include #include +#include #include #include #include Index: sys/arm/arm/mem.c =================================================================== --- sys/arm/arm/mem.c +++ sys/arm/arm/mem.c @@ -62,6 +62,9 @@ #include #include +#include +#include +#include #include #include Index: sys/arm/arm/minidump_machdep.c =================================================================== --- sys/arm/arm/minidump_machdep.c +++ sys/arm/arm/minidump_machdep.c @@ -45,13 +45,15 @@ #include #endif #include +#include +#include +#include #include #include #include #include #include #include -#include CTASSERT(sizeof(struct kerneldumpheader) == 512); Index: sys/arm/arm/physmem.c =================================================================== --- sys/arm/arm/physmem.c +++ sys/arm/arm/physmem.c @@ -39,6 +39,9 @@ #include #include #include +#include +#include +#include #include #include @@ -77,32 +80,6 @@ static size_t hwcnt; static size_t excnt; -/* - * These "avail lists" are globals used to communicate physical memory layout to - * other parts of the kernel. Within the arrays, each value is the starting - * address of a contiguous area of physical address space. The values at even - * indexes are areas that contain usable memory and the values at odd indexes - * are areas that aren't usable. Each list is terminated by a pair of zero - * entries. - * - * dump_avail tells the dump code what regions to include in a crash dump, and - * phys_avail is the way we hand all the remaining physical ram we haven't used - * in early kernel init over to the vm system for allocation management. - * - * We size these arrays to hold twice as many available regions as we allow for - * hardware memory regions, to allow for the fact that exclusions can split a - * hardware region into two or more available regions. In the real world there - * will typically be one or two hardware regions and two or three exclusions. - * - * Each available region in this list occupies two array slots (the start of the - * available region and the start of the unavailable region that follows it). - */ -#define MAX_AVAIL_REGIONS (MAX_HWCNT * 2) -#define MAX_AVAIL_ENTRIES (MAX_AVAIL_REGIONS * 2) - -vm_paddr_t phys_avail[MAX_AVAIL_ENTRIES + 2]; /* +2 to allow for a pair */ -vm_paddr_t dump_avail[MAX_AVAIL_ENTRIES + 2]; /* of zeroes to terminate. */ - /* * realmem is the total number of hardware pages, excluded or not. * Maxmem is one greater than the last physical page number. @@ -405,10 +382,10 @@ { size_t nextidx; - regions_to_avail(dump_avail, EXFLAG_NODUMP, MAX_AVAIL_ENTRIES, NULL, + regions_to_avail(dump_avail, EXFLAG_NODUMP, PHYS_AVAIL_ENTRIES, NULL, NULL); nextidx = regions_to_avail(phys_avail, EXFLAG_NOALLOC, - MAX_AVAIL_ENTRIES, &physmem, &realmem); + PHYS_AVAIL_ENTRIES, &physmem, &realmem); if (nextidx == 0) panic("No memory entries in phys_avail"); Maxmem = atop(phys_avail[nextidx - 1]); Index: sys/arm/include/pmap.h =================================================================== --- sys/arm/include/pmap.h +++ sys/arm/include/pmap.h @@ -41,9 +41,6 @@ #ifdef _KERNEL #include -extern vm_paddr_t dump_avail[]; -extern vm_paddr_t phys_avail[]; - extern char *_tmppt; /* poor name! */ extern vm_offset_t virtual_avail; Index: sys/arm64/include/pmap.h =================================================================== --- sys/arm64/include/pmap.h +++ sys/arm64/include/pmap.h @@ -132,9 +132,6 @@ #define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) #define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) -#define PHYS_AVAIL_SIZE 32 -extern vm_paddr_t phys_avail[]; -extern vm_paddr_t dump_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; Index: sys/i386/i386/machdep.c =================================================================== --- sys/i386/i386/machdep.c +++ sys/i386/i386/machdep.c @@ -194,21 +194,6 @@ FEATURE(pae, "Physical Address Extensions"); #endif -/* - * The number of PHYSMAP entries must be one less than the number of - * PHYSSEG entries because the PHYSMAP entry that spans the largest - * physical address that is accessible by ISA DMA is split into two - * PHYSSEG entries. - */ -#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1)) - -vm_paddr_t phys_avail[PHYSMAP_SIZE + 2]; -vm_paddr_t dump_avail[PHYSMAP_SIZE + 2]; - -/* must be 2 less so 0 0 can signal end of chunks */ -#define PHYS_AVAIL_ARRAY_END (nitems(phys_avail) - 2) -#define DUMP_AVAIL_ARRAY_END (nitems(dump_avail) - 2) - struct kva_md_info kmi; static struct trapframe proc0_tf; @@ -1736,7 +1721,7 @@ physmap_idx += 2; *physmap_idxp = physmap_idx; - if (physmap_idx == PHYSMAP_SIZE) { + if (physmap_idx == PHYS_AVAIL_ENTRIES) { printf( "Too many segments in the physical address map, giving up\n"); return (0); @@ -1823,7 +1808,7 @@ { int has_smap, off, physmap_idx, pa_indx, da_indx; u_long memtest; - vm_paddr_t physmap[PHYSMAP_SIZE]; + vm_paddr_t physmap[PHYS_AVAIL_ENTRIES]; quad_t dcons_addr, dcons_size, physmem_tunable; int hasbrokenint12, i, res; u_int extmem; @@ -2136,7 +2121,7 @@ phys_avail[pa_indx] += PAGE_SIZE; } else { pa_indx++; - if (pa_indx == PHYS_AVAIL_ARRAY_END) { + if (pa_indx == PHYS_AVAIL_ENTRIES) { printf( "Too many holes in the physical address space, giving up\n"); pa_indx--; @@ -2152,7 +2137,7 @@ dump_avail[da_indx] += PAGE_SIZE; } else { da_indx++; - if (da_indx == DUMP_AVAIL_ARRAY_END) { + if (da_indx == PHYS_AVAIL_ENTRIES) { da_indx--; goto do_next; } Index: sys/i386/i386/minidump_machdep_base.c =================================================================== --- sys/i386/i386/minidump_machdep_base.c +++ sys/i386/i386/minidump_machdep_base.c @@ -40,6 +40,9 @@ #include #include #include +#include +#include +#include #include #include #include Index: sys/i386/include/pmap.h =================================================================== --- sys/i386/include/pmap.h +++ sys/i386/include/pmap.h @@ -234,8 +234,6 @@ #ifdef _KERNEL -extern vm_paddr_t phys_avail[]; -extern vm_paddr_t dump_avail[]; extern char *ptvmmap; /* poor name! */ extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; Index: sys/kern/kern_dump.c =================================================================== --- sys/kern/kern_dump.c +++ sys/kern/kern_dump.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include #include Index: sys/mips/atheros/ar531x/ar5315_machdep.c =================================================================== --- sys/mips/atheros/ar531x/ar5315_machdep.c +++ sys/mips/atheros/ar531x/ar5315_machdep.c @@ -42,7 +42,9 @@ #include #include +#include #include +#include #include @@ -52,7 +54,6 @@ #include #include #include -#include #include Index: sys/mips/atheros/ar71xx_machdep.c =================================================================== --- sys/mips/atheros/ar71xx_machdep.c +++ sys/mips/atheros/ar71xx_machdep.c @@ -45,7 +45,9 @@ #include #include +#include #include +#include #include @@ -55,7 +57,6 @@ #include #include #include -#include #include Index: sys/mips/beri/beri_machdep.c =================================================================== --- sys/mips/beri/beri_machdep.c +++ sys/mips/beri/beri_machdep.c @@ -65,8 +65,10 @@ #endif #include +#include #include #include +#include #include #include Index: sys/mips/broadcom/bcm_machdep.c =================================================================== --- sys/mips/broadcom/bcm_machdep.c +++ sys/mips/broadcom/bcm_machdep.c @@ -57,8 +57,10 @@ #include #include +#include #include #include +#include #include #include @@ -73,7 +75,6 @@ #include #include #include -#include #include #include Index: sys/mips/cavium/octeon_machdep.c =================================================================== --- sys/mips/cavium/octeon_machdep.c +++ sys/mips/cavium/octeon_machdep.c @@ -56,8 +56,10 @@ #include #include +#include #include #include +#include #include #include @@ -73,7 +75,6 @@ #include #include #include -#include #include #include Index: sys/mips/include/pmap.h =================================================================== --- sys/mips/include/pmap.h +++ sys/mips/include/pmap.h @@ -48,7 +48,7 @@ #ifndef _MACHINE_PMAP_H_ #define _MACHINE_PMAP_H_ -#include +#include #include #if defined(__mips_n32) || defined(__mips_n64) /* PHYSADDR_64BIT */ @@ -157,15 +157,11 @@ * so we can describe up to (PHYS_AVAIL_ENTRIES / 2) distinct memory * regions. */ -#define PHYS_AVAIL_ENTRIES 10 -extern vm_paddr_t phys_avail[PHYS_AVAIL_ENTRIES + 2]; -extern vm_paddr_t physmem_desc[PHYS_AVAIL_ENTRIES + 2]; +extern vm_paddr_t physmem_desc[PHYS_AVAIL_COUNT]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; -extern vm_paddr_t dump_avail[PHYS_AVAIL_ENTRIES + 2]; - #define pmap_page_get_memattr(m) (((m)->md.pv_flags & PV_MEMATTR_MASK) >> PV_MEMATTR_SHIFT) #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) #define pmap_page_is_write_mapped(m) (((m)->aflags & PGA_WRITEABLE) != 0) Index: sys/mips/ingenic/jz4780_machdep.c =================================================================== --- sys/mips/ingenic/jz4780_machdep.c +++ sys/mips/ingenic/jz4780_machdep.c @@ -48,7 +48,9 @@ #endif #include +#include #include +#include #include @@ -58,7 +60,6 @@ #include #include #include -#include #include #include Index: sys/mips/malta/malta_machdep.c =================================================================== --- sys/mips/malta/malta_machdep.c +++ sys/mips/malta/malta_machdep.c @@ -54,8 +54,10 @@ #include #include +#include #include #include +#include #include #include Index: sys/mips/mediatek/mtk_machdep.c =================================================================== --- sys/mips/mediatek/mtk_machdep.c +++ sys/mips/mediatek/mtk_machdep.c @@ -54,8 +54,10 @@ #include #include +#include #include #include +#include #include #include @@ -70,7 +72,6 @@ #include #include #include -#include #include #include Index: sys/mips/mips/busdma_machdep.c =================================================================== --- sys/mips/mips/busdma_machdep.c +++ sys/mips/mips/busdma_machdep.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include Index: sys/mips/mips/machdep.c =================================================================== --- sys/mips/mips/machdep.c +++ sys/mips/mips/machdep.c @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -140,9 +141,7 @@ struct pcpu *pcpup = (struct pcpu *)pcpu_space; -vm_paddr_t phys_avail[PHYS_AVAIL_ENTRIES + 2]; -vm_paddr_t physmem_desc[PHYS_AVAIL_ENTRIES + 2]; -vm_paddr_t dump_avail[PHYS_AVAIL_ENTRIES + 2]; +vm_paddr_t physmem_desc[PHYS_AVAIL_COUNT]; #ifdef UNIMPLEMENTED struct platform platform; Index: sys/mips/mips/pmap.c =================================================================== --- sys/mips/mips/pmap.c +++ sys/mips/mips/pmap.c @@ -88,6 +88,7 @@ #include #include #include +#include #include #include #include Index: sys/mips/nlm/xlp_machdep.c =================================================================== --- sys/mips/nlm/xlp_machdep.c +++ sys/mips/nlm/xlp_machdep.c @@ -56,7 +56,9 @@ #include #include +#include #include +#include #include #include Index: sys/powerpc/aim/mmu_oea.c =================================================================== --- sys/powerpc/aim/mmu_oea.c +++ sys/powerpc/aim/mmu_oea.c @@ -132,6 +132,8 @@ #include #include #include +#include +#include #include #include @@ -749,7 +751,7 @@ } while (pa < end); } - if (nitems(phys_avail) < regions_sz) + if (PHYS_AVAIL_ENTRIES < regions_sz) panic("moea_bootstrap: phys_avail too small"); phys_avail_count = 0; Index: sys/powerpc/aim/mmu_oea64.c =================================================================== --- sys/powerpc/aim/mmu_oea64.c +++ sys/powerpc/aim/mmu_oea64.c @@ -74,6 +74,7 @@ #include #include #include +#include #include #include #include @@ -784,7 +785,7 @@ mem_regions(&pregions, &pregions_sz, ®ions, ®ions_sz); CTR0(KTR_PMAP, "moea64_bootstrap: physical memory"); - if (nitems(phys_avail) < regions_sz) + if (PHYS_AVAIL_ENTRIES < regions_sz) panic("moea64_bootstrap: phys_avail too small"); phys_avail_count = 0; Index: sys/powerpc/include/pmap.h =================================================================== --- sys/powerpc/include/pmap.h +++ sys/powerpc/include/pmap.h @@ -75,6 +75,7 @@ #include #include #include +#include struct pmap; typedef struct pmap *pmap_t; @@ -268,12 +269,6 @@ #define vtophys(va) pmap_kextract((vm_offset_t)(va)) -#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with - * logical memory block size of 64MB. - * For more Ram increase the lmb or this value. - */ - -extern vm_paddr_t phys_avail[PHYS_AVAIL_SZ]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; Index: sys/powerpc/include/vmparam.h =================================================================== --- sys/powerpc/include/vmparam.h +++ sys/powerpc/include/vmparam.h @@ -149,7 +149,15 @@ }; #endif -#define VM_PHYSSEG_MAX 16 /* 1? */ +#define VM_PHYSSEG_MAX 16 + +#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with + * logical memory block size of 64MB. + * For more Ram increase the lmb or this value. + */ + +/* XXX This is non-sensical. Phys avail should hold contiguous regions. */ +#define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ /* * The physical address space is densely populated on 32-bit systems, Index: sys/powerpc/powerpc/machdep.c =================================================================== --- sys/powerpc/powerpc/machdep.c +++ sys/powerpc/powerpc/machdep.c @@ -100,6 +100,7 @@ #include #include #include +#include #include #include #include Index: sys/powerpc/powerpc/pmap_dispatch.c =================================================================== --- sys/powerpc/powerpc/pmap_dispatch.c +++ sys/powerpc/powerpc/pmap_dispatch.c @@ -75,7 +75,6 @@ vm_offset_t msgbuf_phys; vm_offset_t kernel_vm_end; -vm_paddr_t phys_avail[PHYS_AVAIL_SZ]; vm_offset_t virtual_avail; vm_offset_t virtual_end; Index: sys/riscv/include/pmap.h =================================================================== --- sys/riscv/include/pmap.h +++ sys/riscv/include/pmap.h @@ -127,9 +127,6 @@ #define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) #define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) -#define PHYS_AVAIL_SIZE 10 -extern vm_paddr_t phys_avail[]; -extern vm_paddr_t dump_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; Index: sys/riscv/riscv/machdep.c =================================================================== --- sys/riscv/riscv/machdep.c +++ sys/riscv/riscv/machdep.c @@ -67,6 +67,7 @@ #include #include +#include #include #include #include @@ -100,9 +101,6 @@ static struct trapframe proc0_tf; -vm_paddr_t phys_avail[PHYS_AVAIL_SIZE + 2]; -vm_paddr_t dump_avail[PHYS_AVAIL_SIZE + 2]; - int early_boot = 1; int cold = 1; long realmem = 0; @@ -110,8 +108,7 @@ #define DTB_SIZE_MAX (1024 * 1024) -#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1)) -vm_paddr_t physmap[PHYSMAP_SIZE]; +vm_paddr_t physmap[PHYS_AVAIL_ENTRIES]; u_int physmap_idx; struct kva_md_info kmi; @@ -707,7 +704,7 @@ _physmap_idx += 2; *physmap_idxp = _physmap_idx; - if (_physmap_idx == PHYSMAP_SIZE) { + if (_physmap_idx == PHYS_AVAIL_ENTRIES) { printf( "Too many segments in the physical address map, giving up\n"); return (0); Index: sys/sparc64/include/pmap.h =================================================================== --- sys/sparc64/include/pmap.h +++ sys/sparc64/include/pmap.h @@ -105,7 +105,6 @@ extern struct pmap kernel_pmap_store; #define kernel_pmap (&kernel_pmap_store) extern struct rwlock_padalign tte_list_global_lock; -extern vm_paddr_t phys_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; Index: sys/sparc64/sparc64/pmap.c =================================================================== --- sys/sparc64/sparc64/pmap.c +++ sys/sparc64/sparc64/pmap.c @@ -102,11 +102,10 @@ /* * Map of physical memory reagions */ -vm_paddr_t phys_avail[128]; -static struct ofw_mem_region mra[128]; -struct ofw_mem_region sparc64_memreg[128]; +static struct ofw_mem_region mra[VM_PHYSSEG_MAX]; +struct ofw_mem_region sparc64_memreg[VM_PHYSSEG_MAX]; int sparc64_nmemreg; -static struct ofw_map translations[128]; +static struct ofw_map translations[VM_PHYSSEG_MAX]; static int translations_size; static vm_offset_t pmap_idle_map; @@ -331,7 +330,7 @@ OF_panic("%s: finddevice /memory", __func__); if ((sz = OF_getproplen(pmem, "available")) == -1) OF_panic("%s: getproplen /memory/available", __func__); - if (sizeof(phys_avail) < sz) + if (PHYS_AVAIL_ENTRIES < sz) OF_panic("%s: phys_avail too small", __func__); if (sizeof(mra) < sz) OF_panic("%s: mra too small", __func__); Index: sys/vm/vm_param.h =================================================================== --- sys/vm/vm_param.h +++ sys/vm/vm_param.h @@ -126,6 +126,11 @@ #define KSTACK_MAX_PAGES 32 #endif +#ifndef PHYS_AVAIL_ENTRIES +#define PHYS_AVAIL_ENTRIES (VM_PHYSSEG_MAX * 2) +#endif +#define PHYS_AVAIL_COUNT (PHYS_AVAIL_ENTRIES) + 2 + #ifndef ASSEMBLER #ifdef _KERNEL #define num_pages(x) \ Index: sys/vm/vm_phys.h =================================================================== --- sys/vm/vm_phys.h +++ sys/vm/vm_phys.h @@ -46,6 +46,10 @@ #define VM_NFREEORDER_MAX VM_NFREEORDER #endif +extern vm_paddr_t phys_avail[]; +extern vm_paddr_t dump_avail[]; + + /* Domains must be dense (non-sparse) and zero-based. */ struct mem_affinity { vm_paddr_t start; Index: sys/vm/vm_phys.c =================================================================== --- sys/vm/vm_phys.c +++ sys/vm/vm_phys.c @@ -110,6 +110,20 @@ static int __read_mostly vm_nfreelists; +/* + * These "avail lists" are globals used to communicate boot-time physical + * memory layout to other parts of the kernel. Each physically contiguous + * region of memory is defined by a start address at an even index and an + * end address at the following odd index. Each list is terminated by a + * pair of zero entries. + * + * dump_avail tells the dump code what regions to include in a crash dump, and + * phys_avail is all of the remaining physical memory that is available for + * the vm system. + */ +vm_paddr_t phys_avail[PHYS_AVAIL_COUNT]; +vm_paddr_t dump_avail[PHYS_AVAIL_COUNT]; + /* * Provides the mapping from VM_FREELIST_* to free list indices (flind). */ Index: sys/x86/x86/nexus.c =================================================================== --- sys/x86/x86/nexus.c +++ sys/x86/x86/nexus.c @@ -62,8 +62,10 @@ #include #include -#include #include +#include +#include +#include #include #include