From: Rhys Kidd Date: Sun, 31 May 2015 01:58:57 +0000 (+0000) Subject: Fix OS X host_get_special_port: UNKNOWN host message [id 412, to mach_host_self(... X-Git-Tag: svn/VALGRIND_3_11_0~334 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c8440021c5d5e84d971fd33df1638ac1559ff88a;p=thirdparty%2Fvalgrind.git Fix OS X host_get_special_port: UNKNOWN host message [id 412, to mach_host_self(), reply 0x........] bz#343525 Before: == 591 tests, 220 stderr failures, 14 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures == After: == 591 tests, 220 stderr failures, 14 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures == git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15298 --- diff --git a/NEWS b/NEWS index bb903f5140..164e1d1e6a 100644 --- a/NEWS +++ b/NEWS @@ -165,6 +165,8 @@ where XXXXXX is the bug number as listed below. 343335 unhandled instruction 0x1E638400 (fccmp) aarch64 343523 OS X mach_ports_register: UNKNOWN task message [id 3403, to mach_task_self(), reply 0x30f] +343525 OS X host_get_special_port: UNKNOWN host message [id 412, to + mach_host_self(), reply 0x........] 343597 ppc64le: incorrect use of offseof macro 343732 Unhandled syscall 144 (setgid) on aarch64 343733 Unhandled syscall 187 (msgctl and related) on aarch64 diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index b68af4208e..1145ec7f29 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -573,6 +573,7 @@ DECL_TEMPLATE(darwin, host_page_size); DECL_TEMPLATE(darwin, host_get_io_master); DECL_TEMPLATE(darwin, host_get_clock_service); DECL_TEMPLATE(darwin, host_request_notification); +DECL_TEMPLATE(darwin, host_get_special_port); DECL_TEMPLATE(darwin, mach_port_type); DECL_TEMPLATE(darwin, mach_port_extract_member); DECL_TEMPLATE(darwin, mach_port_allocate); diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 9c5efab9d0..cca98dcd89 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -4963,6 +4963,115 @@ PRE(host_request_notification) } +PRE(host_get_special_port) +{ +#pragma pack(4) + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int node; + int which; + } Request; +#pragma pack() + + Request *req = (Request *)ARG1; + + PRINT("host_get_special_port(node %d)", req->node); + + switch (req->which) { + case HOST_PORT: + PRINT("host_get_special_port(%s, HOST_PORT)", + name_for_port(MACH_REMOTE)); + break; + case HOST_PRIV_PORT: + PRINT("host_get_special_port(%s, HOST_PRIV_PORT)", + name_for_port(MACH_REMOTE)); + break; + case HOST_IO_MASTER_PORT: + PRINT("host_get_special_port(%s, HOST_IO_MASTER_PORT)", + name_for_port(MACH_REMOTE)); + break; + // Not provided by kernel + case HOST_DYNAMIC_PAGER_PORT: + PRINT("host_get_special_port(%s, HOST_DYNAMIC_PAGER_PORT)", + name_for_port(MACH_REMOTE)); + break; + case HOST_AUDIT_CONTROL_PORT: + PRINT("host_get_special_port(%s, HOST_AUDIT_CONTROL_PORT)", + name_for_port(MACH_REMOTE)); + break; + case HOST_USER_NOTIFICATION_PORT: + PRINT("host_get_special_port(%s, HOST_USER_NOTIFICATION_PORT)", + name_for_port(MACH_REMOTE)); + break; + // ... + + default: + PRINT("host_get_special_port(%s, %d)", + name_for_port(MACH_REMOTE), req->which); + break; + } + + MACH_ARG(host_get_special_port.which) = req->which; + + AFTER = POST_FN(host_get_special_port); +} + + +POST(host_get_special_port) +{ +#pragma pack(4) + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t port; + /* end of the kernel processed data */ + } Reply; +#pragma pack() + + Reply *reply = (Reply *)ARG1; + + PRINT("got port %#x ", reply->port.name); + + /* The required entry in the allocated_ports list (mapping) might + not exist, due perhaps to broken syscall wrappers (mach__N etc). + Create a minimal entry so that assign_port_name below doesn't + cause an assertion. */ + if (!port_exists(reply->port.name)) { + port_create_vanilla(reply->port.name); + } + + switch (MACH_ARG(host_get_special_port.which)) { + case HOST_PORT: + assign_port_name(reply->port.name, "port-%p"); + break; + case HOST_PRIV_PORT: + assign_port_name(reply->port.name, "priv-%p"); + break; + case HOST_IO_MASTER_PORT: + assign_port_name(reply->port.name, "io-master-%p"); + break; + // Not provided by kernel + case HOST_DYNAMIC_PAGER_PORT: + assign_port_name(reply->port.name, "dynamic-pager-%p"); + break; + case HOST_AUDIT_CONTROL_PORT: + assign_port_name(reply->port.name, "audit-control-%p"); + break; + case HOST_USER_NOTIFICATION_PORT: + assign_port_name(reply->port.name, "user-notification-%p"); + break; + // ... + + default: + assign_port_name(reply->port.name, "special-%p"); + break; + } + + PRINT("%s", name_for_port(reply->port.name)); +} + /* --------------------------------------------------------------------- mach_msg: messages to a task ------------------------------------------------------------------ */ @@ -7739,6 +7848,10 @@ PRE(mach_msg_host) case 217: CALL_PRE(host_request_notification); return; + + case 412: + CALL_PRE(host_get_special_port); + return; default: // unknown message to host self diff --git a/coregrind/pub_core_threadstate.h b/coregrind/pub_core_threadstate.h index 230c41d6d5..28d8cb84a3 100644 --- a/coregrind/pub_core_threadstate.h +++ b/coregrind/pub_core_threadstate.h @@ -250,6 +250,9 @@ typedef struct { int which_port; } task_get_special_port; + struct { + int which; + } host_get_special_port; struct { char *service_name; } bootstrap_look_up;