diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-11-13 16:16:07 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-11-13 16:16:07 +0100 |
commit | 2dc04aaecba268b79f79fdfa2484c15bb4a71970 (patch) | |
tree | 8029790c2a5bcd6cec710bf96e99e85bc1c61a62 /debian | |
parent | dd88ee3755c39d17e11319267cf7bb46a83a7d84 (diff) |
add patch series
Diffstat (limited to 'debian')
15 files changed, 1141 insertions, 0 deletions
diff --git a/debian/patches/0001-Makeconf-handle-the-gnumach-protocol.patch b/debian/patches/0001-Makeconf-handle-the-gnumach-protocol.patch new file mode 100644 index 00000000..1602299a --- /dev/null +++ b/debian/patches/0001-Makeconf-handle-the-gnumach-protocol.patch @@ -0,0 +1,28 @@ +From 3c7bce4ae45aa108e3ca4037392755ca8282a928 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 7 Nov 2014 11:44:22 +0100 +Subject: [PATCH hurd 01/14] Makeconf: handle the gnumach protocol + +* Makeconf (mach_defs_names): Add `gnumach'. +--- + Makeconf | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Makeconf b/Makeconf +index 32eec13..f0d3fe3 100644 +--- a/Makeconf ++++ b/Makeconf +@@ -575,7 +575,9 @@ vpath %.defs $(top_srcdir)/hurd + # These we want to find in the libc include directory... + mach_defs_names = bootstrap exc mach mach4 \ + mach_host mach_port mach_timer_reply memory_object \ +- memory_object_default notify ++ memory_object_default notify \ ++ gnumach \ ++ + mach_debug_defs_names = mach_debug + device_defs_names = dev_forward device device_reply device_request + +-- +2.1.1 + diff --git a/debian/patches/0002-proc-gracefully-handle-failure-to-increase-priority.patch b/debian/patches/0002-proc-gracefully-handle-failure-to-increase-priority.patch new file mode 100644 index 00000000..8ecb8f6a --- /dev/null +++ b/debian/patches/0002-proc-gracefully-handle-failure-to-increase-priority.patch @@ -0,0 +1,83 @@ +From 1047bdb3bbb7c63a10bfe00470466f92f77b1d22 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 7 Nov 2014 14:57:43 +0100 +Subject: [PATCH hurd 02/14] proc: gracefully handle failure to increase + priority + +* proc/main.c (increase_priority): New function. +(main): Move code increasing the proc servers priority to a new +function and handle errors gracefully. +--- + proc/main.c | 44 ++++++++++++++++++++++++++++++++------------ + 1 file changed, 32 insertions(+), 12 deletions(-) + +diff --git a/proc/main.c b/proc/main.c +index f1f4e1b..3419d44 100644 +--- a/proc/main.c ++++ b/proc/main.c +@@ -60,12 +60,40 @@ message_demuxer (mach_msg_header_t *inp, + + pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; + ++error_t ++increase_priority (void) ++{ ++ mach_port_t pset = MACH_PORT_NULL, psetcntl = MACH_PORT_NULL; ++ error_t err; ++ ++ err = thread_get_assignment (mach_thread_self (), &pset); ++ if (err) ++ goto out; ++ ++ err = host_processor_set_priv (_hurd_host_priv, pset, &psetcntl); ++ if (err) ++ goto out; ++ ++ err = thread_max_priority (mach_thread_self (), psetcntl, 0); ++ if (err) ++ goto out; ++ ++ err = task_priority (mach_task_self (), 2, 1); ++ ++ out: ++ if (MACH_PORT_VALID (pset)) ++ mach_port_deallocate (mach_task_self (), pset); ++ if (MACH_PORT_VALID (psetcntl)) ++ mach_port_deallocate (mach_task_self (), psetcntl); ++ ++ return err; ++} ++ + int + main (int argc, char **argv, char **envp) + { + mach_port_t boot; + error_t err; +- mach_port_t pset, psetcntl; + void *genport; + process_t startup_port; + struct argp argp = { 0, 0, 0, "Hurd process server" }; +@@ -120,17 +148,9 @@ main (int argc, char **argv, char **envp) + + /* Give ourselves good scheduling performance, because we are so + important. */ +- err = thread_get_assignment (mach_thread_self (), &pset); +- assert_perror (err); +- err = host_processor_set_priv (_hurd_host_priv, pset, &psetcntl); +- assert_perror (err); +- thread_max_priority (mach_thread_self (), psetcntl, 0); +- assert_perror (err); +- err = task_priority (mach_task_self (), 2, 1); +- assert_perror (err); +- +- mach_port_deallocate (mach_task_self (), pset); +- mach_port_deallocate (mach_task_self (), psetcntl); ++ err = increase_priority (); ++ if (err) ++ error (0, err, "Increasing priority failed"); + + { + /* Get our stderr set up to print on the console, in case we have +-- +2.1.1 + diff --git a/debian/patches/0003-startup-also-open-console-for-reading.patch b/debian/patches/0003-startup-also-open-console-for-reading.patch new file mode 100644 index 00000000..6fbd7c97 --- /dev/null +++ b/debian/patches/0003-startup-also-open-console-for-reading.patch @@ -0,0 +1,26 @@ +From fe60aba84594f4f367b8edc86cd044c26c2f224e Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 7 Nov 2014 16:15:17 +0100 +Subject: [PATCH hurd 03/14] startup: also open `console' for reading + +* startup/startup.c (main): Also open `console' for reading. +--- + startup/startup.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/startup/startup.c b/startup/startup.c +index ff58270..e177075 100644 +--- a/startup/startup.c ++++ b/startup/startup.c +@@ -557,7 +557,7 @@ main (int argc, char **argv, char **envp) + master device ports, and the console. */ + if (task_get_bootstrap_port (mach_task_self (), &bootport) + || fsys_getpriv (bootport, &host_priv, &device_master, &fstask) +- || device_open (device_master, D_WRITE, "console", &consdev)) ++ || device_open (device_master, D_READ|D_WRITE, "console", &consdev)) + crash_mach (); + + wire_task_self (); +-- +2.1.1 + diff --git a/debian/patches/0004-boot-drop-bootstrap-compat-code.patch b/debian/patches/0004-boot-drop-bootstrap-compat-code.patch new file mode 100644 index 00000000..a13255ab --- /dev/null +++ b/debian/patches/0004-boot-drop-bootstrap-compat-code.patch @@ -0,0 +1,121 @@ +From 139a6178d536b4aa960ec0e937033b5b100e46ad Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Thu, 6 Nov 2014 13:27:43 +0100 +Subject: [PATCH hurd 04/14] boot: drop bootstrap compat code + +GNU Mach never sent old-style bootstrap messages. Drop the unused +compatibility code. + +* boot/boot.c (request_server): Drop unused code. +(bootstrap_compat): Drop unused function. +--- + boot/boot.c | 78 ------------------------------------------------------------- + 1 file changed, 78 deletions(-) + +diff --git a/boot/boot.c b/boot/boot.c +index 03617f5..d5b8096 100644 +--- a/boot/boot.c ++++ b/boot/boot.c +@@ -179,21 +179,7 @@ request_server (mach_msg_header_t *inp, + extern int term_server (mach_msg_header_t *, mach_msg_header_t *); + /* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ + extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); +- extern void bootstrap_compat (); + +-#if 0 +- if (inp->msgh_local_port == bootport && boot_like_cmudef) +- { +- if (inp->msgh_id == 999999) +- { +- bootstrap_compat (inp, outp); +- return 1; +- } +- else +- return bootstrap_server (inp, outp); +- } +- else +-#endif + return (io_server (inp, outp) + || device_server (inp, outp) + || notify_server (inp, outp) +@@ -914,8 +900,6 @@ unlock_readlock () + /* + * Handle bootstrap requests. + */ +-/* These two functions from .../mk/bootstrap/default_pager.c. */ +- + kern_return_t + do_bootstrap_privileged_ports(bootstrap, hostp, devicep) + mach_port_t bootstrap; +@@ -925,68 +909,6 @@ do_bootstrap_privileged_ports(bootstrap, hostp, devicep) + *devicep = pseudo_master_device_port; + return KERN_SUCCESS; + } +- +-void +-bootstrap_compat(in, out) +- mach_msg_header_t *in, *out; +-{ +- mig_reply_header_t *reply = (mig_reply_header_t *) out; +- mach_msg_return_t mr; +- +- struct imsg { +- mach_msg_header_t hdr; +- mach_msg_type_t port_desc_1; +- mach_port_t port_1; +- mach_msg_type_t port_desc_2; +- mach_port_t port_2; +- } imsg; +- +- /* +- * Send back the host and device ports. +- */ +- +- imsg.hdr.msgh_bits = MACH_MSGH_BITS_COMPLEX | +- MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(in->msgh_bits), 0); +- /* msgh_size doesn't need to be initialized */ +- imsg.hdr.msgh_remote_port = in->msgh_remote_port; +- imsg.hdr.msgh_local_port = MACH_PORT_NULL; +- /* msgh_seqno doesn't need to be initialized */ +- imsg.hdr.msgh_id = in->msgh_id + 100; /* this is a reply msg */ +- +- imsg.port_desc_1.msgt_name = MACH_MSG_TYPE_COPY_SEND; +- imsg.port_desc_1.msgt_size = (sizeof(mach_port_t) * 8); +- imsg.port_desc_1.msgt_number = 1; +- imsg.port_desc_1.msgt_inline = TRUE; +- imsg.port_desc_1.msgt_longform = FALSE; +- imsg.port_desc_1.msgt_deallocate = FALSE; +- imsg.port_desc_1.msgt_unused = 0; +- +- imsg.port_1 = privileged_host_port; +- +- imsg.port_desc_2 = imsg.port_desc_1; +- +- imsg.port_desc_2.msgt_name = MACH_MSG_TYPE_MAKE_SEND; +- imsg.port_2 = pseudo_master_device_port; +- +- /* +- * Send the reply message. +- * (mach_msg_server can not do this, because the reply +- * is not in standard format.) +- */ +- +- mr = mach_msg(&imsg.hdr, MACH_SEND_MSG, +- sizeof imsg, 0, MACH_PORT_NULL, +- MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +- if (mr != MACH_MSG_SUCCESS) +- (void) mach_port_deallocate(mach_task_self (), +- imsg.hdr.msgh_remote_port); +- +- /* +- * Tell mach_msg_server to do nothing. +- */ +- +- reply->RetCode = MIG_NO_REPLY; +-} + + /* Implementation of device interface */ + +-- +2.1.1 + diff --git a/debian/patches/0005-boot-remove-unused-function-boot_script_read_file.patch b/debian/patches/0005-boot-remove-unused-function-boot_script_read_file.patch new file mode 100644 index 00000000..279b3ad8 --- /dev/null +++ b/debian/patches/0005-boot-remove-unused-function-boot_script_read_file.patch @@ -0,0 +1,107 @@ +From cd2673431ca4d96696cb7ec89a9b56de03f0038a Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Thu, 6 Nov 2014 13:59:59 +0100 +Subject: [PATCH hurd 05/14] boot: remove unused function + `boot_script_read_file' + +The unused function `boot_script_read_file' requires access to the +default pager, which is privileged. + +* boot/boot.c (defpager): Remove now unused variable. +(boot_script_read_file): Remove unused function. +(main): Do not acquire port to the default pager. +* boot/boot_script.h (boot_script_read_file): Remove declaration. +--- + boot/boot.c | 46 +--------------------------------------------- + boot/boot_script.h | 4 ---- + 2 files changed, 1 insertion(+), 49 deletions(-) + +diff --git a/boot/boot.c b/boot/boot.c +index d5b8096..250018e 100644 +--- a/boot/boot.c ++++ b/boot/boot.c +@@ -109,7 +109,7 @@ typedef struct stat host_stat_t; + + #endif /* UX */ + +-mach_port_t privileged_host_port, master_device_port, defpager; ++mach_port_t privileged_host_port, master_device_port; + mach_port_t pseudo_master_device_port; + mach_port_t receive_set; + mach_port_t pseudo_console, pseudo_root; +@@ -281,47 +281,6 @@ void read_reply (); + void * msg_thread (void *); + + /* Callbacks for boot_script.c; see boot_script.h. */ +- +-mach_port_t +-boot_script_read_file (const char *filename) +-{ +- static const char msg[] = ": cannot open\n"; +- int fd = useropen (filename, O_RDONLY, 0); +- host_stat_t st; +- error_t err; +- mach_port_t memobj; +- vm_address_t region; +- +- write (2, filename, strlen (filename)); +- if (fd < 0) +- { +- write (2, msg, sizeof msg - 1); +- host_exit (1); +- } +- else +- write (2, msg + sizeof msg - 2, 1); +- +- host_fstat (fd, &st); +- +- err = default_pager_object_create (defpager, &memobj, +- round_page (st.st_size)); +- if (err) +- { +- static const char msg[] = "cannot create default-pager object\n"; +- write (2, msg, sizeof msg - 1); +- host_exit (1); +- } +- +- region = 0; +- vm_map (mach_task_self (), ®ion, round_page (st.st_size), +- 0, 1, memobj, 0, 0, VM_PROT_ALL, VM_PROT_ALL, VM_INHERIT_NONE); +- read (fd, (char *) region, st.st_size); +- munmap ((caddr_t) region, round_page (st.st_size)); +- +- close (fd); +- return memobj; +-} +- + int + boot_script_exec_cmd (void *hook, + mach_port_t task, char *path, int argc, +@@ -532,9 +491,6 @@ main (int argc, char **argv, char **envp) + + get_privileged_ports (&privileged_host_port, &master_device_port); + +- defpager = MACH_PORT_NULL; +- vm_set_default_memory_manager (privileged_host_port, &defpager); +- + strcat (bootstrap_args, "f"); + + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_PORT_SET, +diff --git a/boot/boot_script.h b/boot/boot_script.h +index 6245869..da52e6f 100644 +--- a/boot/boot_script.h ++++ b/boot/boot_script.h +@@ -69,10 +69,6 @@ int boot_script_exec_cmd (void *hook, + task_t task, char *path, int argc, + char **argv, char *strings, int stringlen); + +-/* The user must define this function. Load the contents of FILE +- into a fresh anonymous memory object and return the memory object port. */ +-mach_port_t boot_script_read_file (const char *file); +- + /* The user must define this functions to perform the corresponding + Mach task manipulations. */ + int boot_script_task_create (struct cmd *); /* task_create + task_suspend */ +-- +2.1.1 + diff --git a/debian/patches/0006-boot-drop-obsolete-device-procedures.patch b/debian/patches/0006-boot-drop-obsolete-device-procedures.patch new file mode 100644 index 00000000..9cb65ad6 --- /dev/null +++ b/debian/patches/0006-boot-drop-obsolete-device-procedures.patch @@ -0,0 +1,60 @@ +From 49a4a6102da2217aae1599788f879642d0337424 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Thu, 6 Nov 2014 18:49:06 +0100 +Subject: [PATCH hurd 06/14] boot: drop obsolete device procedures + +* boot/boot.c (ds_xxx_device_set_status): Remove function. +(ds_xxx_device_get_status): Likewise. +(ds_xxx_device_set_filter): Likewise. +--- + boot/boot.c | 34 ---------------------------------- + 1 file changed, 34 deletions(-) + +diff --git a/boot/boot.c b/boot/boot.c +index 250018e..a655107 100644 +--- a/boot/boot.c ++++ b/boot/boot.c +@@ -1118,40 +1118,6 @@ ds_device_read_inband (device_t device, + } + + kern_return_t +-ds_xxx_device_set_status (device_t device, +- dev_flavor_t flavor, +- dev_status_t status, +- size_t statu_cnt) +-{ +- if (device != pseudo_console) +- return D_NO_SUCH_DEVICE; +- return D_INVALID_OPERATION; +-} +- +-kern_return_t +-ds_xxx_device_get_status (device_t device, +- dev_flavor_t flavor, +- dev_status_t status, +- size_t *statuscnt) +-{ +- if (device != pseudo_console && device != pseudo_root) +- return D_NO_SUCH_DEVICE; +- return D_INVALID_OPERATION; +-} +- +-kern_return_t +-ds_xxx_device_set_filter (device_t device, +- mach_port_t rec, +- int pri, +- filter_array_t filt, +- size_t len) +-{ +- if (device != pseudo_console && device != pseudo_root) +- return D_NO_SUCH_DEVICE; +- return D_INVALID_OPERATION; +-} +- +-kern_return_t + ds_device_map (device_t device, + vm_prot_t prot, + vm_offset_t offset, +-- +2.1.1 + diff --git a/debian/patches/0007-boot-support-ds_device_get_status-with-flavor-DEV_GE.patch b/debian/patches/0007-boot-support-ds_device_get_status-with-flavor-DEV_GE.patch new file mode 100644 index 00000000..9046e352 --- /dev/null +++ b/debian/patches/0007-boot-support-ds_device_get_status-with-flavor-DEV_GE.patch @@ -0,0 +1,58 @@ +From 3c27bb214cc345e0320a4bcd03f8ecb23c9661e9 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 7 Nov 2014 09:56:29 +0100 +Subject: [PATCH hurd 07/14] boot: support ds_device_get_status with flavor + DEV_GET_RECORDS + +* boot/boot.c (ds_device_get_status): Support flavor DEV_GET_RECORDS. +--- + boot/boot.c | 33 +++++++++++++++++++++------------ + 1 file changed, 21 insertions(+), 12 deletions(-) + +diff --git a/boot/boot.c b/boot/boot.c +index a655107..d35ce50 100644 +--- a/boot/boot.c ++++ b/boot/boot.c +@@ -1150,18 +1150,27 @@ ds_device_get_status (device_t device, + if (device == pseudo_console) + return D_INVALID_OPERATION; + else if (device == pseudo_root) +- if (flavor == DEV_GET_SIZE) +- if (*statuslen < DEV_GET_SIZE_COUNT) +- return D_INVALID_SIZE; +- else +- { +- status[DEV_GET_SIZE_DEVICE_SIZE] = root_store->size; +- status[DEV_GET_SIZE_RECORD_SIZE] = root_store->block_size; +- *statuslen = DEV_GET_SIZE_COUNT; +- return D_SUCCESS; +- } +- else +- return D_INVALID_OPERATION; ++ switch (flavor) ++ { ++ case DEV_GET_SIZE: ++ if (*statuslen < DEV_GET_SIZE_COUNT) ++ return D_INVALID_SIZE; ++ status[DEV_GET_SIZE_DEVICE_SIZE] = root_store->size; ++ status[DEV_GET_SIZE_RECORD_SIZE] = root_store->block_size; ++ *statuslen = DEV_GET_SIZE_COUNT; ++ return D_SUCCESS; ++ ++ case DEV_GET_RECORDS: ++ if (*statuslen < DEV_GET_RECORDS_COUNT) ++ return D_INVALID_SIZE; ++ status[DEV_GET_RECORDS_DEVICE_RECORDS] = root_store->blocks; ++ status[DEV_GET_RECORDS_RECORD_SIZE] = root_store->block_size; ++ *statuslen = DEV_GET_RECORDS_COUNT; ++ return D_SUCCESS; ++ ++ default: ++ return D_INVALID_OPERATION; ++ } + else + return D_NO_SUCH_DEVICE; + } +-- +2.1.1 + diff --git a/debian/patches/0008-boot-implement-pseudo-time-device.patch b/debian/patches/0008-boot-implement-pseudo-time-device.patch new file mode 100644 index 00000000..c690b674 --- /dev/null +++ b/debian/patches/0008-boot-implement-pseudo-time-device.patch @@ -0,0 +1,87 @@ +From 15e19afadfc8103f82682265bbbcae00c42b3674 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 7 Nov 2014 00:27:03 +0100 +Subject: [PATCH hurd 08/14] boot: implement pseudo-time device + +* boot/boot.c (pseudo_time): New variable. +(main): Allocate port `pseudo_time'. +(ds_device_open): Give out `pseudo_time'. +(ds_device_map): Emulate Mach-style `Mapped Time'. +--- + boot/boot.c | 38 +++++++++++++++++++++++++++++++++++--- + 1 file changed, 35 insertions(+), 3 deletions(-) + +diff --git a/boot/boot.c b/boot/boot.c +index d35ce50..747ab73 100644 +--- a/boot/boot.c ++++ b/boot/boot.c +@@ -112,7 +112,7 @@ typedef struct stat host_stat_t; + mach_port_t privileged_host_port, master_device_port; + mach_port_t pseudo_master_device_port; + mach_port_t receive_set; +-mach_port_t pseudo_console, pseudo_root; ++mach_port_t pseudo_console, pseudo_root, pseudo_time; + auth_t authserver; + + struct store *root_store; +@@ -534,6 +534,15 @@ main (int argc, char **argv, char **envp) + if (foo != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), foo); + ++ mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, ++ &pseudo_time); ++ mach_port_move_member (mach_task_self (), pseudo_time, receive_set); ++ mach_port_request_notification (mach_task_self (), pseudo_time, ++ MACH_NOTIFY_NO_SENDERS, 1, pseudo_time, ++ MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); ++ if (foo != MACH_PORT_NULL) ++ mach_port_deallocate (mach_task_self (), foo); ++ + if (kernel_command_line == 0) + asprintf (&kernel_command_line, "%s %s root=%s", + argv[0], bootstrap_args, bootdevice); +@@ -894,6 +903,12 @@ ds_device_open (mach_port_t master_port, + *devicetype = MACH_MSG_TYPE_MAKE_SEND; + return 0; + } ++ else if (!strcmp (name, "time")) ++ { ++ *device = pseudo_time; ++ *devicetype = MACH_MSG_TYPE_MAKE_SEND; ++ return 0; ++ } + else if (strcmp (name, "pseudo-root") == 0) + /* Magic root device. */ + { +@@ -1125,9 +1140,26 @@ ds_device_map (device_t device, + memory_object_t *pager, + int unmap) + { +- if (device != pseudo_console && device != pseudo_root) ++ if (device == pseudo_console || device == pseudo_root) ++ return D_INVALID_OPERATION; ++ else if (device == pseudo_time) ++ { ++ error_t err; ++ mach_port_t wr_memobj; ++ file_t node = file_name_lookup ("/dev/time", O_RDONLY, 0); ++ ++ if (node == MACH_PORT_NULL) ++ return D_IO_ERROR; ++ ++ err = io_map (node, pager, &wr_memobj); ++ if (!err && MACH_PORT_VALID (wr_memobj)) ++ mach_port_deallocate (mach_task_self (), wr_memobj); ++ ++ mach_port_deallocate (mach_task_self (), node); ++ return D_SUCCESS; ++ } ++ else + return D_NO_SUCH_DEVICE; +- return D_INVALID_OPERATION; + } + + kern_return_t +-- +2.1.1 + diff --git a/debian/patches/0009-boot-improve-the-demuxer.patch b/debian/patches/0009-boot-improve-the-demuxer.patch new file mode 100644 index 00000000..c5757264 --- /dev/null +++ b/debian/patches/0009-boot-improve-the-demuxer.patch @@ -0,0 +1,111 @@ +From 7d2b4a67e17e2ace8fcbbe6b975be5aa18d9a176 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 7 Nov 2014 10:43:47 +0100 +Subject: [PATCH hurd 09/14] boot: improve the demuxer + +Handle multiple request types as recommended by the Mach Server +Writer's Guide section 4, subsection "Handling Multiple Request +Types". This avoids initializing the reply message in every X_server +function. + +* boot/boot.c (mig_reply_setup): Provide local version. +(request_server): Rename to `boot_demuxer', and improve the dispatch. +--- + boot/boot.c | 67 ++++++++++++++++++++++++++++++++++++++++++++----------------- + 1 file changed, 49 insertions(+), 18 deletions(-) + +diff --git a/boot/boot.c b/boot/boot.c +index 747ab73..e2cb907 100644 +--- a/boot/boot.c ++++ b/boot/boot.c +@@ -169,22 +169,55 @@ useropen (const char *name, int flags, int mode) + return open (name, flags, mode); + } + +-int +-request_server (mach_msg_header_t *inp, +- mach_msg_header_t *outp) +-{ +- extern int io_server (mach_msg_header_t *, mach_msg_header_t *); +- extern int device_server (mach_msg_header_t *, mach_msg_header_t *); +- extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); +- extern int term_server (mach_msg_header_t *, mach_msg_header_t *); +-/* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ +- extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); ++/* XXX: glibc should provide mig_reply_setup but does not. */ ++/* Fill in default response. */ ++void ++mig_reply_setup ( ++ const mach_msg_header_t *in, ++ mach_msg_header_t *out) ++{ ++ static const mach_msg_type_t RetCodeType = { ++ /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, ++ /* msgt_size = */ 32, ++ /* msgt_number = */ 1, ++ /* msgt_inline = */ TRUE, ++ /* msgt_longform = */ FALSE, ++ /* msgt_deallocate = */ FALSE, ++ /* msgt_unused = */ 0 ++ }; ++ ++#define InP (in) ++#define OutP ((mig_reply_header_t *) out) ++ OutP->Head.msgh_bits = ++ MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(InP->msgh_bits), 0); ++ OutP->Head.msgh_size = sizeof *OutP; ++ OutP->Head.msgh_remote_port = InP->msgh_remote_port; ++ OutP->Head.msgh_local_port = MACH_PORT_NULL; ++ OutP->Head.msgh_seqno = 0; ++ OutP->Head.msgh_id = InP->msgh_id + 100; ++ OutP->RetCodeType = RetCodeType; ++ OutP->RetCode = MIG_BAD_ID; ++#undef InP ++#undef OutP ++} + +- return (io_server (inp, outp) +- || device_server (inp, outp) +- || notify_server (inp, outp) +- || term_server (inp, outp) +- /* || tioctl_server (inp, outp) */); ++int ++boot_demuxer (mach_msg_header_t *inp, ++ mach_msg_header_t *outp) ++{ ++ mig_routine_t routine; ++ mig_reply_setup (inp, outp); ++ if ((routine = io_server_routine (inp)) || ++ (routine = device_server_routine (inp)) || ++ (routine = notify_server_routine (inp)) || ++ (routine = term_server_routine (inp)) ++ /* (routine = tioctl_server_routine (inp)) */) ++ { ++ (*routine) (inp, outp); ++ return TRUE; ++ } ++ else ++ return FALSE; + } + + vm_address_t +@@ -710,15 +743,13 @@ main (int argc, char **argv, char **envp) + else /* We hosed */ + error (5, errno, "select"); + } +- +-/* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */ + } + + void * + msg_thread (void *arg) + { + while (1) +- mach_msg_server (request_server, 0, receive_set); ++ mach_msg_server (boot_demuxer, 0, receive_set); + } + + +-- +2.1.1 + diff --git a/debian/patches/0010-Makeconf-handle-the-task_notify-protocol.patch b/debian/patches/0010-Makeconf-handle-the-task_notify-protocol.patch new file mode 100644 index 00000000..62020efb --- /dev/null +++ b/debian/patches/0010-Makeconf-handle-the-task_notify-protocol.patch @@ -0,0 +1,25 @@ +From 3e0e1944d92c220ac5485604cccd175f4d3885c1 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 7 Nov 2014 11:47:09 +0100 +Subject: [PATCH hurd 10/14] Makeconf: handle the task_notify protocol + +* Makeconf (mach_defs_names): Add `task_notify'. +--- + Makeconf | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Makeconf b/Makeconf +index f0d3fe3..5439913 100644 +--- a/Makeconf ++++ b/Makeconf +@@ -577,6 +577,7 @@ mach_defs_names = bootstrap exc mach mach4 \ + mach_host mach_port mach_timer_reply memory_object \ + memory_object_default notify \ + gnumach \ ++ task_notify \ + + mach_debug_defs_names = mach_debug + device_defs_names = dev_forward device device_reply device_request +-- +2.1.1 + diff --git a/debian/patches/0011-proc-register-for-new-task-notifications.patch b/debian/patches/0011-proc-register-for-new-task-notifications.patch new file mode 100644 index 00000000..02a7371c --- /dev/null +++ b/debian/patches/0011-proc-register-for-new-task-notifications.patch @@ -0,0 +1,126 @@ +From 672950d7b5402ed7d2a35a458b83598a60c7f73a Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Mon, 16 Sep 2013 16:09:05 +0200 +Subject: [PATCH hurd 11/14] proc: register for new task notifications + +* proc/Makefile (MIGSTUBS): Add `gnumachServer.o'. +* proc/main.c (message_demuxer): Handle the `task_notify' protocol. +(main): Register for new task notificatinos. +* proc/mgt.c (S_mach_notify_new_task): Add server function. +--- + proc/Makefile | 4 +++- + proc/main.c | 11 ++++++++++- + proc/mgt.c | 35 ++++++++++++++++++++++++++++++++++- + 3 files changed, 47 insertions(+), 3 deletions(-) + +diff --git a/proc/Makefile b/proc/Makefile +index aa31ffb..2275a66 100644 +--- a/proc/Makefile ++++ b/proc/Makefile +@@ -27,9 +27,11 @@ SRCS = wait.c hash.c host.c info.c main.c mgt.c notify.c pgrp.c msg.c \ + MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h + + MIGSTUBS = processServer.o notifyServer.o \ +- ourmsgUser.o proc_excUser.o proc_excServer.o ++ ourmsgUser.o proc_excUser.o proc_excServer.o \ ++ task_notifyServer.o + OBJS = $(SRCS:.c=.o) $(MIGSTUBS) + HURDLIBS = ihash ports shouldbeinlibc ++ + OTHERLIBS = -lpthread + + include ../Makeconf +diff --git a/proc/main.c b/proc/main.c +index 3419d44..b4288fb 100644 +--- a/proc/main.c ++++ b/proc/main.c +@@ -31,6 +31,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + #include <pids.h> + + #include "proc.h" ++#include "gnumach_U.h" + + const char *argp_program_version = STANDARD_HURD_VERSION (proc); + +@@ -38,6 +39,7 @@ const char *argp_program_version = STANDARD_HURD_VERSION (proc); + #include "notify_S.h" + #include "../libports/interrupt_S.h" + #include "proc_exc_S.h" ++#include "task_notify_S.h" + + int + message_demuxer (mach_msg_header_t *inp, +@@ -47,7 +49,8 @@ message_demuxer (mach_msg_header_t *inp, + if ((routine = process_server_routine (inp)) || + (routine = notify_server_routine (inp)) || + (routine = ports_interrupt_server_routine (inp)) || +- (routine = proc_exc_server_routine (inp))) ++ (routine = proc_exc_server_routine (inp)) || ++ (routine = task_notify_server_routine (inp))) + { + pthread_mutex_lock (&global_lock); + (*routine) (inp, outp); +@@ -152,6 +155,12 @@ main (int argc, char **argv, char **envp) + if (err) + error (0, err, "Increasing priority failed"); + ++ err = register_new_task_notification (_hurd_host_priv, ++ generic_port, ++ MACH_MSG_TYPE_MAKE_SEND); ++ if (err) ++ error (0, err, "Registering task notifications failed"); ++ + { + /* Get our stderr set up to print on the console, in case we have + to panic or something. */ +diff --git a/proc/mgt.c b/proc/mgt.c +index 02d69db..32408ae 100644 +--- a/proc/mgt.c ++++ b/proc/mgt.c +@@ -1,5 +1,5 @@ + /* Process management +- Copyright (C) 1992,93,94,95,96,99,2000,01,02,13 ++ Copyright (C) 1992,93,94,95,96,99,2000,01,02,13,14 + Free Software Foundation, Inc. + + This file is part of the GNU Hurd. +@@ -981,3 +981,36 @@ S_proc_get_code (struct proc *callerp, + + return 0; + } ++ ++/* Handle new task notifications from the kernel. */ ++error_t ++S_mach_notify_new_task (mach_port_t notify, ++ mach_port_t task, ++ mach_port_t parent) ++{ ++ struct proc *parentp, *childp; ++ ++ if (notify != generic_port) ++ return EOPNOTSUPP; ++ ++ parentp = task_find_nocreate (parent); ++ if (! parentp) ++ { ++ mach_port_deallocate (mach_task_self (), task); ++ mach_port_deallocate (mach_task_self (), parent); ++ return ESRCH; ++ } ++ ++ childp = task_find_nocreate (task); ++ if (! childp) ++ { ++ mach_port_mod_refs (mach_task_self (), task, MACH_PORT_RIGHT_SEND, +1); ++ childp = new_proc (task); ++ } ++ ++ /* XXX do something interesting */ ++ ++ mach_port_deallocate (mach_task_self (), task); ++ mach_port_deallocate (mach_task_self (), parent); ++ return 0; ++} +-- +2.1.1 + diff --git a/debian/patches/0012-proc-implement-proc_make_task_namespace.patch b/debian/patches/0012-proc-implement-proc_make_task_namespace.patch new file mode 100644 index 00000000..a7bd19b2 --- /dev/null +++ b/debian/patches/0012-proc-implement-proc_make_task_namespace.patch @@ -0,0 +1,224 @@ +From 5aef28222f05dec56cd1212e70766d8bf779df11 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Tue, 11 Nov 2014 21:23:42 +0100 +Subject: [PATCH hurd 12/14] proc: implement `proc_make_task_namespace' + +* proc/proc.h (struct proc): Add field `p_task_namespace'. +* proc/mgt.c (S_proc_child): Propagate `p_task_namespace' to child. +(allocate_proc): Initialize `p_task_namespace'. +(namespace_terminate): New function. +(process_has_exited): Reparent children of dead tasks in the namespace +to the root process. Terminate all tasks if the root process dies. +Reap dead tasks. +(S_mach_notify_new_task): For newly created tasks thats parent is in a +namespace, call S_proc_child and forward the `mach_notify_new_task' +message. +(S_proc_make_task_namespace): New function. +--- + proc/mgt.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- + proc/proc.h | 4 +++ + 2 files changed, 107 insertions(+), 9 deletions(-) + +diff --git a/proc/mgt.c b/proc/mgt.c +index 32408ae..bf400ba 100644 +--- a/proc/mgt.c ++++ b/proc/mgt.c +@@ -220,6 +220,13 @@ S_proc_child (struct proc *parentp, + childp->end_code = parentp->end_code; + } + ++ if (MACH_PORT_VALID (parentp->p_task_namespace)) ++ { ++ mach_port_mod_refs (mach_task_self (), parentp->p_task_namespace, ++ MACH_PORT_RIGHT_SEND, +1); ++ childp->p_task_namespace = parentp->p_task_namespace; ++ } ++ + return 0; + } + +@@ -577,6 +584,7 @@ allocate_proc (task_t task) + + memset (&p->p_pi + 1, 0, sizeof *p - sizeof p->p_pi); + p->p_task = task; ++ p->p_task_namespace = MACH_PORT_NULL; + p->p_msgport = MACH_PORT_NULL; + + pthread_cond_init (&p->p_wakeup, NULL); +@@ -721,6 +729,16 @@ new_proc (task_t task) + return p; + } + ++/* Used with prociterate to terminate all tasks in a task ++ namespace. */ ++static void ++namespace_terminate (struct proc *p, void *cookie) ++{ ++ mach_port_t *namespacep = cookie; ++ if (p->p_task_namespace == *namespacep) ++ task_terminate (p->p_task); ++} ++ + /* The task associated with process P has died. Drop most state, + and then record us as dead. Our parent will eventually complete the + deallocation. */ +@@ -751,13 +769,39 @@ process_has_exited (struct proc *p) + + ids_rele (p->p_id); + +- /* Reparent our children to init by attaching the head and tail +- of our list onto init's. */ ++ /* Reparent our children to init by attaching the head and tail of ++ our list onto init's. If the process is part of a task ++ namespace, reparent to the process that created the namespace ++ instead. */ + if (p->p_ochild) + { ++ struct proc *reparent_to = init_proc; + struct proc *tp; /* will point to the last one. */ + int isdead = 0; + ++ if (MACH_PORT_VALID (p->p_task_namespace)) ++ { ++ for (tp = p; ++ MACH_PORT_VALID (tp->p_parent->p_task_namespace); ++ tp = tp->p_parent) ++ { ++ /* Walk up the process hierarchy until we find the ++ creator of the task namespace. */ ++ } ++ ++ if (p == tp) ++ { ++ /* The creator of the task namespace died. Terminate ++ all tasks. */ ++ prociterate (namespace_terminate, &p->p_task_namespace); ++ ++ mach_port_deallocate (mach_task_self (), p->p_task_namespace); ++ p->p_task_namespace = MACH_PORT_NULL; ++ } ++ else ++ reparent_to = tp; ++ } ++ + /* first tell them their parent is changing */ + for (tp = p->p_ochild; tp->p_sib; tp = tp->p_sib) + { +@@ -765,7 +809,7 @@ process_has_exited (struct proc *p) + nowait_msg_proc_newids (tp->p_msgport, tp->p_task, + 1, tp->p_pgrp->pg_pgid, + !tp->p_pgrp->pg_orphcnt); +- tp->p_parent = init_proc; ++ tp->p_parent = reparent_to; + if (tp->p_dead) + isdead = 1; + } +@@ -773,17 +817,17 @@ process_has_exited (struct proc *p) + nowait_msg_proc_newids (tp->p_msgport, tp->p_task, + 1, tp->p_pgrp->pg_pgid, + !tp->p_pgrp->pg_orphcnt); +- tp->p_parent = init_proc; ++ tp->p_parent = reparent_to; + + /* And now append the lists. */ +- tp->p_sib = init_proc->p_ochild; ++ tp->p_sib = reparent_to->p_ochild; + if (tp->p_sib) + tp->p_sib->p_prevsib = &tp->p_sib; +- init_proc->p_ochild = p->p_ochild; +- p->p_ochild->p_prevsib = &init_proc->p_ochild; ++ reparent_to->p_ochild = p->p_ochild; ++ p->p_ochild->p_prevsib = &reparent_to->p_ochild; + + if (isdead) +- alert_parent (init_proc); ++ alert_parent (reparent_to); + } + + /* If an operation is in progress for this process, cause it +@@ -795,6 +839,23 @@ process_has_exited (struct proc *p) + + /* Cancel any outstanding RPCs done on behalf of the dying process. */ + ports_interrupt_rpcs (p); ++ ++ /* No one is going to wait for processes in a task namespace. */ ++ if (MACH_PORT_VALID (p->p_task_namespace)) ++ { ++ mach_port_t task; ++ mach_port_deallocate (mach_task_self (), p->p_task_namespace); ++ p->p_waited = 1; ++ ++ /* XXX: `complete_exit' will destroy p->p_task if it is valid. ++ Prevent this so that `do_mach_notify_dead_name' can ++ deallocate the right. The proper fix is not to use ++ mach_port_destroy in the first place. */ ++ task = p->p_task; ++ p->p_task = MACH_PORT_NULL; ++ complete_exit (p); ++ mach_port_deallocate (mach_task_self (), task); ++ } + } + + void +@@ -1008,9 +1069,42 @@ S_mach_notify_new_task (mach_port_t notify, + childp = new_proc (task); + } + +- /* XXX do something interesting */ ++ if (MACH_PORT_VALID (parentp->p_task_namespace)) ++ { ++ error_t err; ++ /* Tasks in a task namespace are not expected to call ++ proc_child, so we do it on their behalf. */ ++ mach_port_mod_refs (mach_task_self (), task, MACH_PORT_RIGHT_SEND, +1); ++ err = S_proc_child (parentp, task); ++ if (! err) ++ /* Relay the notification. This consumes TASK and PARENT. */ ++ return mach_notify_new_task (childp->p_task_namespace, task, parent); ++ } + + mach_port_deallocate (mach_task_self (), task); + mach_port_deallocate (mach_task_self (), parent); + return 0; + } ++ ++/* Implement proc_make_task_namespace as described in ++ <hurd/process.defs>. */ ++error_t ++S_proc_make_task_namespace (struct proc *callerp, ++ mach_port_t notify) ++{ ++ if (! callerp) ++ return EOPNOTSUPP; ++ ++ if (! MACH_PORT_VALID (notify)) ++ return EINVAL; ++ ++ if (MACH_PORT_VALID (callerp->p_task_namespace)) ++ { ++ mach_port_deallocate (mach_task_self (), notify); ++ return EBUSY; ++ } ++ ++ callerp->p_task_namespace = notify; ++ ++ return 0; ++} +diff --git a/proc/proc.h b/proc/proc.h +index 6196697..a056d18 100644 +--- a/proc/proc.h ++++ b/proc/proc.h +@@ -58,6 +58,10 @@ struct proc + /* Process group structure */ + struct pgrp *p_pgrp; + ++ /* Processes may live in a task namespace identified by the ++ notification port registered by proc_make_task_namespace. */ ++ mach_port_t p_task_namespace; /* send right */ ++ + /* Communication */ + mach_port_t p_msgport; /* send right */ + +-- +2.1.1 + diff --git a/debian/patches/0013-hurd-add-proc_make_task_namespace.patch b/debian/patches/0013-hurd-add-proc_make_task_namespace.patch new file mode 100644 index 00000000..d6a52cbd --- /dev/null +++ b/debian/patches/0013-hurd-add-proc_make_task_namespace.patch @@ -0,0 +1,45 @@ +From 7ce85c915882053171ba9a551f241f6e0a3cb7d4 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Wed, 12 Nov 2014 15:30:18 +0100 +Subject: [PATCH hurd 13/14] hurd: add `proc_make_task_namespace' + +Add a new RPC to the process protocol to create task namespaces. +These can be used by an unprivileged process to claims the +responsibility to manage all tasks in this namespace. Any task +created in this namespace will automatically be declared a child of +the root process, and a `mach_notify_new_task' message is sent to a +given port. If the root process dies, the proc server will terminate +all tasks in the namespace. + +* hurd/process.defs (proc_make_task_namespace): New RPC. +--- + hurd/process.defs | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/hurd/process.defs b/hurd/process.defs +index 498faba..4ceb69e 100644 +--- a/hurd/process.defs ++++ b/hurd/process.defs +@@ -1,5 +1,5 @@ + /* Definitions for process server interface +- Copyright (C) 1992,93,94,95,96,97,2001,2013 Free Software Foundation ++ Copyright (C) 1992,93,94,95,96,97,2001,13,14 Free Software Foundation + + This file is part of the GNU Hurd. + +@@ -404,3 +404,12 @@ routine proc_get_code ( + process: process_t; + out start_code: vm_address_t; + out end_code: vm_address_t); ++ ++/* Create a new task namespace. PROCESS claims the responsibility to ++ manage all tasks in this namespace. Any task created in this ++ namespace will automatically be declared a child of PROCESS, and a ++ `mach_notify_new_task' message is sent to NOTIFY. If PROCESS dies, ++ the proc server will terminate all tasks in the namespace. */ ++routine proc_make_task_namespace ( ++ process: process_t; ++ notify: mach_port_send_t); +-- +2.1.1 + diff --git a/debian/patches/0014-proc-fix-build.patch b/debian/patches/0014-proc-fix-build.patch new file mode 100644 index 00000000..da7df7dc --- /dev/null +++ b/debian/patches/0014-proc-fix-build.patch @@ -0,0 +1,26 @@ +From e829c09cc222097e88ec87fb3ee5ee8df917e600 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Thu, 13 Nov 2014 05:27:57 +0100 +Subject: [PATCH hurd 14/14] proc: fix build + +--- + proc/Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/proc/Makefile b/proc/Makefile +index 2275a66..7cc4af5 100644 +--- a/proc/Makefile ++++ b/proc/Makefile +@@ -32,6 +32,9 @@ MIGSTUBS = processServer.o notifyServer.o \ + OBJS = $(SRCS:.c=.o) $(MIGSTUBS) + HURDLIBS = ihash ports shouldbeinlibc + ++# XXX: fix build ++MIGSTUBS += gnumachUser.o task_notifyUser.o ++ + OTHERLIBS = -lpthread + + include ../Makeconf +-- +2.1.1 + diff --git a/debian/patches/series b/debian/patches/series index cfa5c51f..68d7fb27 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -58,3 +58,17 @@ startup-avoid-broken-puts.patch mach-defpager-fix-build.patch +0001-Makeconf-handle-the-gnumach-protocol.patch +0002-proc-gracefully-handle-failure-to-increase-priority.patch +0003-startup-also-open-console-for-reading.patch +0004-boot-drop-bootstrap-compat-code.patch +0005-boot-remove-unused-function-boot_script_read_file.patch +0006-boot-drop-obsolete-device-procedures.patch +0007-boot-support-ds_device_get_status-with-flavor-DEV_GE.patch +0008-boot-implement-pseudo-time-device.patch +0009-boot-improve-the-demuxer.patch +0010-Makeconf-handle-the-task_notify-protocol.patch +0011-proc-register-for-new-task-notifications.patch +0012-proc-implement-proc_make_task_namespace.patch +0013-hurd-add-proc_make_task_namespace.patch +0014-proc-fix-build.patch |