diff --git a/sys/uvm/uvm_fault.c b/sys/uvm/uvm_fault.c index 7e5133f124e90..0ae21b4ad3953 100644 --- a/sys/uvm/uvm_fault.c +++ b/sys/uvm/uvm_fault.c @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_fault.c,v 1.231 2022/10/26 23:27:32 riastradh Exp $ */ +/* $NetBSD: uvm_fault.c,v 1.231.2.1 2023/08/15 09:44:09 martin Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.231 2022/10/26 23:27:32 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.231.2.1 2023/08/15 09:44:09 martin Exp $"); #include "opt_uvmhist.h" @@ -633,8 +633,17 @@ uvmfault_promote(struct uvm_faultinfo *ufi, goto done; } - /* copy page [pg now dirty] */ + /* + * copy the page [pg now dirty] + * + * Remove the pmap entry now for the old page at this address + * so that no thread can modify the new page while any thread + * might still see the old page. + */ if (opg) { + pmap_remove(vm_map_pmap(ufi->orig_map), ufi->orig_rvaddr, + ufi->orig_rvaddr + PAGE_SIZE); + pmap_update(vm_map_pmap(ufi->orig_map)); uvm_pagecopy(opg, pg); } KASSERT(uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_DIRTY);