Blame SOURCES/valgrind-3.10.1-send-recv-mmsg.patch

2601b6
diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
2601b6
index 4a8d7e1..d093974 100644
2601b6
--- a/coregrind/m_syswrap/priv_syswrap-linux.h
2601b6
+++ b/coregrind/m_syswrap/priv_syswrap-linux.h
2601b6
@@ -305,6 +305,10 @@ extern void ML_(linux_POST_sys_msgctl)     ( TId, UW, UW, UW, UW );
2601b6
 extern void ML_(linux_PRE_sys_getsockopt)  ( TId, UW, UW, UW, UW, UW );
2601b6
 extern void ML_(linux_POST_sys_getsockopt) ( TId, SR, UW, UW, UW, UW, UW );
2601b6
 extern void ML_(linux_PRE_sys_setsockopt)  ( TId, UW, UW, UW, UW, UW );
2601b6
+extern void ML_(linux_PRE_sys_recvmmsg)    ( TId, UW, UW, UW, UW, UW );
2601b6
+extern void ML_(linux_POST_sys_recvmmsg)   ( TId, UW, UW, UW, UW, UW, UW );
2601b6
+extern void ML_(linux_PRE_sys_sendmmsg)    ( TId, UW, UW, UW, UW );
2601b6
+extern void ML_(linux_POST_sys_sendmmsg)   ( TId, UW, UW, UW, UW, UW );
2601b6
 
2601b6
 // Linux-specific (but non-arch-specific) ptrace wrapper helpers
2601b6
 extern void ML_(linux_PRE_getregset) ( ThreadId, long, long );
2601b6
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
2601b6
index 16df075..10c1fc2 100644
2601b6
--- a/coregrind/m_syswrap/syswrap-linux.c
2601b6
+++ b/coregrind/m_syswrap/syswrap-linux.c
2601b6
@@ -4063,6 +4063,20 @@ PRE(sys_socketcall)
2601b6
       ML_(generic_PRE_sys_recvmsg)( tid, "msg", (struct vki_msghdr *)ARG2_1 );
2601b6
       break;
2601b6
 
2601b6
+   case VKI_SYS_RECVMMSG:
2601b6
+      /* int recvmmsg(int s, struct mmsghdr *mmsg, int vlen, int flags,
2601b6
+                      struct timespec *timeout); */
2601b6
+      PRE_MEM_READ_ef("socketcall.recvmmsg(args)", ARG2, 5*sizeof(Addr) );
2601b6
+      ML_(linux_PRE_sys_recvmmsg)( tid, ARG2_0, ARG2_1, ARG2_2, ARG2_3,
2601b6
+                                   ARG2_4 );
2601b6
+      break;
2601b6
+
2601b6
+   case VKI_SYS_SENDMMSG:
2601b6
+      /* int sendmmsg(int s, struct mmsghdr *mmsg, int vlen, int flags); */
2601b6
+      PRE_MEM_READ_ef("socketcall.sendmmsg(args)", ARG2, 4*sizeof(Addr) );
2601b6
+      ML_(linux_PRE_sys_sendmmsg)( tid, ARG2_0, ARG2_1, ARG2_2, ARG2_3 );
2601b6
+      break;
2601b6
+
2601b6
    default:
2601b6
       VG_(message)(Vg_DebugMsg,"Warning: unhandled socketcall 0x%lx\n",ARG1);
2601b6
       SET_STATUS_Failure( VKI_EINVAL );
2601b6
@@ -4168,6 +4182,15 @@ POST(sys_socketcall)
2601b6
       ML_(generic_POST_sys_recvmsg)( tid, "msg", (struct vki_msghdr *)ARG2_1, RES );
2601b6
       break;
2601b6
 
