diff options
author | Richard Braun <rbraun@sceen.net> | 2016-12-24 02:31:34 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2016-12-24 02:31:34 +0100 |
commit | 2b0f19f602e08fd9d37268233b962674fd592634 (patch) | |
tree | 90a4bfa49483ccdcddbbcd20749de7f864272d64 /vm/vm_user.c | |
parent | 023401c5b97023670a44059a60eb2a3a11c8a929 (diff) | |
download | gnumach-2b0f19f602e08fd9d37268233b962674fd592634.tar.gz gnumach-2b0f19f602e08fd9d37268233b962674fd592634.tar.bz2 gnumach-2b0f19f602e08fd9d37268233b962674fd592634.zip |
VM: add the vm_wire_all call
This call maps the POSIX mlockall and munlockall calls.
* Makefrag.am (include_mach_HEADERS): Add include/mach/vm_wire.h.
* include/mach/gnumach.defs (vm_wire_t): New type.
(vm_wire_all): New routine.
* include/mach/mach_types.h: Include mach/vm_wire.h.
* vm/vm_map.c: Likewise.
(vm_map_enter): Automatically wire new entries if requested.
(vm_map_copyout): Likewise.
(vm_map_pageable_all): New function.
vm/vm_map.h: Include mach/vm_wire.h.
(struct vm_map): Update description of member `wiring_required'.
(vm_map_pageable_all): New function.
* vm/vm_user.c (vm_wire_all): New function.
Diffstat (limited to 'vm/vm_user.c')
-rw-r--r-- | vm/vm_user.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/vm/vm_user.c b/vm/vm_user.c index 46684423..6c1e3d6f 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -447,3 +447,35 @@ kern_return_t vm_wire(port, map, start, size, access) return vm_map_pageable(map, trunc_page(start), round_page(start+size), access, TRUE, TRUE); } + +kern_return_t vm_wire_all(const ipc_port_t port, vm_map_t map, vm_wire_t flags) +{ + if (!IP_VALID(port)) + return KERN_INVALID_HOST; + + ip_lock(port); + + if (!ip_active(port) + || (ip_kotype(port) != IKOT_HOST_PRIV)) { + ip_unlock(port); + return KERN_INVALID_HOST; + } + + ip_unlock(port); + + if (map == VM_MAP_NULL) { + return KERN_INVALID_TASK; + } + + if (flags & ~VM_WIRE_ALL) { + return KERN_INVALID_ARGUMENT; + } + + /*Check if range includes projected buffer; + user is not allowed direct manipulation in that case*/ + if (projected_buffer_in_range(map, map->min_offset, map->max_offset)) { + return KERN_INVALID_ARGUMENT; + } + + return vm_map_pageable_all(map, flags); +} |