summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-07-25 04:09:40 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-07-25 04:09:40 +0200
commit556ea3de84b3f309b284f60d9420bdabcc549af2 (patch)
tree7fcd4bf4a22c6d25ed313544d1ae1a984397d40f /debian
parent1a98ae4443e6bed218c62b09f10be3f489b5fceb (diff)
add patch series
Diffstat (limited to 'debian')
-rw-r--r--debian/patches/series10
-rw-r--r--debian/patches/upstreamme0001-kern-new-function-thread_sleep_lock.patch59
-rw-r--r--debian/patches/upstreamme0002-yyy-more-general-locks-crashes-maybe-b-c-interrupt-h.patch226
-rw-r--r--debian/patches/upstreamme0003-turn-all_psets_lock-into-a-general-lock.patch241
-rw-r--r--debian/patches/upstreamme0004-device-use-general-lock-for-mach_device.patch70
-rw-r--r--debian/patches/upstreamme0005-device-use-general-lock-for-port-lists.patch116
-rw-r--r--debian/patches/upstreamme0006-vm-use-a-general-lock-to-protect-the-default-memory-.patch102
-rw-r--r--debian/patches/upstreamme0007-kern-bootstrap-tune-locking.patch30
-rw-r--r--debian/patches/upstreamme0008-vm-object-use-a-general-lock-to-protect-the-object-c.patch48
-rw-r--r--debian/patches/upstreamme0009-vm-object-use-a-general-lock-to-protect-vm-objects.patch86
-rw-r--r--debian/patches/upstreamme0010-kern-use-a-general-lock-for-the-IPC-structures.patch74
11 files changed, 1062 insertions, 0 deletions
diff --git a/debian/patches/series b/debian/patches/series
index 029e46a..7def737 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -13,3 +13,13 @@ sysenter0001-yyy-sysenter-prototype.patch
vm-cache-policy0001-VM-cache-policy-change.patch
vm-cache-policy0002-vm-keep-track-of-clean-pages.patch
vm-cache-policy0003-vm-evict-clean-pages-first.patch
+upstreamme0001-kern-new-function-thread_sleep_lock.patch
+upstreamme0002-yyy-more-general-locks-crashes-maybe-b-c-interrupt-h.patch
+upstreamme0003-turn-all_psets_lock-into-a-general-lock.patch
+upstreamme0004-device-use-general-lock-for-mach_device.patch
+upstreamme0005-device-use-general-lock-for-port-lists.patch
+upstreamme0006-vm-use-a-general-lock-to-protect-the-default-memory-.patch
+upstreamme0007-kern-bootstrap-tune-locking.patch
+upstreamme0008-vm-object-use-a-general-lock-to-protect-the-object-c.patch
+upstreamme0009-vm-object-use-a-general-lock-to-protect-vm-objects.patch
+upstreamme0010-kern-use-a-general-lock-for-the-IPC-structures.patch
diff --git a/debian/patches/upstreamme0001-kern-new-function-thread_sleep_lock.patch b/debian/patches/upstreamme0001-kern-new-function-thread_sleep_lock.patch
new file mode 100644
index 0000000..2729c6c
--- /dev/null
+++ b/debian/patches/upstreamme0001-kern-new-function-thread_sleep_lock.patch
@@ -0,0 +1,59 @@
+From e9ce90462680d53e9918aeb45ed53a33af6867d3 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 25 Jul 2015 01:46:53 +0200
+Subject: [PATCH gnumach 01/10] kern: new function `thread_sleep_lock'
+
+* kern/sched_prim.c (thread_sleep_lock): New function.
+* kern/sched_prim.h (thread_sleep_lock): New delcaration.
+---
+ kern/sched_prim.c | 18 ++++++++++++++++++
+ kern/sched_prim.h | 4 ++++
+ 2 files changed, 22 insertions(+)
+
+diff --git a/kern/sched_prim.c b/kern/sched_prim.c
+index e8f260e..e354a21 100644
+--- a/kern/sched_prim.c
++++ b/kern/sched_prim.c
+@@ -458,6 +458,24 @@ void thread_sleep(
+ }
+
+ /*
++ * thread_sleep_lock:
++ *
++ * Cause the current thread to wait until the specified event
++ * occurs. The specified lock is unlocked before releasing
++ * the cpu. (This is a convenient way to sleep without manually
++ * calling assert_wait).
++ */
++void thread_sleep_lock(
++ event_t event,
++ lock_t lock,
++ boolean_t interruptible)
++{
++ assert_wait(event, interruptible); /* assert event */
++ lock_done(lock); /* release the lock */
++ thread_block((void (*)()) 0); /* block ourselves */
++}
++
++/*
+ * thread_bind:
+ *
+ * Force a thread to execute on the specified processor.
+diff --git a/kern/sched_prim.h b/kern/sched_prim.h
+index 62698dc..83d4594 100644
+--- a/kern/sched_prim.h
++++ b/kern/sched_prim.h
+@@ -69,6 +69,10 @@ extern void thread_sleep(
+ event_t event,
+ simple_lock_t lock,
+ boolean_t interruptible);
++extern void thread_sleep_lock(
++ event_t event,
++ lock_t lock,
++ boolean_t interruptible);
+ extern void thread_wakeup(void); /* for function pointers */
+ extern void thread_wakeup_prim(
+ event_t event,
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0002-yyy-more-general-locks-crashes-maybe-b-c-interrupt-h.patch b/debian/patches/upstreamme0002-yyy-more-general-locks-crashes-maybe-b-c-interrupt-h.patch
new file mode 100644
index 0000000..b096270
--- /dev/null
+++ b/debian/patches/upstreamme0002-yyy-more-general-locks-crashes-maybe-b-c-interrupt-h.patch
@@ -0,0 +1,226 @@
+From 96393b1a0885751365781c59cae792897c065c1e Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 18 Jul 2015 16:55:12 +0200
+Subject: [PATCH gnumach 02/10] yyy more general locks, crashes, maybe b/c
+ interrupt handler
+
+---
+ device/kmsg.c | 43 +++++++++++++++++++++++--------------------
+ ipc/ipc_object.h | 10 +++++-----
+ kern/processor.c | 2 +-
+ kern/processor.h | 7 ++++---
+ 4 files changed, 33 insertions(+), 29 deletions(-)
+
+diff --git a/device/kmsg.c b/device/kmsg.c
+index c80775d..dbf6b8a 100644
+--- a/device/kmsg.c
++++ b/device/kmsg.c
+@@ -44,7 +44,10 @@ static queue_head_t kmsg_read_queue;
+ /* Used for exclusive access to the device */
+ static boolean_t kmsg_in_use;
+ /* Used for exclusive access to the routines */
+-decl_simple_lock_data (static, kmsg_lock);
++static struct lock kmsg_lock_data;
++#define kmsg_lock_init() lock_init (&kmsg_lock_data, FALSE)
++#define kmsg_lock() lock_write (&kmsg_lock_data)
++#define kmsg_unlock() lock_write_done (&kmsg_lock_data)
+ /* If already initialized or not */
+ static boolean_t kmsg_init_done = FALSE;
+
+@@ -56,23 +59,23 @@ kmsginit (void)
+ kmsg_read_offset = 0;
+ queue_init (&kmsg_read_queue);
+ kmsg_in_use = FALSE;
+- simple_lock_init (&kmsg_lock);
++ kmsg_lock_init ();
+ }
+
+ /* Kernel Message Open Handler */
+ io_return_t
+ kmsgopen (dev_t dev, int flag, const io_req_t ior)
+ {
+- simple_lock (&kmsg_lock);
++ kmsg_lock ();
+ if (kmsg_in_use)
+ {
+- simple_unlock (&kmsg_lock);
++ kmsg_unlock ();
+ return D_ALREADY_OPEN;
+ }
+
+ kmsg_in_use = TRUE;
+
+- simple_unlock (&kmsg_lock);
++ kmsg_unlock ();
+ return D_SUCCESS;
+ }
+
+@@ -80,10 +83,10 @@ kmsgopen (dev_t dev, int flag, const io_req_t ior)
+ void
+ kmsgclose (dev_t dev, int flag)
+ {
+- simple_lock (&kmsg_lock);
++ kmsg_lock ();
+ kmsg_in_use = FALSE;
+-
+- simple_unlock (&kmsg_lock);
++
++ kmsg_unlock ();
+ }
+
+ static boolean_t kmsg_read_done (io_req_t ior);
+@@ -99,19 +102,19 @@ kmsgread (dev_t dev, io_req_t ior)
+ if (err != KERN_SUCCESS)
+ return err;
+
+- simple_lock (&kmsg_lock);
++ kmsg_lock ();
+ if (kmsg_read_offset == kmsg_write_offset)
+ {
+ /* The queue is empty. */
+ if (ior->io_mode & D_NOWAIT)
+ {
+- simple_unlock (&kmsg_lock);
++ kmsg_unlock ();
+ return D_WOULD_BLOCK;
+ }
+
+ ior->io_done = kmsg_read_done;
+ enqueue_tail (&kmsg_read_queue, (queue_entry_t) ior);
+- simple_unlock (&kmsg_lock);
++ kmsg_unlock ();
+ return D_IO_QUEUED;
+ }
+
+@@ -141,8 +144,8 @@ kmsgread (dev_t dev, io_req_t ior)
+ kmsg_read_offset -= KMSGBUFSIZE;
+
+ ior->io_residual = ior->io_count - amt;
+-
+- simple_unlock (&kmsg_lock);
++
++ kmsg_unlock ();
+ return D_SUCCESS;
+ }
+
+@@ -151,13 +154,13 @@ kmsg_read_done (io_req_t ior)
+ {
+ int amt, len;
+
+- simple_lock (&kmsg_lock);
++ kmsg_lock ();
+ if (kmsg_read_offset == kmsg_write_offset)
+ {
+ /* The queue is empty. */
+ ior->io_done = kmsg_read_done;
+ enqueue_tail (&kmsg_read_queue, (queue_entry_t) ior);
+- simple_unlock (&kmsg_lock);
++ kmsg_unlock ();
+ return FALSE;
+ }
+
+@@ -188,7 +191,7 @@ kmsg_read_done (io_req_t ior)
+
+ ior->io_residual = ior->io_count - amt;
+
+- simple_unlock (&kmsg_lock);
++ kmsg_unlock ();
+ ds_read_done (ior);
+
+ return TRUE;
+@@ -226,8 +229,8 @@ kmsg_putchar (int c)
+ kmsginit ();
+ kmsg_init_done = TRUE;
+ }
+-
+- simple_lock (&kmsg_lock);
++
++ kmsg_lock ();
+ offset = kmsg_write_offset + 1;
+ if (offset == KMSGBUFSIZE)
+ offset = 0;
+@@ -235,7 +238,7 @@ kmsg_putchar (int c)
+ if (offset == kmsg_read_offset)
+ {
+ /* Discard C. */
+- simple_unlock (&kmsg_lock);
++ kmsg_unlock ();
+ return;
+ }
+
+@@ -246,5 +249,5 @@ kmsg_putchar (int c)
+ while ((ior = (io_req_t) dequeue_head (&kmsg_read_queue)) != NULL)
+ iodone (ior);
+
+- simple_unlock (&kmsg_lock);
++ kmsg_unlock ();
+ }
+diff --git a/ipc/ipc_object.h b/ipc/ipc_object.h
+index be5bea7..8504a23 100644
+--- a/ipc/ipc_object.h
++++ b/ipc/ipc_object.h
+@@ -46,7 +46,7 @@ typedef unsigned int ipc_object_bits_t;
+ typedef unsigned int ipc_object_type_t;
+
+ typedef struct ipc_object {
+- decl_simple_lock_data(,io_lock_data)
++ struct lock io_lock_data;
+ ipc_object_refs_t io_references;
+ ipc_object_bits_t io_bits;
+ } *ipc_object_t;
+@@ -85,10 +85,10 @@ extern struct kmem_cache ipc_object_caches[IOT_NUMBER];
+ #define io_free(otype, io) \
+ kmem_cache_free(&ipc_object_caches[(otype)], (vm_offset_t) (io))
+
+-#define io_lock_init(io) simple_lock_init(&(io)->io_lock_data)
+-#define io_lock(io) simple_lock(&(io)->io_lock_data)
+-#define io_lock_try(io) simple_lock_try(&(io)->io_lock_data)
+-#define io_unlock(io) simple_unlock(&(io)->io_lock_data)
++#define io_lock_init(io) lock_init(&(io)->io_lock_data, TRUE)
++#define io_lock(io) lock_write(&(io)->io_lock_data)
++#define io_lock_try(io) lock_try_write(&(io)->io_lock_data)
++#define io_unlock(io) lock_write_done(&(io)->io_lock_data)
+
+ #define io_check_unlock(io) \
+ MACRO_BEGIN \
+diff --git a/kern/processor.c b/kern/processor.c
+index 48e9273..a7c3fbf 100644
+--- a/kern/processor.c
++++ b/kern/processor.c
+@@ -155,7 +155,7 @@ void pset_init(
+ simple_lock_init(&pset->ref_lock);
+ queue_init(&pset->all_psets);
+ pset->active = FALSE;
+- simple_lock_init(&pset->lock);
++ pset_lock_init (pset);
+ pset->pset_self = IP_NULL;
+ pset->pset_name_self = IP_NULL;
+ pset->max_priority = BASEPRI_USER;
+diff --git a/kern/processor.h b/kern/processor.h
+index b81526c..69ddf87 100644
+--- a/kern/processor.h
++++ b/kern/processor.h
+@@ -68,7 +68,7 @@ struct processor_set {
+ decl_simple_lock_data(, ref_lock) /* lock for ref count */
+ queue_chain_t all_psets; /* link for all_psets */
+ boolean_t active; /* is pset in use */
+- decl_simple_lock_data(, lock) /* lock for everything else */
++ struct lock lock; /* lock for everything else */
+ struct ipc_port * pset_self; /* port for operations */
+ struct ipc_port * pset_name_self; /* port for information */
+ int max_priority; /* maximum priority */
+@@ -216,8 +216,9 @@ extern processor_t processor_ptr[NCPUS];
+
+ /* Useful lock macros */
+
+-#define pset_lock(pset) simple_lock(&(pset)->lock)
+-#define pset_unlock(pset) simple_unlock(&(pset)->lock)
++#define pset_lock_init(pset) lock_init(&(pset)->lock, FALSE)
++#define pset_lock(pset) lock_write(&(pset)->lock)
++#define pset_unlock(pset) lock_write_done(&(pset)->lock)
+ #define pset_ref_lock(pset) simple_lock(&(pset)->ref_lock)
+ #define pset_ref_unlock(pset) simple_unlock(&(pset)->ref_lock)
+
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0003-turn-all_psets_lock-into-a-general-lock.patch b/debian/patches/upstreamme0003-turn-all_psets_lock-into-a-general-lock.patch
new file mode 100644
index 0000000..4ff6313
--- /dev/null
+++ b/debian/patches/upstreamme0003-turn-all_psets_lock-into-a-general-lock.patch
@@ -0,0 +1,241 @@
+From f5dd85e25364a498675cda4b143a029c7fed325b Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue, 21 Jul 2015 00:54:07 +0200
+Subject: [PATCH gnumach 03/10] turn all_psets_lock into a general lock
+
+---
+ kern/host.c | 6 +++---
+ kern/mach_factor.c | 4 ++--
+ kern/processor.c | 14 +++++++-------
+ kern/processor.h | 5 ++++-
+ kern/sched_prim.c | 4 ++--
+ kern/task.c | 8 ++++----
+ kern/thread.c | 8 ++++----
+ 7 files changed, 26 insertions(+), 23 deletions(-)
+
+diff --git a/kern/host.c b/kern/host.c
+index 2855cd2..86955a6 100644
+--- a/kern/host.c
++++ b/kern/host.c
+@@ -244,7 +244,7 @@ host_processor_sets(
+ size = 0; addr = 0;
+
+ for (;;) {
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ actual = all_psets_count;
+
+ /* do we have the memory we need? */
+@@ -254,7 +254,7 @@ host_processor_sets(
+ break;
+
+ /* unlock and allocate more memory */
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+
+ if (size != 0)
+ kfree(addr, size);
+@@ -281,7 +281,7 @@ host_processor_sets(
+ assert(queue_end(&all_psets, (queue_entry_t) pset));
+
+ /* can unlock now that we've got the pset refs */
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+
+ /*
+ * Always have default port.
+diff --git a/kern/mach_factor.c b/kern/mach_factor.c
+index debce0b..6598707 100644
+--- a/kern/mach_factor.c
++++ b/kern/mach_factor.c
+@@ -63,7 +63,7 @@ void compute_mach_factor(void)
+ long average_now;
+ long load_now;
+
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ pset = (processor_set_t) queue_first(&all_psets);
+ while (!queue_end(&all_psets, (queue_entry_t)pset)) {
+
+@@ -146,5 +146,5 @@ void compute_mach_factor(void)
+ pset = (processor_set_t) queue_next(&pset->all_psets);
+ }
+
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+ }
+diff --git a/kern/processor.c b/kern/processor.c
+index a7c3fbf..bc70dde 100644
+--- a/kern/processor.c
++++ b/kern/processor.c
+@@ -60,7 +60,7 @@ struct processor processor_array[NCPUS];
+
+ queue_head_t all_psets;
+ int all_psets_count;
+-decl_simple_lock_data(, all_psets_lock);
++struct lock all_psets_lock_data;
+
+ processor_t master_processor;
+ processor_t processor_ptr[NCPUS];
+@@ -84,7 +84,7 @@ void pset_sys_bootstrap(void)
+ }
+ master_processor = cpu_to_processor(master_cpu);
+ queue_init(&all_psets);
+- simple_lock_init(&all_psets_lock);
++ all_psets_lock_init();
+ queue_enter(&all_psets, &default_pset, processor_set_t, all_psets);
+ all_psets_count = 1;
+ default_pset.active = TRUE;
+@@ -357,14 +357,14 @@ void pset_deallocate(
+ pset->ref_count = 1;
+ pset_ref_unlock(pset);
+
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ pset_ref_lock(pset);
+ if (--pset->ref_count > 0) {
+ /*
+ * Made an extra reference.
+ */
+ pset_ref_unlock(pset);
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+ return;
+ }
+
+@@ -383,7 +383,7 @@ void pset_deallocate(
+ all_psets_count--;
+
+ pset_ref_unlock(pset);
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+
+ /*
+ * That's it, free data structure.
+@@ -539,10 +539,10 @@ processor_set_create(
+ ipc_pset_init(pset);
+ pset->active = TRUE;
+
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ queue_enter(&all_psets, pset, processor_set_t, all_psets);
+ all_psets_count++;
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+
+ ipc_pset_enable(pset);
+
+diff --git a/kern/processor.h b/kern/processor.h
+index 69ddf87..b52ecda 100644
+--- a/kern/processor.h
++++ b/kern/processor.h
+@@ -117,7 +117,10 @@ extern struct processor processor_array[NCPUS];
+ */
+ extern queue_head_t all_psets;
+ extern int all_psets_count;
+-decl_simple_lock_data(extern, all_psets_lock);
++extern struct lock all_psets_lock_data;
++#define all_psets_lock_init() lock_init(&all_psets_lock_data, FALSE)
++#define lock_all_psets() lock_write(&all_psets_lock_data)
++#define unlock_all_psets() lock_write_done(&all_psets_lock_data)
+
+ /*
+ * The lock ordering is:
+diff --git a/kern/sched_prim.c b/kern/sched_prim.c
+index e354a21..aa6bb92 100644
+--- a/kern/sched_prim.c
++++ b/kern/sched_prim.c
+@@ -1969,12 +1969,12 @@ void do_thread_scan(void)
+
+ do {
+ #if MACH_HOST
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ queue_iterate(&all_psets, pset, processor_set_t, all_psets) {
+ if (restart_needed = do_runq_scan(&pset->runq))
+ break;
+ }
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+ #else /* MACH_HOST */
+ restart_needed = do_runq_scan(&default_pset.runq);
+ #endif /* MACH_HOST */
+diff --git a/kern/task.c b/kern/task.c
+index b384347..a40b629 100644
+--- a/kern/task.c
++++ b/kern/task.c
+@@ -1140,14 +1140,14 @@ void task_collect_scan(void)
+ prev_task = TASK_NULL;
+ prev_pset = PROCESSOR_SET_NULL;
+
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ queue_iterate(&all_psets, pset, processor_set_t, all_psets) {
+ pset_lock(pset);
+ queue_iterate(&pset->tasks, task, task_t, pset_tasks) {
+ task_reference(task);
+ pset_reference(pset);
+ pset_unlock(pset);
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+
+ machine_task_collect (task);
+ pmap_collect(task->map->pmap);
+@@ -1160,12 +1160,12 @@ void task_collect_scan(void)
+ pset_deallocate(prev_pset);
+ prev_pset = pset;
+
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ pset_lock(pset);
+ }
+ pset_unlock(pset);
+ }
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+
+ if (prev_task != TASK_NULL)
+ task_deallocate(prev_task);
+diff --git a/kern/thread.c b/kern/thread.c
+index 1f47553..63a6c26 100644
+--- a/kern/thread.c
++++ b/kern/thread.c
+@@ -2249,7 +2249,7 @@ void thread_collect_scan(void)
+ prev_thread = THREAD_NULL;
+ prev_pset = PROCESSOR_SET_NULL;
+
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ queue_iterate(&all_psets, pset, processor_set_t, all_psets) {
+ pset_lock(pset);
+ queue_iterate(&pset->threads, thread, thread_t, pset_threads) {
+@@ -2268,7 +2268,7 @@ void thread_collect_scan(void)
+ (void) splx(s);
+ pset->ref_count++;
+ pset_unlock(pset);
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+
+ pcb_collect(thread);
+
+@@ -2280,7 +2280,7 @@ void thread_collect_scan(void)
+ pset_deallocate(prev_pset);
+ prev_pset = pset;
+
+- simple_lock(&all_psets_lock);
++ lock_all_psets();
+ pset_lock(pset);
+ } else {
+ thread_unlock(thread);
+@@ -2289,7 +2289,7 @@ void thread_collect_scan(void)
+ }
+ pset_unlock(pset);
+ }
+- simple_unlock(&all_psets_lock);
++ unlock_all_psets();
+
+ if (prev_thread != THREAD_NULL)
+ thread_deallocate(prev_thread);
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0004-device-use-general-lock-for-mach_device.patch b/debian/patches/upstreamme0004-device-use-general-lock-for-mach_device.patch
new file mode 100644
index 0000000..768b3cb
--- /dev/null
+++ b/debian/patches/upstreamme0004-device-use-general-lock-for-mach_device.patch
@@ -0,0 +1,70 @@
+From 7e6ed5d82d5941e9f59ae2d4be06d3129d1d236e Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 25 Jul 2015 01:47:54 +0200
+Subject: [PATCH gnumach 04/10] device: use general lock for `mach_device'
+
+* device/dev_hdr.h (struct mach_device): Turn lock into a general lock.
+(device_lock_init): New macro.
+(device_lock, device_unlock): Adapt accordingly.
+* device/dev_lookup.c (device_lookup): Use `device_lock_init'.
+* device/ds_routines.c (device_open): Adapt accordingly.
+---
+ device/dev_hdr.h | 7 ++++---
+ device/dev_lookup.c | 2 +-
+ device/ds_routines.c | 2 +-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/device/dev_hdr.h b/device/dev_hdr.h
+index ff7d2ef..5f80d4a 100644
+--- a/device/dev_hdr.h
++++ b/device/dev_hdr.h
+@@ -82,7 +82,7 @@ typedef struct device *device_t;
+ struct mach_device {
+ decl_simple_lock_data(,ref_lock)/* lock for reference count */
+ int ref_count; /* reference count */
+- decl_simple_lock_data(, lock) /* lock for rest of state */
++ struct lock lock; /* lock for rest of state */
+ short state; /* state: */
+ #define DEV_STATE_INIT 0 /* not open */
+ #define DEV_STATE_OPENING 1 /* being opened */
+@@ -127,8 +127,9 @@ boolean_t dev_map(boolean_t (*)(), mach_port_t);
+ /*
+ * To lock and unlock state and open-count
+ */
+-#define device_lock(device) simple_lock(&(device)->lock)
+-#define device_unlock(device) simple_unlock(&(device)->lock)
++#define device_lock_init(device) lock_init(&(device)->lock, FALSE)
++#define device_lock(device) lock_write(&(device)->lock)
++#define device_unlock(device) lock_write_done(&(device)->lock)
+
+ /*
+ * device name lookup
+diff --git a/device/dev_lookup.c b/device/dev_lookup.c
+index a80830c..297dcde 100644
+--- a/device/dev_lookup.c
++++ b/device/dev_lookup.c
+@@ -154,7 +154,7 @@ device_lookup(char *name)
+ new_device = (mach_device_t) kmem_cache_alloc(&dev_hdr_cache);
+ simple_lock_init(&new_device->ref_lock);
+ new_device->ref_count = 1;
+- simple_lock_init(&new_device->lock);
++ device_lock_init(new_device);
+ new_device->state = DEV_STATE_INIT;
+ new_device->flag = 0;
+ new_device->open_count = 0;
+diff --git a/device/ds_routines.c b/device/ds_routines.c
+index 43ed5b5..33cfd89 100644
+--- a/device/ds_routines.c
++++ b/device/ds_routines.c
+@@ -443,7 +443,7 @@ device_open(const ipc_port_t reply_port,
+ while (device->state == DEV_STATE_OPENING ||
+ device->state == DEV_STATE_CLOSING) {
+ device->io_wait = TRUE;
+- thread_sleep((event_t)device, simple_lock_addr(device->lock), TRUE);
++ thread_sleep_lock((event_t)device, &device->lock, TRUE);
+ device_lock(device);
+ }
+
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0005-device-use-general-lock-for-port-lists.patch b/debian/patches/upstreamme0005-device-use-general-lock-for-port-lists.patch
new file mode 100644
index 0000000..a943390
--- /dev/null
+++ b/debian/patches/upstreamme0005-device-use-general-lock-for-port-lists.patch
@@ -0,0 +1,116 @@
+From 148ca384324574ffdbd9350cd95d19c5ebf36453 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 25 Jul 2015 01:55:22 +0200
+Subject: [PATCH gnumach 05/10] device: use general lock for port lists
+
+* device/if_hdr.h (struct ifnet): Turn the port list locks into
+general locks.
+(port_list_{lock_init,lock,unlock): New macros.
+* device/net_io.c (net_filter, net_set_filter): Use new macros.
+* device/subrs.c (if_init_queues): Likewise.
+---
+ device/if_hdr.h | 12 +++++++-----
+ device/net_io.c | 20 ++++++++++----------
+ device/subrs.c | 4 ++--
+ 3 files changed, 19 insertions(+), 17 deletions(-)
+
+diff --git a/device/if_hdr.h b/device/if_hdr.h
+index e53983b..58a670c 100644
+--- a/device/if_hdr.h
++++ b/device/if_hdr.h
+@@ -92,11 +92,13 @@ struct ifnet {
+ struct ifqueue if_snd; /* output queue */
+ queue_head_t if_rcv_port_list; /* input filter list */
+ queue_head_t if_snd_port_list; /* output filter list */
+- decl_simple_lock_data(,
+- if_rcv_port_list_lock) /* lock for input filter list */
+- decl_simple_lock_data(,
+- if_snd_port_list_lock) /* lock for output filter list */
+-/* statistics */
++ struct lock if_rcv_port_list_lock; /* lock for input filter list */
++ struct lock if_snd_port_list_lock; /* lock for output filter list */
++#define port_list_lock_init(l) lock_init(l, FALSE)
++#define port_list_lock(l) lock_write(l)
++#define port_list_unlock(l) lock_write_done(l)
++
++ /* statistics */
+ int if_ipackets; /* packets received */
+ int if_ierrors; /* input errors */
+ int if_opackets; /* packets sent */
+diff --git a/device/net_io.c b/device/net_io.c
+index 47ef2ea..12a1e9c 100644
+--- a/device/net_io.c
++++ b/device/net_io.c
+@@ -722,8 +722,8 @@ net_filter(kmsg, send_list)
+ * Both locks are hold in case a filter is removed from both
+ * queues.
+ */
+- simple_lock(&ifp->if_rcv_port_list_lock);
+- simple_lock(&ifp->if_snd_port_list_lock);
++ port_list_lock(&ifp->if_rcv_port_list_lock);
++ port_list_lock(&ifp->if_snd_port_list_lock);
+ FILTER_ITERATE(if_port_list, infp, nextfp,
+ net_kmsg(kmsg)->sent ? &infp->output : &infp->input)
+ {
+@@ -853,8 +853,8 @@ net_filter(kmsg, send_list)
+ }
+ }
+ FILTER_ITERATE_END
+- simple_unlock(&ifp->if_snd_port_list_lock);
+- simple_unlock(&ifp->if_rcv_port_list_lock);
++ port_list_unlock(&ifp->if_snd_port_list_lock);
++ port_list_unlock(&ifp->if_rcv_port_list_lock);
+
+ /*
+ * Deallocate dead filters.
+@@ -1255,8 +1255,8 @@ net_set_filter(
+ in = (filter[0] & NETF_IN) != 0;
+ out = (filter[0] & NETF_OUT) != 0;
+
+- simple_lock(&ifp->if_rcv_port_list_lock);
+- simple_lock(&ifp->if_snd_port_list_lock);
++ port_list_lock(&ifp->if_rcv_port_list_lock);
++ port_list_lock(&ifp->if_snd_port_list_lock);
+
+ if (in)
+ check_filter_list(&ifp->if_rcv_port_list);
+@@ -1272,8 +1272,8 @@ net_set_filter(
+ }
+ if (i == N_NET_HASH) {
+ simple_unlock(&net_hash_header_lock);
+- simple_unlock(&ifp->if_snd_port_list_lock);
+- simple_unlock(&ifp->if_rcv_port_list_lock);
++ port_list_unlock(&ifp->if_snd_port_list_lock);
++ port_list_unlock(&ifp->if_rcv_port_list_lock);
+
+ ipc_port_release_send(rcv_port);
+ if (match != 0)
+@@ -1352,8 +1352,8 @@ net_set_filter(
+ hash_entp->rcv_qlimit = net_add_q_info(rcv_port);
+ }
+
+- simple_unlock(&ifp->if_snd_port_list_lock);
+- simple_unlock(&ifp->if_rcv_port_list_lock);
++ port_list_unlock(&ifp->if_snd_port_list_lock);
++ port_list_unlock(&ifp->if_rcv_port_list_lock);
+
+ clean_and_return:
+ /* No locks are held at this point. */
+diff --git a/device/subrs.c b/device/subrs.c
+index a10b72d..cfaaecd 100644
+--- a/device/subrs.c
++++ b/device/subrs.c
+@@ -80,8 +80,8 @@ void if_init_queues(struct ifnet *ifp)
+ IFQ_INIT(&ifp->if_snd);
+ queue_init(&ifp->if_rcv_port_list);
+ queue_init(&ifp->if_snd_port_list);
+- simple_lock_init(&ifp->if_rcv_port_list_lock);
+- simple_lock_init(&ifp->if_snd_port_list_lock);
++ port_list_lock_init(&ifp->if_rcv_port_list_lock);
++ port_list_lock_init(&ifp->if_snd_port_list_lock);
+ }
+
+
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0006-vm-use-a-general-lock-to-protect-the-default-memory-.patch b/debian/patches/upstreamme0006-vm-use-a-general-lock-to-protect-the-default-memory-.patch
new file mode 100644
index 0000000..3a46e18
--- /dev/null
+++ b/debian/patches/upstreamme0006-vm-use-a-general-lock-to-protect-the-default-memory-.patch
@@ -0,0 +1,102 @@
+From c77bee5ce27603a1825b5799c16576d1fdcb8173 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 25 Jul 2015 02:13:17 +0200
+Subject: [PATCH gnumach 06/10] vm: use a general lock to protect the default
+ memory manager
+
+* vm/memory_object.c: Use a general lock to protect the default memory
+manager.
+---
+ vm/memory_object.c | 29 ++++++++++++++++++-----------
+ 1 file changed, 18 insertions(+), 11 deletions(-)
+
+diff --git a/vm/memory_object.c b/vm/memory_object.c
+index 097ed23..eeba168 100644
+--- a/vm/memory_object.c
++++ b/vm/memory_object.c
+@@ -73,8 +73,15 @@ typedef int memory_object_lock_result_t; /* moved from below */
+
+
+ ipc_port_t memory_manager_default = IP_NULL;
+-decl_simple_lock_data(,memory_manager_default_lock)
+
++struct lock default_memory_manager_lock_data;
++
++#define default_memory_manager_lock_init() \
++ lock_init(&default_memory_manager_lock_data, FALSE)
++#define default_memory_manager_lock() \
++ lock_write(&default_memory_manager_lock_data)
++#define default_memory_manager_unlock() \
++ lock_write_done(&default_memory_manager_lock_data)
+ /*
+ * Important note:
+ * All of these routines gain a reference to the
+@@ -1033,7 +1040,7 @@ kern_return_t vm_set_default_memory_manager(host, default_manager)
+ return(KERN_INVALID_HOST);
+
+ new_manager = *default_manager;
+- simple_lock(&memory_manager_default_lock);
++ default_memory_manager_lock();
+ current_manager = memory_manager_default;
+
+ if (new_manager == IP_NULL) {
+@@ -1060,7 +1067,7 @@ kern_return_t vm_set_default_memory_manager(host, default_manager)
+ thread_wakeup((event_t) &memory_manager_default);
+ }
+
+- simple_unlock(&memory_manager_default_lock);
++ default_memory_manager_unlock();
+
+ *default_manager = returned_manager;
+ return(KERN_SUCCESS);
+@@ -1078,17 +1085,17 @@ ipc_port_t memory_manager_default_reference(void)
+ {
+ ipc_port_t current_manager;
+
+- simple_lock(&memory_manager_default_lock);
++ default_memory_manager_lock();
+
+ while (current_manager = ipc_port_copy_send(memory_manager_default),
+ !IP_VALID(current_manager)) {
+- thread_sleep((event_t) &memory_manager_default,
+- simple_lock_addr(memory_manager_default_lock),
++ thread_sleep_lock((event_t) &memory_manager_default,
++ &default_memory_manager_lock_data,
+ FALSE);
+- simple_lock(&memory_manager_default_lock);
++ default_memory_manager_lock();
+ }
+
+- simple_unlock(&memory_manager_default_lock);
++ default_memory_manager_unlock();
+
+ return current_manager;
+ }
+@@ -1109,7 +1116,7 @@ boolean_t memory_manager_default_port(port)
+ ipc_port_t current;
+ boolean_t result;
+
+- simple_lock(&memory_manager_default_lock);
++ default_memory_manager_lock();
+ current = memory_manager_default;
+ if (IP_VALID(current)) {
+ /*
+@@ -1122,7 +1129,7 @@ boolean_t memory_manager_default_port(port)
+ result = port->ip_receiver == current->ip_receiver;
+ } else
+ result = FALSE;
+- simple_unlock(&memory_manager_default_lock);
++ default_memory_manager_unlock();
+
+ return result;
+ }
+@@ -1130,5 +1137,5 @@ boolean_t memory_manager_default_port(port)
+ void memory_manager_default_init(void)
+ {
+ memory_manager_default = IP_NULL;
+- simple_lock_init(&memory_manager_default_lock);
++ default_memory_manager_lock_init();
+ }
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0007-kern-bootstrap-tune-locking.patch b/debian/patches/upstreamme0007-kern-bootstrap-tune-locking.patch
new file mode 100644
index 0000000..e2a8fcd
--- /dev/null
+++ b/debian/patches/upstreamme0007-kern-bootstrap-tune-locking.patch
@@ -0,0 +1,30 @@
+From abf1fbce2aa3be4a9f5c906680b99c7d7cdb679d Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 25 Jul 2015 02:15:31 +0200
+Subject: [PATCH gnumach 07/10] kern/bootstrap: tune locking
+
+* kern/bootstrap.c (boot_script_exec_cmd): Avoid holding the lock
+across the call to `thread_create'.
+---
+ kern/bootstrap.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kern/bootstrap.c b/kern/bootstrap.c
+index cb0f976..aad0fb1 100644
+--- a/kern/bootstrap.c
++++ b/kern/bootstrap.c
+@@ -719,10 +719,10 @@ boot_script_exec_cmd (void *hook, task_t task, char *path, int argc,
+ thread_t thread;
+ struct user_bootstrap_info info = { mod, argv, 0, };
+ simple_lock_init (&info.lock);
+- simple_lock (&info.lock);
+
+ err = thread_create ((task_t)task, &thread);
+ assert(err == 0);
++ simple_lock (&info.lock);
+ thread->saved.other = &info;
+ thread_start (thread, user_bootstrap);
+ err = thread_resume (thread);
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0008-vm-object-use-a-general-lock-to-protect-the-object-c.patch b/debian/patches/upstreamme0008-vm-object-use-a-general-lock-to-protect-the-object-c.patch
new file mode 100644
index 0000000..3ff7e24
--- /dev/null
+++ b/debian/patches/upstreamme0008-vm-object-use-a-general-lock-to-protect-the-object-c.patch
@@ -0,0 +1,48 @@
+From 95062009c1d55ecefa976c81e9cee941eae600fe Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 25 Jul 2015 02:21:33 +0200
+Subject: [PATCH gnumach 08/10] vm/object: use a general lock to protect the
+ object cache
+
+* vm/vm_object.c: Use a general lock to protect the object cache.
+---
+ vm/vm_object.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/vm/vm_object.c b/vm/vm_object.c
+index deac0c2..b403d30 100644
+--- a/vm/vm_object.c
++++ b/vm/vm_object.c
+@@ -178,14 +178,16 @@ queue_head_t vm_object_cached_list;
+ int vm_object_cached_count;
+ int vm_object_cached_max = 4000; /* may be patched*/
+
+-decl_simple_lock_data(,vm_object_cached_lock_data)
++struct lock vm_object_cache_lock_data;
+
++#define vm_object_cache_lock_init() \
++ lock_init(&vm_object_cache_lock_data, FALSE)
+ #define vm_object_cache_lock() \
+- simple_lock(&vm_object_cached_lock_data)
++ lock_write(&vm_object_cache_lock_data)
+ #define vm_object_cache_lock_try() \
+- simple_lock_try(&vm_object_cached_lock_data)
++ lock_try_write(&vm_object_cache_lock_data)
+ #define vm_object_cache_unlock() \
+- simple_unlock(&vm_object_cached_lock_data)
++ lock_write_done(&vm_object_cache_lock_data)
+
+ /*
+ * Number of physical pages referenced by cached objects.
+@@ -261,7 +263,7 @@ void vm_object_bootstrap(void)
+ sizeof(struct vm_object), 0, NULL, NULL, NULL, 0);
+
+ queue_init(&vm_object_cached_list);
+- simple_lock_init(&vm_object_cached_lock_data);
++ vm_object_cache_lock_init();
+
+ /*
+ * Fill in a template object, for quick initialization
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0009-vm-object-use-a-general-lock-to-protect-vm-objects.patch b/debian/patches/upstreamme0009-vm-object-use-a-general-lock-to-protect-vm-objects.patch
new file mode 100644
index 0000000..f03a998
--- /dev/null
+++ b/debian/patches/upstreamme0009-vm-object-use-a-general-lock-to-protect-vm-objects.patch
@@ -0,0 +1,86 @@
+From bcef2e3112634dd780b9d694fcc3b266d45a203f Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 25 Jul 2015 02:26:36 +0200
+Subject: [PATCH gnumach 09/10] vm/object: use a general lock to protect vm
+ objects
+
+* vm/vm_object.h (struct vm_object): Use a general lock, adapt macros.
+---
+ vm/vm_object.h | 25 +++++++++++++------------
+ 1 file changed, 13 insertions(+), 12 deletions(-)
+
+diff --git a/vm/vm_object.h b/vm/vm_object.h
+index 3bfc67a..3c9055f 100644
+--- a/vm/vm_object.h
++++ b/vm/vm_object.h
+@@ -63,7 +63,7 @@ typedef struct ipc_port * pager_request_t;
+
+ struct vm_object {
+ queue_chain_t memq; /* Resident memory */
+- decl_simple_lock_data(, Lock) /* Synchronization */
++ struct lock Lock; /* Synchronization */
+ #if VM_OBJECT_DEBUG
+ thread_t LockHolder; /* Thread holding Lock */
+ #endif /* VM_OBJECT_DEBUG */
+@@ -336,14 +336,15 @@ vm_object_t vm_object_copy_delayed(
+ */
+
+ #if VM_OBJECT_DEBUG
++
+ #define vm_object_lock_init(object) \
+ MACRO_BEGIN \
+- simple_lock_init(&(object)->Lock); \
++ lock_init(&(object)->Lock, TRUE); \
+ (object)->LockHolder = 0; \
+ MACRO_END
+ #define vm_object_lock(object) \
+ MACRO_BEGIN \
+- simple_lock(&(object)->Lock); \
++ lock_write(&(object)->Lock); \
+ (object)->LockHolder = current_thread(); \
+ MACRO_END
+ #define vm_object_unlock(object) \
+@@ -351,10 +352,10 @@ MACRO_BEGIN \
+ if ((object)->LockHolder != current_thread()) \
+ panic("vm_object_unlock 0x%x", (object)); \
+ (object)->LockHolder = 0; \
+- simple_unlock(&(object)->Lock); \
++ lock_done(&(object)->Lock); \
+ MACRO_END
+ #define vm_object_lock_try(object) \
+- (simple_lock_try(&(object)->Lock) \
++ (lock_try_write(&(object)->Lock) \
+ ? ( ((object)->LockHolder = current_thread()) , TRUE) \
+ : FALSE)
+ #define vm_object_sleep(event, object, interruptible) \
+@@ -362,20 +363,20 @@ MACRO_BEGIN \
+ if ((object)->LockHolder != current_thread()) \
+ panic("vm_object_sleep %#x", (object)); \
+ (object)->LockHolder = 0; \
+- thread_sleep((event_t)(event), simple_lock_addr((object)->Lock), \
++ thread_sleep_lock((event_t)(event), &(object)->Lock, \
+ (interruptible)); \
+ MACRO_END
+ #define vm_object_lock_taken(object) \
+ ((object)->LockHolder == current_thread())
+ #else /* VM_OBJECT_DEBUG */
+-#define vm_object_lock_init(object) simple_lock_init(&(object)->Lock)
+-#define vm_object_lock(object) simple_lock(&(object)->Lock)
+-#define vm_object_unlock(object) simple_unlock(&(object)->Lock)
+-#define vm_object_lock_try(object) simple_lock_try(&(object)->Lock)
++#define vm_object_lock_init(object) lock_init(&(object)->Lock, TRUE)
++#define vm_object_lock(object) lock_write(&(object)->Lock)
++#define vm_object_unlock(object) lock_done(&(object)->Lock)
++#define vm_object_lock_try(object) lock_try_write(&(object)->Lock)
+ #define vm_object_sleep(event, object, interruptible) \
+- thread_sleep((event_t)(event), simple_lock_addr((object)->Lock), \
++ thread_sleep_lock((event_t)(event), &(object)->Lock, \
+ (interruptible))
+-#define vm_object_lock_taken(object) simple_lock_taken(&(object)->Lock)
++#define vm_object_lock_taken(object) lock_taken(&(object)->Lock)
+ #endif /* VM_OBJECT_DEBUG */
+
+ /*
+--
+2.1.4
+
diff --git a/debian/patches/upstreamme0010-kern-use-a-general-lock-for-the-IPC-structures.patch b/debian/patches/upstreamme0010-kern-use-a-general-lock-for-the-IPC-structures.patch
new file mode 100644
index 0000000..c0d213a
--- /dev/null
+++ b/debian/patches/upstreamme0010-kern-use-a-general-lock-for-the-IPC-structures.patch
@@ -0,0 +1,74 @@
+From 8b089caa29240ffce138bdcbdcbe6ccab3c4a3ab Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Sat, 25 Jul 2015 02:29:58 +0200
+Subject: [PATCH gnumach 10/10] kern: use a general lock for the IPC structures
+
+* ipc/ipc_thread.h (ith_{lock_init,lock,unlock}): Use a general lock.
+* kern/task.h (struct task): Use a general lock for `itk_lock_data'.
+(itk_{lock_init,lock,unlock}): Use a general lock.
+* kern/thread.h (struct thread): Use a general lock for `ith_lock_data'.
+---
+ ipc/ipc_thread.h | 6 +++---
+ kern/task.h | 8 ++++----
+ kern/thread.h | 2 +-
+ 3 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/ipc/ipc_thread.h b/ipc/ipc_thread.h
+index 008ab4a..9e2c079 100644
+--- a/ipc/ipc_thread.h
++++ b/ipc/ipc_thread.h
+@@ -42,9 +42,9 @@ typedef thread_t ipc_thread_t;
+
+ #define ITH_NULL THREAD_NULL
+
+-#define ith_lock_init(thread) simple_lock_init(&(thread)->ith_lock_data)
+-#define ith_lock(thread) simple_lock(&(thread)->ith_lock_data)
+-#define ith_unlock(thread) simple_unlock(&(thread)->ith_lock_data)
++#define ith_lock_init(thread) lock_init(&(thread)->ith_lock_data, FALSE)
++#define ith_lock(thread) lock_write(&(thread)->ith_lock_data)
++#define ith_unlock(thread) lock_write_done(&(thread)->ith_lock_data)
+
+ /*
+ * Note that this isn't a queue, but rather a stack. This causes
+diff --git a/kern/task.h b/kern/task.h
+index 2a4c28f..93087ff 100644
+--- a/kern/task.h
++++ b/kern/task.h
+@@ -89,7 +89,7 @@ struct task {
+ time_value_t creation_time; /* time stamp at creation */
+
+ /* IPC structures */
+- decl_simple_lock_data(, itk_lock_data)
++ struct lock itk_lock_data;
+ struct ipc_port *itk_self; /* not a right, doesn't hold ref */
+ struct ipc_port *itk_sself; /* a send right */
+ struct ipc_port *itk_exception; /* a send right */
+@@ -128,9 +128,9 @@ struct task {
+ #define task_lock(task) simple_lock(&(task)->lock)
+ #define task_unlock(task) simple_unlock(&(task)->lock)
+
+-#define itk_lock_init(task) simple_lock_init(&(task)->itk_lock_data)
+-#define itk_lock(task) simple_lock(&(task)->itk_lock_data)
+-#define itk_unlock(task) simple_unlock(&(task)->itk_lock_data)
++#define itk_lock_init(task) lock_init(&(task)->itk_lock_data, FALSE)
++#define itk_lock(task) lock_write(&(task)->itk_lock_data)
++#define itk_unlock(task) lock_write_done(&(task)->itk_lock_data)
+
+ /*
+ * Exported routines/macros
+diff --git a/kern/thread.h b/kern/thread.h
+index 0e85d8c..adf8b86 100644
+--- a/kern/thread.h
++++ b/kern/thread.h
+@@ -168,7 +168,7 @@ struct thread {
+ See ipc_kmsg_destroy() for more details. */
+ struct ipc_kmsg_queue ith_messages;
+
+- decl_simple_lock_data(, ith_lock_data)
++ struct lock ith_lock_data;
+ struct ipc_port *ith_self; /* not a right, doesn't hold ref */
+ struct ipc_port *ith_sself; /* a send right */
+ struct ipc_port *ith_exception; /* a send right */
+--
+2.1.4
+