]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD syscall: add wrapper for kcmp
authorPaul Floyd <pjfloyd@wanadoo.fr>
Wed, 24 Apr 2024 19:34:03 +0000 (21:34 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Wed, 24 Apr 2024 19:36:13 +0000 (21:36 +0200)
For FreeBSD 15.0-CURRENT. Will need to add for 14.1 when it is out.
Mostly the same as the Linux kcmp syscall (small differences in the
supported types).

coregrind/m_syswrap/priv_syswrap-freebsd.h
coregrind/m_syswrap/syswrap-freebsd.c
include/vki/vki-freebsd.h
include/vki/vki-scnums-freebsd.h

index 7e8924d889bf40f8ab9744594b0fa53bdf8ff144..ed0889d200b734a14aeebc2d61cdbdcb9c07c698 100644 (file)
@@ -573,6 +573,7 @@ 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
+DECL_TEMPLATE(freebsd, sys_kcmp) // 588
 #endif
 
 DECL_TEMPLATE(freebsd, sys_fake_sigreturn)
index bcd181e9dd7b342af8e7e5f6d58761c051f2c251..0a937d37fdd98feafcdd5bdaf312c331e9336c6a 100644 (file)
@@ -7138,6 +7138,32 @@ POST(sys_timerfd_settime)
       POST_MEM_WRITE(ARG4, sizeof(struct vki_itimerspec));
    }
 }
+
+// SYS_kcmp 588
+// int kcmp(pid_t pid1, pid_t pid2, int type, uintptr_t idx1, uintptr_t idx2);
+PRE(sys_kcmp)
+{
+   PRINT("kcmp(%ld, %ld, %ld, %" FMT_REGWORD "u, %" FMT_REGWORD "u)",
+         SARG1, SARG2, SARG3, ARG4, ARG5);
+   switch (ARG3) {
+   case VKI_KCMP_FILES:
+   case VKI_KCMP_VM:
+   case VKI_KCMP_SIGHAND:
+      /* Most of the comparison types don't look at |idx1| or |idx2|. */
+      PRE_REG_READ3(int, "kcmp",
+                    vki_pid_t, pid1, vki_pid_t, pid2, int, type);
+      break;
+   case VKI_KCMP_FILE:
+   case VKI_KCMP_FILEOBJ:
+   default:
+      PRE_REG_READ5(int, "kcmp",
+                    vki_pid_t, pid1, vki_pid_t, pid2, int, type,
+                    unsigned long, idx1, unsigned long, idx2);
+      break;
+   }
+}
+
+
 #endif
 
 #undef PRE
@@ -7873,6 +7899,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    BSDXY(__NR_timerfd_create,   sys_timerfd_create),    // 585
    BSDXY(__NR_timerfd_settime,  sys_timerfd_settime),   // 586
    BSDXY(__NR_timerfd_gettime,  sys_timerfd_gettime),   // 587
+   BSDX_(__NR_kcmp,             sys_kcmp),              // 588
 #endif
 
 
index 14b1703886e88cae73f47132fc462caff4589437..77f75457d8f640cf6d0bfd825b47f29bf78b4e5b 100644 (file)
@@ -1623,6 +1623,13 @@ struct vki_spacectl_range {
 
 #define VKI_RFSPAWN         (1U<<31U)
 
+/* kcmp() options. */
+#define VKI_KCMP_FILE       100
+#define VKI_KCMP_FILEOBJ    101
+#define VKI_KCMP_FILES      102
+#define VKI_KCMP_SIGHAND    103
+#define VKI_KCMP_VM         104
+
 #define VKI_CLOSE_RANGE_CLOEXEC     (1<<2)
 
 //----------------------------------------------------------------------
index 344b932fa73fc0bcd6f821020d8fa6757bacd2b2..967cd7835ecc24bcaeb8ff45a112cadd08edc5d6 100644 (file)
 #define __NR_timerfd_create      585
 #define __NR_timerfd_gettime     586
 #define __NR_timerfd_settime     587
+#define __NR_kcmp                588
 
 #endif