macos: Fix missing syscall ulock_wait (OS X 10.12). bz#379754

Based upon patch available at:
https://bugs.kde.org/attachment.cgi?id=105482
This commit is contained in:
Rhys Kidd 2018-02-11 20:42:17 -05:00
parent f61cd55a9e
commit 2b0aa0a5b8
5 changed files with 48 additions and 4 deletions

1
NEWS
View File

@ -69,6 +69,7 @@ where XXXXXX is the bug number as listed below.
379373 Fix syscall param msg->desc.port.name points to uninitialised byte(s)
on macOS 10.12
379748 Fix missing pselect syscall (OS X 10.11)
379754 Fix missing syscall ulock_wait (OS X 10.12)
380397 s390x: __GI_strcspn() replacemenet needed
381162 possible array overrun in VEX register allocator
381272 ppc64 doesn't compile test_isa_2_06_partx.c without VSX support

View File

@ -630,7 +630,7 @@ DECL_TEMPLATE(darwin, getentropy); // 500
// 512
// 513
// 514
// NYI ulock_wait // 515
DECL_TEMPLATE(darwin, ulock_wait); // 515
DECL_TEMPLATE(darwin, ulock_wake); // 516
// NYI fclonefileat // 517
// NYI fs_snapshot // 518

View File

@ -9922,6 +9922,15 @@ PRE(getentropy)
void*, buffer, size_t, size);
}
static const HChar *ulop_name(int op)
{
switch (op) {
case VKI_UL_UNFAIR_LOCK: return "UL_UNFAIR_LOCK";
case VKI_UL_COMPARE_AND_WAIT: return "UL_COMPARE_AND_WAIT";
default: return "??";
}
}
PRE(ulock_wake)
{
PRINT("ulock_wake(operation:%ld, addr:%#lx, wake_value:%ld) FIXME",
@ -9930,6 +9939,30 @@ PRE(ulock_wake)
uint32_t, operation, void*, addr, uint64_t, wake_value);
}
PRE(ulock_wait)
{
uint ul_opcode = ARG1 & VKI_UL_OPCODE_MASK;
uint ul_flags = ARG1 & VKI_UL_FLAGS_MASK;
switch (ul_opcode) {
case VKI_UL_UNFAIR_LOCK:
case VKI_UL_COMPARE_AND_WAIT: {
const char* name = ulop_name(ul_opcode);
PRINT("ulock_wait(operation:%s (flags: %#x), addr:%#lx, value:%ld, timeout:%ld)",
name, ul_flags, ARG2, ARG3, ARG4);
PRE_REG_READ4(int, "ulock_wait",
uint32_t, operation, void*, addr, uint64_t, value, uint32_t, timeout);
PRE_MEM_READ("ulock_wait(addr)", ARG2, 4 );
break;
}
default:
PRINT("ulock_wait(operation:%ld (opcode: %u [??], flags: %#x), addr:%#lx, value:%ld, timeout:%ld)", ARG1, ul_opcode, ul_flags, ARG2, ARG3, ARG4);
log_decaying("UNKNOWN ulock_wait %ld (opcode: %u [??], flags: %#x)!", ARG1, ul_opcode, ul_flags);
break;
}
}
PRE(host_create_mach_voucher_trap)
{
// munge_wwww -- no need to call helper
@ -10629,7 +10662,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
_____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(512)), // ???
_____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(513)), // ???
_____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(514)), // ???
// _____(__NR_ulock_wait), // 515
MACX_(__NR_ulock_wait, ulock_wait), // 515
MACX_(__NR_ulock_wake, ulock_wake), // 516
// _____(__NR_fclonefileat), // 517
// _____(__NR_fs_snapshot), // 518

View File

@ -229,8 +229,6 @@ Should possibly take
379373 Syscall param msg->desc.port.name points to uninitialised byte(s)
on macOS 10.12
379754 Missing syscall ulock_wait (OS X 10.12)
379893 valgrind segfault os x 10.12.4
380269 No multithreading in macOS Sierra (10.12)

View File

@ -1128,5 +1128,17 @@ struct vki_necp_aggregate_result {
};
#endif /* DARWIN_VERS == DARWIN_10_10 */
#if DARWIN_VERS >= DARWIN_10_12
// ulock_wake & ulock_wait operations
#define VKI_UL_OPCODE_MASK 0x000000FF
#define VKI_UL_FLAGS_MASK 0xFFFFFF00
#define VKI_UL_COMPARE_AND_WAIT 1
#define VKI_UL_UNFAIR_LOCK 2
// ulock_wake & ulock_wait flags
#define ULF_NO_ERRNO 0x01000000
// ulock_wait flags
#define WKI_ULF_WAIT_WORKQ_DATA_CONTENTION 0x00010000
#endif /* DARWIN_VERS >= DARWIN_10_12 */
#endif