--- Gnu-Mach/vm/vm_user.c 2020/09/02 04:47:47 1.1.1.3 +++ Gnu-Mach/vm/vm_user.c 2020/09/02 04:54:14 1.1.1.6 @@ -182,7 +182,7 @@ kern_return_t vm_statistics( *stat = vm_stat; stat->pagesize = PAGE_SIZE; - stat->free_count = vm_page_free_count; + stat->free_count = vm_page_mem_free(); stat->active_count = vm_page_active_count; stat->inactive_count = vm_page_inactive_count; stat->wire_count = vm_page_wire_count; @@ -197,8 +197,8 @@ kern_return_t vm_cache_statistics( if (map == VM_MAP_NULL) return KERN_INVALID_ARGUMENT; - stats->cache_object_count = vm_object_cached_count; - stats->cache_count = vm_object_cached_pages; + stats->cache_object_count = vm_object_external_count; + stats->cache_count = vm_object_external_pages; /* XXX Not implemented yet */ stats->active_tmp_count = 0; @@ -405,15 +405,29 @@ kern_return_t vm_map( * * [ To unwire the pages, specify VM_PROT_NONE. ] */ -kern_return_t vm_wire(host, map, start, size, access) - const host_t host; +kern_return_t vm_wire(port, map, start, size, access) + const ipc_port_t port; vm_map_t map; vm_offset_t start; vm_size_t size; vm_prot_t access; { - if (host == HOST_NULL) + boolean_t priv; + + if (!IP_VALID(port)) + return KERN_INVALID_HOST; + + ip_lock(port); + if (!ip_active(port) || + (ip_kotype(port) != IKOT_HOST_PRIV + && ip_kotype(port) != IKOT_HOST)) + { + ip_unlock(port); return KERN_INVALID_HOST; + } + + priv = ip_kotype(port) == IKOT_HOST_PRIV; + ip_unlock(port); if (map == VM_MAP_NULL) return KERN_INVALID_TASK; @@ -426,6 +440,10 @@ kern_return_t vm_wire(host, map, start, if (projected_buffer_in_range(map, start, start+size)) return(KERN_INVALID_ARGUMENT); + /* TODO: make it tunable */ + if (!priv && access != VM_PROT_NONE && map->user_wired + size > 65536) + return KERN_NO_ACCESS; + return vm_map_pageable_user(map, trunc_page(start), round_page(start+size),