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