Zap anon pages mappings in uvm_anon_release() instead of in the fault handler.
authormpi <mpi@openbsd.org>
Sat, 2 Sep 2023 08:24:40 +0000 (08:24 +0000)
committermpi <mpi@openbsd.org>
Sat, 2 Sep 2023 08:24:40 +0000 (08:24 +0000)
This makes all code paths deactivating or freeing anons consistent.

No objection from the usual suspects.

sys/uvm/uvm_anon.c
sys/uvm/uvm_fault.c

index 13d36f2..abb3e8d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uvm_anon.c,v 1.55 2023/04/11 00:45:09 jsg Exp $       */
+/*     $OpenBSD: uvm_anon.c,v 1.56 2023/09/02 08:24:40 mpi Exp $       */
 /*     $NetBSD: uvm_anon.c,v 1.10 2000/11/25 06:27:59 chs Exp $        */
 
 /*
@@ -255,6 +255,7 @@ uvm_anon_release(struct vm_anon *anon)
        KASSERT(anon->an_ref == 0);
 
        uvm_lock_pageq();
+       pmap_page_protect(pg, PROT_NONE);
        uvm_pagefree(pg);
        uvm_unlock_pageq();
        KASSERT(anon->an_page == NULL);
index 4548410..28fa1da 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uvm_fault.c,v 1.133 2022/11/04 09:36:44 mpi Exp $     */
+/*     $OpenBSD: uvm_fault.c,v 1.134 2023/09/02 08:24:40 mpi Exp $     */
 /*     $NetBSD: uvm_fault.c,v 1.51 2000/08/06 00:22:53 thorpej Exp $   */
 
 /*
@@ -396,7 +396,6 @@ uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap,
                         * anon and try again.
                         */
                        if (pg->pg_flags & PG_RELEASED) {
-                               pmap_page_protect(pg, PROT_NONE);
                                KASSERT(anon->an_ref == 0);
                                /*
                                 * Released while we had unlocked amap.