aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-04-06 18:56:37 +0000
committerMark Johnston <markj@FreeBSD.org>2021-04-06 19:02:17 +0000
commite7b28b5bb38ed942bc49b4cf9d313f9a051c9966 (patch)
treed9f78d4a78acaa45ebabe29a4a0cdc5ec8a4a8f7
parentf1d1353d2d7b84434cb7d6bb003d6f560bfc83e3 (diff)
-rw-r--r--sys/vm/vm_fault.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index cf2db256eaa3..7829b3691d83 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -1298,6 +1298,33 @@ readrest:
vm_page_unwire(fs.m, PQ_INACTIVE);
vm_page_unlock(fs.m);
}
+
+ /*
+ * Typically, the shadow object is either
+ * private to this address space
+ * (OBJ_ONEMAPPING) or its pages are read only.
+ * In the highly unusual case where the pages of
+ * a shadow object are read/write shared between
+ * this and other address spaces, we need to
+ * ensure that any pmap-level mappings to the
+ * original, copy-on-write page from the backing
+ * object are removed from those other address
+ * spaces.
+ *
+ * The flag check is racy, but this is
+ * tolerable: if OBJ_ONEMAPPING is cleared after
+ * the check, the busy state ensures that new
+ * mappings of fs.m can't be created.
+ * pmap_enter() will replace an existing mapping
+ * in the current address space. If
+ * OBJ_ONEMAPPING is set after the check,
+ * removing mappings will at worse trigger some
+ * unnecessary page faults.
+ */
+ vm_page_assert_xbusied(fs.m);
+ if ((fs.first_object->flags & OBJ_ONEMAPPING) == 0)
+ pmap_remove_all(fs.m);
+
/*
* We no longer need the old page or object.
*/