2601b6
+   case VKI_SYS_RECVMMSG:
2601b6
+      ML_(linux_POST_sys_recvmmsg)( tid, RES,
2601b6
+                                    ARG2_0, ARG2_1, ARG2_2, ARG2_3, ARG2_4 );
2601b6
+      break;
2601b6
+
2601b6
+   case VKI_SYS_SENDMMSG:
2601b6
+      ML_(linux_POST_sys_sendmmsg)( tid, RES, ARG2_0, ARG2_1, ARG2_2, ARG2_3 );
2601b6
+      break;
2601b6
+
2601b6
    default:
2601b6
       VG_(message)(Vg_DebugMsg,"FATAL: unhandled socketcall 0x%lx\n",ARG1);
2601b6
       VG_(core_panic)("... bye!\n");
2601b6
@@ -4846,64 +4869,31 @@ PRE(sys_process_vm_writev)
2601b6
 
2601b6
 PRE(sys_sendmmsg)
2601b6
 {
2601b6
-   struct vki_mmsghdr *mmsg = (struct vki_mmsghdr *)ARG2;
2601b6
-   HChar name[32];
2601b6
-   UInt i;
2601b6
    *flags |= SfMayBlock;
2601b6
    PRINT("sys_sendmmsg ( %ld, %#lx, %ld, %ld )",ARG1,ARG2,ARG3,ARG4);
2601b6
    PRE_REG_READ4(long, "sendmmsg",
2601b6
                  int, s, const struct mmsghdr *, mmsg, int, vlen, int, flags);
2601b6
-   for (i = 0; i < ARG3; i++) {
2601b6
-      VG_(sprintf)(name, "mmsg[%u].msg_hdr", i);
2601b6
-      ML_(generic_PRE_sys_sendmsg)(tid, name, &mmsg[i].msg_hdr);
2601b6
-      VG_(sprintf)(name, "sendmmsg(mmsg[%u].msg_len)", i);
2601b6
-      PRE_MEM_WRITE( name, (Addr)&mmsg[i].msg_len, sizeof(mmsg[i].msg_len) );
2601b6
-   }
2601b6
+   ML_(linux_PRE_sys_sendmmsg)(tid, ARG1,ARG2,ARG3,ARG4);
2601b6
 }
2601b6
 
2601b6
 POST(sys_sendmmsg)
2601b6
 {
2601b6
-   if (RES > 0) {
2601b6
-      struct vki_mmsghdr *mmsg = (struct vki_mmsghdr *)ARG2;
2601b6
-      UInt i;
2601b6
-      for (i = 0; i < RES; i++) {
2601b6
-         POST_MEM_WRITE( (Addr)&mmsg[i].msg_len, sizeof(mmsg[i].msg_len) );
2601b6
-      }
2601b6
-   }
2601b6
+   ML_(linux_POST_sys_sendmmsg) (tid, RES, ARG1,ARG2,ARG3,ARG4);
2601b6
 }
2601b6
 
2601b6
 PRE(sys_recvmmsg)
2601b6
 {
2601b6
-   struct vki_mmsghdr *mmsg = (struct vki_mmsghdr *)ARG2;
2601b6
-   HChar name[32];
2601b6
-   UInt i;
2601b6
    *flags |= SfMayBlock;
2601b6
    PRINT("sys_recvmmsg ( %ld, %#lx, %ld, %ld, %#lx )",ARG1,ARG2,ARG3,ARG4,ARG5);
2601b6
    PRE_REG_READ5(long, "recvmmsg",
2601b6
                  int, s, struct mmsghdr *, mmsg, int, vlen,
2601b6
                  int, flags, struct timespec *, timeout);
2601b6
-   for (i = 0; i < ARG3; i++) {
2601b6
-      VG_(sprintf)(name, "mmsg[%u].msg_hdr", i);
2601b6
-      ML_(generic_PRE_sys_recvmsg)(tid, name, &mmsg[i].msg_hdr);
2601b6
-      VG_(sprintf)(name, "recvmmsg(mmsg[%u].msg_len)", i);
2601b6
-      PRE_MEM_WRITE( name, (Addr)&mmsg[i].msg_len, sizeof(mmsg[i].msg_len) );
2601b6
-   }
2601b6
-   if (ARG5)
2601b6
-      PRE_MEM_READ( "recvmmsg(timeout)", ARG5, sizeof(struct vki_timespec) );
2601b6
+   ML_(linux_PRE_sys_recvmmsg)(tid, ARG1,ARG2,ARG3,ARG4,ARG5);
2601b6
 }
