summaryrefslogtreecommitdiffstats
path: root/sys/amd64
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/amd64
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/amd64')
-rw-r--r--sys/amd64/amd64/pmap.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 6d894f3..fe3850f 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -130,6 +130,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>
@@ -836,6 +837,15 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
*/
create_pagetables(firstaddr);
+ /*
+ * 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));
+
virtual_avail = (vm_offset_t) KERNBASE + *firstaddr;
virtual_avail = pmap_kmem_choose(virtual_avail);
@@ -1060,8 +1070,7 @@ pmap_init(void)
/*
* Calculate the size of the pv head table for superpages.
*/
- for (i = 0; phys_avail[i + 1]; i += 2);
- pv_npg = round_2mpage(phys_avail[(i - 2) + 1]) / NBPDR;
+ pv_npg = howmany(vm_phys_segs[vm_phys_nsegs - 1].end, NBPDR);
/*
* Allocate memory for the pv head table for superpages.
OpenPOWER on IntegriCloud