From owner-svn-src-all@freebsd.org Fri Aug 16 00:45:23 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 027B8BB7F1; Fri, 16 Aug 2019 00:45:23 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 468l3Q70b6z4byB; Fri, 16 Aug 2019 00:45:22 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D356120F6C; Fri, 16 Aug 2019 00:45:22 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7G0jMmE007370; Fri, 16 Aug 2019 00:45:22 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7G0jE3x007325; Fri, 16 Aug 2019 00:45:14 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <201908160045.x7G0jE3x007325@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Fri, 16 Aug 2019 00:45:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351108 - in head/sys: amd64/amd64 amd64/include arm/arm arm/include arm64/include i386/i386 i386/include kern mips/atheros mips/atheros/ar531x mips/beri mips/broadcom mips/cavium mips/... X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: in head/sys: amd64/amd64 amd64/include arm/arm arm/include arm64/include i386/i386 i386/include kern mips/atheros mips/atheros/ar531x mips/beri mips/broadcom mips/cavium mips/include mips/ingenic mips... X-SVN-Commit-Revision: 351108 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Aug 2019 00:45:23 -0000 Author: jeff Date: Fri Aug 16 00:45:14 2019 New Revision: 351108 URL: https://svnweb.freebsd.org/changeset/base/351108 Log: Move phys_avail definition into MI code. It is consumed in the MI layer and doing so adds more flexibility with less redundant code. Reviewed by: jhb, markj, kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D21250 Modified: head/sys/amd64/amd64/machdep.c head/sys/amd64/include/pmap.h head/sys/arm/arm/busdma_machdep-v4.c head/sys/arm/arm/busdma_machdep-v6.c head/sys/arm/arm/mem.c head/sys/arm/arm/minidump_machdep.c head/sys/arm/arm/physmem.c head/sys/arm/include/pmap.h head/sys/arm64/include/pmap.h head/sys/i386/i386/machdep.c head/sys/i386/i386/minidump_machdep_base.c head/sys/i386/include/pmap.h head/sys/kern/kern_dump.c head/sys/mips/atheros/ar531x/ar5315_machdep.c head/sys/mips/atheros/ar71xx_machdep.c head/sys/mips/beri/beri_machdep.c head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/cavium/octeon_machdep.c head/sys/mips/include/pmap.h head/sys/mips/ingenic/jz4780_machdep.c head/sys/mips/malta/malta_machdep.c head/sys/mips/mediatek/mtk_machdep.c head/sys/mips/mips/busdma_machdep.c head/sys/mips/mips/machdep.c head/sys/mips/mips/pmap.c head/sys/mips/nlm/xlp_machdep.c head/sys/powerpc/aim/mmu_oea.c head/sys/powerpc/aim/mmu_oea64.c head/sys/powerpc/booke/pmap.c head/sys/powerpc/include/pmap.h head/sys/powerpc/include/vmparam.h head/sys/powerpc/powerpc/machdep.c head/sys/powerpc/powerpc/pmap_dispatch.c head/sys/riscv/include/pmap.h head/sys/riscv/riscv/machdep.c head/sys/sparc64/include/pmap.h head/sys/sparc64/sparc64/pmap.c head/sys/vm/vm_param.h head/sys/vm/vm_phys.c head/sys/vm/vm_phys.h head/sys/x86/x86/nexus.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/amd64/amd64/machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -210,21 +210,6 @@ int cold = 1; 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 @@ add_physmap_entry(uint64_t base, uint64_t length, vm_p 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 @@ static void 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 @@ skip_memtest: 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 @@ do_dump_avail: 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; } Modified: head/sys/amd64/include/pmap.h ============================================================================== --- head/sys/amd64/include/pmap.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/amd64/include/pmap.h Fri Aug 16 00:45:14 2019 (r351108) @@ -408,8 +408,6 @@ struct pv_chunk { 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; Modified: head/sys/arm/arm/busdma_machdep-v4.c ============================================================================== --- head/sys/arm/arm/busdma_machdep-v4.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/arm/arm/busdma_machdep-v4.c Fri Aug 16 00:45:14 2019 (r351108) @@ -70,7 +70,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include #include #include Modified: head/sys/arm/arm/busdma_machdep-v6.c ============================================================================== --- head/sys/arm/arm/busdma_machdep-v6.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/arm/arm/busdma_machdep-v6.c Fri Aug 16 00:45:14 2019 (r351108) @@ -52,7 +52,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include #include #include Modified: head/sys/arm/arm/mem.c ============================================================================== --- head/sys/arm/arm/mem.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/arm/arm/mem.c Fri Aug 16 00:45:14 2019 (r351108) @@ -62,6 +62,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include #include #include Modified: head/sys/arm/arm/minidump_machdep.c ============================================================================== --- head/sys/arm/arm/minidump_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/arm/arm/minidump_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -45,13 +45,15 @@ __FBSDID("$FreeBSD$"); #include #endif #include +#include +#include +#include #include #include #include #include #include #include -#include CTASSERT(sizeof(struct kerneldumpheader) == 512); Modified: head/sys/arm/arm/physmem.c ============================================================================== --- head/sys/arm/arm/physmem.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/arm/arm/physmem.c Fri Aug 16 00:45:14 2019 (r351108) @@ -39,6 +39,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include @@ -78,32 +81,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 @@ arm_physmem_init_kernel_globals(void) { 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]); Modified: head/sys/arm/include/pmap.h ============================================================================== --- head/sys/arm/include/pmap.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/arm/include/pmap.h Fri Aug 16 00:45:14 2019 (r351108) @@ -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; Modified: head/sys/arm64/include/pmap.h ============================================================================== --- head/sys/arm64/include/pmap.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/arm64/include/pmap.h Fri Aug 16 00:45:14 2019 (r351108) @@ -132,9 +132,6 @@ extern struct pmap kernel_pmap_store; #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; Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/i386/i386/machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -194,21 +194,6 @@ long realmem = 0; 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 @@ add_physmap_entry(uint64_t base, uint64_t length, vm_p 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 @@ getmemsize(int first) { 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 @@ skip_memtest: 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 @@ do_dump_avail: 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; } Modified: head/sys/i386/i386/minidump_machdep_base.c ============================================================================== --- head/sys/i386/i386/minidump_machdep_base.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/i386/i386/minidump_machdep_base.c Fri Aug 16 00:45:14 2019 (r351108) @@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include #include Modified: head/sys/i386/include/pmap.h ============================================================================== --- head/sys/i386/include/pmap.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/i386/include/pmap.h Fri Aug 16 00:45:14 2019 (r351108) @@ -234,8 +234,6 @@ struct pv_chunk { #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; Modified: head/sys/kern/kern_dump.c ============================================================================== --- head/sys/kern/kern_dump.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/kern/kern_dump.c Fri Aug 16 00:45:14 2019 (r351108) @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include Modified: head/sys/mips/atheros/ar531x/ar5315_machdep.c ============================================================================== --- head/sys/mips/atheros/ar531x/ar5315_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/atheros/ar531x/ar5315_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -42,7 +42,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include @@ -52,7 +54,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include Modified: head/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- head/sys/mips/atheros/ar71xx_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/atheros/ar71xx_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -45,7 +45,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include @@ -55,7 +57,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include Modified: head/sys/mips/beri/beri_machdep.c ============================================================================== --- head/sys/mips/beri/beri_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/beri/beri_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -65,8 +65,10 @@ __FBSDID("$FreeBSD$"); #endif #include +#include #include #include +#include #include #include Modified: head/sys/mips/broadcom/bcm_machdep.c ============================================================================== --- head/sys/mips/broadcom/bcm_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/broadcom/bcm_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -57,8 +57,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include +#include #include #include @@ -73,7 +75,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: head/sys/mips/cavium/octeon_machdep.c ============================================================================== --- head/sys/mips/cavium/octeon_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/cavium/octeon_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -56,8 +56,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include +#include #include #include @@ -73,7 +75,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: head/sys/mips/include/pmap.h ============================================================================== --- head/sys/mips/include/pmap.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/include/pmap.h Fri Aug 16 00:45:14 2019 (r351108) @@ -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,14 +157,10 @@ struct pv_chunk { * 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)) Modified: head/sys/mips/ingenic/jz4780_machdep.c ============================================================================== --- head/sys/mips/ingenic/jz4780_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/ingenic/jz4780_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -48,7 +48,9 @@ __FBSDID("$FreeBSD$"); #endif #include +#include #include +#include #include @@ -58,7 +60,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: head/sys/mips/malta/malta_machdep.c ============================================================================== --- head/sys/mips/malta/malta_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/malta/malta_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -54,8 +54,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include +#include #include #include Modified: head/sys/mips/mediatek/mtk_machdep.c ============================================================================== --- head/sys/mips/mediatek/mtk_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/mediatek/mtk_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -54,8 +54,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include +#include #include #include @@ -70,7 +72,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: head/sys/mips/mips/busdma_machdep.c ============================================================================== --- head/sys/mips/mips/busdma_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/mips/busdma_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include Modified: head/sys/mips/mips/machdep.c ============================================================================== --- head/sys/mips/mips/machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/mips/machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -140,9 +141,7 @@ char pcpu_space[MAXCPU][PAGE_SIZE * 2] \ 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; Modified: head/sys/mips/mips/pmap.c ============================================================================== --- head/sys/mips/mips/pmap.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/mips/pmap.c Fri Aug 16 00:45:14 2019 (r351108) @@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: head/sys/mips/nlm/xlp_machdep.c ============================================================================== --- head/sys/mips/nlm/xlp_machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/mips/nlm/xlp_machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -56,7 +56,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include #include #include Modified: head/sys/powerpc/aim/mmu_oea.c ============================================================================== --- head/sys/powerpc/aim/mmu_oea.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/powerpc/aim/mmu_oea.c Fri Aug 16 00:45:14 2019 (r351108) @@ -132,6 +132,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -749,7 +751,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm } 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; Modified: head/sys/powerpc/aim/mmu_oea64.c ============================================================================== --- head/sys/powerpc/aim/mmu_oea64.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/powerpc/aim/mmu_oea64.c Fri Aug 16 00:45:14 2019 (r351108) @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -784,7 +785,7 @@ moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernels 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; Modified: head/sys/powerpc/booke/pmap.c ============================================================================== --- head/sys/powerpc/booke/pmap.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/powerpc/booke/pmap.c Fri Aug 16 00:45:14 2019 (r351108) @@ -1687,7 +1687,7 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_o mem_regions(&physmem_regions, &physmem_regions_sz, &availmem_regions, &availmem_regions_sz); - if (nitems(phys_avail) < availmem_regions_sz) + if (PHYS_AVAIL_ENTRIES < availmem_regions_sz) panic("mmu_booke_bootstrap: phys_avail too small"); sz = 0; Modified: head/sys/powerpc/include/pmap.h ============================================================================== --- head/sys/powerpc/include/pmap.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/powerpc/include/pmap.h Fri Aug 16 00:45:14 2019 (r351108) @@ -75,6 +75,7 @@ #include #include #include +#include struct pmap; typedef struct pmap *pmap_t; @@ -268,12 +269,6 @@ boolean_t pmap_mmu_install(char *name, int prio); #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; Modified: head/sys/powerpc/include/vmparam.h ============================================================================== --- head/sys/powerpc/include/vmparam.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/powerpc/include/vmparam.h Fri Aug 16 00:45:14 2019 (r351108) @@ -154,7 +154,15 @@ struct pmap_physseg { }; #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, Modified: head/sys/powerpc/powerpc/machdep.c ============================================================================== --- head/sys/powerpc/powerpc/machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/powerpc/powerpc/machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -100,6 +100,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: head/sys/powerpc/powerpc/pmap_dispatch.c ============================================================================== --- head/sys/powerpc/powerpc/pmap_dispatch.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/powerpc/powerpc/pmap_dispatch.c Fri Aug 16 00:45:14 2019 (r351108) @@ -75,7 +75,6 @@ struct pmap kernel_pmap_store; 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; Modified: head/sys/riscv/include/pmap.h ============================================================================== --- head/sys/riscv/include/pmap.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/riscv/include/pmap.h Fri Aug 16 00:45:14 2019 (r351108) @@ -127,9 +127,6 @@ extern struct pmap kernel_pmap_store; #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; Modified: head/sys/riscv/riscv/machdep.c ============================================================================== --- head/sys/riscv/riscv/machdep.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/riscv/riscv/machdep.c Fri Aug 16 00:45:14 2019 (r351108) @@ -67,9 +67,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include +#include #include #include #include @@ -100,9 +102,6 @@ struct pcpu __pcpu[MAXCPU]; 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 +109,7 @@ long Maxmem = 0; #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 +705,7 @@ add_physmap_entry(uint64_t base, uint64_t length, vm_p _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); Modified: head/sys/sparc64/include/pmap.h ============================================================================== --- head/sys/sparc64/include/pmap.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/sparc64/include/pmap.h Fri Aug 16 00:45:14 2019 (r351108) @@ -105,7 +105,6 @@ void pmap_set_kctx(void); 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; Modified: head/sys/sparc64/sparc64/pmap.c ============================================================================== --- head/sys/sparc64/sparc64/pmap.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/sparc64/sparc64/pmap.c Fri Aug 16 00:45:14 2019 (r351108) @@ -102,11 +102,10 @@ __FBSDID("$FreeBSD$"); /* * 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 @@ pmap_bootstrap(u_int cpu_impl) 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__); Modified: head/sys/vm/vm_param.h ============================================================================== --- head/sys/vm/vm_param.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/vm/vm_param.h Fri Aug 16 00:45:14 2019 (r351108) @@ -126,6 +126,11 @@ struct xswdev { #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) \ Modified: head/sys/vm/vm_phys.c ============================================================================== --- head/sys/vm/vm_phys.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/vm/vm_phys.c Fri Aug 16 00:45:14 2019 (r351108) @@ -111,6 +111,24 @@ static struct vm_freelist __aligned(CACHE_LINE_SIZE) 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. + * + * Initially dump_avail and phys_avail are identical. Boot time memory + * allocations remove extents from phys_avail that may still be included + * in dumps. + */ +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). */ static int __read_mostly vm_freelist_to_flind[VM_NFREELIST]; Modified: head/sys/vm/vm_phys.h ============================================================================== --- head/sys/vm/vm_phys.h Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/vm/vm_phys.h Fri Aug 16 00:45:14 2019 (r351108) @@ -46,6 +46,9 @@ #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; Modified: head/sys/x86/x86/nexus.c ============================================================================== --- head/sys/x86/x86/nexus.c Thu Aug 15 23:56:19 2019 (r351107) +++ head/sys/x86/x86/nexus.c Fri Aug 16 00:45:14 2019 (r351108) @@ -62,8 +62,10 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include +#include +#include +#include #include #include