2601b6
 
2601b6
 POST(sys_recvmmsg)
2601b6
 {
2601b6
-   if (RES > 0) {
2601b6
-      struct vki_mmsghdr *mmsg = (struct vki_mmsghdr *)ARG2;
2601b6
-      HChar name[32];
2601b6
-      UInt i;
2601b6
-      for (i = 0; i < RES; i++) {
2601b6
-         VG_(sprintf)(name, "mmsg[%u].msg_hdr", i);
2601b6
-         ML_(generic_POST_sys_recvmsg)(tid, name, &mmsg[i].msg_hdr, mmsg[i].msg_len);
2601b6
-         POST_MEM_WRITE( (Addr)&mmsg[i].msg_len, sizeof(mmsg[i].msg_len) );
2601b6
-      }
2601b6
-   }
2601b6
+   ML_(linux_POST_sys_recvmmsg) (tid, RES, ARG1,ARG2,ARG3,ARG4,ARG5);
2601b6
 }
2601b6
 
2601b6
 /* ---------------------------------------------------------------------
2601b6
@@ -10271,6 +10261,69 @@ ML_(linux_PRE_sys_setsockopt) ( ThreadId tid,
2601b6
    }
2601b6
 }
2601b6
 
2601b6
+void
2601b6
+ML_(linux_PRE_sys_recvmmsg) ( ThreadId tid,
2601b6
+                              UWord arg1, UWord arg2, UWord arg3,
2601b6
+                              UWord arg4, UWord arg5 )
2601b6
+{
2601b6
+   struct vki_mmsghdr *mmsg = (struct vki_mmsghdr *)arg2;
2601b6
+   HChar name[40];     // large enough
2601b6
+   UInt i;
2601b6
+   for (i = 0; i < arg3; i++) {
2601b6
+      VG_(sprintf)(name, "mmsg[%u].msg_hdr", i);
2601b6
+      ML_(generic_PRE_sys_recvmsg)(tid, name, &mmsg[i].msg_hdr);
2601b6
+      VG_(sprintf)(name, "recvmmsg(mmsg[%u].msg_len)", i);
2601b6
+      PRE_MEM_WRITE( name, (Addr)&mmsg[i].msg_len, sizeof(mmsg[i].msg_len) );
2601b6
+   }
2601b6
+   if (arg5)
2601b6
+      PRE_MEM_READ( "recvmmsg(timeout)", arg5, sizeof(struct vki_timespec) );
2601b6
+}
2601b6
+
2601b6
+void
2601b6
+ML_(linux_POST_sys_recvmmsg) (ThreadId tid, UWord res,
2601b6
+                              UWord arg1, UWord arg2, UWord arg3,
2601b6
+                              UWord arg4, UWord arg5 )
2601b6
+{
2601b6
+   if (res > 0) {
2601b6
+      struct vki_mmsghdr *mmsg = (struct vki_mmsghdr *)arg2;
2601b6
+      HChar name[32];    // large enough
2601b6
+      UInt i;
2601b6
+      for (i = 0; i < res; i++) {
2601b6
+         VG_(sprintf)(name, "mmsg[%u].msg_hdr", i);
2601b6
+         ML_(generic_POST_sys_recvmsg)(tid, name, &mmsg[i].msg_hdr, mmsg[i].msg_len);
2601b6
+         POST_MEM_WRITE( (Addr)&mmsg[i].msg_len, sizeof(mmsg[i].msg_len) );
2601b6
+      }
2601b6
+   }
2601b6
+}
2601b6
+
2601b6
+void
2601b6
+ML_(linux_PRE_sys_sendmmsg) ( ThreadId tid,
2601b6
+                              UWord arg1, UWord arg2, UWord arg3, UWord arg4 )
2601b6
+{
2601b6
+   struct vki_mmsghdr *mmsg = (struct vki_mmsghdr *)arg2;
2601b6
+   HChar name[40];     // large enough
2601b6
+   UInt i;
2601b6
+   for (i = 0; i < arg3; i++) {
2601b6
+      VG_(sprintf)(name, "mmsg[%u].msg_hdr", i);
2601b6
+      ML_(generic_PRE_sys_sendmsg)(tid, name, &mmsg[i].msg_hdr);
2601b6
+      VG_(sprintf)(name, "sendmmsg(mmsg[%u].msg_len)", i);
2601b6
+      PRE_MEM_WRITE( name, (Addr)&mmsg[i].msg_len, sizeof(mmsg[i].msg_len) );
2601b6
+   }
2601b6
+}
2601b6
+
2601b6
+void
2601b6
+ML_(linux_POST_sys_sendmmsg) (ThreadId tid, UWord res,
2601b6
+                              UWord arg1, UWord arg2, UWord arg3, UWord arg4 )
2601b6
+{
2601b6
+   if (res > 0) {
2601b6
+      struct vki_mmsghdr *mmsg = (struct vki_mmsghdr *)arg2;
2601b6
+      UInt i;
2601b6
+      for (i = 0; i < res; i++) {
2601b6
+         POST_MEM_WRITE( (Addr)&mmsg[i].msg_len, sizeof(mmsg[i].msg_len) );
2601b6
+      }
2601b6
+   }
2601b6
+}
2601b6
+
2601b6
 /* ---------------------------------------------------------------------
2601b6
    ptrace wrapper helpers
2601b6
    ------------------------------------------------------------------ */
