]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix OS X host_get_special_port: UNKNOWN host message [id 412, to mach_host_self(...
authorRhys Kidd <rhyskidd@gmail.com>
Sun, 31 May 2015 01:58:57 +0000 (01:58 +0000)
committerRhys Kidd <rhyskidd@gmail.com>
Sun, 31 May 2015 01:58:57 +0000 (01:58 +0000)
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

NEWS
coregrind/m_syswrap/priv_syswrap-darwin.h
coregrind/m_syswrap/syswrap-darwin.c
coregrind/pub_core_threadstate.h

diff --git a/NEWS b/NEWS
index bb903f51401bfe02f525bdc866657d89d9dfbae4..164e1d1e6a73c733fb67d6db1431eff65d9866ed 100644 (file)
--- 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
index b68af4208e68044267d502b7ca9d25d7c3897842..1145ec7f2989f1c802af841793e18cefa61e10f7 100644 (file)
@@ -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);
index 9c5efab9d0617f2e7f53848c800a57c9d6af71ec..cca98dcd89ef3d836da6dc31e8304da2bd921107 100644 (file)
@@ -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
index 230c41d6d51d4eb6972603f938ccbf082808c587..28d8cb84a3fcd987a4dc27fcbdc21b01a63b8e79 100644 (file)
@@ -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;