Date: Tue, 20 Sep 2016 09:38:08 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306020 - in head/sys/amd64: amd64 include Message-ID: <201609200938.u8K9c81i030762@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Tue Sep 20 09:38:07 2016 New Revision: 306020 URL: https://svnweb.freebsd.org/changeset/base/306020 Log: Move pmap_p*e_index() inline functions from pmap.c to pmap.h. They are already used in minidump code. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/amd64/amd64/minidump_machdep.c head/sys/amd64/amd64/pmap.c head/sys/amd64/include/pmap.h Modified: head/sys/amd64/amd64/minidump_machdep.c ============================================================================== --- head/sys/amd64/amd64/minidump_machdep.c Tue Sep 20 09:19:22 2016 (r306019) +++ head/sys/amd64/amd64/minidump_machdep.c Tue Sep 20 09:38:07 2016 (r306020) @@ -239,10 +239,10 @@ minidumpsys(struct dumperinfo *di) * page written corresponds to 1GB of space */ pmapsize += PAGE_SIZE; - ii = (va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1); + ii = pmap_pml4e_index(va); pml4 = (uint64_t *)PHYS_TO_DMAP(KPML4phys) + ii; pdp = (uint64_t *)PHYS_TO_DMAP(*pml4 & PG_FRAME); - i = (va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1); + i = pmap_pdpe_index(va); if ((pdp[i] & PG_V) == 0) { va += NBPDP; continue; @@ -264,7 +264,7 @@ minidumpsys(struct dumperinfo *di) pd = (uint64_t *)PHYS_TO_DMAP(pdp[i] & PG_FRAME); for (n = 0; n < NPDEPG; n++, va += NBPDR) { - j = (va >> PDRSHIFT) & ((1ul << NPDEPGSHIFT) - 1); + j = pmap_pde_index(va); if ((pd[j] & PG_V) == 0) continue; @@ -368,10 +368,10 @@ minidumpsys(struct dumperinfo *di) bzero(fakepd, sizeof(fakepd)); for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + nkpt * NBPDR, kernel_vm_end); va += NBPDP) { - ii = (va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1); + ii = pmap_pml4e_index(va); pml4 = (uint64_t *)PHYS_TO_DMAP(KPML4phys) + ii; pdp = (uint64_t *)PHYS_TO_DMAP(*pml4 & PG_FRAME); - i = (va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1); + i = pmap_pdpe_index(va); /* We always write a page, even if it is zero */ if ((pdp[i] & PG_V) == 0) { Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Tue Sep 20 09:19:22 2016 (r306019) +++ head/sys/amd64/amd64/pmap.c Tue Sep 20 09:38:07 2016 (r306020) @@ -673,35 +673,6 @@ pmap_pde_pindex(vm_offset_t va) } -/* Return various clipped indexes for a given VA */ -static __inline vm_pindex_t -pmap_pte_index(vm_offset_t va) -{ - - return ((va >> PAGE_SHIFT) & ((1ul << NPTEPGSHIFT) - 1)); -} - -static __inline vm_pindex_t -pmap_pde_index(vm_offset_t va) -{ - - return ((va >> PDRSHIFT) & ((1ul << NPDEPGSHIFT) - 1)); -} - -static __inline vm_pindex_t -pmap_pdpe_index(vm_offset_t va) -{ - - return ((va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1)); -} - -static __inline vm_pindex_t -pmap_pml4e_index(vm_offset_t va) -{ - - return ((va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1)); -} - /* Return a pointer to the PML4 slot that corresponds to a VA */ static __inline pml4_entry_t * pmap_pml4e(pmap_t pmap, vm_offset_t va) Modified: head/sys/amd64/include/pmap.h ============================================================================== --- head/sys/amd64/include/pmap.h Tue Sep 20 09:19:22 2016 (r306019) +++ head/sys/amd64/include/pmap.h Tue Sep 20 09:38:07 2016 (r306020) @@ -416,6 +416,35 @@ boolean_t pmap_map_io_transient(vm_page_ void pmap_unmap_io_transient(vm_page_t *, vm_offset_t *, int, boolean_t); #endif /* _KERNEL */ +/* Return various clipped indexes for a given VA */ +static __inline vm_pindex_t +pmap_pte_index(vm_offset_t va) +{ + + return ((va >> PAGE_SHIFT) & ((1ul << NPTEPGSHIFT) - 1)); +} + +static __inline vm_pindex_t +pmap_pde_index(vm_offset_t va) +{ + + return ((va >> PDRSHIFT) & ((1ul << NPDEPGSHIFT) - 1)); +} + +static __inline vm_pindex_t +pmap_pdpe_index(vm_offset_t va) +{ + + return ((va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1)); +} + +static __inline vm_pindex_t +pmap_pml4e_index(vm_offset_t va) +{ + + return ((va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1)); +} + #endif /* !LOCORE */ #endif /* !_MACHINE_PMAP_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609200938.u8K9c81i030762>