Fix breakage caused by r254466 in minidumpsys().

r254466 increased the KVA from 512GB to 2TB which requires 4 PDP pages as
opposed to a single one before the change. This broke minidumpsys() since
it assumed that the entire KVA could be addressed via a single PDP page.

Fix this by obtaining the address of the PDP page from the PML4 entry
associated with the KVA being dumped.

Reported by:	pho
Submitted by:	kib
Pointy hat to:	neel
This commit is contained in:
Neel Natu 2013-08-20 02:09:26 +00:00
parent c9612b2db8
commit 15e683837c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=254547

View File

@ -221,8 +221,8 @@ minidumpsys(struct dumperinfo *di)
vm_offset_t va;
int error;
uint64_t bits;
uint64_t *pdp, *pd, *pt, pa;
int i, j, k, n, bit;
uint64_t *pml4, *pdp, *pd, *pt, pa;
int i, ii, j, k, n, bit;
int retry_count;
struct minidumphdr mdhdr;
@ -232,7 +232,6 @@ minidumpsys(struct dumperinfo *di)
counter = 0;
/* Walk page table pages, set bits in vm_page_dump */
pmapsize = 0;
pdp = (uint64_t *)PHYS_TO_DMAP(KPDPphys);
for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + nkpt * NBPDR,
kernel_vm_end); ) {
/*
@ -240,6 +239,9 @@ minidumpsys(struct dumperinfo *di)
* page written corresponds to 1GB of space
*/
pmapsize += PAGE_SIZE;
ii = (va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1);
pml4 = (uint64_t *)PHYS_TO_DMAP(KPML4phys) + ii;
pdp = (uint64_t *)PHYS_TO_DMAP(*pml4 & PG_FRAME);
i = (va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1);
if ((pdp[i] & PG_V) == 0) {
va += NBPDP;
@ -364,9 +366,11 @@ minidumpsys(struct dumperinfo *di)
/* Dump kernel page directory pages */
bzero(fakepd, sizeof(fakepd));
pdp = (uint64_t *)PHYS_TO_DMAP(KPDPphys);
for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + nkpt * NBPDR,
kernel_vm_end); va += NBPDP) {
ii = (va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1);
pml4 = (uint64_t *)PHYS_TO_DMAP(KPML4phys) + ii;
pdp = (uint64_t *)PHYS_TO_DMAP(*pml4 & PG_FRAME);
i = (va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1);
/* We always write a page, even if it is zero */