From: Paul Floyd Date: Wed, 13 Apr 2022 21:00:44 +0000 (+0200) Subject: Updates to FreeBSD syscalls for FreeBSD 14 X-Git-Tag: VALGRIND_3_20_0~105 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=cdd98111c798a7ff2b24bc76aef3eb5e98d85ee1;p=valgrind.git Updates to FreeBSD syscalls for FreeBSD 14 3 new syscalls, and swapoff has a COMPAT13 version. --- diff --git a/coregrind/m_syswrap/priv_syswrap-freebsd.h b/coregrind/m_syswrap/priv_syswrap-freebsd.h index db0b647f53..6297033e14 100644 --- a/coregrind/m_syswrap/priv_syswrap-freebsd.h +++ b/coregrind/m_syswrap/priv_syswrap-freebsd.h @@ -371,7 +371,13 @@ DECL_TEMPLATE(freebsd, sys_sigreturn) // 417 DECL_TEMPLATE(freebsd, sys_getcontext) // 421 DECL_TEMPLATE(freebsd, sys_setcontext) // 422 DECL_TEMPLATE(freebsd, sys_swapcontext) // 423 + +#if (FREEBSD_VERS >= FREEBSD_14) +DECL_TEMPLATE(freebsd, sys_freebsd13_swapoff) // 424 +#else DECL_TEMPLATE(freebsd, sys_swapoff) // 424 +#endif + DECL_TEMPLATE(freebsd, sys___acl_get_link) // 425 DECL_TEMPLATE(freebsd, sys___acl_set_link) // 426 DECL_TEMPLATE(freebsd, sys___acl_delete_link) // 427 @@ -546,6 +552,13 @@ DECL_TEMPLATE(freebsd, sys___specialfd) // 577 #endif +#if (FREEBSD_VERS >= FREEBSD_14) + +// unimpl __NR_fspacectl 580 +// unimpl __NR_sched_getcpu 581 +DECL_TEMPLATE(freebsd, __NR_swapoff) // 582 +#endif + DECL_TEMPLATE(freebsd, sys_fake_sigreturn) #endif // PRIV_SYSWRAP_FREEBSD_H diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index fcbd11fbbb..64260f8a9a 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -3856,7 +3856,16 @@ POST(sys_swapcontext) POST_MEM_WRITE( ARG1, sizeof(struct vki_ucontext) ); } -// @todo PJF In FreeBSD 14 and onwards this is SYS_freebsd13_swapoff +#if (FREEBSD_VERS >= FREEBSD_14) +// SYS_freebsd13_swapoff 424 +// int swapoff(const char *special); +PRE(sys_freebsd13_swapoff) +{ + PRINT("sys_freebsd13_swapoff ( %#" FMT_REGWORD "x(%s) )", ARG1,(char *)ARG1); + PRE_REG_READ1(int, "swapoff", const char *, special); + PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 ); +} +#else // SYS_swapoff 424 // int swapoff(const char *special); PRE(sys_swapoff) @@ -3865,6 +3874,7 @@ PRE(sys_swapoff) PRE_REG_READ1(int, "swapoff", const char *, special); PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 ); } +#endif // SYS___acl_get_link 425 // int __acl_get_link(const char *path, acl_type_t type, struct acl *aclp); @@ -6248,6 +6258,19 @@ PRE(sys___specialfd) #endif // (FREEBSD_VERS >= FREEBSD_13_0) +#if (FREEBSD_VERS >= FREEBSD_14) + +// SYS_swapoff 582 +// int swapoff(const char *special, u_int flags); +PRE(sys_swapoff) +{ + PRINT("sys_swapoff ( %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u )", ARG1,(char *)ARG1, ARG2); + PRE_REG_READ2(int, "swapoff", const char *, special, u_int, flags); + PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 ); +} + +#endif + #undef PRE #undef POST @@ -6752,7 +6775,11 @@ const SyscallTableEntry ML_(syscall_table)[] = { BSDX_(__NR_setcontext, sys_setcontext), // 422 BSDXY(__NR_swapcontext, sys_swapcontext), // 423 +#if (FREEBSD_VERS >= FREEBSD_14) + BSDX_(__NR_freebsd13_swapoff, sys_freebsd13_swapoff), // 424 +#else BSDX_(__NR_swapoff, sys_swapoff), // 424 +#endif BSDXY(__NR___acl_get_link, sys___acl_get_link), // 425 BSDX_(__NR___acl_set_link, sys___acl_set_link), // 426 BSDX_(__NR___acl_delete_link, sys___acl_delete_link), // 427 @@ -6960,7 +6987,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { #if (FREEBSD_VERS >= FREEBSD_14) // unimpl __NR_fspacectl 580 // unimpl __NR_sched_getcpu 581 - // unimpl __NR_swapoff 582 + BSDX_(__NR_swapoff, sys_swapoff), // 582 #endif BSDX_(__NR_fake_sigreturn, sys_fake_sigreturn), // 1000, fake sigreturn diff --git a/include/vki/vki-scnums-freebsd.h b/include/vki/vki-scnums-freebsd.h index 2bce8b523d..cd806dcb94 100644 --- a/include/vki/vki-scnums-freebsd.h +++ b/include/vki/vki-scnums-freebsd.h @@ -458,7 +458,11 @@ #define __NR_getcontext 421 #define __NR_setcontext 422 #define __NR_swapcontext 423 +#if (FREEBSD_VERS >= FREEBSD_14) +#define __NR_freebsd14_swapoff 424 +#else #define __NR_swapoff 424 +#endif #define __NR___acl_get_link 425 #define __NR___acl_set_link 426 #define __NR___acl_delete_link 427 diff --git a/memcheck/tests/freebsd/filter_scalar b/memcheck/tests/freebsd/filter_scalar index 2be15ade9b..52b7c456ee 100755 --- a/memcheck/tests/freebsd/filter_scalar +++ b/memcheck/tests/freebsd/filter_scalar @@ -13,4 +13,5 @@ sed '/at 0x........: syscall (in \/...libc...)/d' | # filter differences between FreeBSD 12 and 13/14 -sed 's/SYS_freebsd12/ SYS/' +sed 's/SYS_freebsd12/ SYS/' | +sed 's/SYS_freebsd13/ SYS/' diff --git a/memcheck/tests/freebsd/scalar.c b/memcheck/tests/freebsd/scalar.c index 50c70e4f23..5a0b4e85d1 100644 --- a/memcheck/tests/freebsd/scalar.c +++ b/memcheck/tests/freebsd/scalar.c @@ -1396,9 +1396,15 @@ int main(void) GO(SYS_swapcontext, "2s 2m"); SY(SYS_swapcontext, x0+1, x0+2); FAIL; +#if (FREEBSD_VERS >= FREEBSD_14) + /* SYS_freebsd13_swapoff 424 */ + GO(SYS_freebsd13_swapoff, "1s 1m"); + SY(SYS_freebsd13_swapoff, x0+1); FAIL; +#else /* SYS_swapoff 424 */ GO(SYS_swapoff, "1s 1m"); SY(SYS_swapoff, x0+1); FAIL; +#endif /* SYS___acl_get_link 425 */ GO(SYS___acl_get_link, "3s 2m");