--- Gnu-Mach/vm/vm_user.c 2020/09/02 04:36:57 1.1.1.1 +++ Gnu-Mach/vm/vm_user.c 2020/09/02 04:45:26 1.1.1.2 @@ -38,11 +38,14 @@ #include #include #include +#include #include #include #include +#include #include #include +#include #include @@ -187,6 +190,29 @@ kern_return_t vm_statistics(map, stat) return(KERN_SUCCESS); } +kern_return_t vm_cache_statistics( + vm_map_t map, + vm_cache_statistics_data_t *stats) +{ + if (map == VM_MAP_NULL) + return KERN_INVALID_ARGUMENT; + + stats->cache_object_count = vm_object_cached_count; + stats->cache_count = vm_object_cached_pages; + + /* XXX Not implemented yet */ + stats->active_tmp_count = 0; + stats->inactive_tmp_count = 0; + stats->active_perm_count = 0; + stats->inactive_perm_count = 0; + stats->dirty_count = 0; + stats->laundry_count = 0; + stats->writeback_count = 0; + stats->slab_count = 0; + stats->slab_reclaim_count = 0; + return KERN_SUCCESS; +} + /* * Handle machine-specific attributes for a mapping, such * as cachability, migrability, etc. @@ -275,6 +301,7 @@ kern_return_t vm_copy(map, source_addres return KERN_SUCCESS; } + /* * Routine: vm_map */ @@ -315,6 +342,9 @@ kern_return_t vm_map( return(KERN_INVALID_ARGUMENT); } + if (size == 0) + return KERN_INVALID_ARGUMENT; + *address = trunc_page(*address); size = round_page(size); @@ -324,7 +354,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