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 <sys/uio.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/vm_map.h>
 #include <vm/vm_extern.h>
 #include <vm/vm_kern.h>

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 <sys/uio.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/vm_map.h>
 #include <vm/vm_extern.h>
 #include <vm/vm_kern.h>

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 <sys/uio.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/pmap.h>
 #include <vm/vm_extern.h>
 

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 <sys/watchdog.h>
 #endif
 #include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/pmap.h>
 #include <machine/atomic.h>
 #include <machine/cpu.h>
 #include <machine/elf.h>
 #include <machine/md_var.h>
 #include <machine/minidump.h>
-#include <machine/vmparam.h>
 
 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 <sys/param.h>
 #include <sys/systm.h>
 #include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <machine/md_var.h>
 #include <arm/include/physmem.h>
 
@@ -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 <sys/systm.h>
 
-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 <sys/msgbuf.h>
 #include <sys/watchdog.h>
 #include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/pmap.h>
 #include <machine/atomic.h>
 #include <machine/elf.h>

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 <sys/watchdog.h>
 #include <vm/vm.h>
 #include <vm/vm_param.h>
+#include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/pmap.h>
 #include <machine/dump.h>
 #include <machine/elf.h>

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 <sys/boot.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <net/ethernet.h>
 
@@ -52,7 +54,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/hwfunc.h>
 #include <machine/md_var.h>
 #include <machine/trap.h>
-#include <machine/vmparam.h>
 
 #include <mips/atheros/ar531x/ar5315reg.h>
 

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 <sys/reboot.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <net/ethernet.h>
 
@@ -55,7 +57,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/hwfunc.h>
 #include <machine/md_var.h>
 #include <machine/trap.h>
-#include <machine/vmparam.h>
 
 #include <mips/atheros/ar71xxreg.h>
 

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 <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <machine/bootinfo.h>
 #include <machine/clock.h>

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 <sys/user.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <machine/cache.h>
 #include <machine/clock.h>
@@ -73,7 +75,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/pte.h>
 #include <machine/sigframe.h>
 #include <machine/trap.h>
-#include <machine/vmparam.h>
 
 #include <dev/bhnd/bhnd.h>
 #include <dev/bhnd/bhndreg.h>

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 <sys/user.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <machine/atomic.h>
 #include <machine/cache.h>
@@ -73,7 +75,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/pcpu.h>
 #include <machine/pte.h>
 #include <machine/trap.h>
-#include <machine/vmparam.h>
 
 #include <contrib/octeon-sdk/cvmx.h>
 #include <contrib/octeon-sdk/cvmx-bootmem.h>

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 <machine/vmparam.h>
+#include <vm/vm_param.h>
 #include <machine/pte.h>
 
 #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 <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <net/ethernet.h>
 
@@ -58,7 +60,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/hwfunc.h>
 #include <machine/md_var.h>
 #include <machine/trap.h>
-#include <machine/vmparam.h>
 
 #include <mips/ingenic/jz4780_regs.h>
 #include <mips/ingenic/jz4780_cpuregs.h>

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 <sys/user.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <machine/clock.h>
 #include <machine/cpu.h>

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 <sys/user.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <machine/cache.h>
 #include <machine/clock.h>
@@ -70,7 +72,6 @@ __FBSDID("$FreeBSD$");
 #include <machine/pte.h>
 #include <machine/sigframe.h>
 #include <machine/trap.h>
-#include <machine/vmparam.h>
 
 #include <mips/mediatek/mtk_sysctl.h>
 #include <mips/mediatek/mtk_soc.h>

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 <vm/vm_extern.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/vm_map.h>
 
 #include <machine/atomic.h>

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 <vm/vm_kern.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 #include <vm/vm_pager.h>
@@ -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 <vm/vm_param.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/vm_map.h>
 #include <vm/vm_object.h>
 #include <vm/vm_extern.h>

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 <sys/timetc.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 
 #include <machine/cpu.h>
 #include <machine/cpufunc.h>

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 <vm/vm_map.h>
 #include <vm/vm_object.h>
 #include <vm/vm_extern.h>
+#include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/vm_pageout.h>
 #include <vm/uma.h>
 
@@ -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 <vm/vm_param.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/vm_map.h>
 #include <vm/vm_object.h>
 #include <vm/vm_extern.h>
@@ -784,7 +785,7 @@ moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernels
        mem_regions(&pregions, &pregions_sz, &regions, &regions_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 <machine/pte.h>
 #include <machine/slb.h>
 #include <machine/tlb.h>
+#include <machine/vmparam.h>
 
 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 <vm/vm_extern.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/vm_map.h>
 #include <vm/vm_object.h>
 #include <vm/vm_pager.h>

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 <sys/vmmeter.h>
 
 #include <vm/vm.h>
+#include <vm/vm_param.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 #include <vm/vm_pager.h>
@@ -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 <sys/interrupt.h>
 
 #include <machine/md_var.h>
-#include <machine/vmparam.h>
 #include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_page.h>
+#include <vm/vm_phys.h>
 #include <vm/pmap.h>
 
 #include <machine/metadata.h>
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to