diff options
author | Damien Zammit <damien@zamaudio.com> | 2024-02-22 08:24:32 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2024-02-22 09:42:54 +0100 |
commit | 13b2f36d85756df7088be24acdcf847944b6b9ef (patch) | |
tree | 57a41ee343119631e4a0b390bcdd7bac3b00fa13 /vm | |
parent | 7ccf464afa11dfd849c61dd71c2ceadd2c1e8391 (diff) | |
download | gnumach-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')
-rw-r--r-- | vm/vm_fault.c | 4 | ||||
-rw-r--r-- | vm/vm_map.c | 9 | ||||
-rw-r--r-- | vm/vm_map.h | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/vm/vm_fault.c b/vm/vm_fault.c index c6e28004..d99425a3 100644 --- a/vm/vm_fault.c +++ b/vm/vm_fault.c @@ -1213,7 +1213,7 @@ kern_return_t vm_fault( * it to begin the search. */ - if ((kr = vm_map_lookup(&map, vaddr, fault_type, &version, + if ((kr = vm_map_lookup(&map, vaddr, fault_type, FALSE, &version, &object, &offset, &prot, &wired)) != KERN_SUCCESS) { goto done; @@ -1375,7 +1375,7 @@ kern_return_t vm_fault( * take another fault. */ kr = vm_map_lookup(&map, vaddr, - fault_type & ~VM_PROT_WRITE, &version, + fault_type & ~VM_PROT_WRITE, FALSE, &version, &retry_object, &retry_offset, &retry_prot, &wired); 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); \ } diff --git a/vm/vm_map.h b/vm/vm_map.h index a4949e4e..7e25d9f4 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -412,7 +412,7 @@ extern kern_return_t vm_map_inherit(vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t); /* Look up an address */ -extern kern_return_t vm_map_lookup(vm_map_t *, vm_offset_t, vm_prot_t, +extern kern_return_t vm_map_lookup(vm_map_t *, vm_offset_t, vm_prot_t, boolean_t, vm_map_version_t *, vm_object_t *, vm_offset_t *, vm_prot_t *, boolean_t *); /* Find a map entry */ |