Hi tb and ports,

I have adapted the system call number definition to the new syscall.h

comments, ok?

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/valgrind/Makefile,v
retrieving revision 1.29
diff -u -p -r1.29 Makefile
--- Makefile    3 Sep 2022 09:42:46 -0000       1.29
+++ Makefile    7 Oct 2022 05:31:46 -0000
@@ -1,4 +1,3 @@
-BROKEN =               syscall table and wrappers need to be updated to 
reflect reality
 ONLY_FOR_ARCHS =       amd64
 
 COMMENT =              instrumentation framework for dynamic analysis tools
@@ -6,7 +5,7 @@ CATEGORIES =            devel
 
 V =                    3.10.1
 PV =                   20160331
-REVISION =             20
+REVISION =             21
 DISTNAME =             valgrind-${V}
 EXTRACT_SUFX =         .tar.bz2
 
Index: patches/patch-coregrind_m_aspacemgr_aspacemgr-common_c
===================================================================
RCS file: 
/cvs/ports/devel/valgrind/patches/patch-coregrind_m_aspacemgr_aspacemgr-common_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-coregrind_m_aspacemgr_aspacemgr-common_c
--- patches/patch-coregrind_m_aspacemgr_aspacemgr-common_c      2 Oct 2019 
17:19:29 -0000       1.1
+++ patches/patch-coregrind_m_aspacemgr_aspacemgr-common_c      7 Oct 2022 
05:31:46 -0000
@@ -1,5 +1,16 @@
 --- coregrind/m_aspacemgr/aspacemgr-common.c.orig
 +++ coregrind/m_aspacemgr/aspacemgr-common.c
+@@ -187,8 +187,8 @@
+ #  elif defined(VGP_amd64_openbsd)
+    if (flags & VKI_MAP_ANONYMOUS && fd == 0)
+       fd = -1;
+-   res = VG_(do_syscall7)(__NR_mmap, (UWord)start, length,
+-                        prot, flags, fd, 0, offset);
++   res = VG_(do_syscall6)(__NR_mmap, (UWord)start, length,
++                        prot, flags, fd, offset);
+ #  else
+ #    error Unknown platform
+ #  endif
 @@ -458,7 +458,11 @@ VgStack* VG_(am_alloc_VgStack)( /*OUT*/Addr* initial_sp )
     szB = VG_STACK_GUARD_SZB
           + VG_STACK_ACTIVE_SZB + VG_STACK_GUARD_SZB;
Index: patches/patch-coregrind_m_syswrap_priv_syswrap_openbsd_h
===================================================================
RCS file: 
/cvs/ports/devel/valgrind/patches/patch-coregrind_m_syswrap_priv_syswrap_openbsd_h,v
retrieving revision 1.2
diff -u -p -r1.2 patch-coregrind_m_syswrap_priv_syswrap_openbsd_h
--- patches/patch-coregrind_m_syswrap_priv_syswrap_openbsd_h    23 Dec 2019 
23:26:32 -0000      1.2
+++ patches/patch-coregrind_m_syswrap_priv_syswrap_openbsd_h    7 Oct 2022 
05:31:46 -0000
@@ -1,19 +1,58 @@
 --- coregrind/m_syswrap/priv_syswrap-openbsd.h.orig
 +++ coregrind/m_syswrap/priv_syswrap-openbsd.h
