svn commit: r339046 - head/sys/amd64/amd64

Mark Johnston markj at FreeBSD.org
Mon Oct 1 14:47:50 UTC 2018


Author: markj
Date: Mon Oct  1 14:47:49 2018
New Revision: 339046
URL: https://svnweb.freebsd.org/changeset/base/339046

Log:
  Count bootstrap data as resident in the kernel pmap.
  
  Such data may later be unmapped.  This occurs, for example, when a
  loader-provided microcode update file is discarded.
  
  Reviewed by:	alc, kib
  Approved by:	re (gjb)
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D17340

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c	Mon Oct  1 14:39:59 2018	(r339045)
+++ head/sys/amd64/amd64/pmap.c	Mon Oct  1 14:47:49 2018	(r339046)
@@ -1098,9 +1098,11 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
 	vm_offset_t va;
 	pt_entry_t *pte;
 	uint64_t cr4;
+	u_long res;
 	int i;
 
 	KERNend = *firstaddr;
+	res = atop(KERNend - (vm_paddr_t)kernphys);
 
 	if (!pti)
 		pg_g = X86_PG_G;
@@ -1120,10 +1122,8 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
 	vm_phys_add_seg(KPTphys, KPTphys + ptoa(nkpt));
 
 	virtual_avail = (vm_offset_t) KERNBASE + *firstaddr;
-
 	virtual_end = VM_MAX_KERNEL_ADDRESS;
 
-
 	/*
 	 * Enable PG_G global pages, then switch to the kernel page
 	 * table from the bootstrap page table.  After the switch, it
@@ -1142,6 +1142,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
 
 	/*
 	 * Initialize the kernel pmap (which is statically allocated).
+	 * Count bootstrap data as being resident.
 	 */
 	PMAP_LOCK_INIT(kernel_pmap);
 	kernel_pmap->pm_pml4 = (pdp_entry_t *)PHYS_TO_DMAP(KPML4phys);
@@ -1149,6 +1150,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
 	kernel_pmap->pm_ucr3 = PMAP_NO_CR3;
 	CPU_FILL(&kernel_pmap->pm_active);	/* don't allow deactivation */
 	TAILQ_INIT(&kernel_pmap->pm_pvchunk);
+	kernel_pmap->pm_stats.resident_count = res;
 	kernel_pmap->pm_flags = pmap_flags;
 
  	/*


More information about the svn-src-head mailing list