diff options
Diffstat (limited to 'debian/patches/0006-xxx-cleanup.patch')
| -rw-r--r-- | debian/patches/0006-xxx-cleanup.patch | 668 |
1 files changed, 668 insertions, 0 deletions
diff --git a/debian/patches/0006-xxx-cleanup.patch b/debian/patches/0006-xxx-cleanup.patch new file mode 100644 index 0000000..b1842ad --- /dev/null +++ b/debian/patches/0006-xxx-cleanup.patch @@ -0,0 +1,668 @@ +From ce29a835655193058442b7c7b569bbf471603cf3 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sat, 16 May 2015 14:22:20 +0200 +Subject: [PATCH gnumach 06/10] xxx cleanup + +--- + ddb/db_print.c | 20 +-- + include/mach_debug/ipc_info.h | 3 - + include/mach_debug/mach_debug_types.defs | 2 +- + ipc/ipc_kmsg.c | 8 +- + ipc/ipc_space.c | 70 +---------- + ipc/ipc_space.h | 10 +- + ipc/mach_debug.c | 203 +++---------------------------- + ipc/mach_port.c | 60 ++------- + 8 files changed, 42 insertions(+), 334 deletions(-) + +diff --git a/ddb/db_print.c b/ddb/db_print.c +index 24a3e33..fb4efaa 100644 +--- a/ddb/db_print.c ++++ b/ddb/db_print.c +@@ -439,17 +439,11 @@ db_port_iterate(thread, func) + void (*func)(); + { + ipc_entry_t entry; +- int index; + int n = 0; +- int size; +- ipc_space_t space; +- +- space = thread->task->itk_space; +- entry = space->is_table; +- size = space->is_table_size; +- for (index = 0; index < size; index++, entry++) { ++ struct rdxtree_iter iter; ++ rdxtree_for_each(&thread->task->itk_space->is_map, &iter, entry) { + if (entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) +- (*func)(index, (ipc_port_t) entry->ie_object, ++ (*func)(entry->ie_name, (ipc_port_t) entry->ie_object, + entry->ie_bits, n++); + } + return(n); +@@ -460,16 +454,14 @@ db_lookup_port( + thread_t thread, + int id) + { +- ipc_space_t space; + ipc_entry_t entry; + + if (thread == THREAD_NULL) + return(0); +- space = thread->task->itk_space; +- if (id < 0 || id >= space->is_table_size) ++ if (id < 0) + return(0); +- entry = &space->is_table[id]; +- if (entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) ++ entry = ipc_entry_lookup(thread->task->itk_space, (mach_port_t) id); ++ if (entry && entry->ie_bits & MACH_PORT_TYPE_PORT_RIGHTS) + return((ipc_port_t)entry->ie_object); + return(0); + } +diff --git a/include/mach_debug/ipc_info.h b/include/mach_debug/ipc_info.h +index ef0b0c6..8c5bc5a 100644 +--- a/include/mach_debug/ipc_info.h ++++ b/include/mach_debug/ipc_info.h +@@ -56,14 +56,11 @@ typedef struct ipc_info_space { + + typedef struct ipc_info_name { + mach_port_t iin_name; /* port name, including gen number */ +-/*boolean_t*/integer_t iin_collision; /* collision at this entry? */ +-/*boolean_t*/integer_t iin_compat; /* is this a compat-mode entry? */ + /*boolean_t*/integer_t iin_marequest; /* extant msg-accepted request? */ + mach_port_type_t iin_type; /* straight port type */ + mach_port_urefs_t iin_urefs; /* user-references */ + vm_offset_t iin_object; /* object pointer */ + natural_t iin_next; /* marequest/next in free list */ +- natural_t iin_hash; /* hash index */ + } ipc_info_name_t; + + typedef ipc_info_name_t *ipc_info_name_array_t; +diff --git a/include/mach_debug/mach_debug_types.defs b/include/mach_debug/mach_debug_types.defs +index d24b6f9..e8399d6 100644 +--- a/include/mach_debug/mach_debug_types.defs ++++ b/include/mach_debug/mach_debug_types.defs +@@ -40,7 +40,7 @@ type hash_info_bucket_array_t = array[] of hash_info_bucket_t; + + type ipc_info_space_t = struct[6] of natural_t; + +-type ipc_info_name_t = struct[9] of natural_t; ++type ipc_info_name_t = struct[6] of natural_t; + type ipc_info_name_array_t = array[] of ipc_info_name_t; + + type ipc_info_tree_name_t = struct[11] of natural_t; +diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c +index 03f07a0..5076809 100644 +--- a/ipc/ipc_kmsg.c ++++ b/ipc/ipc_kmsg.c +@@ -50,7 +50,6 @@ + #include <vm/vm_user.h> + #include <ipc/port.h> + #include <ipc/ipc_entry.h> +-#include <ipc/ipc_hash.h> + #include <ipc/ipc_kmsg.h> + #include <ipc/ipc_thread.h> + #include <ipc/ipc_marequest.h> +@@ -1774,7 +1773,7 @@ ipc_kmsg_copyout_header( + break; + + is_write_lock(space); +- if (!space->is_active || space->is_table->ie_next == 0) { ++ if (!space->is_active || space->is_free_list == NULL) { + is_write_unlock(space); + break; + } +@@ -2258,12 +2257,13 @@ ipc_kmsg_copyout_object( + + ip_lock(port); + if (!ip_active(port) || +- !ipc_hash_local_lookup(space, (ipc_object_t) port, +- namep, &entry)) { ++ (entry = ipc_reverse_lookup(space, ++ (ipc_object_t) port)) == NULL) { + ip_unlock(port); + is_write_unlock(space); + goto slow_copyout; + } ++ *namep = entry->ie_name; + + /* + * Copyout the send right, incrementing urefs +diff --git a/ipc/ipc_space.c b/ipc/ipc_space.c +index 5f939bb..ea3cb3b 100644 +--- a/ipc/ipc_space.c ++++ b/ipc/ipc_space.c +@@ -46,8 +46,6 @@ + #include <kern/slab.h> + #include <ipc/port.h> + #include <ipc/ipc_entry.h> +-#include <ipc/ipc_splay.h> +-#include <ipc/ipc_hash.h> + #include <ipc/ipc_table.h> + #include <ipc/ipc_port.h> + #include <ipc/ipc_space.h> +@@ -105,52 +103,17 @@ ipc_space_create( + ipc_space_t *spacep) + { + ipc_space_t space; +- ipc_entry_t table; +- ipc_entry_num_t new_size; +- mach_port_index_t index; + + space = is_alloc(); + if (space == IS_NULL) + return KERN_RESOURCE_SHORTAGE; + +- table = it_entries_alloc(initial); +- if (table == IE_NULL) { +- is_free(space); +- return KERN_RESOURCE_SHORTAGE; +- } +- +- new_size = initial->its_size; +- memset((void *) table, 0, new_size * sizeof(struct ipc_entry)); +- +- /* +- * Initialize the free list in the table. +- * Add the entries in reverse order, and +- * set the generation number to -1, so that +- * initial allocations produce "natural" names. +- */ +- +- for (index = 0; index < new_size; index++) { +- ipc_entry_t entry = &table[index]; +- +- entry->ie_bits = IE_BITS_GEN_MASK; +- entry->ie_next = index+1; +- } +- table[new_size-1].ie_next = 0; +- + is_ref_lock_init(space); + space->is_references = 2; + + is_lock_init(space); + space->is_active = TRUE; +- space->is_growing = FALSE; +- space->is_table = table; +- space->is_table_size = new_size; +- space->is_table_next = initial+1; +- +- ipc_splay_tree_init(&space->is_tree); +- space->is_tree_total = 0; +- space->is_tree_small = 0; +- space->is_tree_hash = 0; ++ + rdxtree_init(&space->is_map); + rdxtree_init(&space->is_reverse_map); + /* The zeroth entry is reserved. */ +@@ -211,10 +174,6 @@ void + ipc_space_destroy( + ipc_space_t space) + { +- ipc_tree_entry_t tentry; +- ipc_entry_t table; +- ipc_entry_num_t size; +- mach_port_index_t index; + boolean_t active; + + assert(space != IS_NULL); +@@ -237,36 +196,13 @@ ipc_space_destroy( + + if (type != MACH_PORT_TYPE_NONE) { + mach_port_t name = +- MACH_PORT_MAKEB(index, entry->ie_bits); ++ MACH_PORT_MAKEB(entry->ie_name, entry->ie_bits); + + ipc_right_clean(space, name, entry); + } +- } +- +- it_entries_free(space->is_table_next-1, table); +- +- for (tentry = ipc_splay_traverse_start(&space->is_tree); +- tentry != ITE_NULL; +- tentry = ipc_splay_traverse_next(&space->is_tree, TRUE)) { +- mach_port_type_t type = IE_BITS_TYPE(tentry->ite_bits); +- mach_port_t name = tentry->ite_name; +- +- assert(type != MACH_PORT_TYPE_NONE); +- +- /* use object before ipc_right_clean releases ref */ +- +- if (type == MACH_PORT_TYPE_SEND) +- ipc_hash_global_delete(space, tentry->ite_object, +- name, tentry); + +- ipc_right_clean(space, name, &tentry->ite_entry); +- } +- ipc_splay_traverse_finish(&space->is_tree); +- +- ipc_entry_t entry; +- struct rdxtree_iter iter; +- rdxtree_for_each(&space->is_map, &iter, entry) + ie_free(entry); ++ } + rdxtree_remove_all(&space->is_map); + rdxtree_remove_all(&space->is_reverse_map); + +diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h +index 17d5b75..c90a2a3 100644 +--- a/ipc/ipc_space.h ++++ b/ipc/ipc_space.h +@@ -47,7 +47,7 @@ + #include <kern/lock.h> + #include <kern/rdxtree.h> + #include <kern/slab.h> +-#include <ipc/ipc_splay.h> ++#include <ipc/ipc_entry.h> + #include <ipc/ipc_types.h> + + /* +@@ -73,14 +73,6 @@ struct ipc_space { + + decl_simple_lock_data(,is_lock_data) + boolean_t is_active; /* is the space alive? */ +- boolean_t is_growing; /* is the space growing? */ +- ipc_entry_t is_table; /* an array of entries */ +- ipc_entry_num_t is_table_size; /* current size of table */ +- struct ipc_table_size *is_table_next; /* info for larger table */ +- struct ipc_splay_tree is_tree; /* a splay tree of entries */ +- ipc_entry_num_t is_tree_total; /* number of entries in the tree */ +- ipc_entry_num_t is_tree_small; /* # of small entries in the tree */ +- ipc_entry_num_t is_tree_hash; /* # of hashed entries in the tree */ + struct rdxtree is_map; /* a map of entries */ + size_t is_size; /* number of entries */ + struct rdxtree is_reverse_map; /* maps objects to entries */ +diff --git a/ipc/mach_debug.c b/ipc/mach_debug.c +index eb52e1c..9d01d84 100644 +--- a/ipc/mach_debug.c ++++ b/ipc/mach_debug.c +@@ -46,7 +46,6 @@ + #include <vm/vm_kern.h> + #include <ipc/ipc_space.h> + #include <ipc/ipc_port.h> +-#include <ipc/ipc_hash.h> + #include <ipc/ipc_marequest.h> + #include <ipc/ipc_table.h> + #include <ipc/ipc_right.h> +@@ -111,64 +110,7 @@ host_ipc_hash_info( + hash_info_bucket_array_t *infop, + mach_msg_type_number_t *countp) + { +- vm_offset_t addr; +- vm_size_t size = 0; /* Suppress gcc warning */ +- hash_info_bucket_t *info; +- unsigned int potential, actual; +- kern_return_t kr; +- +- if (host == HOST_NULL) +- return KERN_INVALID_HOST; +- +- /* start with in-line data */ +- +- info = *infop; +- potential = *countp; +- +- for (;;) { +- actual = ipc_hash_info(info, potential); +- if (actual <= potential) +- break; +- +- /* allocate more memory */ +- +- if (info != *infop) +- kmem_free(ipc_kernel_map, addr, size); +- +- size = round_page(actual * sizeof *info); +- kr = kmem_alloc_pageable(ipc_kernel_map, &addr, size); +- if (kr != KERN_SUCCESS) +- return KERN_RESOURCE_SHORTAGE; +- +- info = (hash_info_bucket_t *) addr; +- potential = size/sizeof *info; +- } +- +- if (info == *infop) { +- /* data fit in-line; nothing to deallocate */ +- +- *countp = actual; +- } else if (actual == 0) { +- kmem_free(ipc_kernel_map, addr, size); +- +- *countp = 0; +- } else { +- vm_map_copy_t copy; +- vm_size_t used; +- +- used = round_page(actual * sizeof *info); +- +- if (used != size) +- kmem_free(ipc_kernel_map, addr + used, size - used); +- +- kr = vm_map_copyin(ipc_kernel_map, addr, used, +- TRUE, ©); +- assert(kr == KERN_SUCCESS); +- +- *infop = (hash_info_bucket_t *) copy; +- *countp = actual; +- } +- ++ *countp = 0; + return KERN_SUCCESS; + } + +@@ -278,13 +220,6 @@ mach_port_space_info( + unsigned int table_potential, table_actual; + vm_offset_t table_addr; + vm_size_t table_size = 0; /* Suppress gcc warning */ +- ipc_info_tree_name_t *tree_info; +- unsigned int tree_potential, tree_actual; +- vm_offset_t tree_addr; +- vm_size_t tree_size = 0; /* Suppress gcc warning */ +- ipc_tree_entry_t tentry; +- ipc_entry_t table; +- ipc_entry_num_t tsize; + mach_port_index_t index; + kern_return_t kr; + +@@ -295,8 +230,6 @@ mach_port_space_info( + + table_info = *tablep; + table_potential = *tableCntp; +- tree_info = *treep; +- tree_potential = *treeCntp; + + for (;;) { + is_read_lock(space); +@@ -305,17 +238,12 @@ mach_port_space_info( + if (table_info != *tablep) + kmem_free(ipc_kernel_map, + table_addr, table_size); +- if (tree_info != *treep) +- kmem_free(ipc_kernel_map, +- tree_addr, tree_size); + return KERN_INVALID_TASK; + } + +- table_actual = space->is_table_size; +- tree_actual = space->is_tree_total; ++ table_actual = space->is_size; + +- if ((table_actual <= table_potential) && +- (tree_actual <= tree_potential)) ++ if (table_actual <= table_potential) + break; + + is_read_unlock(space); +@@ -329,99 +257,37 @@ mach_port_space_info( + sizeof *table_info); + kr = kmem_alloc(ipc_kernel_map, + &table_addr, table_size); +- if (kr != KERN_SUCCESS) { +- if (tree_info != *treep) +- kmem_free(ipc_kernel_map, +- tree_addr, tree_size); +- ++ if (kr != KERN_SUCCESS) + return KERN_RESOURCE_SHORTAGE; +- } + + table_info = (ipc_info_name_t *) table_addr; + table_potential = table_size/sizeof *table_info; + } +- +- if (tree_actual > tree_potential) { +- if (tree_info != *treep) +- kmem_free(ipc_kernel_map, +- tree_addr, tree_size); +- +- tree_size = round_page(tree_actual * +- sizeof *tree_info); +- kr = kmem_alloc(ipc_kernel_map, +- &tree_addr, tree_size); +- if (kr != KERN_SUCCESS) { +- if (table_info != *tablep) +- kmem_free(ipc_kernel_map, +- table_addr, table_size); +- +- return KERN_RESOURCE_SHORTAGE; +- } +- +- tree_info = (ipc_info_tree_name_t *) tree_addr; +- tree_potential = tree_size/sizeof *tree_info; +- } + } + /* space is read-locked and active; we have enough wired memory */ + + infop->iis_genno_mask = MACH_PORT_NGEN(MACH_PORT_DEAD); +- infop->iis_table_size = space->is_table_size; +- infop->iis_table_next = space->is_table_next->its_size; +- infop->iis_tree_size = space->is_tree_total; +- infop->iis_tree_small = space->is_tree_small; +- infop->iis_tree_hash = space->is_tree_hash; ++ infop->iis_table_size = 0; ++ infop->iis_table_next = 0; ++ infop->iis_tree_size = 0; ++ infop->iis_tree_small = 0; ++ infop->iis_tree_hash = 0; + +- table = space->is_table; +- tsize = space->is_table_size; +- +- for (index = 0; index < tsize; index++) { ++ ipc_entry_t entry; ++ struct rdxtree_iter iter; ++ index = 0; ++ rdxtree_for_each(&space->is_map, &iter, entry) { + ipc_info_name_t *iin = &table_info[index]; +- ipc_entry_t entry = &table[index]; + ipc_entry_bits_t bits = entry->ie_bits; + +- iin->iin_name = MACH_PORT_MAKEB(index, bits); +- iin->iin_collision = (bits & IE_BITS_COLLISION) ? TRUE : FALSE; +- iin->iin_compat = FALSE; ++ iin->iin_name = MACH_PORT_MAKEB(entry->ie_name, bits); + iin->iin_marequest = (bits & IE_BITS_MAREQUEST) ? TRUE : FALSE; + iin->iin_type = IE_BITS_TYPE(bits); + iin->iin_urefs = IE_BITS_UREFS(bits); + iin->iin_object = (vm_offset_t) entry->ie_object; +- iin->iin_next = entry->ie_next; +- iin->iin_hash = entry->ie_index; ++ iin->iin_next = entry->ie_request; ++ index += 1; + } +- +- for (tentry = ipc_splay_traverse_start(&space->is_tree), index = 0; +- tentry != ITE_NULL; +- tentry = ipc_splay_traverse_next(&space->is_tree, FALSE)) { +- ipc_info_tree_name_t *iitn = &tree_info[index++]; +- ipc_info_name_t *iin = &iitn->iitn_name; +- ipc_entry_t entry = &tentry->ite_entry; +- ipc_entry_bits_t bits = entry->ie_bits; +- +- assert(IE_BITS_TYPE(bits) != MACH_PORT_TYPE_NONE); +- +- iin->iin_name = tentry->ite_name; +- iin->iin_collision = (bits & IE_BITS_COLLISION) ? TRUE : FALSE; +- iin->iin_compat = FALSE; +- iin->iin_marequest = (bits & IE_BITS_MAREQUEST) ? TRUE : FALSE; +- iin->iin_type = IE_BITS_TYPE(bits); +- iin->iin_urefs = IE_BITS_UREFS(bits); +- iin->iin_object = (vm_offset_t) entry->ie_object; +- iin->iin_next = entry->ie_next; +- iin->iin_hash = entry->ie_index; +- +- if (tentry->ite_lchild == ITE_NULL) +- iitn->iitn_lchild = MACH_PORT_NULL; +- else +- iitn->iitn_lchild = tentry->ite_lchild->ite_name; +- +- if (tentry->ite_rchild == ITE_NULL) +- iitn->iitn_rchild = MACH_PORT_NULL; +- else +- iitn->iitn_rchild = tentry->ite_rchild->ite_name; +- +- } +- ipc_splay_traverse_finish(&space->is_tree); + is_read_unlock(space); + + if (table_info == *tablep) { +@@ -459,41 +325,8 @@ mach_port_space_info( + *tableCntp = table_actual; + } + +- if (tree_info == *treep) { +- /* data fit in-line; nothing to deallocate */ +- +- *treeCntp = tree_actual; +- } else if (tree_actual == 0) { +- kmem_free(ipc_kernel_map, tree_addr, tree_size); +- +- *treeCntp = 0; +- } else { +- vm_size_t size_used, rsize_used; +- vm_map_copy_t copy; +- +- /* kmem_alloc doesn't zero memory */ +- +- size_used = tree_actual * sizeof *tree_info; +- rsize_used = round_page(size_used); +- +- if (rsize_used != tree_size) +- kmem_free(ipc_kernel_map, +- tree_addr + rsize_used, +- tree_size - rsize_used); +- +- if (size_used != rsize_used) +- memset((void *) (tree_addr + size_used), 0, +- rsize_used - size_used); +- +- kr = vm_map_copyin(ipc_kernel_map, tree_addr, rsize_used, +- TRUE, ©); +- +- assert(kr == KERN_SUCCESS); +- +- *treep = (ipc_info_tree_name_t *) copy; +- *treeCntp = tree_actual; +- } +- ++ /* The splay tree is gone. */ ++ *treeCntp = 0; + return KERN_SUCCESS; + } + +diff --git a/ipc/mach_port.c b/ipc/mach_port.c +index 4e89527..93a1248 100644 +--- a/ipc/mach_port.c ++++ b/ipc/mach_port.c +@@ -150,10 +150,6 @@ mach_port_names( + mach_port_type_t **typesp, + mach_msg_type_number_t *typesCnt) + { +- ipc_tree_entry_t tentry; +- ipc_entry_t table; +- ipc_entry_num_t tsize; +- mach_port_index_t index; + ipc_entry_num_t actual; /* this many names */ + ipc_port_timestamp_t timestamp; /* logical time of this operation */ + mach_port_t *names; +@@ -190,7 +186,7 @@ mach_port_names( + + /* upper bound on number of names in the space */ + +- bound = space->is_table_size + space->is_tree_total; ++ bound = space->is_size; + size_needed = round_page(bound * sizeof(mach_port_t)); + + if (size_needed <= size) +@@ -235,33 +231,16 @@ mach_port_names( + + timestamp = ipc_port_timestamp(); + +- table = space->is_table; +- tsize = space->is_table_size; +- +- for (index = 0; index < tsize; index++) { +- ipc_entry_t entry = &table[index]; ++ ipc_entry_t entry; ++ struct rdxtree_iter iter; ++ rdxtree_for_each(&space->is_map, &iter, entry) { + ipc_entry_bits_t bits = entry->ie_bits; + + if (IE_BITS_TYPE(bits) != MACH_PORT_TYPE_NONE) { +- mach_port_t name = MACH_PORT_MAKEB(index, bits); +- +- mach_port_names_helper(timestamp, entry, name, ++ mach_port_names_helper(timestamp, entry, entry->ie_name, + names, types, &actual); + } + } +- +- for (tentry = ipc_splay_traverse_start(&space->is_tree); +- tentry != ITE_NULL; +- tentry = ipc_splay_traverse_next(&space->is_tree, FALSE)) { +- ipc_entry_t entry = &tentry->ite_entry; +- mach_port_t name = tentry->ite_name; +- +- assert(IE_BITS_TYPE(tentry->ite_bits) != MACH_PORT_TYPE_NONE); +- +- mach_port_names_helper(timestamp, entry, name, +- names, types, &actual); +- } +- ipc_splay_traverse_finish(&space->is_tree); + is_read_unlock(space); + + if (actual == 0) { +@@ -946,10 +925,7 @@ mach_port_get_set_status( + size = PAGE_SIZE; /* initial guess */ + + for (;;) { +- ipc_tree_entry_t tentry; +- ipc_entry_t entry, table; +- ipc_entry_num_t tsize; +- mach_port_index_t index; ++ ipc_entry_t entry; + mach_port_t *names; + ipc_pset_t pset; + +@@ -986,11 +962,9 @@ mach_port_get_set_status( + maxnames = size / sizeof(mach_port_t); + actual = 0; + +- table = space->is_table; +- tsize = space->is_table_size; +- +- for (index = 0; index < tsize; index++) { +- ipc_entry_t ientry = &table[index]; ++ ipc_entry_t ientry; ++ struct rdxtree_iter iter; ++ rdxtree_for_each(&space->is_map, &iter, ientry) { + ipc_entry_bits_t bits = ientry->ie_bits; + + if (bits & MACH_PORT_TYPE_RECEIVE) { +@@ -1002,22 +976,6 @@ mach_port_get_set_status( + } + } + +- for (tentry = ipc_splay_traverse_start(&space->is_tree); +- tentry != ITE_NULL; +- tentry = ipc_splay_traverse_next(&space->is_tree,FALSE)) { +- ipc_entry_bits_t bits = tentry->ite_bits; +- +- assert(IE_BITS_TYPE(bits) != MACH_PORT_TYPE_NONE); +- +- if (bits & MACH_PORT_TYPE_RECEIVE) { +- ipc_port_t port = +- (ipc_port_t) tentry->ite_object; +- +- mach_port_gst_helper(pset, port, maxnames, +- names, &actual); +- } +- } +- ipc_splay_traverse_finish(&space->is_tree); + is_read_unlock(space); + + if (actual <= maxnames) +-- +2.1.4 + |