-@@ -50,7 +50,7 @@
- DECL_TEMPLATE(openbsd, sys_open);
- DECL_TEMPLATE(openbsd, sys_close);
- DECL_TEMPLATE(openbsd, sys_getentropy);
--DECL_TEMPLATE(openbsd, sys___tfork);
-+DECL_TEMPLATE(openbsd, sys___tfork_thread);
- DECL_TEMPLATE(openbsd, sys_link);
- DECL_TEMPLATE(openbsd, sys_unlink);
- DECL_TEMPLATE(openbsd, sys_wait4);
-@@ -144,6 +144,7 @@
- DECL_TEMPLATE(openbsd, sys_pledge);
- DECL_TEMPLATE(openbsd, sys_ppoll);
- DECL_TEMPLATE(openbsd, sys_pselect);
-+DECL_TEMPLATE(openbsd, sys_unveil);
- DECL_TEMPLATE(openbsd, sys_sigsuspend);
- DECL_TEMPLATE(openbsd, sys_gettimeofday);
- DECL_TEMPLATE(openbsd, sys_getrusage);
+@@ -80,7 +80,7 @@
+ DECL_TEMPLATE(openbsd, sys_chflagsat);
+ DECL_TEMPLATE(openbsd, sys_fchflags);
+ DECL_TEMPLATE(openbsd, sys_sync);
+-DECL_TEMPLATE(openbsd, sys_kill);
++DECL_TEMPLATE(openbsd, sys_msyscall);
+ DECL_TEMPLATE(openbsd, sys_getppid);
+ DECL_TEMPLATE(openbsd, sys_dup);
+ DECL_TEMPLATE(openbsd, sys_dup3);
+@@ -93,7 +93,7 @@
+ DECL_TEMPLATE(openbsd, sys_sigprocmask);
+ DECL_TEMPLATE(openbsd, sys_sigtimedwait);
+ DECL_TEMPLATE(openbsd, sys_sigwaitinfo);
+-DECL_TEMPLATE(openbsd, sys_getlogin);
++DECL_TEMPLATE(openbsd, sys_getlogin_r);
+ DECL_TEMPLATE(openbsd, sys_setlogin);
+ DECL_TEMPLATE(openbsd, sys_acct);
+ DECL_TEMPLATE(openbsd, sys_sigpending);
+@@ -118,7 +118,6 @@
+ DECL_TEMPLATE(openbsd, sys_munmap);
+ DECL_TEMPLATE(openbsd, sys_mprotect);
+ DECL_TEMPLATE(openbsd, sys_madvise);
+-DECL_TEMPLATE(openbsd, sys_mincore);
+ DECL_TEMPLATE(openbsd, sys_getgroups);
+ DECL_TEMPLATE(openbsd, sys_setgroups);
+ DECL_TEMPLATE(openbsd, sys_getpgrp);
+@@ -151,6 +150,7 @@
+ DECL_TEMPLATE(openbsd, sys_getsockopt);
+ DECL_TEMPLATE(openbsd, sys_readv);
+ DECL_TEMPLATE(openbsd, sys_writev);
++DECL_TEMPLATE(openbsd, sys_kill);
+ DECL_TEMPLATE(openbsd, sys_settimeofday);
+ DECL_TEMPLATE(openbsd, sys_fchown);
+ DECL_TEMPLATE(openbsd, sys_fchmod);
+@@ -168,12 +168,12 @@
+ DECL_TEMPLATE(openbsd, sys_adjtime);
+ DECL_TEMPLATE(openbsd, sys_setsid);
+ DECL_TEMPLATE(openbsd, sys_quotactl);
++DECL_TEMPLATE(openbsd, sys_ypconnect);
+ DECL_TEMPLATE(openbsd, sys_nfssvc);
+ DECL_TEMPLATE(openbsd, sys_getdomainname);
+ DECL_TEMPLATE(openbsd, sys_setdomainname);
+ DECL_TEMPLATE(openbsd, sys_getfh);
+ DECL_TEMPLATE(openbsd, sys_sysarch);
+-DECL_TEMPLATE(openbsd, sys_pread);
+ DECL_TEMPLATE(openbsd, sys_pwrite);
+ DECL_TEMPLATE(openbsd, sys_setgid);
+ DECL_TEMPLATE(openbsd, sys_setegid);
+@@ -190,6 +190,7 @@
+ DECL_TEMPLATE(openbsd, sys_lseek);
+ DECL_TEMPLATE(openbsd, sys_truncate);
+ DECL_TEMPLATE(openbsd, sys_ftruncate);
++DECL_TEMPLATE(openbsd, sys_pread);
+ DECL_TEMPLATE(openbsd, sys___sysctl);
+ DECL_TEMPLATE(openbsd, sys_sendfile);
+ DECL_TEMPLATE(openbsd, sys_mlock);
Index: patches/patch-coregrind_m_syswrap_syswrap_amd64_openbsd_c
===================================================================
RCS file: 
/cvs/ports/devel/valgrind/patches/patch-coregrind_m_syswrap_syswrap_amd64_openbsd_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-coregrind_m_syswrap_syswrap_amd64_openbsd_c
--- patches/patch-coregrind_m_syswrap_syswrap_amd64_openbsd_c   23 Dec 2019 
23:26:32 -0000      1.1
+++ patches/patch-coregrind_m_syswrap_syswrap_amd64_openbsd_c   7 Oct 2022 
05:31:46 -0000
@@ -1,6 +1,6 @@
 --- coregrind/m_syswrap/syswrap-amd64-openbsd.c.orig
 +++ coregrind/m_syswrap/syswrap-amd64-openbsd.c
-@@ -120,6 +120,212 @@
+@@ -120,6 +120,209 @@
  #define PRE(name)       DEFN_PRE_TEMPLATE(openbsd, name)
  #define POST(name)      DEFN_POST_TEMPLATE(openbsd, name)
  
@@ -82,7 +82,7 @@
 +   This function was implemented with reference to the syswrap-amd64-linux.c:
 +   do_clone() function.
 + */
-+static SysRes do_tfork_thread ( ThreadId ptid,
++static SysRes do_tfork ( ThreadId ptid,
 +                         Addr params,
 +                         ULong psize,
 +                         Addr startfunc,
@@ -114,7 +114,7 @@
 +   /* Copy register state
 +
 +      Both parent and child return to the same place, and the code
-+      following the __tfork_thread syscall works out which is which, so we
++      following the __tfork syscall works out which is which, so we
 +      don't need to worry about it.
 +
 +      The parent gets the child's new tid returned from clone, but the
@@ -161,9 +161,6 @@
 +   VG_TRACK ( pre_thread_ll_create, ptid, ctid );
 +
 +   /* start the thread with everything blocked */
-+#if 1 /* for debug by asou */
-+   VG_(sigdelset)(&blockall, VKI_SIGTRAP);
-+#endif
 +   VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, &savedmask);
 +
 +   /* Create the new thread */
@@ -186,19 +183,19 @@
 +   return res;
 +}
 +
