]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD: add syscall wrapper for membarrier (added in FreeBSD 15)
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 17 Sep 2023 09:50:54 +0000 (11:50 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 17 Sep 2023 09:50:54 +0000 (11:50 +0200)
I also noticed that the Linux membarrier syscall wrapper
is out of date. It only takes one argument. Depending on the kernel
version it can also take 2 or 3 arguments (3 being the latest).

NEWS
coregrind/m_syswrap/priv_syswrap-freebsd.h
coregrind/m_syswrap/syswrap-freebsd.c
memcheck/tests/freebsd/scalar_15_plus.c
memcheck/tests/freebsd/scalar_15_plus.stderr.exp

diff --git a/NEWS b/NEWS
index 736e33baf59e847d78de2d5d2827dc41590de2de..cf0b93ca4e6e530c74d9ff5fcecebaff9707d58b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,8 +22,8 @@ AMD64/macOS 10.13 and nanoMIPS/Linux.
 
 * Support has been added for FreeBSD 14 and FreeBSD 15.
 * Add support for the folllowing FreeBSD system calls:
-  close_range, kqueuex, timerfd_create, timerfd_settime and
-  timerfd_gettime (all added in FreeBSD 15).
+  close_range, kqueuex, membarrier, timerfd_create,
+  timerfd_settime and timerfd_gettime (all added in FreeBSD 15).
 
 * ==================== TOOL CHANGES ===================
 
index b02d9fb4a5b40dadbc5964e0facbfcb2453335a3..5dcdc376a3a5670e2b3aa5f609527796c0a9a3db 100644 (file)
@@ -563,7 +563,7 @@ DECL_TEMPLATE(freebsd, sys_swapoff) // 582
 
 #if (FREEBSD_VERS >= FREEBSD_15)
 DECL_TEMPLATE(freebsd, sys_kqueuex); // 583
-// unimpl __NR_membarrier          584
+DECL_TEMPLATE(freebsd, sys_membarrier); // 584
 DECL_TEMPLATE(freebsd, sys_timerfd_create); // 585
 DECL_TEMPLATE(freebsd, sys_timerfd_gettime); // 586
 DECL_TEMPLATE(freebsd, sys_timerfd_settime); // 587
index fda60920c2a31460be9ecd1b1046e46f3cbe2683..3efb64a43f9a65c0ef318571a80dadb154cf024a 100644 (file)
@@ -6798,7 +6798,17 @@ POST(sys_kqueuex)
    }
 }
 
-// SYS_membarrier 584 unimpl
+// SYS_membarrier 584
+// syscalls.master
+// int membarrier(int cmd, unsigned flags, int cpu_id);
+PRE(sys_membarrier)
+{
+   // cmd is signed int but the constants in the headers
+   // are hex so print in hex
+   PRINT("sys_membarrier(%#" FMT_REGWORD "x, %#" FMT_REGWORD "x, %" FMT_REGWORD "d)",
+         ARG1, ARG2, SARG3);
+   PRE_REG_READ3(int, "membarrier", int, cmd, unsigned, flags, int, cpu_id);
+}
 
 // SYS_timerfd_create 585
 // int timerfd_create(int clockid, int flags);
@@ -7593,8 +7603,8 @@ const SyscallTableEntry ML_(syscall_table)[] = {
 #endif
 
 #if (FREEBSD_VERS >= FREEBSD_15)
-   BSDXY( __NR_kqueuex,         sys_kqueuex),           // 583
-   // unimpl __NR_membarrier          584
+   BSDXY(__NR_kqueuex,          sys_kqueuex),           // 583
+   BSDX_(__NR_membarrier,       sys_membarrier),        // 584
    BSDXY(__NR_timerfd_create,   sys_timerfd_create),    // 585
    BSDXY(__NR_timerfd_settime,  sys_timerfd_settime),   // 586
    BSDXY(__NR_timerfd_gettime,  sys_timerfd_gettime),   // 587
index 2945060c2934b94d3a8d55cf0cda93bef550c536..d3d8af2c0c8f1f0e2af48cd71baca2b0ad05f187 100644 (file)
@@ -11,7 +11,8 @@ int main(void)
    SY(SYS_kqueuex, x0+123); FAIL;
 
    /* SYS_membarrier                     584 */
-   /* unimpl */
+   GO(SYS_membarrier, " 3s 0m");
+   SY(SYS_membarrier, x0+123, x0+456, x0+789); FAIL;
 
    /* SYS_timerfd_create                 585 */
    GO(SYS_timerfd_create, " 2s 0m");
index 5717326f32dd9dfa914abdcb0f369cf00c60d761..af4069c4738c6c6779a6df52138247eca4fc81c6 100644 (file)
@@ -4,6 +4,18 @@
 Syscall param kqueuex(flags) contains uninitialised byte(s)
    ...
 
+---------------------------------------------------------
+584:          SYS_membarrier  3s 0m
+---------------------------------------------------------
+Syscall param membarrier(cmd) contains uninitialised byte(s)
+   ...
+
+Syscall param membarrier(flags) contains uninitialised byte(s)
+   ...
+
+Syscall param membarrier(cpu_id) contains uninitialised byte(s)
+   ...
+
 ---------------------------------------------------------
 585:      SYS_timerfd_create  2s 0m
 ---------------------------------------------------------