From 4dac787cbc2b79683b8a422cfed223aaba0cea73 Mon Sep 17 00:00:00 2001 From: mpi Date: Sat, 2 Sep 2023 08:24:40 +0000 Subject: [PATCH] Zap anon pages mappings in uvm_anon_release() instead of in the fault handler. This makes all code paths deactivating or freeing anons consistent. No objection from the usual suspects. --- sys/uvm/uvm_anon.c | 3 ++- sys/uvm/uvm_fault.c | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/uvm/uvm_anon.c b/sys/uvm/uvm_anon.c index 13d36f2789d..abb3e8de3d8 100644 --- a/sys/uvm/uvm_anon.c +++ b/sys/uvm/uvm_anon.c @@ -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); diff --git a/sys/uvm/uvm_fault.c b/sys/uvm/uvm_fault.c index 4548410449a..28fa1da147c 100644 --- a/sys/uvm/uvm_fault.c +++ b/sys/uvm/uvm_fault.c @@ -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. -- 2.20.1