From a6dd09428707bfb87e27abcb0c8f7066e2eaf988 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 11 May 2016 00:42:10 +0000 Subject: [PATCH] Implement decoding of preadv2 and pwritev2 syscalls * io.c: Include "xlat/rwf_flags.h". (do_preadv, do_pwritev, SYS_FUNC(preadv2), SYS_FUNC(pwritev2)): New functions. (SYS_FUNC(preadv)): Use do_preadv. (SYS_FUNC(pwritev)): Use do_pwritev. * linux/32/syscallent.h (preadv2, pwritev2): New entries. * linux/64/syscallent.h: Likewise. * linux/arm/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/i386/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/m68k/syscallent.h: Likewise. * linux/mips/syscallent-n32.h: Likewise. * linux/mips/syscallent-n64.h: Likewise. * linux/mips/syscallent-o32.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/powerpc64/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * syscall.c (dumpio): Handle SEN_preadv2 and SEN_pwritev2. * xlat/rwf_flags.in: New file. * NEWS: Mention parsers of new syscalls. --- NEWS | 5 +++-- io.c | 36 ++++++++++++++++++++++++++++++++++-- linux/32/syscallent.h | 2 ++ linux/64/syscallent.h | 2 ++ linux/arm/syscallent.h | 2 ++ linux/hppa/syscallent.h | 2 ++ linux/i386/syscallent.h | 2 ++ linux/ia64/syscallent.h | 2 ++ linux/m68k/syscallent.h | 2 ++ linux/mips/syscallent-n32.h | 2 ++ linux/mips/syscallent-n64.h | 2 ++ linux/mips/syscallent-o32.h | 2 ++ linux/powerpc/syscallent.h | 2 ++ linux/powerpc64/syscallent.h | 2 ++ linux/s390/syscallent.h | 2 ++ linux/s390x/syscallent.h | 2 ++ linux/sparc/syscallent.h | 2 ++ linux/sparc64/syscallent.h | 2 ++ linux/x32/syscallent.h | 2 ++ linux/x86_64/syscallent.h | 2 ++ syscall.c | 2 ++ xlat/rwf_flags.in | 1 + 22 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 xlat/rwf_flags.in diff --git a/NEWS b/NEWS index 08e23093..e12fb459 100644 --- a/NEWS +++ b/NEWS @@ -10,8 +10,9 @@ Noteworthy changes in release ?.?? (????-??-??) * Added decoding of bind, listen, and setsockopt direct syscalls on sparc. * Implemented caching of netlink conversations to reduce amount of time spent in decoding socket details in -yy mode. - * Implemented decoding of copy_file_range syscall. - * Implemented dumping of preadv, pwritev, and vmsplice syscalls. + * Implemented decoding of copy_file_range, preadv2, and pwritev2 syscalls. + * Implemented dumping of preadv, preadv2, pwritev, pwritev2, and vmsplice + syscalls. * Updated lists of ioctl commands from Linux 4.5. * Bug fixes diff --git a/io.c b/io.c index a52904cf..3c4ef592 100644 --- a/io.c +++ b/io.c @@ -207,7 +207,10 @@ print_lld_from_low_high_val(struct tcb *tcp, int arg) #endif } -SYS_FUNC(preadv) +#include "xlat/rwf_flags.h" + +static int +do_preadv(struct tcb *tcp, const int flags_arg) { if (entering(tcp)) { printfd(tcp, tcp->u_arg[0]); @@ -217,21 +220,50 @@ SYS_FUNC(preadv) tcp->u_rval); tprintf(", %lu, ", tcp->u_arg[2]); print_lld_from_low_high_val(tcp, 3); + if (flags_arg >= 0) { + tprints(", "); + printflags(rwf_flags, tcp->u_arg[flags_arg], "RWF_???"); + } } return 0; } -SYS_FUNC(pwritev) +SYS_FUNC(preadv) +{ + return do_preadv(tcp, -1); +} + +SYS_FUNC(preadv2) +{ + return do_preadv(tcp, 5); +} + +static int +do_pwritev(struct tcb *tcp, const int flags_arg) { printfd(tcp, tcp->u_arg[0]); tprints(", "); tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1); tprintf(", %lu, ", tcp->u_arg[2]); print_lld_from_low_high_val(tcp, 3); + if (flags_arg >= 0) { + tprints(", "); + printflags(rwf_flags, tcp->u_arg[flags_arg], "RWF_???"); + } return RVAL_DECODED; } +SYS_FUNC(pwritev) +{ + return do_pwritev(tcp, -1); +} + +SYS_FUNC(pwritev2) +{ + return do_pwritev(tcp, 5); +} + #include "xlat/splice_flags.h" SYS_FUNC(tee) diff --git a/linux/32/syscallent.h b/linux/32/syscallent.h index 03874ac8..9c864855 100644 --- a/linux/32/syscallent.h +++ b/linux/32/syscallent.h @@ -276,6 +276,8 @@ [283] = { 2, 0, SEN(membarrier), "membarrier", }, [284] = { 3, TM, SEN(mlock2), "mlock2" }, [285] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[286] = { 6, TD, SEN(preadv2), "preadv2" }, +[287] = { 6, TD, SEN(pwritev2), "pwritev2" }, #undef sys_ARCH_mmap #undef ARCH_WANT_SYNC_FILE_RANGE2 diff --git a/linux/64/syscallent.h b/linux/64/syscallent.h index fc78605f..55c011cf 100644 --- a/linux/64/syscallent.h +++ b/linux/64/syscallent.h @@ -269,3 +269,5 @@ [283] = { 2, 0, SEN(membarrier), "membarrier", }, [284] = { 3, TM, SEN(mlock2), "mlock2" }, [285] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[286] = { 6, TD, SEN(preadv2), "preadv2" }, +[287] = { 6, TD, SEN(pwritev2), "pwritev2" }, diff --git a/linux/arm/syscallent.h b/linux/arm/syscallent.h index 52605518..18910e4b 100644 --- a/linux/arm/syscallent.h +++ b/linux/arm/syscallent.h @@ -416,6 +416,8 @@ [389] = { 2, 0, SEN(membarrier), "membarrier", }, [390] = { 3, TM, SEN(mlock2), "mlock2" }, [391] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[392] = { 6, TD, SEN(preadv2), "preadv2" }, +[393] = { 6, TD, SEN(pwritev2), "pwritev2" }, #ifdef __ARM_EABI__ # define ARM_FIRST_SHUFFLED_SYSCALL 400 diff --git a/linux/hppa/syscallent.h b/linux/hppa/syscallent.h index a22e73e7..49280479 100644 --- a/linux/hppa/syscallent.h +++ b/linux/hppa/syscallent.h @@ -349,3 +349,5 @@ [344] = { 1, TD, SEN(userfaultfd), "userfaultfd", }, [345] = { 3, TM, SEN(mlock2), "mlock2" }, [346] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[347] = { 6, TD, SEN(preadv2), "preadv2" }, +[348] = { 6, TD, SEN(pwritev2), "pwritev2" }, diff --git a/linux/i386/syscallent.h b/linux/i386/syscallent.h index 1bba2e73..d6175fae 100644 --- a/linux/i386/syscallent.h +++ b/linux/i386/syscallent.h @@ -403,6 +403,8 @@ [375] = { 2, 0, SEN(membarrier), "membarrier", }, [376] = { 3, TM, SEN(mlock2), "mlock2" }, [377] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[378] = { 6, TD, SEN(preadv2), "preadv2" }, +[379] = { 6, TD, SEN(pwritev2), "pwritev2" }, #define SYS_socket_subcall 400 #include "subcall.h" diff --git a/linux/ia64/syscallent.h b/linux/ia64/syscallent.h index 911e21f3..713cab89 100644 --- a/linux/ia64/syscallent.h +++ b/linux/ia64/syscallent.h @@ -364,3 +364,5 @@ [1345] = { 5, 0, SEN(kcmp), "kcmp" }, [1346] = { 3, TM, SEN(mlock2), "mlock2" }, [1347] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[1348] = { 6, TD, SEN(preadv2), "preadv2" }, +[1349] = { 6, TD, SEN(pwritev2), "pwritev2" }, diff --git a/linux/m68k/syscallent.h b/linux/m68k/syscallent.h index a7652e33..0f4895c5 100644 --- a/linux/m68k/syscallent.h +++ b/linux/m68k/syscallent.h @@ -402,6 +402,8 @@ [374] = { 2, 0, SEN(membarrier), "membarrier", }, [375] = { 3, TM, SEN(mlock2), "mlock2" }, [376] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[377] = { 6, TD, SEN(preadv2), "preadv2" }, +[378] = { 6, TD, SEN(pwritev2), "pwritev2" }, #define SYS_socket_subcall 400 #include "subcall.h" diff --git a/linux/mips/syscallent-n32.h b/linux/mips/syscallent-n32.h index 9084fda7..398b12c9 100644 --- a/linux/mips/syscallent-n32.h +++ b/linux/mips/syscallent-n32.h @@ -325,6 +325,8 @@ [6322] = { 2, 0, SEN(membarrier), "membarrier", }, [6323] = { 3, TM, SEN(mlock2), "mlock2" }, [6324] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[6325] = { 6, TD, SEN(preadv2), "preadv2" }, +[6326] = { 6, TD, SEN(pwritev2), "pwritev2" }, # define SYS_socket_subcall 6400 # include "subcall.h" diff --git a/linux/mips/syscallent-n64.h b/linux/mips/syscallent-n64.h index c1ecddd6..7321f0e7 100644 --- a/linux/mips/syscallent-n64.h +++ b/linux/mips/syscallent-n64.h @@ -321,6 +321,8 @@ [5318] = { 2, 0, SEN(membarrier), "membarrier", }, [5319] = { 3, TM, SEN(mlock2), "mlock2" }, [5320] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[5321] = { 6, TD, SEN(preadv2), "preadv2" }, +[5322] = { 6, TD, SEN(pwritev2), "pwritev2" }, # define SYS_socket_subcall 5400 # include "subcall.h" diff --git a/linux/mips/syscallent-o32.h b/linux/mips/syscallent-o32.h index f65be702..cb8afb96 100644 --- a/linux/mips/syscallent-o32.h +++ b/linux/mips/syscallent-o32.h @@ -361,6 +361,8 @@ [4358] = { 2, 0, SEN(membarrier), "membarrier", }, [4359] = { 3, TM, SEN(mlock2), "mlock2" }, [4360] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[4361] = { 6, TD, SEN(preadv2), "preadv2" }, +[4362] = { 6, TD, SEN(pwritev2), "pwritev2" }, # define SYS_socket_subcall 4400 # include "subcall.h" diff --git a/linux/powerpc/syscallent.h b/linux/powerpc/syscallent.h index d4c9402c..b6dfb850 100644 --- a/linux/powerpc/syscallent.h +++ b/linux/powerpc/syscallent.h @@ -406,6 +406,8 @@ [377] = { 3, TI, SEN(shmctl), "shmctl" }, [378] = { 3, TM, SEN(mlock2), "mlock2" }, [379] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[380] = { 6, TD, SEN(preadv2), "preadv2" }, +[381] = { 6, TD, SEN(pwritev2), "pwritev2" }, #define SYS_socket_subcall 400 #include "subcall.h" diff --git a/linux/powerpc64/syscallent.h b/linux/powerpc64/syscallent.h index 1239a6f2..e0c18af4 100644 --- a/linux/powerpc64/syscallent.h +++ b/linux/powerpc64/syscallent.h @@ -401,6 +401,8 @@ [377] = { 3, TI, SEN(shmctl), "shmctl" }, [378] = { 3, TM, SEN(mlock2), "mlock2" }, [379] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[380] = { 6, TD, SEN(preadv2), "preadv2" }, +[381] = { 6, TD, SEN(pwritev2), "pwritev2" }, #define SYS_socket_subcall 400 #include "subcall.h" diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h index 92b5c9c6..af300e97 100644 --- a/linux/s390/syscallent.h +++ b/linux/s390/syscallent.h @@ -404,6 +404,8 @@ [373] = { 2, TN, SEN(shutdown), "shutdown" }, [374] = { 3, TM, SEN(mlock2), "mlock2" }, [375] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[376] = { 6, TD, SEN(preadv2), "preadv2" }, +[377] = { 6, TD, SEN(pwritev2), "pwritev2" }, #define SYS_socket_subcall 400 #include "subcall.h" diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h index fcbe69dd..f41f2eb8 100644 --- a/linux/s390x/syscallent.h +++ b/linux/s390x/syscallent.h @@ -388,6 +388,8 @@ [373] = { 2, TN, SEN(shutdown), "shutdown" }, [374] = { 3, TM, SEN(mlock2), "mlock2" }, [375] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[376] = { 6, TD, SEN(preadv2), "preadv2" }, +[377] = { 6, TD, SEN(pwritev2), "pwritev2" }, #define SYS_socket_subcall 400 #include "subcall.h" diff --git a/linux/sparc/syscallent.h b/linux/sparc/syscallent.h index 89b22247..ec86f7e7 100644 --- a/linux/sparc/syscallent.h +++ b/linux/sparc/syscallent.h @@ -356,6 +356,8 @@ [355] = { 5, TN, SEN(setsockopt), "setsockopt" }, [356] = { 3, TM, SEN(mlock2), "mlock2" }, [357] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[358] = { 6, TD, SEN(preadv2), "preadv2" }, +[359] = { 6, TD, SEN(pwritev2), "pwritev2" }, #define SYS_socket_subcall 400 #include "subcall.h" diff --git a/linux/sparc64/syscallent.h b/linux/sparc64/syscallent.h index 23de9c9b..8bf5c3a4 100644 --- a/linux/sparc64/syscallent.h +++ b/linux/sparc64/syscallent.h @@ -354,6 +354,8 @@ [355] = { 5, TN, SEN(setsockopt), "setsockopt" }, [356] = { 3, TM, SEN(mlock2), "mlock2" }, [357] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[358] = { 6, TD, SEN(preadv2), "preadv2" }, +[359] = { 6, TD, SEN(pwritev2), "pwritev2" }, #define SYS_socket_subcall 400 #include "subcall.h" diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h index 5ef4a667..965a5dcc 100644 --- a/linux/x32/syscallent.h +++ b/linux/x32/syscallent.h @@ -325,6 +325,8 @@ [324] = { 2, 0, SEN(membarrier), "membarrier", }, [325] = { 3, TM, SEN(mlock2), "mlock2" }, [326] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[327] = { 6, TD, SEN(printargs), "64:preadv2" }, +[328] = { 6, TD, SEN(printargs), "64:pwritev2" }, [327 ... 511] = { }, /* * x32-specific system call numbers start at 512 to avoid cache impact diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h index 52d73bf0..265d55f0 100644 --- a/linux/x86_64/syscallent.h +++ b/linux/x86_64/syscallent.h @@ -325,3 +325,5 @@ [324] = { 2, 0, SEN(membarrier), "membarrier", }, [325] = { 3, TM, SEN(mlock2), "mlock2" }, [326] = { 6, TD, SEN(copy_file_range), "copy_file_range" }, +[327] = { 6, TD, SEN(preadv2), "preadv2" }, +[328] = { 6, TD, SEN(pwritev2), "pwritev2" }, diff --git a/syscall.c b/syscall.c index 6c5119f3..d71ead34 100644 --- a/syscall.c +++ b/syscall.c @@ -686,6 +686,7 @@ dumpio(struct tcb *tcp) return; case SEN_readv: case SEN_preadv: + case SEN_preadv2: dumpiov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], tcp->u_rval); return; @@ -707,6 +708,7 @@ dumpio(struct tcb *tcp) break; case SEN_writev: case SEN_pwritev: + case SEN_pwritev2: case SEN_vmsplice: dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]); break; diff --git a/xlat/rwf_flags.in b/xlat/rwf_flags.in new file mode 100644 index 00000000..2f97916f --- /dev/null +++ b/xlat/rwf_flags.in @@ -0,0 +1 @@ +RWF_HIPRI 1