git: 4ab02274ed39 - stable/13 - Move INVLPG to pmap_quick_enter_page() from pmap_quick_remove_page().

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 20 Jan 2023 03:23:56 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=4ab02274ed392d088f4bbd17811a668d657a63bc

commit 4ab02274ed392d088f4bbd17811a668d657a63bc
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-12-29 20:48:51 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-01-20 03:22:02 +0000

    Move INVLPG to pmap_quick_enter_page() from pmap_quick_remove_page().
    
    Tested by:      pho
    
    (cherry picked from commit 231d75568f169fe6adc30373c12512b992c5c672)
---
 sys/amd64/amd64/pmap.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 62fa64881c7b..e990ed0b93af 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -10275,6 +10275,13 @@ pmap_quick_enter_page(vm_page_t m)
 		return (PHYS_TO_DMAP(paddr));
 	mtx_lock_spin(&qframe_mtx);
 	KASSERT(*vtopte(qframe) == 0, ("qframe busy"));
+
+	/*
+	 * Since qframe is exclusively mapped by us, and we do not set
+	 * PG_G, we can use INVLPG here.
+	 */
+	invlpg(qframe);
+
 	pte_store(vtopte(qframe), paddr | X86_PG_RW | X86_PG_V | X86_PG_A |
 	    X86_PG_M | pmap_cache_bits(kernel_pmap, m->md.pat_mode, 0));
 	return (qframe);
@@ -10287,14 +10294,6 @@ pmap_quick_remove_page(vm_offset_t addr)
 	if (addr != qframe)
 		return;
 	pte_store(vtopte(qframe), 0);
-
-	/*
-	 * Since qframe is exclusively mapped by
-	 * pmap_quick_enter_page() and that function doesn't set PG_G,
-	 * we can use INVLPG here.
-	 */
-	invlpg(qframe);
-
 	mtx_unlock_spin(&qframe_mtx);
 }