]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix missing kevent_qos syscall (macOS 10.11). bz#383723
authorRhys Kidd <rhyskidd@gmail.com>
Sun, 3 Jun 2018 16:40:13 +0000 (12:40 -0400)
committerRhys Kidd <rhyskidd@gmail.com>
Sun, 3 Jun 2018 16:53:18 +0000 (12:53 -0400)
Based upon patch from Alexandru Croitor.

NEWS
coregrind/m_syswrap/priv_syswrap-darwin.h
coregrind/m_syswrap/syswrap-darwin.c
include/vki/vki-darwin.h
memcheck/tests/darwin/scalar.c
memcheck/tests/darwin/scalar.stderr.exp

diff --git a/NEWS b/NEWS
index 95d4d0d33abc557115d4174e528b42ad511316f8..eaa05d9bdb3b9f60e70d2633bdbd17d125e33268 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -77,6 +77,7 @@ where XXXXXX is the bug number as listed below.
 382563  MIPS MSA ASE support
 382998  xml-socket doesn't work
 383275  massif valgrind: m_xarray.c:162 (ensureSpaceXA): Assertion '!xa->arr' failed
+383723  Fix missing kevent_qos syscall (macOS 10.11)
 384096  Mention AddrCheck at Memcheck's command line option --undef-value-errors=no
 384230  vex x86->IR: unhandled instruction bytes: 0x67 0xE8 0xAB 0x68
 384526  reduce number of spill instructions generated by VEX register allocator v3
index d344f078221cf38f91057a5567dc6e23e9e4398e..bdb38cf043fe80875431817d2d29d8e913752a97 100644 (file)
@@ -470,7 +470,7 @@ DECL_TEMPLATE(darwin, __thread_selfid);         // 372
 #endif
 // 373
 #if DARWIN_VERS >= DARWIN_10_11
-// NYI kevent_qos                               // 374
+DECL_TEMPLATE(darwin, kevent_qos);              // 374
 #endif /* DARWIN_VERS >= DARWIN_10_11 */
 #if DARWIN_VERS >= DARWIN_10_13
 // NYI kevent_id                                // 375
index 9969afaf846081adf00388567de6a1e28c6471de..f5b5b61e2a24fb096084d2615c4c3e800654c73a 100644 (file)
@@ -9848,6 +9848,40 @@ PRE(guarded_writev_np)
 
 #if DARWIN_VERS >= DARWIN_10_11
 
+PRE(kevent_qos)
+{
+   PRINT("kevent_qos( %ld, %#lx, %ld, %#lx, %ld, %#lx, %ld, %ld )",
+         SARG1, ARG2, SARG3, ARG4, SARG5, ARG6, SARG7, ARG8);
+   PRE_REG_READ8(int,"kevent_qos",
+                 int,kq,
+                 const struct vki_kevent_qos_s *,changelist,
+                 int,nchanges,
+                 struct vki_kevent_qos_s *,eventlist,
+                 int,nevents,
+                 void*,data_out,
+                 size_t*,data_available,
+                 unsigned int,flags);
+
+   if (ARG3) PRE_MEM_READ ("kevent_qos(changelist)",
+                           ARG2, ARG3 * sizeof(struct vki_kevent_qos_s));
+   if (ARG5) PRE_MEM_WRITE("kevent_qos(eventlist)",
+                           ARG4, ARG5 * sizeof(struct vki_kevent_qos_s));
+   if (ARG7) PRE_MEM_WRITE("kevent_qos(data_out)",
+                           ARG6, ARG7 * sizeof(void*));
+
+   *flags |= SfMayBlock;
+}
+
+POST(kevent_qos)
+{
+   PRINT("kevent_qos ret %ld dst %#lx (%zu)", RES, ARG4, sizeof(struct vki_kevent_qos_s));
+   if (RES > 0) {
+      ML_(sync_mappings)("after", "kevent_qos", 0);
+      POST_MEM_WRITE(ARG4, RES * sizeof(struct vki_kevent_qos_s));
+   }
+}
+
+
 PRE(pselect)
 {
    *flags |= SfMayBlock;
@@ -10466,7 +10500,9 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(372)),   // ???
 #endif
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(373)),   // ???
+#if DARWIN_VERS < DARWIN_10_11
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(374)),   // ???
+#endif
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(375)),   // ???
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(376)),   // ???
    _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(377)),   // ???
@@ -10561,7 +10597,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
 #endif
 #if DARWIN_VERS >= DARWIN_10_11
 // _____(__NR_kdebug_trace_string),                     // 178
