git: fe9670298c07 - stable/13 - amd64: Handle 1GB mappings in pmap_enter_quick_locked()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 01 Oct 2022 16:13:23 UTC
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fe9670298c0792f6b14d7a8772b11c74eef4461d commit fe9670298c0792f6b14d7a8772b11c74eef4461d Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-09-24 13:20:29 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-10-01 15:33:49 +0000 amd64: Handle 1GB mappings in pmap_enter_quick_locked() This code path can be triggered by applying MADV_WILLNEED to a 1GB mapping. Reviewed by: alc, kib (cherry picked from commit 6c2e9f4c32a44f3c239aba346322d871097eaed0) --- sys/amd64/amd64/pmap.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 5288cd7fbfef..aa3774524023 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -7404,8 +7404,9 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, * resident, we are creating it here. */ if (va < VM_MAXUSER_ADDRESS) { + pdp_entry_t *pdpe; + pd_entry_t *pde; vm_pindex_t ptepindex; - pd_entry_t *ptepa; /* * Calculate pagetable page index @@ -7414,31 +7415,35 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, if (mpte && (mpte->pindex == ptepindex)) { mpte->ref_count++; } else { - /* - * Get the page directory entry - */ - ptepa = pmap_pde(pmap, va); - /* * If the page table page is mapped, we just increment * the hold count, and activate it. Otherwise, we - * attempt to allocate a page table page. If this - * attempt fails, we don't retry. Instead, we give up. + * attempt to allocate a page table page, passing NULL + * instead of the PV list lock pointer because we don't + * intend to sleep. If this attempt fails, we don't + * retry. Instead, we give up. */ - if (ptepa && (*ptepa & PG_V) != 0) { - if (*ptepa & PG_PS) + pdpe = pmap_pdpe(pmap, va); + if (pdpe != NULL && (*pdpe & PG_V) != 0) { + if ((*pdpe & PG_PS) != 0) return (NULL); - mpte = PHYS_TO_VM_PAGE(*ptepa & PG_FRAME); - mpte->ref_count++; + pde = pmap_pdpe_to_pde(pdpe, va); + if ((*pde & PG_V) != 0) { + if ((*pde & PG_PS) != 0) + return (NULL); + mpte = PHYS_TO_VM_PAGE(*pde & PG_FRAME); + mpte->ref_count++; + } else { + mpte = pmap_allocpte_alloc(pmap, + ptepindex, NULL, va); + if (mpte == NULL) + return (NULL); + } } else { - /* - * Pass NULL instead of the PV list lock - * pointer, because we don't intend to sleep. - */ mpte = pmap_allocpte_alloc(pmap, ptepindex, NULL, va); if (mpte == NULL) - return (mpte); + return (NULL); } } pte = (pt_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(mpte));