-/* $OpenBSD: uvm_map.c,v 1.312 2023/02/13 14:52:55 deraadt Exp $ */
+/* $OpenBSD: uvm_map.c,v 1.313 2023/02/24 15:17:48 mpi Exp $ */
/* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
/*
* => never a need to flush amap layer since the anonymous memory has
* no permanent home, but may deactivate pages there
* => called from sys_msync() and sys_madvise()
- * => caller must not write-lock map (read OK).
- * => we may sleep while cleaning if SYNCIO [with map read-locked]
+ * => caller must not have map locked
*/
int
if (start > end || start < map->min_offset || end > map->max_offset)
return EINVAL;
- vm_map_lock_read(map);
+ vm_map_lock(map);
first = uvm_map_entrybyaddr(&map->addr, start);
/* Make a first pass to check for holes. */
for (entry = first; entry != NULL && entry->start < end;
entry = RBT_NEXT(uvm_map_addr, entry)) {
if (UVM_ET_ISSUBMAP(entry)) {
- vm_map_unlock_read(map);
+ vm_map_unlock(map);
return EINVAL;
}
if (UVM_ET_ISSUBMAP(entry) ||
UVM_ET_ISHOLE(entry) ||
(entry->end < end &&
VMMAP_FREE_END(entry) != entry->end)) {
- vm_map_unlock_read(map);
+ vm_map_unlock(map);
return EFAULT;
}
}
+ vm_map_busy(map);
+ vm_map_unlock(map);
error = 0;
for (entry = first; entry != NULL && entry->start < end;
entry = RBT_NEXT(uvm_map_addr, entry)) {
}
}
- vm_map_unlock_read(map);
+ vm_map_unbusy(map);
return error;
}