-/* $OpenBSD: uvm_fault.c,v 1.134 2023/09/02 08:24:40 mpi Exp $ */
+/* $OpenBSD: uvm_fault.c,v 1.135 2023/09/05 05:08:26 guenther Exp $ */
/* $NetBSD: uvm_fault.c,v 1.51 2000/08/06 00:22:53 thorpej Exp $ */
/*
*/
if ((amap_flags(amap) & AMAP_SHARED) != 0) {
pmap_page_protect(uobjpage, PROT_NONE);
- }
+ }
+#if defined(MULTIPROCESSOR) && !defined(__HAVE_PMAP_MPSAFE_ENTER_COW)
+ /*
+ * Otherwise:
+ * If there are multiple threads, either uvm or the
+ * pmap has to make sure no threads see the old RO
+ * mapping once any have seen the new RW mapping.
+ * uvm does it here by forcing it to PROT_NONE before
+ * inserting the new mapping.
+ */
+ else if (P_HASSIBLING(curproc)) {
+ pmap_page_protect(uobjpage, PROT_NONE);
+ }
+#endif
/* dispose of uobjpage. drop handle to uobj as well. */
if (uobjpage->pg_flags & PG_WANTED)