From: Rhys Kidd Date: Sun, 3 Jun 2018 16:40:13 +0000 (-0400) Subject: Fix missing kevent_qos syscall (macOS 10.11). bz#383723 X-Git-Tag: VALGRIND_3_14_0~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92d6a538862a784156ee5fff297eb7daba733127;p=thirdparty%2Fvalgrind.git Fix missing kevent_qos syscall (macOS 10.11). bz#383723 Based upon patch from Alexandru Croitor. --- diff --git a/NEWS b/NEWS index 95d4d0d33a..eaa05d9bdb 100644 --- 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 diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index d344f07822..bdb38cf043 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -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 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 9969afaf84..f5b5b61e2a 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -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 diff --git a/include/vki/vki-darwin.h b/include/vki/vki-darwin.h index 53d14f3227..5bebbba72e 100644 --- a/include/vki/vki-darwin.h +++ b/include/vki/vki-darwin.h @@ -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 diff --git a/memcheck/tests/darwin/scalar.c b/memcheck/tests/darwin/scalar.c index 4aac07ae0a..225615523b 100644 --- a/memcheck/tests/darwin/scalar.c +++ b/memcheck/tests/darwin/scalar.c @@ -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 diff --git a/memcheck/tests/darwin/scalar.stderr.exp b/memcheck/tests/darwin/scalar.stderr.exp index aba39e8636..9212c8fcc8 100644 --- a/memcheck/tests/darwin/scalar.stderr.exp +++ b/memcheck/tests/darwin/scalar.stderr.exp @@ -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 -----------------------------------------------------