2601b6
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
2601b6
index bf3ffee..af5cbaf 100644
2601b6
--- a/include/vki/vki-linux.h
2601b6
+++ b/include/vki/vki-linux.h
2601b6
@@ -596,6 +596,8 @@ typedef struct vki_sigevent {
2601b6
 #define VKI_SYS_SENDMSG		16	/* sys_sendmsg(2)		*/
2601b6
 #define VKI_SYS_RECVMSG		17	/* sys_recvmsg(2)		*/
2601b6
 #define VKI_SYS_ACCEPT4		18	/* sys_accept4(2)		*/
2601b6
+#define VKI_SYS_RECVMMSG	19	/* sys_recvmmsg(2)              */
2601b6
+#define VKI_SYS_SENDMMSG	20	/* sys_sendmmsg(2)              */
2601b6
 
2601b6
 #ifndef ARCH_HAS_SOCKET_TYPES
2601b6
 enum vki_sock_type {
2601b6
commit 4b2fb567b7422b2563c52a0ff2c1c166264a02e0
2601b6
Author: mjw <mjw@a5019735-40e9-0310-863c-91ae7b9d1cf9>
2601b6
Date:   Tue Feb 17 16:04:09 2015 +0000
2601b6
2601b6
    Bug #344279 syscall sendmmsg on arm64 (269) and ppc32/64 (349) unhandled.
2601b6
    
2601b6
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14939 a5019735-40e9-0310-863c-91ae7b9d1cf9
2601b6
2601b6
diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
2601b6
index 1f9670a..e8f4a3e 100644
2601b6
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
2601b6
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
2601b6
@@ -1043,6 +1043,7 @@ static SyscallTableEntry syscall_main_table[] = {
2601b6
    LINXY(__NR_accept4,           sys_accept4),           // 242
2601b6
    GENXY(__NR_wait4,             sys_wait4),             // 260
2601b6
 
2601b6
+   LINXY(__NR_sendmmsg,          sys_sendmmsg),          // 269
2601b6
    LINXY(__NR_process_vm_readv,  sys_process_vm_readv),  // 270
2601b6
    LINX_(__NR_process_vm_writev, sys_process_vm_writev), // 271
2601b6
    LINXY(__NR_getrandom,         sys_getrandom),         // 278
2601b6
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
2601b6
index 6b53abe..2ce6673 100644
2601b6
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
2601b6
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
2601b6
@@ -1255,6 +1255,8 @@ static SyscallTableEntry syscall_table[] = {
2601b6
 
2601b6
    LINX_(__NR_clock_adjtime,     sys_clock_adjtime),    // 347
2601b6
 
2601b6
+   LINXY(__NR_sendmmsg,          sys_sendmmsg),         // 349
2601b6
+
2601b6
    LINXY(__NR_process_vm_readv,  sys_process_vm_readv), // 351
2601b6
    LINX_(__NR_process_vm_writev, sys_process_vm_writev),// 352
2601b6
 
2601b6
diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
2601b6
index 8d5fa08..f18a10c 100644
2601b6
--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
2601b6
+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
2601b6
@@ -1156,6 +1156,8 @@ static SyscallTableEntry syscall_table[] = {
2601b6
 
2601b6
    LINXY(__NR_clock_adjtime,     sys_clock_adjtime),    // 347
2601b6
 
2601b6
+   LINXY(__NR_sendmmsg,          sys_sendmmsg),         // 349
2601b6
+
2601b6
    LINXY(__NR_process_vm_readv,  sys_process_vm_readv), // 351
2601b6
    LINX_(__NR_process_vm_writev, sys_process_vm_writev),// 352
2601b6
 
2601b6
2601b6
diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
2601b6
index e8f4a3e..7b7e824 100644
2601b6
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
2601b6
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
2601b6
@@ -1040,7 +1040,10 @@ static SyscallTableEntry syscall_main_table[] = {
2601b6
    LINX_(__NR_mbind,             sys_mbind),             // 235
2601b6
    LINXY(__NR_get_mempolicy,     sys_get_mempolicy),     // 236
2601b6
    LINX_(__NR_set_mempolicy,     sys_set_mempolicy),     // 237
2601b6
+
2601b6
+   LINXY(__NR_recvmmsg,          sys_recvmmsg),          // 243
2601b6
    LINXY(__NR_accept4,           sys_accept4),           // 242
2601b6
+
2601b6
    GENXY(__NR_wait4,             sys_wait4),             // 260
2601b6
 
2601b6
    LINXY(__NR_sendmmsg,          sys_sendmmsg),          // 269
2601b6
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
2601b6
index 2ce6673..7f09fc4 100644
2601b6
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
2601b6
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
2601b6
@@ -1251,6 +1251,7 @@ static SyscallTableEntry syscall_table[] = {
2601b6
    LINX_(__NR_shutdown,          sys_shutdown),         // 338
2601b6
    LINX_(__NR_setsockopt,        sys_setsockopt),       // 339
2601b6
 
2601b6
+   LINXY(__NR_recvmmsg,          sys_recvmmsg),         // 343
2601b6
    LINXY(__NR_accept4,           sys_accept4),          // 344
2601b6
 
2601b6
    LINX_(__NR_clock_adjtime,     sys_clock_adjtime),    // 347
2601b6
diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
2601b6
index f18a10c..b309f43 100644
2601b6
--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
2601b6
+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
2601b6
@@ -1152,6 +1152,7 @@ static SyscallTableEntry syscall_table[] = {
2601b6
    LINX_(__NR_pwritev,           sys_pwritev),          // 321
2601b6
    LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo),// 322
2601b6
 
2601b6
+   LINXY(__NR_recvmmsg,          sys_recvmmsg),         // 343
2601b6
    LINXY(__NR_accept4,           sys_accept4),          // 344
2601b6
 
2601b6
    LINXY(__NR_clock_adjtime,     sys_clock_adjtime),    // 347