aboutsummaryrefslogtreecommitdiff
path: root/vm/vm_map.c
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2024-02-22 08:24:32 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2024-02-22 09:42:54 +0100
commit13b2f36d85756df7088be24acdcf847944b6b9ef (patch)
tree57a41ee343119631e4a0b390bcdd7bac3b00fa13 /vm/vm_map.c
parent7ccf464afa11dfd849c61dd71c2ceadd2c1e8391 (diff)
downloadgnumach-13b2f36d85756df7088be24acdcf847944b6b9ef.tar.gz
gnumach-13b2f36d85756df7088be24acdcf847944b6b9ef.tar.bz2
gnumach-13b2f36d85756df7088be24acdcf847944b6b9ef.zip
vm_map_lookup: Add parameter for keeping map locked
This adds a parameter called keep_map_locked to vm_map_lookup() that allows the function to return with the map locked. This is to prepare for fixing a bug with gsync where the map is locked twice by mistake. Co-Authored-By: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240222082410.422869-3-damien@zamaudio.com>
Diffstat (limited to 'vm/vm_map.c')
-rw-r--r--vm/vm_map.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/vm/vm_map.c b/vm/vm_map.c
index e454bb2a..c237afbe 100644
--- a/vm/vm_map.c
+++ b/vm/vm_map.c
@@ -4607,8 +4607,9 @@ vm_map_t vm_map_fork(vm_map_t old_map)
* In order to later verify this lookup, a "version"
* is returned.
*
- * The map should not be locked; it will not be
- * locked on exit. In order to guarantee the
+ * The map should not be locked; it will be
+ * unlocked on exit unless keep_map_locked is set and
+ * the lookup succeeds. In order to guarantee the
* existence of the returned object, it is returned
* locked.
*
@@ -4621,6 +4622,7 @@ kern_return_t vm_map_lookup(
vm_map_t *var_map, /* IN/OUT */
vm_offset_t vaddr,
vm_prot_t fault_type,
+ boolean_t keep_map_locked,
vm_map_version_t *out_version, /* OUT */
vm_object_t *object, /* OUT */
@@ -4642,7 +4644,8 @@ kern_return_t vm_map_lookup(
#define RETURN(why) \
{ \
- vm_map_unlock_read(map); \
+ if (!(keep_map_locked && (why == KERN_SUCCESS))) \
+ vm_map_unlock_read(map); \
return(why); \
}