-// _____(__NR_kevent_qos),                              // 374
+   MACXY(__NR_kevent_qos, kevent_qos),                  // 374
    MACX_(__NR_pselect, pselect),                        // 394
 // _____(__NR_netagent_trigger),                        // 490
 // _____(__NR_stack_snapshot_with_config),              // 491
index 53d14f3227641b5ae02b3ef367443d5f5da40f6d..5bebbba72eea9acd38f26473a3f888920028206d 100644 (file)
@@ -807,6 +807,19 @@ typedef
 #define vki_kevent kevent
 #define vki_kevent64 kevent64_s
 
+// xnu_root/bsd/sys/event.h
+
+struct vki_kevent_qos_s {
+    uint64_t    ident;      /* identifier for this event */
+    int16_t     filter;     /* filter for event */
+    uint16_t    flags;      /* general flags */
+    int32_t     qos;        /* quality of service */
+    uint64_t    udata;      /* opaque user data identifier */
+    uint32_t    fflags;     /* filter-specific flags */
+    uint32_t    xflags;     /* extra filter-specific flags */
+    int64_t     data;       /* filter-specific data */
+    uint64_t    ext[4];     /* filter-specific extensions */
+};
 
 #include <sys/ev.h>
 
index 4aac07ae0ad9e851d5c933e32d8444186cedd903..225615523b50b294508911bf390a19725405868b 100644 (file)
@@ -660,7 +660,17 @@ int main(void)
    // __NR_workq_open 367
    // __NR_workq_ops 368
 
-   GO_UNIMP(369-379, "unused");
+   GO_UNIMP(369-373, "unused");
+
+#if DARWIN_VERS >= DARWIN_10_11
+   {
+      long args[8] = { x0+8, x0+0xffffffee, x0+1, x0+1, x0+1, x0+1, x0+1, x0+1 };
+      GO(__NR_kevent_qos, 374, "1s 8m");
+      SY(__NR_kevent_qos, args+x0); FAIL;
+   }
+#endif /* DARWIN_VERS >= DARWIN_10_11 */
+
+   GO_UNIMP(375-379, "unused");
 
    // __NR___mac_execve 380
    // __NR___mac_syscall 381
index aba39e86368e7375371c20145cc87d5142695b08..9212c8fcc837845d66ce80b771eb55808294065e 100644 (file)
@@ -1174,33 +1174,66 @@ Syscall param getfsstat64(buf) points to unaddressable byte(s)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 -----------------------------------------------------
-(369-379):       unused
+(369-373):       unused
+-----------------------------------------------------
+-----------------------------------------------------
+x2000176(374):     __NR_kevent_qos 1s 8m
+-----------------------------------------------------
+Syscall param kevent_qos(changelist) contains uninitialised byte(s)
+   ...
+   by 0x........: main (scalar.c:669)
+
+Syscall param kevent_qos(nchanges) contains uninitialised byte(s)
+   ...
+   by 0x........: main (scalar.c:669)
+
+Syscall param kevent_qos(data_available) contains uninitialised byte(s)
+   ...
+   by 0x........: main (scalar.c:669)
+
+Syscall param kevent_qos(flags) contains uninitialised byte(s)
+   ...
+   by 0x........: main (scalar.c:669)
+
+Syscall param kevent_qos(changelist) points to uninitialised byte(s)
+   ...
+   by 0x........: main (scalar.c:669)
+ Address 0x........ is on thread 1's stack
+ in frame #1, created by main (scalar.c:12)
+
+Syscall param kevent_qos(eventlist) points to unaddressable byte(s)
+   ...
+   by 0x........: main (scalar.c:669)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+-----------------------------------------------------
+(375-379):       unused
 -----------------------------------------------------
 -----------------------------------------------------
 x200018a(394):        __NR_pselect 1s 6m
 -----------------------------------------------------
 Syscall param pselect(readfds) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:684)
+   by 0x........: main (scalar.c:694)
 
 Syscall param pselect(writefds) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:684)
+   by 0x........: main (scalar.c:694)
 
 Syscall param pselect(readfds) points to uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:684)
+   by 0x........: main (scalar.c:694)
  Address 0x........ is on thread 1's stack
  in frame #1, created by main (scalar.c:12)
 
 Syscall param pselect(writefds) points to unaddressable byte(s)
    ...
-   by 0x........: main (scalar.c:684)
+   by 0x........: main (scalar.c:694)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 Syscall param pselect(exceptfds) points to unaddressable byte(s)
    ...
-   by 0x........: main (scalar.c:684)
+   by 0x........: main (scalar.c:694)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 -----------------------------------------------------