From: Paul Floyd Date: Wed, 17 Nov 2021 22:15:23 +0000 (+0100) Subject: Bug 445607 Unhandled amd64-freebsd syscall: 247 X-Git-Tag: VALGRIND_3_19_0~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f13667b1eff8d3d06590683b9981ced611bd3c69;p=thirdparty%2Fvalgrind.git Bug 445607 Unhandled amd64-freebsd syscall: 247 I can't find much in the way of documentation for this. Added to scalar, but no specific tests. --- diff --git a/coregrind/m_syswrap/priv_syswrap-freebsd.h b/coregrind/m_syswrap/priv_syswrap-freebsd.h index 348a7fcdbd..0b60467df1 100644 --- a/coregrind/m_syswrap/priv_syswrap-freebsd.h +++ b/coregrind/m_syswrap/priv_syswrap-freebsd.h @@ -227,7 +227,7 @@ DECL_TEMPLATE(freebsd, sys_timer_getoverrun) // 239 // unimpl ffclock_setestimate 242 // unimpl ffclock_getestimate 243 DECL_TEMPLATE(freebsd, sys_clock_nanosleep) // 244 -// unimpl clock_getcpuclockid2 247 +DECL_TEMPLATE(freebsd, sys_clock_getcpuclockid2) // 247 // unimpl ntp_gettime 248 DECL_TEMPLATE(freebsd, sys_minherit) // 250 DECL_TEMPLATE(freebsd, sys_rfork) // 251 diff --git a/coregrind/m_syswrap/syswrap-amd64-freebsd.c b/coregrind/m_syswrap/syswrap-amd64-freebsd.c index 24226fa17c..076f5b4c4d 100644 --- a/coregrind/m_syswrap/syswrap-amd64-freebsd.c +++ b/coregrind/m_syswrap/syswrap-amd64-freebsd.c @@ -290,6 +290,18 @@ PRE(sys_freebsd6_ftruncate) } #endif +// SYS_clock_getcpuclockid2 247 +// no manpage for this, from syscalls.master +// int clock_getcpuclockid2(id_t id, int which, _Out_ clockid_t *clock_id); +PRE(sys_clock_getcpuclockid2) +{ + PRINT("sys_clock_getcpuclockid2( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", + SARG1,SARG2,ARG3); + PRE_REG_READ3(int, "clock_getcpuclockid2", + id_t, id, int, len, clockid_t *, clock_id); + PRE_MEM_WRITE("clock_getcpuclockid2(clock_id)", ARG3, sizeof(vki_clockid_t)); +} + // SYS_rfork 251 // pid_t rfork(int flags); PRE(sys_rfork) diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index 6dbf48d557..07f00b497d 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -2438,12 +2438,17 @@ PRE(sys_clock_nanosleep) POST(sys_clock_nanosleep) { if (ARG2 != 0) - PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG2, sizeof(struct vki_timespec) ); + POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) ); } // SYS_clock_getcpuclockid2 247 -// no manpage for this -// @todo +// x86/amd64 + +POST(sys_clock_getcpuclockid2) +{ + POST_MEM_WRITE(ARG3, sizeof(vki_clockid_t)); +} + // SYS_ntp_gettime 248 // int ntp_gettime(struct ntptimeval *); @@ -6519,7 +6524,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { // unimpl SYS_ffclock_getestimate 243 BSDXY(__NR_clock_nanosleep, sys_clock_nanosleep), // 244 - // unimpl SYS_clock_getcpuclockid2 247 + BSDXY(__NR_clock_getcpuclockid2, sys_clock_getcpuclockid2), // 247 // unimpl SYS_ntp_gettime 248 BSDXY(__NR_minherit, sys_minherit), // 250 diff --git a/coregrind/m_syswrap/syswrap-x86-freebsd.c b/coregrind/m_syswrap/syswrap-x86-freebsd.c index d65d0100c4..0c8da316f9 100644 --- a/coregrind/m_syswrap/syswrap-x86-freebsd.c +++ b/coregrind/m_syswrap/syswrap-x86-freebsd.c @@ -1,6 +1,6 @@ /*--------------------------------------------------------------------*/ -/*--- Platform-specific syscalls stuff. syswrap-x86-freebsd.c ---*/ +/*--- Platform-specific syscalls stuff. syswrap-x86-freebsd.c ---*/ /*--------------------------------------------------------------------*/ /* @@ -662,6 +662,20 @@ PRE(sys_freebsd6_ftruncate) } #endif +// SYS_clock_getcpuclockid2 247 +// no manpage for this, from syscalls.master +// int clock_getcpuclockid2(id_t id, int which, _Out_ clockid_t *clock_id); +PRE(sys_clock_getcpuclockid2) +{ + PRINT("sys_clock_getcpuclockid2( %lld, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", + MERGE64(ARG1,ARG2),SARG3,ARG4); + PRE_REG_READ4(int, "clock_getcpuclockid2", + vki_uint32_t, MERGE64_FIRST(offset), + vki_uint32_t, MERGE64_SECOND(offset), + int, len, clockid_t *, clock_id); + PRE_MEM_WRITE("clock_getcpuclockid2(clock_id)", ARG3, sizeof(vki_clockid_t)); +} + // SYS_rfork 251 // pid_t rfork(int flags); PRE(sys_rfork) diff --git a/memcheck/tests/freebsd/scalar.c b/memcheck/tests/freebsd/scalar.c index ce604df352..3364625c72 100644 --- a/memcheck/tests/freebsd/scalar.c +++ b/memcheck/tests/freebsd/scalar.c @@ -889,7 +889,9 @@ int main(void) SY(SYS_clock_nanosleep, x0+5000, x0+3000, x0, x0+1); SUCC; #endif - // unimpl SYS_clock_getcpuclockid2 247 + // SYS_clock_getcpuclockid2 247 + GO(SYS_clock_getcpuclockid2, "3s 1m"); + SY(SYS_clock_getcpuclockid2, x0+1, x0+1, x0+1); FAIL; // BSDXY(__NR_ntp_gettime, sys_ntp_gettime), // 248 diff --git a/memcheck/tests/freebsd/scalar.stderr.exp-freebsd130 b/memcheck/tests/freebsd/scalar.stderr.exp-freebsd130 index 3a74760bd5..309749f072 100644 --- a/memcheck/tests/freebsd/scalar.stderr.exp-freebsd130 +++ b/memcheck/tests/freebsd/scalar.stderr.exp-freebsd130 @@ -1890,6 +1890,22 @@ Syscall param clock_nanosleep(rmtp) points to unaddressable byte(s) ... Address 0x........ is not stack'd, malloc'd or (recently) free'd +--------------------------------------------------------- +247:SYS_clock_getcpuclockid2 3s 1m +--------------------------------------------------------- +Syscall param clock_getcpuclockid2(id) contains uninitialised byte(s) + ... + +Syscall param clock_getcpuclockid2(len) contains uninitialised byte(s) + ... + +Syscall param clock_getcpuclockid2(clock_id) contains uninitialised byte(s) + ... + +Syscall param clock_getcpuclockid2(clock_id) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + --------------------------------------------------------- 250: SYS_minherit @todo --------------------------------------------------------- diff --git a/memcheck/tests/freebsd/scalar.stderr.exp-freebsd130-x86 b/memcheck/tests/freebsd/scalar.stderr.exp-freebsd130-x86 index 8d587d4537..62ed782c5f 100644 --- a/memcheck/tests/freebsd/scalar.stderr.exp-freebsd130-x86 +++ b/memcheck/tests/freebsd/scalar.stderr.exp-freebsd130-x86 @@ -1890,6 +1890,22 @@ Syscall param clock_nanosleep(rmtp) points to unaddressable byte(s) ... Address 0x........ is not stack'd, malloc'd or (recently) free'd +--------------------------------------------------------- +247:SYS_clock_getcpuclockid2 3s 1m +--------------------------------------------------------- +Syscall param clock_getcpuclockid2(offset_low) contains uninitialised byte(s) + ... + +Syscall param clock_getcpuclockid2(offset_high) contains uninitialised byte(s) + ... + +Syscall param clock_getcpuclockid2(len) contains uninitialised byte(s) + ... + +Syscall param clock_getcpuclockid2(clock_id) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + --------------------------------------------------------- 250: SYS_minherit @todo ---------------------------------------------------------