summaryrefslogtreecommitdiffstats
path: root/sys/i386/i386
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2015-01-02 17:45:52 +0000
committeralc <alc@FreeBSD.org>2015-01-02 17:45:52 +0000
commitd5a13901bff0d31efdcb363925086b0e00bea32b (patch)
treefa41565eff257f888b11c0e324e0bc2f147f72ad /sys/i386/i386
parent5309e52c3c33e83023a6edac5ef5dea2b34b5c55 (diff)
downloadFreeBSD-src-d5a13901bff0d31efdcb363925086b0e00bea32b.zip
FreeBSD-src-d5a13901bff0d31efdcb363925086b0e00bea32b.tar.gz
MFC r273701, r274556
By the time that pmap_init() runs, vm_phys_segs[] has been initialized. Obtaining the end of memory address from vm_phys_segs[] is a little easier than obtaining it from phys_avail[]. Enable the use of VM_PHYSSEG_SPARSE on amd64 and i386, making it the default on i386 PAE. (The use of VM_PHYSSEG_SPARSE on i386 PAE saves us some precious kernel virtual address space that would have been wasted on unused vm_page structures.)
Diffstat (limited to 'sys/i386/i386')
-rw-r--r--sys/i386/i386/pmap.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index c9bff6b..3bd44d9 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -133,6 +133,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_extern.h>
#include <vm/vm_pageout.h>
#include <vm/vm_pager.h>
+#include <vm/vm_phys.h>
#include <vm/vm_radix.h>
#include <vm/vm_reserv.h>
#include <vm/uma.h>
@@ -374,6 +375,15 @@ pmap_bootstrap(vm_paddr_t firstaddr)
int i;
/*
+ * Add a physical memory segment (vm_phys_seg) corresponding to the
+ * preallocated kernel page table pages so that vm_page structures
+ * representing these pages will be created. The vm_page structures
+ * are required for promotion of the corresponding kernel virtual
+ * addresses to superpage mappings.
+ */
+ vm_phys_add_seg(KPTphys, KPTphys + ptoa(nkpt));
+
+ /*
* Initialize the first available kernel virtual address. However,
* using "firstaddr" may waste a few pages of the kernel virtual
* address space, because locore may not have mapped every physical
@@ -778,9 +788,10 @@ pmap_init(void)
/*
* Calculate the size of the pv head table for superpages.
+ * Handle the possibility that "vm_phys_segs[...].end" is zero.
*/
- for (i = 0; phys_avail[i + 1]; i += 2);
- pv_npg = round_4mpage(phys_avail[(i - 2) + 1]) / NBPDR;
+ pv_npg = trunc_4mpage(vm_phys_segs[vm_phys_nsegs - 1].end -
+ PAGE_SIZE) / NBPDR + 1;
/*
* Allocate memory for the pv head table for superpages.
OpenPOWER on IntegriCloud