summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-03-15 14:43:59 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-03-15 14:43:59 +0100
commit57e08ee64875d33c830a58b39765d4af86ad7128 (patch)
tree32c0257323e6a78b2bb5cbb7da2707deffa2274f /debian
parenta6947217a73eb4b1bcba70f19cf39bf5400cc0e1 (diff)
update fix-receiver-lookups.patch
Diffstat (limited to 'debian')
-rw-r--r--debian/patches/fix-receiver-lookups.patch290
1 files changed, 252 insertions, 38 deletions
diff --git a/debian/patches/fix-receiver-lookups.patch b/debian/patches/fix-receiver-lookups.patch
index 5ed2c300..042c2649 100644
--- a/debian/patches/fix-receiver-lookups.patch
+++ b/debian/patches/fix-receiver-lookups.patch
@@ -22,20 +22,48 @@ index 8ad82dc..4885503 100644
msgseqno seqno : mach_port_seqno_t;
object_size_limit : vm_size_t);
diff --git a/mach-defpager/Makefile b/mach-defpager/Makefile
-index e38a0be..c8e33c5 100644
+index e38a0be..09debed 100644
--- a/mach-defpager/Makefile
+++ b/mach-defpager/Makefile
-@@ -34,4 +34,4 @@ LDFLAGS += -static
+@@ -29,9 +29,10 @@ OBJS := $(SRCS:.c=.o) \
+ memory_object default_pager memory_object_default exc) \
+ default_pager_replyUser.o
+
++HURDLIBS:= ihash
+ OTHERLIBS:= -lpthread
+ LDFLAGS += -static
include ../Makeconf
-MIGSFLAGS = -DSEQNOS
+MIGSFLAGS = -DSEQNOS -imacros $(srcdir)/mig-mutate.h
diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c
-index 8f8e13e..b718262 100644
+index 8f8e13e..77caa4a 100644
--- a/mach-defpager/default_pager.c
+++ b/mach-defpager/default_pager.c
-@@ -60,6 +60,8 @@
+@@ -38,14 +38,17 @@
+ #include <mach/default_pager_types.h>
+
+ #include <pthread.h>
++#include <stddef.h>
+
+ #include <device/device_types.h>
+ #include <device/device.h>
+
+-#include <queue.h>
+-#include <wiring.h>
+-#include <kalloc.h>
+-#include <default_pager.h>
++#include <hurd/ihash.h>
++
++#include "queue.h"
++#include "wiring.h"
++#include "kalloc.h"
++#include "default_pager.h"
+
+ #include <assert.h>
+ #include <errno.h>
+@@ -60,6 +63,8 @@
#include "default_pager_S.h"
#include "exc_S.h"
@@ -44,7 +72,7 @@ index 8f8e13e..b718262 100644
#define debug 0
static char my_name[] = "(default pager):";
-@@ -106,47 +108,6 @@ synchronized_printf (const char *fmt, ...)
+@@ -106,47 +111,6 @@ synchronized_printf (const char *fmt, ...)
#define ptoa(p) ((p)*vm_page_size)
#define atop(a) ((a)/vm_page_size)
@@ -92,7 +120,7 @@ index 8f8e13e..b718262 100644
partition_t partition_of(x)
int x;
{
-@@ -632,81 +593,6 @@ ddprintf ("pager_dealloc_page(%d,%x,%d)\n",pindex,page,lock_it);
+@@ -632,81 +596,6 @@ ddprintf ("pager_dealloc_page(%d,%x,%d)\n",pindex,page,lock_it);
}
/*
@@ -174,7 +202,7 @@ index 8f8e13e..b718262 100644
* Object sizes are rounded up to the next power of 2,
* unless they are bigger than a given maximum size.
*/
-@@ -1885,40 +1771,6 @@ default_has_page(ds, offset)
+@@ -1885,40 +1774,6 @@ default_has_page(ds, offset)
return ( ! no_block(pager_read_offset(ds, offset)) );
}
@@ -215,7 +243,44 @@ index 8f8e13e..b718262 100644
#if PARALLEL
#define dstruct_lock_init(ds) pthread_mutex_init(&ds->lock, NULL)
#define dstruct_lock(ds) pthread_mutex_lock(&ds->lock)
-@@ -1960,17 +1812,6 @@ void pager_port_list_insert(port, ds)
+@@ -1929,25 +1784,14 @@ typedef struct dstruct * default_pager_t;
+ #define dstruct_unlock(ds)
+ #endif /* PARALLEL */
+
+-/*
+- * List of all pagers. A specific pager is
+- * found directly via its port, this list is
+- * only used for monitoring purposes by the
+- * default_pager_object* calls
+- */
+-struct pager_port {
+- queue_head_t queue;
+- pthread_mutex_t lock;
+- int count; /* saves code */
+- queue_head_t leak_queue;
+-} all_pagers;
++struct pager_port all_pagers;
+
+ #define pager_port_list_init() \
+ { \
+ pthread_mutex_init(&all_pagers.lock, NULL); \
+- queue_init(&all_pagers.queue); \
++ hurd_ihash_init (&all_pagers.htable, \
++ offsetof (struct dstruct, htable_locp)); \
+ queue_init(&all_pagers.leak_queue); \
+- all_pagers.count = 0; \
+ }
+
+ void pager_port_list_insert(port, ds)
+@@ -1955,28 +1799,18 @@ void pager_port_list_insert(port, ds)
+ default_pager_t ds;
+ {
+ pthread_mutex_lock(&all_pagers.lock);
+- queue_enter(&all_pagers.queue, ds, default_pager_t, links);
+- all_pagers.count++;
++ hurd_ihash_add (&all_pagers.htable,
++ (hurd_ihash_key_t) port,
++ (hurd_ihash_value_t) ds);
pthread_mutex_unlock(&all_pagers.lock);
}
@@ -233,7 +298,58 @@ index 8f8e13e..b718262 100644
void pager_port_list_delete(ds)
default_pager_t ds;
{
-@@ -2450,15 +2291,14 @@ memory_object_copy_strategy_t default_pager_copy_strategy =
+ pthread_mutex_lock(&all_pagers.lock);
+- queue_remove(&all_pagers.queue, ds, default_pager_t, links);
+- all_pagers.count--;
++ hurd_ihash_locp_remove (&all_pagers.htable,
++ ds->htable_locp);
+ pthread_mutex_unlock(&all_pagers.lock);
+ }
+
+@@ -2023,7 +1857,8 @@ dprintf("Partition x%x (id x%x) for %s, all_ok %d\n", part, id, name, all_ok);
+ pthread_mutex_lock(&part->p_lock);
+
+ pthread_mutex_lock(&all_pagers.lock);
+- queue_iterate(&all_pagers.queue, entry, default_pager_t, links) {
++ HURD_IHASH_ITERATE (&all_pagers.htable, val) {
++ entry = (default_pager_t) val;
+
+ dstruct_lock(entry);
+
+@@ -2397,7 +2232,6 @@ seqnos_memory_object_create(old_pager, seqno, new_pager, new_size,
+ vm_size_t new_page_size;
+ {
+ default_pager_t ds;
+- kern_return_t kr;
+
+ assert(old_pager == default_pager_default_port);
+ assert(MACH_PORT_VALID(new_pager_request));
+@@ -2405,24 +2239,6 @@ seqnos_memory_object_create(old_pager, seqno, new_pager, new_size,
+ assert(new_page_size == vm_page_size);
+
+ ds = pager_port_alloc(new_size);
+-rename_it:
+- kr = mach_port_rename( default_pager_self,
+- new_pager, (mach_port_t)pnameof(ds));
+- if (kr != KERN_SUCCESS) {
+- default_pager_t ds1;
+-
+- if (kr != KERN_NAME_EXISTS)
+- panic("%s m_o_create", my_name);
+- ds1 = (default_pager_t) kalloc(sizeof *ds1);
+- *ds1 = *ds;
+- pthread_mutex_lock(&all_pagers.lock);
+- queue_enter(&all_pagers.leak_queue, ds, default_pager_t, links);
+- pthread_mutex_unlock(&all_pagers.lock);
+- ds = ds1;
+- goto rename_it;
+- }
+-
+- new_pager = (mach_port_t) pnameof(ds);
+
+ /*
+ * Set up associations between these ports
+@@ -2450,15 +2266,14 @@ memory_object_copy_strategy_t default_pager_copy_strategy =
MEMORY_OBJECT_COPY_DELAY;
kern_return_t
@@ -251,7 +367,7 @@ index 8f8e13e..b718262 100644
kern_return_t kr;
static char here[] = "%sinit";
-@@ -2466,7 +2306,6 @@ seqnos_memory_object_init(pager, seqno, pager_request, pager_name,
+@@ -2466,7 +2281,6 @@ seqnos_memory_object_init(pager, seqno, pager_request, pager_name,
assert(MACH_PORT_VALID(pager_name));
assert(pager_page_size == vm_page_size);
@@ -259,7 +375,7 @@ index 8f8e13e..b718262 100644
if (ds == DEFAULT_PAGER_NULL)
panic(here, my_name);
pager_port_lock(ds, seqno);
-@@ -2512,7 +2351,7 @@ seqnos_memory_object_terminate(pager, seqno, pager_request, pager_name)
+@@ -2512,7 +2326,7 @@ seqnos_memory_object_terminate(pager, seqno, pager_request, pager_name)
* not send rights.
*/
@@ -268,7 +384,7 @@ index 8f8e13e..b718262 100644
if (ds == DEFAULT_PAGER_NULL)
panic(here, my_name);
ddprintf ("seqnos_memory_object_terminate <%p>: pager_port_lock: <%p>[s:%d,r:%d,w:%d,l:%d], %d\n",
-@@ -2578,7 +2417,7 @@ void default_pager_no_senders(pager, seqno, mscount)
+@@ -2578,7 +2392,7 @@ void default_pager_no_senders(pager, seqno, mscount)
*/
@@ -277,7 +393,7 @@ index 8f8e13e..b718262 100644
if (ds == DEFAULT_PAGER_NULL)
panic(here,my_name);
pager_port_lock(ds, seqno);
-@@ -2639,16 +2478,15 @@ int default_pager_pageout_count = 0;
+@@ -2639,16 +2453,15 @@ int default_pager_pageout_count = 0;
static __thread default_pager_thread_t *dpt;
kern_return_t
@@ -296,7 +412,7 @@ index 8f8e13e..b718262 100644
vm_offset_t addr;
unsigned int errors;
kern_return_t rc;
-@@ -2657,7 +2495,6 @@ seqnos_memory_object_data_request(pager, seqno, reply_to, offset,
+@@ -2657,7 +2470,6 @@ seqnos_memory_object_data_request(pager, seqno, reply_to, offset,
if (length != vm_page_size)
panic(here,my_name);
@@ -304,7 +420,7 @@ index 8f8e13e..b718262 100644
if (ds == DEFAULT_PAGER_NULL)
panic(here,my_name);
ddprintf ("seqnos_memory_object_data_request <%p>: pager_port_lock: <%p>[s:%d,r:%d,w:%d,l:%d], %d\n",
-@@ -2742,9 +2579,9 @@ ddprintf ("seqnos_memory_object_data_request <%p>: pager_port_unlock: <%p>[s:%d,
+@@ -2742,9 +2554,9 @@ ddprintf ("seqnos_memory_object_data_request <%p>: pager_port_unlock: <%p>[s:%d,
* also assumes that the default_pager is single-threaded.
*/
kern_return_t
@@ -316,7 +432,7 @@ index 8f8e13e..b718262 100644
mach_port_seqno_t seqno;
mach_port_t pager_request;
register
-@@ -2754,14 +2591,12 @@ seqnos_memory_object_data_initialize(pager, seqno, pager_request,
+@@ -2754,14 +2566,12 @@ seqnos_memory_object_data_initialize(pager, seqno, pager_request,
vm_size_t data_cnt;
{
vm_offset_t amount_sent;
@@ -331,7 +447,7 @@ index 8f8e13e..b718262 100644
if (ds == DEFAULT_PAGER_NULL)
panic(here,my_name);
ddprintf ("seqnos_memory_object_data_initialize <%p>: pager_port_lock: <%p>[s:%d,r:%d,w:%d,l:%d], %d\n",
-@@ -2804,9 +2639,9 @@ ddprintf ("seqnos_memory_object_data_initialize <%p>: pager_port_unlock: <%p>[s:
+@@ -2804,9 +2614,9 @@ ddprintf ("seqnos_memory_object_data_initialize <%p>: pager_port_unlock: <%p>[s:
* into individual pages and pass them off to default_write.
*/
kern_return_t
@@ -343,7 +459,7 @@ index 8f8e13e..b718262 100644
mach_port_seqno_t seqno;
mach_port_t pager_request;
register
-@@ -2817,7 +2652,6 @@ seqnos_memory_object_data_write(pager, seqno, pager_request,
+@@ -2817,7 +2627,6 @@ seqnos_memory_object_data_write(pager, seqno, pager_request,
{
register
vm_size_t amount_sent;
@@ -351,7 +467,7 @@ index 8f8e13e..b718262 100644
static char here[] = "%sdata_write";
int err;
-@@ -2828,7 +2662,6 @@ seqnos_memory_object_data_write(pager, seqno, pager_request,
+@@ -2828,7 +2637,6 @@ seqnos_memory_object_data_write(pager, seqno, pager_request,
if ((data_cnt % vm_page_size) != 0)
panic(here,my_name);
@@ -359,7 +475,7 @@ index 8f8e13e..b718262 100644
if (ds == DEFAULT_PAGER_NULL)
panic(here,my_name);
-@@ -2888,7 +2721,7 @@ seqnos_memory_object_data_write(pager, seqno, pager_request,
+@@ -2888,7 +2696,7 @@ seqnos_memory_object_data_write(pager, seqno, pager_request,
kern_return_t
seqnos_memory_object_copy(old_memory_object, seqno, old_memory_control,
offset, length, new_memory_object)
@@ -368,7 +484,7 @@ index 8f8e13e..b718262 100644
mach_port_seqno_t seqno;
memory_object_control_t
old_memory_control;
-@@ -2916,7 +2749,7 @@ seqnos_memory_object_lock_completed (memory_object_t pager,
+@@ -2916,7 +2724,7 @@ seqnos_memory_object_lock_completed (memory_object_t pager,
kern_return_t
seqnos_memory_object_data_unlock(pager, seqno, pager_request,
offset, length, protection_required)
@@ -377,7 +493,7 @@ index 8f8e13e..b718262 100644
mach_port_seqno_t seqno;
mach_port_t pager_request;
vm_offset_t offset;
-@@ -2931,7 +2764,7 @@ kern_return_t
+@@ -2931,7 +2739,7 @@ kern_return_t
seqnos_memory_object_supply_completed(pager, seqno, pager_request,
offset, length,
result, error_offset)
@@ -386,7 +502,7 @@ index 8f8e13e..b718262 100644
mach_port_seqno_t seqno;
mach_port_t pager_request;
vm_offset_t offset;
-@@ -2949,10 +2782,10 @@ seqnos_memory_object_supply_completed(pager, seqno, pager_request,
+@@ -2949,10 +2757,10 @@ seqnos_memory_object_supply_completed(pager, seqno, pager_request,
* into individual pages and pass them off to default_write.
*/
kern_return_t
@@ -399,7 +515,7 @@ index 8f8e13e..b718262 100644
mach_port_seqno_t seqno;
mach_port_t pager_request;
vm_offset_t offset;
-@@ -2962,7 +2795,7 @@ seqnos_memory_object_data_return(pager, seqno, pager_request,
+@@ -2962,7 +2770,7 @@ seqnos_memory_object_data_return(pager, seqno, pager_request,
boolean_t kernel_copy;
{
@@ -408,7 +524,68 @@ index 8f8e13e..b718262 100644
offset, addr, data_cnt);
}
-@@ -3756,14 +3589,12 @@ S_default_pager_object_pages (mach_port_t pager,
+@@ -3364,23 +3172,14 @@ S_default_pager_object_create (mach_port_t pager,
+ return KERN_INVALID_ARGUMENT;
+
+ ds = pager_port_alloc(size);
+-rename_it:
+- port = (mach_port_t) pnameof(ds);
+- result = mach_port_allocate_name(default_pager_self,
+- MACH_PORT_RIGHT_RECEIVE, port);
+- if (result != KERN_SUCCESS) {
+- default_pager_t ds1;
+-
+- if (result != KERN_NAME_EXISTS) return (result);
+-
+- ds1 = (default_pager_t) kalloc(sizeof *ds1);
+- *ds1 = *ds;
+- pthread_mutex_lock(&all_pagers.lock);
+- queue_enter(&all_pagers.leak_queue, ds, default_pager_t, links);
+- pthread_mutex_unlock(&all_pagers.lock);
+- ds = ds1;
+- goto rename_it;
+- }
++ result = mach_port_allocate (default_pager_self,
++ MACH_PORT_RIGHT_RECEIVE,
++ &port);
++ if (result != KERN_SUCCESS)
++ {
++ kfree ((char *) ds, sizeof *ds);
++ return result;
++ }
+
+ /*
+ * Set up associations between these ports
+@@ -3454,7 +3253,7 @@ S_default_pager_objects (mach_port_t pager,
+ /*
+ * We will send no more than this many
+ */
+- actual = all_pagers.count;
++ actual = all_pagers.htable.nr_items;
+ pthread_mutex_unlock(&all_pagers.lock);
+
+ if (opotential < actual) {
+@@ -3496,7 +3295,8 @@ S_default_pager_objects (mach_port_t pager,
+ pthread_mutex_lock(&all_pagers.lock);
+
+ num_pagers = 0;
+- queue_iterate(&all_pagers.queue, entry, default_pager_t, links) {
++ HURD_IHASH_ITERATE (&all_pagers.htable, val) {
++ entry = (default_pager_t) val;
+
+ mach_port_t port;
+ vm_size_t size;
+@@ -3674,7 +3474,8 @@ S_default_pager_object_pages (mach_port_t pager,
+ default_pager_t entry;
+
+ pthread_mutex_lock(&all_pagers.lock);
+- queue_iterate(&all_pagers.queue, entry, default_pager_t, links) {
++ HURD_IHASH_ITERATE (&all_pagers.htable, val) {
++ entry = (default_pager_t) val;
+ dstruct_lock(entry);
+ if (entry->pager_name == object) {
+ pthread_mutex_unlock(&all_pagers.lock);
+@@ -3756,14 +3557,12 @@ S_default_pager_object_pages (mach_port_t pager,
kern_return_t
@@ -424,12 +601,25 @@ index 8f8e13e..b718262 100644
if (ds == DEFAULT_PAGER_NULL)
return KERN_INVALID_ARGUMENT;
+diff --git a/mach-defpager/main.c b/mach-defpager/main.c
+index fe6f735..e33c2b3 100644
+--- a/mach-defpager/main.c
++++ b/mach-defpager/main.c
+@@ -43,7 +43,7 @@
+ #include <hurd/fd.h>
+ /* XXX */
+
+-#include <default_pager.h>
++#include "default_pager.h"
+
+ mach_port_t bootstrap_master_device_port; /* local name */
+ mach_port_t bootstrap_master_host_port; /* local name */
diff --git a/mach-defpager/mig-decls.h b/mach-defpager/mig-decls.h
new file mode 100644
-index 0000000..f63fef2
+index 0000000..8118d61
--- /dev/null
+++ b/mach-defpager/mig-decls.h
-@@ -0,0 +1,37 @@
+@@ -0,0 +1,34 @@
+/*
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Written by Justus Winter.
@@ -459,11 +649,8 @@ index 0000000..f63fef2
+static inline struct dstruct * __attribute__ ((unused))
+begin_using_default_pager (mach_port_t port)
+{
-+ if (! MACH_PORT_VALID(port)
-+ || ((default_pager_t) dnameof(port))->pager != (port))
-+ return DEFAULT_PAGER_NULL;
-+
-+ return (default_pager_t) dnameof(port);
++ return (default_pager_t) hurd_ihash_find (&all_pagers.htable,
++ (hurd_ihash_key_t) port);
+}
+
+#endif /* __MACH_DEFPAGER_MIG_DECLS_H__ */
@@ -497,10 +684,10 @@ index 0000000..54aeeba
+#define DEFAULT_PAGER_IMPORTS import "mig-decls.h";
diff --git a/mach-defpager/priv.h b/mach-defpager/priv.h
new file mode 100644
-index 0000000..20711b2
+index 0000000..3684565
--- /dev/null
+++ b/mach-defpager/priv.h
-@@ -0,0 +1,188 @@
+@@ -0,0 +1,200 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993-1989 Carnegie Mellon University
@@ -532,6 +719,7 @@ index 0000000..20711b2
+
+#include <mach.h>
+#include <queue.h>
++#include <hurd/ihash.h>
+
+/*
+ * Bitmap allocation.
@@ -653,6 +841,7 @@ index 0000000..20711b2
+ * Mapping between pager port and paging object.
+ */
+struct dstruct {
++ hurd_ihash_locp_t htable_locp; /* for the ihash table */
+ queue_chain_t links; /* Link in pager-port list */
+
+ pthread_mutex_t lock; /* Lock for the structure */
@@ -683,9 +872,34 @@ index 0000000..20711b2
+typedef struct dstruct * default_pager_t;
+#define DEFAULT_PAGER_NULL ((default_pager_t)0)
+
-+/* given a data structure return a good port-name to associate it to */
-+#define pnameof(_x_) (((vm_offset_t) (_x_)) + 1)
-+/* reverse, assumes no-odd-pointers */
-+#define dnameof(_x_) (((vm_offset_t) (_x_)) & ~1)
++/*
++ * List of all pagers. A specific pager is
++ * found directly via its port, this list is
++ * only used for monitoring purposes by the
++ * default_pager_object* calls
++ */
++struct pager_port {
++ struct hurd_ihash htable;
++ pthread_mutex_t lock;
++ queue_head_t leak_queue;
++};
++
++/* The list of pagers. */
++extern struct pager_port all_pagers;
+
+#endif /* __MACH_DEFPAGER_PRIV_H__ */
+diff --git a/mach-defpager/setup.c b/mach-defpager/setup.c
+index 7c1afbc..e4ec8d9 100644
+--- a/mach-defpager/setup.c
++++ b/mach-defpager/setup.c
+@@ -25,8 +25,8 @@
+ #include <string.h>
+ #include <strings.h>
+
+-#include <default_pager.h>
+-#include <kalloc.h>
++#include "default_pager.h"
++#include "kalloc.h"
+
+ #include "file_io.h"
+ #include "default_pager_S.h"