diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2009-11-28 17:37:54 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2009-11-28 17:37:54 +0100 |
commit | d088a062c1dcbd5047a6bf41ccb2cb1da2c78060 (patch) | |
tree | 8754ffd902b553ca3e95486d3ee6fba4d3c2ec46 /vm | |
parent | 43347f8e5f17cf246d2199b4db5b899e8bb08557 (diff) |
Add memory object proxies
Memory object proxies permit to replicate objects with different parameters,
like reduced privileged, different offset, etc. They are e.g. essential for
properly managing memory access permissions.
2005-06-06 Marcus Brinkmann <marcus@gnu.org>
* include/mach/mach4.defs: Add memory_object_create_proxy
interface.
* Makefile.in (vm-cfiles): Add memory_object_proxy.c.
* i386/include/mach/i386/vm_types.h (vm_offset_array_t): New type.
* include/mach/memory_object.h (memory_object_array_t): New type.
* vm/memory_object_proxy.c: New file.
* kern/ipc_kobject.h: New macro IKOT_PAGER_PROXY. Bump up macros
IKOT_UNKNOWN and IKOT_MAX_TYPE.
* kern/ipc_kobject.c (ipc_kobject_notify): Call
memory_object_proxy_notify for IKOT_PAGER_PROXY.
* vm/vm_init.c (vm_mem_init): Call memory_object_proxy_init.
* vm/vm_user.c (vm_map): Implement support for proxy memory
objects.
Diffstat (limited to 'vm')
-rw-r--r-- | vm/vm_init.c | 1 | ||||
-rw-r--r-- | vm/vm_user.c | 23 |
2 files changed, 23 insertions, 1 deletions
diff --git a/vm/vm_init.c b/vm/vm_init.c index 06317ac..f6a4060 100644 --- a/vm/vm_init.c +++ b/vm/vm_init.c @@ -82,4 +82,5 @@ void vm_mem_bootstrap() void vm_mem_init() { vm_object_init(); + memory_object_proxy_init(); } diff --git a/vm/vm_user.c b/vm/vm_user.c index 813b100..672daab 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -276,6 +276,12 @@ kern_return_t vm_copy(map, source_address, size, dest_address) return KERN_SUCCESS; } + +/* XXX From memory_object_proxy.c */ +kern_return_t +memory_object_proxy_lookup (ipc_port_t proxy_object, ipc_port_t *object, + vm_prot_t *max_protection); + /* * Routine: vm_map */ @@ -325,7 +331,22 @@ kern_return_t vm_map( copy = FALSE; } else if ((object = vm_object_enter(memory_object, size, FALSE)) == VM_OBJECT_NULL) - return(KERN_INVALID_ARGUMENT); + { + ipc_port_t real_memobj; + vm_prot_t prot; + result = memory_object_proxy_lookup (memory_object, &real_memobj, + &prot); + if (result != KERN_SUCCESS) + return result; + + /* Reduce the allowed access to the memory object. */ + max_protection &= prot; + cur_protection &= prot; + + if ((object = vm_object_enter(real_memobj, size, FALSE)) + == VM_OBJECT_NULL) + return KERN_INVALID_ARGUMENT; + } /* * Perform the copy if requested |