From 4cdcf788532a1ea6fce8a2d558dc1daf15d588d9 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 16 Nov 2022 11:18:39 -0500 Subject: [PATCH 03/52] mips: Check for the kernel pmap before calling pmap_promote_pde() No functional change intended. --- sys/mips/mips/pmap_mips64.c | 45 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/sys/mips/mips/pmap_mips64.c b/sys/mips/mips/pmap_mips64.c index f7ba7b43807f..ba18af97f930 100644 --- a/sys/mips/mips/pmap_mips64.c +++ b/sys/mips/mips/pmap_mips64.c @@ -2873,13 +2873,8 @@ pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va, vm_offset_t oldpteva; vm_page_t mpte; - if (is_kernel_pmap(pmap)) { - /* XXX not doing kernel pmap yet */ - atomic_add_long(&pmap_pde_p_failures, 1); - CTR3(KTR_PMAP, "%s: failure for va %#lx in pmap %p", - __func__, va, pmap); - return; - } + KASSERT(!is_kernel_pmap(pmap), + ("%s: called with kernel pmap", __func__)); PMAP_LOCK_ASSERT(pmap, MA_OWNED); /* @@ -3213,24 +3208,26 @@ validate: pte_store(pte, newpte); } - /* - * If both the page table page and the reservation are fully - * populated, then attempt promotion. - */ - if ((mpte == NULL || mpte->wire_count == NPTEPG) && - (m->flags & PG_FICTITIOUS) == 0 && - pg_ps_enabled && vm_reserv_level_iffullpop(m) == 0) - pmap_promote_pde(pmap, pde, va, &lock); + if (!is_kernel_pmap(pmap)) { + /* + * If both the page table page and the reservation are fully + * populated, then attempt promotion. + */ + if ((mpte == NULL || mpte->wire_count == NPTEPG) && + (m->flags & PG_FICTITIOUS) == 0 && + pg_ps_enabled && vm_reserv_level_iffullpop(m) == 0) + pmap_promote_pde(pmap, pde, va, &lock); - /* - * Sync I & D caches for executable pages. Do this only if the - * target pmap belongs to the current process. Otherwise, an - * unresolvable TLB miss may occur. - */ - if (!is_kernel_pmap(pmap) && (pmap == &curproc->p_vmspace->vm_pmap) && - (prot & VM_PROT_EXECUTE)) { - mips_icache_sync_range(va, PAGE_SIZE); - mips_dcache_wbinv_range(va, PAGE_SIZE); + /* + * Sync I & D caches for executable pages. Do this only if the + * target pmap belongs to the current process. Otherwise, an + * unresolvable TLB miss may occur. + */ + if (pmap == &curproc->p_vmspace->vm_pmap && + (prot & VM_PROT_EXECUTE)) { + mips_icache_sync_range(va, PAGE_SIZE); + mips_dcache_wbinv_range(va, PAGE_SIZE); + } } if (lock != NULL) rw_wunlock(lock); -- 2.41.0