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
This commit is contained in:
markj 2018-10-01 14:47:49 +00:00
parent 1ba09d8822
commit fef3b3efcb

View File

@ -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;
/*