-+PRE(sys___tfork_thread)
++PRE(sys___tfork)
 +{
 +   struct __vki_tfork * tfork;
-+   PRINT("sys___tfork_thread ( %#lx, %ld, %#lx, %#lx )",ARG1,ARG2,ARG3,ARG4);
-+   PRE_REG_READ4(long, "__tfork_thread", struct __tfork *, params, size_t, 
psize,
++   PRINT("sys___tfork ( %#lx, %ld, %#lx, %#lx )",ARG1,ARG2,ARG3,ARG4);
++   PRE_REG_READ4(long, "__tfork", struct __tfork *, params, size_t, psize,
 +               void (*)(void *), startfunc, void *, startarg);
-+   PRE_MEM_READ( "__tfork_thread(params, psize)", ARG1, ARG2 );
++   PRE_MEM_READ( "__tfork(params, psize)", ARG1, ARG2 );
 +   tfork = (struct __vki_tfork *)ARG1;
 +   if (tfork->tf_tid != NULL)
-+      PRE_MEM_READ("__tfork_thread(params.tf_tid)", (Addr)tfork->tf_tid,
++      PRE_MEM_READ("__tfork(params.tf_tid)", (Addr)tfork->tf_tid,
 +                 sizeof (pid_t));
 +   SET_STATUS_from_SysRes(
-+      do_tfork_thread(tid, (Addr)ARG1, (ULong)ARG2, (Addr)ARG3, (Addr)ARG4));
++      do_tfork(tid, (Addr)ARG1, (ULong)ARG2, (Addr)ARG3, (Addr)ARG4));
 +
 +   if (SUCCESS) {
 +      POST_MEM_WRITE((Addr)tfork->tf_tcb, sizeof (void *));
@@ -213,3 +210,145 @@
  #if 0
  PRE(sys_thr_new)
  {
+@@ -505,29 +708,20 @@
+ 
+ /* This is here because on x86 the off_t is passed in 2 regs. Don't ask about 
pad.  */
+ 
+-/* caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, int 
pad, off_t pos); */
+-/*              ARG1           ARG2       ARG3      ARG4       ARG5    ARG6   
  ARG7 */
++/* void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t 
offset); */
++/*                  ARG1         ARG2     ARG3      ARG4       ARG5      ARG6 
*/
+ 
+ PRE(sys_mmap)
+ {
+    SysRes r;
+ 
+-   PRINT("sys_mmap ( %#lx, %lu, %ld, %ld, %ld, pad%ld, 0x%lx)",
+-         ARG1, (UWord)ARG2, ARG3, ARG4, ARG5, ARG6, ARG7 );
+-#if !defined(VGO_openbsd)
+-   PRE_REG_READ7(long, "mmap",
+-                 char *, addr, unsigned long, len, int, prot,  int, flags,
+-                 int, fd,  int, pad, unsigned long, pos);
+-#else
+-   /* Take account of __syscall sysno (arg1). */
+-   PRE_REG_READ8(long, "mmap",
+-               long, sysno,
+-                 char *, addr, unsigned long, len, int, prot,  int, flags,
+-                 int, fd,  int, pad, unsigned long, pos);
+-   // XXX XXX XXX Check all other __syscall users too
+-#endif
++   PRINT("sys_mmap ( %#lx, %llu, %ld, %ld, %ld, %llu)",
++         ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, (ULong)ARG6);
++   PRE_REG_READ6(long, "mmap",
++                 void *, addr, vki_size_t, len, int, prot, int, flags,
++                 int, fd,  vki_off_t, offset);
+ 
+-   r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG7 );
++   r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 );
+    SET_STATUS_from_SysRes(r);
+ }
+ 
+@@ -550,18 +744,8 @@
+ 
+ PRE(sys_lseek)
+ {
+-   PRINT("sys_lseek ( %ld, 0x%lx, %#lx, %ld )", ARG1,ARG2,ARG3,ARG4);
+-
+-#if !defined(VGO_openbsd)
+-   PRE_REG_READ4(long, "lseek",
+-                 unsigned int, fd, int, pad, unsigned long, offset,
+-                 unsigned int, whence);
+-#else
+-   PRE_REG_READ5(long, "lseek",
+-                 long, sysno,
+-                 unsigned int, fd, int, pad, unsigned long, offset,
+-                 unsigned int, whence);
+-#endif
++   PRINT("sys_lseek ( %ld, %llu, %ld )", ARG1, (ULong)ARG2, ARG3);
++   PRE_REG_READ4(long, "lseek", long, sysno, int, filedes, vki_off_t, offset, 
int, whence);
+ }
+ 
+ #if 0
+@@ -577,24 +761,17 @@
+ PRE(sys_pread)
+ {
+    *flags |= SfMayBlock;
+-   PRINT("sys_read ( %ld, %#lx, %lu, %lu, %lu )", ARG1, ARG2, ARG3, ARG4, 
ARG5);
+-#if !defined(VGO_openbsd)
++
++   PRINT("sys_read ( %ld, %#lx, %llu, %llu )", ARG1, ARG2, ARG3, ARG4);
+    PRE_REG_READ5(ssize_t, "read",
+-                 unsigned int, fd, char *, buf, vki_size_t, count,
+-                 int, pad, unsigned long, off);
+-#else
+-   PRE_REG_READ6(ssize_t, "read",
+                  long, sysno,
+-                 unsigned int, fd, char *, buf, vki_size_t, count,
+-                 int, pad, unsigned long, off);
+-#endif
++                 int, d, void *, buf, vki_size_t, nbytes, vki_off_t, offset);
+ 
+-   if (!ML_(fd_allowed)(ARG1, "read", tid, False))
++   if (!ML_(fd_allowed)(ARG1, "pread", tid, False))
+       SET_STATUS_Failure( VKI_EBADF );
+    else
+-      PRE_MEM_WRITE( "read(buf)", ARG2, ARG3 );
++      PRE_MEM_WRITE( "pread(buf)", ARG2, ARG3 );
+ }
+-
+ POST(sys_pread)
+ {
+    vg_assert(SUCCESS);
+@@ -627,27 +804,22 @@
+ {
+    Bool ok;
+    *flags |= SfMayBlock;
+-   PRINT("sys_write ( %ld, %#lx, %lu, %lu, %lu )", ARG1, ARG2, ARG3, ARG4, 
ARG5);
+-#if !defined(VGO_openbsd)
+-   PRE_REG_READ5(ssize_t, "write",
+-                 unsigned int, fd, const char *, buf, vki_size_t, count,
+-                 int, pad, unsigned long, off);
+-#else
+-   PRE_REG_READ6(ssize_t, "write",
++
++   PRINT("sys_pwrite ( %ld, %#lx, %llu, %llu )", ARG1, ARG2, ARG3, ARG4);
++   PRE_REG_READ5(ssize_t, "pwrite",
+                  long, sysno,
+-                 unsigned int, fd, const char *, buf, vki_size_t, count,
+-                 int, pad, unsigned long, off);
+-#endif
++                 int, d, void *, buf, vki_size_t, count, vki_off_t, offset);
++
+    /* check to see if it is allowed.  If not, try for an exemption from
+       --sim-hints=enable-outer (used for self hosting). */
+-   ok = ML_(fd_allowed)(ARG1, "write", tid, False);
++   ok = ML_(fd_allowed)(ARG1, "pwrite", tid, False);
+    if (!ok && ARG1 == 2/*stderr*/
+            && SimHintiS(SimHint_enable_outer, VG_(clo_sim_hints)))
+       ok = True;
+    if (!ok)
+       SET_STATUS_Failure( VKI_EBADF );
+    else
+-      PRE_MEM_READ( "write(buf)", ARG2, ARG3 );
++      PRE_MEM_READ( "pwrite(buf)", ARG2, ARG3 );
+ }
+ 
+ #if 0
+@@ -675,14 +847,9 @@
+ PRE(sys_ftruncate)
+ {
+    *flags |= SfMayBlock;
+-   PRINT("sys_ftruncate ( %ld, %lu )", ARG1,ARG3);
+-#if !defined(VGO_openbsd)
+-   PRE_REG_READ3(long, "ftruncate", unsigned int, fd, int, pad,
+-                unsigned int, length);
+-#else
+-   PRE_REG_READ4(long, "ftruncate", long, sysno, unsigned int, fd, int, pad,
+-                unsigned int, length);
+-#endif
++   PRINT("sys_ftruncate ( %#lx, %llu )", ARG1, ARG2);
++   PRE_REG_READ3(long, "ftruncate", long, sysno, unsigned int, fd,
++               vki_off_t, length);
+ }
+ 
+ #if 0
Index: patches/patch-coregrind_m_syswrap_syswrap_openbsd_c
===================================================================
RCS file: 
/cvs/ports/devel/valgrind/patches/patch-coregrind_m_syswrap_syswrap_openbsd_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-coregrind_m_syswrap_syswrap_openbsd_c
--- patches/patch-coregrind_m_syswrap_syswrap_openbsd_c 22 May 2020 08:51:24 
-0000      1.3
+++ patches/patch-coregrind_m_syswrap_syswrap_openbsd_c 7 Oct 2022 05:31:46 
-0000
@@ -55,23 +55,154 @@
  PRE(sys_getsockname)
  {
     PRINT("sys_getsockname ( %ld, %#lx, %#lx )",ARG1,ARG2,ARG3);
-@@ -780,15 +791,6 @@
+@@ -780,22 +791,12 @@
     SET_STATUS_Success(0);
  }
  
 -PRE(sys___tfork)
++PRE(sys_getlogin_r)
+ {
+-// XXXTBD
++   PRINT("sys_getlogin_r ( %#lx, %llu )", ARG1, (ULong)ARG2);
++   PRE_REG_READ2(long, "getlogin_r", char *, name, vki_size_t, namelen);
++   PRE_MEM_WRITE( "getlogin_r(buf, len)", ARG1, ARG2 );
+ }
+-POST(sys___tfork)
 -{
 -// XXXTBD
 -}
--POST(sys___tfork)
+-
+-PRE(sys_getlogin)
+-{
+-   PRINT("sys_getlogin ( %#lx, %ld )",ARG1,ARG2);
+-   PRE_REG_READ2(long, "getlogin",
+-                 char *, buf, int, len);
+-   PRE_MEM_WRITE( "getlogin(buf, len)", ARG1, ARG2 );
+-}
+ POST(sys_getlogin)
+ {
+    if (ARG1 != 0) {
+@@ -831,6 +832,12 @@
+    PRE_MEM_RASCIIZ( "quotactl(path)", ARG1 );
+ }
+ 
++PRE(sys_ypconnect)
++{
++   PRINT("sys_ypconnect (%ld)", ARG1);
++   PRE_REG_READ1(long, "ypconnect", int, type);
++}
++
+ PRE(sys_nfssvc)
+ {
+ // XXXTBD
+@@ -1053,6 +1060,14 @@
+       PRE_MEM_READ( "lutimes(tvp)", ARG2, sizeof(struct vki_timeval) );
+ }
+ 
++PRE(sys_mquery)
++{
++   PRINT("sys_mquery ( %#lx, %llu, %ld, %ld, %ld, %llu)", ARG1, (ULong)ARG2,
++       ARG3, ARG4, ARG5, (ULong)ARG6);
++   PRE_REG_READ6(long, "mquery", void *, addr, vki_size_t, len, int, prot, 
int,
++               flags, int, fd, vki_off_t, offset);
++}
++
+ PRE(sys_futimes)
+ {
+    PRINT("sys_lutimes ( %ld, %#lx )", ARG1,ARG2);
+@@ -2651,6 +2666,13 @@
+    PRE_REG_READ2(long, "fchflags", unsigned int, fildes, vki_int32_t, flags);
+ }
+ 
++PRE(sys_msyscall)
++{
++   *flags |= SfMayBlock;
++   PRINT("sys_msyscall ( %#lx, %llu )", ARG1, (ULong)ARG2);
++   PRE_REG_READ2(long, "msyscall", void *, addr, vki_size_t, addrlen);
++}
++
+ PRE(sys_profil)
+ {
+ // XXXTBD
+@@ -2737,23 +2759,69 @@
+ 
+ PRE(sys_preadv)
+ {
+-// XXXTBD
++   Int i;
++   struct vki_iovec * vec;
++   *flags |= SfMayBlock;
++   PRINT("sys_preadv ( %ld, %#lx, %ld )", ARG1, ARG2, ARG3);
++   PRE_REG_READ3(ssize_t, "preadv",
++               int, fd, const struct iovec *, iov, int, iovcnt);
++   if (!ML_(fd_allowed)(ARG1, "preadv", tid, False)) {
++      SET_STATUS_Failure( VKI_EBADF );
++   } else {
++      PRE_MEM_READ( "preadv(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) );
++
++      if (ARG2 != 0) {
++         /* ToDo: don't do any of the following if the vector is invalid */
++         vec = (struct vki_iovec *)ARG2;
++         for (i = 0; i < (Int)ARG3; i++)
++            PRE_MEM_WRITE( "preadv(vector[...])",
++                           (Addr)vec[i].iov_base, vec[i].iov_len );
++      }
++   }
+ }
++
+ POST(sys_preadv)
+ {
+-// XXXTBD
++   vg_assert(SUCCESS);
++   if (RES > 0) {
++      Int i;
++      struct vki_iovec * vec = (struct vki_iovec *)ARG2;
++      Int remains = RES;
++
++      /* RES holds the number of bytes read. */
++      for (i = 0; i < ARG3; i++) {
++       Int nReadThisBuf = vec[i].iov_len;
++       if (nReadThisBuf > remains) nReadThisBuf = remains;
++       POST_MEM_WRITE( (Addr)vec[i].iov_base, nReadThisBuf );
++       remains -= nReadThisBuf;
++       if (remains < 0) VG_(core_panic)("preadv: remains < 0");
++      }
++   }
+ }
+ 
+ PRE(sys_pwritev)
+ {
+-// XXXTBD
++   Int i;
++   struct vki_iovec * vec;
++   *flags |= SfMayBlock;
++   PRINT("sys_pwritev ( %ld, %#lx, %ld )", ARG1, ARG2, ARG3);
++   PRE_REG_READ3(ssize_t, "pwritev",
++                 int, fd, const struct iovec *, iov, int, iovcnt);
++   if (!ML_(fd_allowed)(ARG1, "pwritev", tid, False)) {
++      SET_STATUS_Failure( VKI_EBADF );
++   } else {
++      PRE_MEM_READ( "pwritev(vector)", 
++                   ARG2, ARG3 * sizeof(struct vki_iovec) );
++      if (ARG2 != 0) {
++         /* ToDo: don't do any of the following if the vector is invalid */
++         vec = (struct vki_iovec *)ARG2;
++         for (i = 0; i < ARG3; i++)
++            PRE_MEM_READ( "pwritev(vector[...])",
++                           (Addr)vec[i].iov_base, vec[i].iov_len );
++      }
++   }
+ }
+ 
+-PRE(sys_mquery)
 -{
 -// XXXTBD
 -}
 -
- PRE(sys_getlogin)
+ PRE(sys_closefrom)
  {
-    PRINT("sys_getlogin ( %#lx, %ld )",ARG1,ARG2);
-@@ -2776,17 +2778,40 @@
+ // XXXTBD
+@@ -2776,17 +2844,40 @@
  
  PRE(sys___thrsleep)
  {
@@ -115,7 +246,7 @@
  }
  
  PRE(sys___thrsigdivert)
-@@ -2819,6 +2844,68 @@
+@@ -2819,6 +2910,68 @@
  // XXXTBD
  }
  
@@ -184,16 +315,34 @@
  PRE(sys_utimensat)
  {
  // XXXTBD
-@@ -3950,7 +4037,7 @@
+@@ -3950,7 +4103,7 @@
    
    GENXY(__NR_close,           sys_close),             // 6
    BSDXY(__NR_getentropy,      sys_getentropy),        // 7
 -  BSDXY(__NR___tfork,         sys___tfork),           // 8
-+  BSDX_(__NR___tfork_thread,  sys___tfork_thread),    // 8
++  BSDX_(__NR___tfork,         sys___tfork),           // 8
    GENX_(__NR_link,            sys_link),              // 9
    GENX_(__NR_unlink,          sys_unlink),            // 10
    
-@@ -4031,7 +4118,7 @@
+@@ -3986,7 +4139,7 @@
+   BSDX_(__NR_fchflags,                sys_fchflags),          // 35
+ 
+   GENX_(__NR_sync,            sys_sync),              // 36
+-  GENX_(__NR_o58_kill,                sys_kill),              // 37
++  BSDX_(__NR_msyscall,                sys_msyscall),          // 37
+   BSDXY(__NR_stat,            sys_stat),              // 38
+   GENX_(__NR_getppid,         sys_getppid),           // 39
+   BSDXY(__NR_lstat,           sys_lstat),             // 40
+@@ -4000,7 +4153,7 @@
+   BSDXY(__NR_sigaction,               sys_sigaction),         // 46
+   GENX_(__NR_getgid,          sys_getgid),            // 47
+   BSDX_(__NR_sigprocmask,     sys_sigprocmask),       // 48
+-  BSDX_(__NR_getlogin,                sys_getlogin),          // 49
++  BSDX_(__NR_mmap,            sys_mmap),              // 49
+   BSDX_(__NR_setlogin,                sys_setlogin),          // 50
+ 
+   BSDX_(__NR_acct,            sys_acct),              // 51
+@@ -4031,18 +4184,18 @@
    GENX_(__NR_select,          sys_select),            // 71
    BSDXY(__NR_kevent,          sys_kevent),            // 72
    GENX_(__NR_munmap,          sys_munmap),            // 73
@@ -202,7 +351,11 @@
    GENX_(__NR_madvise,         sys_madvise),           // 75
  
    GENX_(__NR_utimes,          sys_utimes),            // 76
-@@ -4042,7 +4129,7 @@
+   BSDX_(__NR_futimes,         sys_futimes),           // 77
+-  GENX_(__NR_mincore,         sys_mincore),           // 78
++  BSDX_(__NR_mquery,          sys_mquery),            // 78
+   GENXY(__NR_getgroups,               sys_getgroups),         // 79
+   GENX_(__NR_setgroups,               sys_setgroups),         // 80
  
    GENX_(__NR_getpgrp,         sys_getpgrp),           // 81
    GENX_(__NR_setpgid,         sys_setpgid),           // 82
@@ -211,7 +364,7 @@
    BSDX_(__NR_utimensat,               sys_utimensat),         // 84
    BSDX_(__NR_futimens,                sys_futimens),          // 85
  
-@@ -4079,7 +4166,7 @@
+@@ -4079,7 +4232,7 @@
    BSDX_(__NR_sigsuspend,      sys_sigsuspend),        // 111
    BSDX_(__NR_sendsyslog,      sys_sendsyslog),        // 112
    // obsol orecvmsg                                   // 113
@@ -220,3 +373,60 @@
    // obsol vtrace                                     // 115
  
    BSDX_(__NR_getsockopt,      sys_getsockopt),        // 118
+@@ -4108,8 +4261,8 @@
+   GENX_(__NR_rmdir,           sys_rmdir),             // 137
+   // obsol 4.2 sigreturn                              // 139
+   BSDX_(__NR_adjtime,         sys_adjtime),           // 140
++  BSDX_(__NR_getlogin_r,      sys_getlogin_r),        // 141
+ 
+-  // obsol ogetpeername                                       // 141
+   // obsol ogethostid                                 // 142
+   // obsol osethostid                                 // 143
+   // obsol ogetrlimit                                 // 144
+@@ -4138,17 +4291,17 @@
+   // obsol osetdomainname                             // 163
+   // unimpl ouname                                    // 164
+   BSDX_(__NR_sysarch,         sys_sysarch),           // 165
++  BSDX_(__NR_lseek,           sys_lseek),             // 166
++  BSDX_(__NR_truncate,                sys_truncate),          // 167
+ 
+-  // unimpl                                           // 166
+-  // unimpl                                           // 167
+   // unimpl                                           // 168
+-  // obsol semsys10                                   // 169
+-  // obsol msgsys10                                   // 170
++  BSDXY(__NR_pread,           sys_pread),             // 169
++  BSDX_(__NR_pwrite,          sys_pwrite),            // 170
++  BSDXY(__NR_preadv,          sys_preadv),            // 171
+ 
+-  // obsol shmsys10                                   // 171
+   // unimpl                                           // 172
+-  BSDXY(__NR_pread,           sys_pread),             // 173
+-  BSDX_(__NR_pwrite,          sys_pwrite),            // 174
++  BSDXY(__NR_pad_pread,               sys_pread),             // 173
++  BSDX_(__NR_pad_pwrite,      sys_pwrite),            // 174
+   // unimpl ntp_gettime                                       // 175
+ 
+   // unimpl ntp_adjtime                                       // 176
+@@ -4176,10 +4329,9 @@
+   BSDX_(__NR_setrlimit,               sys_setrlimit),         // 195
+ 
+   // obsol ogetdirentries48                           // 196
+-  BSDX_(__NR_mmap,            sys_mmap),              // 197
++  BSDX_(__NR_pad_mmap,                sys_mmap),              // 197
+   // BSDX_(__NR___syscall,            sys___syscall),         // 198
+-  BSDX_(__NR_lseek,           sys_lseek),             // 199
+-  BSDX_(__NR_truncate,                sys_truncate),          // 200
++  BSDX_(__NR_pad_truncate,    sys_truncate),          // 200
+ 
+   BSDX_(__NR_ftruncate,               sys_ftruncate),         // 201
+   BSDXY(__NR_sysctl,          sys___sysctl),          // 202
+@@ -4249,7 +4401,7 @@
+   // unimpl                                           // 265
+ 
+   // unimpl                                           // 266
+-  BSDXY(__NR_preadv,          sys_preadv),            // 267
++  BSDXY(__NR_pad_preadv,      sys_preadv),            // 267
+   BSDX_(__NR_pwritev,         sys_pwritev),           // 268
+   BSDX_(__NR_kqueue,          sys_kqueue),            // 269
+ 
Index: patches/patch-coregrind_m_syswrap_syswrap_x86_openbsd_c
===================================================================
RCS file: 
/cvs/ports/devel/valgrind/patches/patch-coregrind_m_syswrap_syswrap_x86_openbsd_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-coregrind_m_syswrap_syswrap_x86_openbsd_c
--- patches/patch-coregrind_m_syswrap_syswrap_x86_openbsd_c     23 Dec 2019 
23:26:32 -0000      1.1
+++ patches/patch-coregrind_m_syswrap_syswrap_x86_openbsd_c     7 Oct 2022 
05:31:46 -0000
@@ -4,11 +4,11 @@
  #define PRE(name)       DEFN_PRE_TEMPLATE(openbsd, name)
  #define POST(name)      DEFN_POST_TEMPLATE(openbsd, name)
  
-+PRE(sys___tfork_thread)
++PRE(sys___tfork)
 +{
 +// XXXTBD
 +}
-+POST(sys___tfork_thread)
++POST(sys___tfork)
 +{
 +// XXXTBD
 +}
Index: patches/patch-include_vki_vki_scnums_openbsd_h
===================================================================
RCS file: 
/cvs/ports/devel/valgrind/patches/patch-include_vki_vki_scnums_openbsd_h,v
retrieving revision 1.2
diff -u -p -r1.2 patch-include_vki_vki_scnums_openbsd_h
--- patches/patch-include_vki_vki_scnums_openbsd_h      23 Dec 2019 23:26:32 
-0000      1.2
+++ patches/patch-include_vki_vki_scnums_openbsd_h      7 Oct 2022 05:31:46 
-0000
@@ -1,14 +1,32 @@
 --- include/vki/vki-scnums-openbsd.h.orig
 +++ include/vki/vki-scnums-openbsd.h
-@@ -41,7 +41,7 @@
- #define       __NR_open               5
- #define       __NR_close              6
- #define       __NR_getentropy         7
--#define       __NR___tfork            8
-+#define       __NR___tfork_thread     8
- #define       __NR_link               9
- #define       __NR_unlink             10
- #define       __NR_wait4              11
+@@ -70,7 +70,7 @@
+ #define       __NR_chflags            34
+ #define       __NR_fchflags           35
+ #define       __NR_sync               36
+-#define       __NR_o58_kill           37
++#define       __NR_msyscall           37
+ #define       __NR_stat               38
+ #define       __NR_getppid            39
+ #define       __NR_lstat              40
+@@ -82,7 +82,7 @@
+ #define       __NR_sigaction          46
+ #define       __NR_getgid             47
+ #define       __NR_sigprocmask        48
+-#define       __NR_getlogin           49
++#define       __NR_mmap               49
+ #define       __NR_setlogin           50
+ #define       __NR_acct               51
+ #define       __NR_sigpending         52
+@@ -111,7 +111,7 @@
+ #define       __NR_madvise            75
+ #define       __NR_utimes             76
+ #define       __NR_futimes            77
+-#define       __NR_mincore            78
++#define       __NR_mquery             78
+ #define       __NR_getgroups          79
+ #define       __NR_setgroups          80
+ #define       __NR_getpgrp            81
 @@ -116,7 +116,7 @@
  #define       __NR_setgroups          80
  #define       __NR_getpgrp            81
@@ -18,11 +36,70 @@
  #define __NR_utimensat                84
  #define __NR_futimens         85
  #define __NR_kbind            86
-@@ -146,6 +146,7 @@
+@@ -146,6 +146,8 @@
  #define       __NR_pselect            110
  #define       __NR_sigsuspend         111
  #define       __NR_sendsyslog         112
 +#define       __NR_unveil             114
++#define       __NR___realpath         115
  #define       __NR_getsockopt         118
  #define       __NR_thrkill            119
  #define       __NR_readv              120
+@@ -165,13 +166,22 @@
+ #define       __NR_mkdir              136
+ #define       __NR_rmdir              137
+ #define       __NR_adjtime            140
++#define       __NR_getlogin_r         141
+ #define       __NR_setsid             147
+ #define       __NR_quotactl           148
++#define       __NR_ypconnect          150
+ #define       __NR_nfssvc             155
+ #define       __NR_getfh              161
++#define       __NR___tmpfd            164
+ #define       __NR_sysarch            165
+-#define       __NR_pread              173
+-#define       __NR_pwrite             174
++#define       __NR_lseek              166
++#define       __NR_truncate           167
++#define       __NR_pread              173 /* XXX 169 */
++#define       __NR_pwrite             170
++#define       __NR_preadv             171
++#define       __NR_pwritev            172
++#define       __NR_pad_pread          173
++#define       __NR_pad_pwrite         174
+ #define       __NR_setgid             181
+ #define       __NR_setegid            182
+ #define       __NR_seteuid            183
+@@ -180,10 +190,9 @@
+ #define       __NR_swapctl            193
+ #define       __NR_getrlimit          194
+ #define       __NR_setrlimit          195
+-#define       __NR_mmap               197
++#define       __NR_pad_mmap           197
+ #define       __NR___syscall          198
+-#define       __NR_lseek              199
+-#define       __NR_truncate           200
++#define       __NR_pad_truncate       200
+ #define       __NR_ftruncate          201
+ #define       __NR_sysctl             202
+ #define       __NR_mlock              203
+@@ -204,8 +213,8 @@
+ #define       __NR_msync              256
+ #define       __NR_pipe               263
+ #define       __NR_fhopen             264
+-#define       __NR_preadv             267
+-#define       __NR_pwritev            268
++#define       __NR_pad_preadv         267
++#define       __NR_pad_pwritev        268
+ #define       __NR_kqueue             269
+ #define       __NR_mlockall           271
+ #define       __NR_munlockall         272
+@@ -213,7 +222,7 @@
+ #define       __NR_setresuid          282
+ #define       __NR_getresgid          283
+ #define       __NR_setresgid          284
+-#define       __NR_mquery             286
++#define       __NR_pad_mquery         286
+ #define       __NR_closefrom          287
+ #define       __NR_sigaltstack        288
+ #define       __NR_shmget             289

--
ASOU Masato

From: Theo Buehler <t...@theobuehler.org>
Date: Mon, 22 Aug 2022 18:37:11 +0200

> Since guenther removed pad arguments from various syscalls and renamed
> the existing ones to contain a _pad_, the already rather outdated
> vki-scnums-openbsd.h diverged a step too far from reality.
> 
> mmap() is now syscall 41, which valgrind thinks is getlogin(), so you
> get output such as
> 
> ==66088== Syscall param getlogin(buf, len) points to unaddressable byte(s)
> ==66088==    at 0x410C5BA: ???
> ==66088==    by 0x410336E: ???
> ==66088==    by 0x4103C65: ???
> ==66088==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
> 
> Most other output is equally useless. Thus I suggest we add a broken
> marker until someone sits down and does the non-trivial amount of work
> needed to fix this:
> 
> BROKEN = syscall table and wrappers need to be updated to reflect reality
> 
> Here's a diff between valgrind's idea of OpenBSD syscalls, and -current
> syscall.h (slightly modified to filter out noise).
> 
> --- vki-scnums-openbsd.h      Mon Aug 22 16:07:57 2022
> +++ syscall.h Mon Aug 22 16:13:29 2022
> @@ -1,38 +1,3 @@
> -
> -/*
> -   This file is part of Valgrind, a dynamic binary instrumentation
> -   framework.
> -
> -   Copyright (C) 2000-2005 Julian Seward 
> -      jsew...@acm.org
> -
> -   This program is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU General Public License as
> -   published by the Free Software Foundation; either version 2 of the
> -   License, or (at your option) any later version.
> -
> -   This program is distributed in the hope that it will be useful, but
> -   WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   General Public License for more details.
> -
> -   You should have received a copy of the GNU General Public License
> -   along with this program; if not, write to the Free Software
> -   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> -   02111-1307, USA.
> -
> -   The GNU General Public License is contained in the file COPYING.
> -*/
> -
> -#ifndef __VKI_UNISTD_OPENBSD_H
> -#define __VKI_UNISTD_OPENBSD_H
> -
> -#define VG_OPENBSD_SYSCALL_STD       0
> -#define VG_OPENBSD_SYSCALL0  1
> -#define VG_OPENBSD_SYSCALL198        2
> -
> -// From sys/syscall.h
> -
>  #define      __NR_syscall            0
>  #define      __NR_exit               1
>  #define      __NR_fork               2
> @@ -41,7 +6,7 @@
>  #define      __NR_open               5
>  #define      __NR_close              6
>  #define      __NR_getentropy         7
> -#define      __NR___tfork_thread     8
> +#define      __NR___tfork            8
>  #define      __NR_link               9
>  #define      __NR_unlink             10
>  #define      __NR_wait4              11
> @@ -70,7 +35,7 @@
>  #define      __NR_chflags            34
>  #define      __NR_fchflags           35
>  #define      __NR_sync               36
> -#define      __NR_o58_kill           37
> +#define      __NR_msyscall           37
>  #define      __NR_stat               38
>  #define      __NR_getppid            39
>  #define      __NR_lstat              40
> @@ -82,7 +47,7 @@
>  #define      __NR_sigaction          46
>  #define      __NR_getgid             47
>  #define      __NR_sigprocmask        48
> -#define      __NR_getlogin           49
> +#define      __NR_mmap               49
>  #define      __NR_setlogin           50
>  #define      __NR_acct               51
>  #define      __NR_sigpending         52
> @@ -111,7 +76,7 @@
>  #define      __NR_madvise            75
>  #define      __NR_utimes             76
>  #define      __NR_futimes            77
> -#define      __NR_mincore            78
> +#define      __NR_mquery             78
>  #define      __NR_getgroups          79
>  #define      __NR_setgroups          80
>  #define      __NR_getpgrp            81
> @@ -147,6 +112,7 @@
>  #define      __NR_sigsuspend         111
>  #define      __NR_sendsyslog         112
>  #define      __NR_unveil             114
> +#define      __NR___realpath         115
>  #define      __NR_getsockopt         118
>  #define      __NR_thrkill            119
>  #define      __NR_readv              120
> @@ -165,13 +131,23 @@
>  #define      __NR_mkdir              136
>  #define      __NR_rmdir              137
>  #define      __NR_adjtime            140
> +#define      __NR_getlogin_r         141
>  #define      __NR_setsid             147
>  #define      __NR_quotactl           148
> +#define      __NR_ypconnect          150
>  #define      __NR_nfssvc             155
>  #define      __NR_getfh              161
> +#define      __NR___tmpfd            164
>  #define      __NR_sysarch            165
> -#define      __NR_pread              173
> -#define      __NR_pwrite             174
> +#define      __NR_lseek              166
> +#define      __NR_truncate           167
> +#define      __NR_ftruncate          168
> +#define      __NR_pread              169
> +#define      __NR_pwrite             170
> +#define      __NR_preadv             171
> +#define      __NR_pwritev            172
> +#define      __NR_pad_pread          173
> +#define      __NR_pad_pwrite         174
>  #define      __NR_setgid             181
>  #define      __NR_setegid            182
>  #define      __NR_seteuid            183
> @@ -180,11 +156,11 @@
>  #define      __NR_swapctl            193
>  #define      __NR_getrlimit          194
>  #define      __NR_setrlimit          195
> -#define      __NR_mmap               197
> +#define      __NR_pad_mmap           197
>  #define      __NR___syscall          198
> -#define      __NR_lseek              199
> -#define      __NR_truncate           200
> -#define      __NR_ftruncate          201
> +#define      __NR_pad_lseek          199
> +#define      __NR_pad_truncate               200
> +#define      __NR_pad_ftruncate              201
>  #define      __NR_sysctl             202
>  #define      __NR_mlock              203
>  #define      __NR_munlock            204
> @@ -204,8 +180,8 @@
>  #define      __NR_msync              256
>  #define      __NR_pipe               263
>  #define      __NR_fhopen             264
> -#define      __NR_preadv             267
> -#define      __NR_pwritev            268
> +#define      __NR_pad_preadv         267
> +#define      __NR_pad_pwritev                268
>  #define      __NR_kqueue             269
>  #define      __NR_mlockall           271
>  #define      __NR_munlockall         272
> @@ -213,7 +189,7 @@
>  #define      __NR_setresuid          282
>  #define      __NR_getresgid          283
>  #define      __NR_setresgid          284
> -#define      __NR_mquery             286
> +#define      __NR_pad_mquery         286
>  #define      __NR_closefrom          287
>  #define      __NR_sigaltstack        288
>  #define      __NR_shmget             289
> @@ -245,9 +221,4 @@
>  #define      __NR_unlinkat           325
>  #define      __NR___set_tcb          329
>  #define      __NR___get_tcb          330
> -
>  #define      __NR_MAXSYSCALL         331
> -
> -#define __NR_fake_sigreturn  1000
> -
> -#endif /* __VKI_UNISTD_OPENBSD_H */
> 

Reply via email to