Home | History | Annotate | Download | only in m_syswrap
      1 
      2 /*--------------------------------------------------------------------*/
      3 /*--- Platform-specific syscalls stuff.      syswrap-s390x-linux.c ---*/
      4 /*--------------------------------------------------------------------*/
      5 
      6 /*
      7    This file is part of Valgrind, a dynamic binary instrumentation
      8    framework.
      9 
     10    Copyright IBM Corp. 2010-2015
     11 
     12    This program is free software; you can redistribute it and/or
     13    modify it under the terms of the GNU General Public License as
     14    published by the Free Software Foundation; either version 2 of the
     15    License, or (at your option) any later version.
     16 
     17    This program is distributed in the hope that it will be useful, but
     18    WITHOUT ANY WARRANTY; without even the implied warranty of
     19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     20    General Public License for more details.
     21 
     22    You should have received a copy of the GNU General Public License
     23    along with this program; if not, write to the Free Software
     24    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     25    02111-1307, USA.
     26 
     27    The GNU General Public License is contained in the file COPYING.
     28 */
     29 
     30 /* Contributed by Christian Borntraeger */
     31 
     32 #if defined(VGP_s390x_linux)
     33 
     34 #include "pub_core_basics.h"
     35 #include "pub_core_vki.h"
     36 #include "pub_core_vkiscnums.h"
     37 #include "pub_core_threadstate.h"
     38 #include "pub_core_aspacemgr.h"
     39 #include "pub_core_debuglog.h"
     40 #include "pub_core_libcbase.h"
     41 #include "pub_core_libcassert.h"
     42 #include "pub_core_libcprint.h"
     43 #include "pub_core_libcproc.h"
     44 #include "pub_core_libcsignal.h"
     45 #include "pub_core_mallocfree.h"
     46 #include "pub_core_options.h"
     47 #include "pub_core_scheduler.h"
     48 #include "pub_core_sigframe.h"      // For VG_(sigframe_destroy)()
     49 #include "pub_core_signals.h"
     50 #include "pub_core_syscall.h"
     51 #include "pub_core_syswrap.h"
     52 #include "pub_core_tooliface.h"
     53 
     54 #include "priv_types_n_macros.h"
     55 #include "priv_syswrap-generic.h"    /* for decls of generic wrappers */
     56 #include "priv_syswrap-linux.h"      /* for decls of linux-ish wrappers */
     57 #include "priv_syswrap-linux-variants.h" /* decls of linux variant wrappers */
     58 #include "priv_syswrap-main.h"
     59 
     60 
     61 /* ---------------------------------------------------------------------
     62    clone() handling
     63    ------------------------------------------------------------------ */
     64 
     65 /* Call f(arg1), but first switch stacks, using 'stack' as the new
     66    stack, and use 'retaddr' as f's return-to address.  Also, clear all
     67    the integer registers before entering f.
     68    Thought: Why are we clearing the GPRs ? The callee pointed to by f
     69    is a regular C function which will play by the ABI rules. So there is
     70    no need to zero out the GPRs. If we assumed that f accesses registers at
     71    will, then it would make sense to create a defined register state.
     72    But then, why only for the GPRs and not the FPRs ? */
     73 __attribute__((noreturn))
     74 void ML_(call_on_new_stack_0_1) ( Addr stack,
     75                                   Addr retaddr,
     76                                   void (*f)(Word),
     77                                   Word arg1 );
     78 /* Upon entering this function we have the following setup:
     79      r2 = stack
     80      r3 = retaddr
     81      r4 = f_desc
     82      r5 = arg1
     83 */
     84 asm(
     85     ".text\n"
     86     ".align 4\n"
     87     ".globl vgModuleLocal_call_on_new_stack_0_1\n"
     88     ".type vgModuleLocal_call_on_new_stack_0_1, @function\n"
     89     "vgModuleLocal_call_on_new_stack_0_1:\n"
     90     "   lgr %r15,%r2\n"     // stack to r15
     91     "   lgr %r14,%r3\n"     // retaddr to r14
     92     "   lgr %r2,%r5\n"      // arg1 to r2
     93     // zero all gprs to get a defined state
     94     "   lghi  %r0,0\n"
     95     "   lghi  %r1,0\n"
     96     // r2 holds the argument for the callee
     97     "   lghi  %r3,0\n"
     98     // r4 holds the callee address
     99     "   lghi  %r5,0\n"
    100     "   lghi  %r6,0\n"
    101     "   lghi  %r7,0\n"
    102     "   lghi  %r8,0\n"
    103     "   lghi  %r9,0\n"
    104     "   lghi  %r10,0\n"
    105     "   lghi  %r11,0\n"
    106     "   lghi  %r12,0\n"
    107     "   lghi  %r13,0\n"
    108     // r14 holds the return address for the callee
    109     // r15 is the stack pointer
    110     "   br  %r4\n"          // jump to f
    111     ".previous\n"
    112     );
    113 
    114 /*
    115         Perform a clone system call.  clone is strange because it has
    116         fork()-like return-twice semantics, so it needs special
    117         handling here.
    118 
    119         Upon entry, we have:
    120             void*  child_stack   in r2
    121             long   flags         in r3
    122             int*   parent_tid    in r4
    123             int*   child_tid     in r5
    124             int*   tls address   in r6
    125             Word   (*fn)(void *) 160(r15)
    126             void   *arg          168(r15)
    127 
    128         System call requires:
    129             void*  child_stack  in r2  (sc arg1)
    130             long   flags        in r3  (sc arg2)
    131             int*   parent_tid   in r4  (sc arg3)
    132             int*   child_tid    in r5  (sc arg4)
    133             void*  tlsaddr      in r6  (sc arg5)
    134 
    135         Returns a ULong encoded as: top half is %cr following syscall,
    136         low half is syscall return value (r3).
    137  */
    138 #define __NR_CLONE        VG_STRINGIFY(__NR_clone)
    139 #define __NR_EXIT         VG_STRINGIFY(__NR_exit)
    140 
    141 extern
    142 ULong do_syscall_clone_s390x_linux ( void  *stack,
    143                                      ULong flags,
    144                                      Int   *parent_tid,
    145                                      Int   *child_tid,
    146                                      Addr  tlsaddr,
    147                                      Word (*fn)(void *),
    148                                      void  *arg);
    149 asm(
    150    "   .text\n"
    151    "   .align  4\n"
    152    ".globl do_syscall_clone_s390x_linux\n"
    153    "do_syscall_clone_s390x_linux:\n"
    154    "   lg    %r1, 160(%r15)\n"   // save fn from parent stack into r1
    155    "   lg    %r0, 168(%r15)\n"   // save arg from parent stack into r0
    156    "   aghi  %r2, -160\n"        // create stack frame for child
    157    // all syscall parameters are already in place (r2-r6)
    158    "   svc " __NR_CLONE"\n"        // clone()
    159    "   ltgr  %r2,%r2\n"           // child if retval == 0
    160    "   jne   1f\n"
    161 
    162    // CHILD - call thread function
    163    "   lgr   %r2, %r0\n"            // get arg from r0
    164    "   basr  %r14,%r1\n"            // call fn
    165 
    166    // exit. The result is already in r2
    167    "   svc " __NR_EXIT"\n"
    168 
    169    // Exit returned?!
    170    "   j +2\n"
    171 
    172    "1:\n"  // PARENT or ERROR
    173    "   br %r14\n"
    174    ".previous\n"
    175 );
    176 
    177 #undef __NR_CLONE
    178 #undef __NR_EXIT
    179 
    180 void VG_(cleanup_thread) ( ThreadArchState* arch )
    181 {
    182   /* only used on x86 for descriptor tables */
    183 }
    184 
    185 static void setup_child ( /*OUT*/ ThreadArchState *child,
    186                    /*IN*/  ThreadArchState *parent )
    187 {
    188    /* We inherit our parent's guest state. */
    189    child->vex = parent->vex;
    190    child->vex_shadow1 = parent->vex_shadow1;
    191    child->vex_shadow2 = parent->vex_shadow2;
    192 }
    193 
    194 
    195 /*
    196    When a client clones, we need to keep track of the new thread.  This means:
    197    1. allocate a ThreadId+ThreadState+stack for the thread
    198 
    199    2. initialize the thread's new VCPU state
    200 
    201    3. create the thread using the same args as the client requested,
    202    but using the scheduler entrypoint for IP, and a separate stack
    203    for SP.
    204  */
    205 static SysRes do_clone ( ThreadId ptid,
    206                          Addr sp, ULong flags,
    207                          Int *parent_tidptr,
    208                          Int *child_tidptr,
    209                          Addr tlsaddr)
    210 {
    211    static const Bool debug = False;
    212 
    213    ThreadId     ctid = VG_(alloc_ThreadState)();
    214    ThreadState* ptst = VG_(get_ThreadState)(ptid);
    215    ThreadState* ctst = VG_(get_ThreadState)(ctid);
    216    UWord*       stack;
    217    SysRes       res;
    218    ULong        r2;
    219    vki_sigset_t blockall, savedmask;
    220 
    221    VG_(sigfillset)(&blockall);
    222 
    223    vg_assert(VG_(is_running_thread)(ptid));
    224    vg_assert(VG_(is_valid_tid)(ctid));
    225 
    226    stack = (UWord*)ML_(allocstack)(ctid);
    227    if (stack == NULL) {
    228       res = VG_(mk_SysRes_Error)( VKI_ENOMEM );
    229       goto out;
    230    }
    231 
    232    /* Copy register state
    233 
    234       Both parent and child return to the same place, and the code
    235       following the clone syscall works out which is which, so we
    236       don't need to worry about it.
    237 
    238       The parent gets the child's new tid returned from clone, but the
    239       child gets 0.
    240 
    241       If the clone call specifies a NULL sp for the new thread, then
    242       it actually gets a copy of the parent's sp.
    243    */
    244    setup_child( &ctst->arch, &ptst->arch );
    245 
    246    /* Make sys_clone appear to have returned Success(0) in the
    247       child. */
    248    ctst->arch.vex.guest_r2 = 0;
    249 
    250    if (sp != 0)
    251       ctst->arch.vex.guest_SP = sp;
    252 
    253    ctst->os_state.parent = ptid;
    254 
    255    /* inherit signal mask */
    256    ctst->sig_mask = ptst->sig_mask;
    257    ctst->tmp_sig_mask = ptst->sig_mask;
    258 
    259    /* have the parents thread group */
    260    ctst->os_state.threadgroup = ptst->os_state.threadgroup;
    261 
    262    ML_(guess_and_register_stack) (sp, ctst);
    263 
    264    /* Assume the clone will succeed, and tell any tool that wants to
    265       know that this thread has come into existence.  If the clone
    266       fails, we'll send out a ll_exit notification for it at the out:
    267       label below, to clean up. */
    268    vg_assert(VG_(owns_BigLock_LL)(ptid));
    269    VG_TRACK ( pre_thread_ll_create, ptid, ctid );
    270 
    271    if (flags & VKI_CLONE_SETTLS) {
    272       if (debug)
    273 	 VG_(printf)("clone child has SETTLS: tls at %#lx\n", tlsaddr);
    274       ctst->arch.vex.guest_a0 = (UInt) (tlsaddr >> 32);
    275       ctst->arch.vex.guest_a1 = (UInt) tlsaddr;
    276    }
    277    flags &= ~VKI_CLONE_SETTLS;
    278 
    279    /* start the thread with everything blocked */
    280    VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, &savedmask);
    281 
    282    /* Create the new thread */
    283    r2 = do_syscall_clone_s390x_linux(
    284             stack, flags, parent_tidptr, child_tidptr, tlsaddr,
    285             ML_(start_thread_NORETURN), &VG_(threads)[ctid]);
    286 
    287    res = VG_(mk_SysRes_s390x_linux)( r2 );
    288 
    289    VG_(sigprocmask)(VKI_SIG_SETMASK, &savedmask, NULL);
    290 
    291   out:
    292    if (sr_isError(res)) {
    293       /* clone failed */
    294       ctst->status = VgTs_Empty;
    295       /* oops.  Better tell the tool the thread exited in a hurry :-) */
    296       VG_TRACK( pre_thread_ll_exit, ctid );
    297    }
    298 
    299    return res;
    300 
    301 }
    302 
    303 
    304 
    305 /* ---------------------------------------------------------------------
    306    PRE/POST wrappers for s390x/Linux-specific syscalls
    307    ------------------------------------------------------------------ */
    308 
    309 #define PRE(name)       DEFN_PRE_TEMPLATE(s390x_linux, name)
    310 #define POST(name)      DEFN_POST_TEMPLATE(s390x_linux, name)
    311 
    312 /* Add prototypes for the wrappers declared here, so that gcc doesn't
    313    harass us for not having prototypes.  Really this is a kludge --
    314    the right thing to do is to make these wrappers 'static' since they
    315    aren't visible outside this file, but that requires even more macro
    316    magic. */
    317 
    318 DECL_TEMPLATE(s390x_linux, sys_ptrace);
    319 DECL_TEMPLATE(s390x_linux, sys_mmap);
    320 DECL_TEMPLATE(s390x_linux, sys_clone);
    321 DECL_TEMPLATE(s390x_linux, sys_sigreturn);
    322 DECL_TEMPLATE(s390x_linux, sys_rt_sigreturn);
    323 DECL_TEMPLATE(s390x_linux, sys_fadvise64);
    324 
    325 /* PEEK TEXT,DATA and USER are common to all architectures.
    326    PEEKUSR_AREA and POKEUSR_AREA are special, having a memory area
    327    containing the real addr, data, and len field pointed to by ARG3
    328    instead of ARG4.
    329    GETREGSET and SETREGSET use a struct iovec (pointed to by ARG4) for
    330    the address and size of the user buffer. */
    331 
    332 PRE(sys_ptrace)
    333 {
    334    PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )", SARG1, SARG2, ARG3, ARG4);
    335    PRE_REG_READ4(int, "ptrace",
    336                  long, request, long, pid, unsigned long, addr,
    337                  unsigned long, data);
    338    switch (ARG1) {
    339    case VKI_PTRACE_PEEKTEXT:
    340    case VKI_PTRACE_PEEKDATA:
    341    case VKI_PTRACE_PEEKUSR:
    342       PRE_MEM_WRITE( "ptrace(peek)", ARG4,
    343 		     sizeof (long));
    344       break;
    345    case VKI_PTRACE_GETEVENTMSG:
    346       PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4, sizeof(unsigned long));
    347       break;
    348    case VKI_PTRACE_GETSIGINFO:
    349       PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t));
    350       break;
    351    case VKI_PTRACE_SETSIGINFO:
    352       PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
    353       break;
    354    case VKI_PTRACE_PEEKUSR_AREA:
    355       {
    356          vki_ptrace_area *pa;
    357 
    358          /* Reads a part of the user area into memory at pa->process_addr */
    359 	 pa = (vki_ptrace_area *) ARG3;
    360          PRE_MEM_READ("ptrace(peekusrarea ptrace_area->len)",
    361                       (unsigned long) &pa->vki_len, sizeof(pa->vki_len));
    362          PRE_MEM_READ("ptrace(peekusrarea ptrace_area->kernel_addr)",
    363                       (unsigned long) &pa->vki_kernel_addr, sizeof(pa->vki_kernel_addr));
    364          PRE_MEM_READ("ptrace(peekusrarea ptrace_area->process_addr)",
    365                       (unsigned long) &pa->vki_process_addr, sizeof(pa->vki_process_addr));
    366          PRE_MEM_WRITE("ptrace(peekusrarea *(ptrace_area->process_addr))",
    367                        pa->vki_process_addr, pa->vki_len);
    368          break;
    369       }
    370    case VKI_PTRACE_POKEUSR_AREA:
    371       {
    372          vki_ptrace_area *pa;
    373 
    374          /* Updates a part of the user area from memory at pa->process_addr */
    375 	 pa = (vki_ptrace_area *) ARG3;
    376          PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->len)",
    377                       (unsigned long) &pa->vki_len, sizeof(pa->vki_len));
    378          PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->kernel_addr)",
    379                       (unsigned long) &pa->vki_kernel_addr,
    380                       sizeof(pa->vki_kernel_addr));
    381          PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->process_addr)",
    382                       (unsigned long) &pa->vki_process_addr,
    383                       sizeof(pa->vki_process_addr));
    384          PRE_MEM_READ("ptrace(pokeusrarea *(ptrace_area->process_addr))",
    385                        pa->vki_process_addr, pa->vki_len);
    386          break;
    387       }
    388    case VKI_PTRACE_GETREGSET:
    389       ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
    390       break;
    391    case VKI_PTRACE_SETREGSET:
    392       ML_(linux_PRE_setregset)(tid, ARG3, ARG4);
    393       break;
    394    default:
    395       break;
    396    }
    397 }
    398 
    399 POST(sys_ptrace)
    400 {
    401    switch (ARG1) {
    402    case VKI_PTRACE_PEEKTEXT:
    403    case VKI_PTRACE_PEEKDATA:
    404    case VKI_PTRACE_PEEKUSR:
    405       POST_MEM_WRITE( ARG4, sizeof (long));
    406       break;
    407    case VKI_PTRACE_GETEVENTMSG:
    408       POST_MEM_WRITE( ARG4, sizeof(unsigned long));
    409       break;
    410    case VKI_PTRACE_GETSIGINFO:
    411       /* XXX: This is a simplification. Different parts of the
    412        * siginfo_t are valid depending on the type of signal.
    413        */
    414       POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t));
    415       break;
    416    case VKI_PTRACE_PEEKUSR_AREA:
    417       {
    418          vki_ptrace_area *pa;
    419 
    420 	 pa = (vki_ptrace_area *) ARG3;
    421          POST_MEM_WRITE(pa->vki_process_addr, pa->vki_len);
    422 	 break;
    423       }
    424    case VKI_PTRACE_GETREGSET:
    425       ML_(linux_POST_getregset)(tid, ARG3, ARG4);
    426       break;
    427    default:
    428       break;
    429    }
    430 }
    431 
    432 PRE(sys_mmap)
    433 {
    434    UWord a0, a1, a2, a3, a4, a5;
    435    SysRes r;
    436 
    437    UWord* args = (UWord*)ARG1;
    438    PRE_REG_READ1(long, "sys_mmap", struct mmap_arg_struct *, args);
    439    PRE_MEM_READ( "sys_mmap(args)", (Addr) args, 6*sizeof(UWord) );
    440 
    441    a0 = args[0];
    442    a1 = args[1];
    443    a2 = args[2];
    444    a3 = args[3];
    445    a4 = args[4];
    446    a5 = args[5];
    447 
    448    PRINT("sys_mmap ( %#lx, %lu, %ld, %ld, %ld, %ld )",
    449          a0, a1, (Word)a2, (Word)a3, (Word)a4, (Word)a5 );
    450 
    451    r = ML_(generic_PRE_sys_mmap)( tid, a0, a1, a2, a3, a4, (Off64T)a5 );
    452    SET_STATUS_from_SysRes(r);
    453 }
    454 
    455 PRE(sys_clone)
    456 {
    457    UInt cloneflags;
    458 
    459    PRINT("sys_clone ( %lx, %#lx, %#lx, %#lx, %#lx )",ARG1,ARG2,ARG3,ARG4, ARG5);
    460    PRE_REG_READ2(int, "clone",
    461                  void *,        child_stack,
    462                  unsigned long, flags);
    463 
    464    if (ARG2 & VKI_CLONE_PARENT_SETTID) {
    465       if (VG_(tdict).track_pre_reg_read)
    466          PRA3("clone(parent_tidptr)", int *, parent_tidptr);
    467       PRE_MEM_WRITE("clone(parent_tidptr)", ARG3, sizeof(Int));
    468       if (!VG_(am_is_valid_for_client)(ARG3, sizeof(Int),
    469                                              VKI_PROT_WRITE)) {
    470          SET_STATUS_Failure( VKI_EFAULT );
    471          return;
    472       }
    473    }
    474    if (ARG2 & (VKI_CLONE_CHILD_SETTID | VKI_CLONE_CHILD_CLEARTID)) {
    475       if (VG_(tdict).track_pre_reg_read)
    476          PRA4("clone(child_tidptr)", int *, child_tidptr);
    477       PRE_MEM_WRITE("clone(child_tidptr)", ARG4, sizeof(Int));
    478       if (!VG_(am_is_valid_for_client)(ARG4, sizeof(Int),
    479                                              VKI_PROT_WRITE)) {
    480          SET_STATUS_Failure( VKI_EFAULT );
    481          return;
    482       }
    483    }
    484 
    485    /* The kernel simply copies reg6 (ARG5) into AR0 and AR1, no checks */
    486    if (ARG2 & VKI_CLONE_SETTLS) {
    487       if (VG_(tdict).track_pre_reg_read) {
    488          PRA5("clone", Addr, tlsinfo);
    489       }
    490    }
    491 
    492    cloneflags = ARG2;
    493 
    494    if (!ML_(client_signal_OK)(ARG2 & VKI_CSIGNAL)) {
    495       SET_STATUS_Failure( VKI_EINVAL );
    496       return;
    497    }
    498 
    499    /* Only look at the flags we really care about */
    500    switch (cloneflags & (VKI_CLONE_VM | VKI_CLONE_FS
    501                          | VKI_CLONE_FILES | VKI_CLONE_VFORK)) {
    502    case VKI_CLONE_VM | VKI_CLONE_FS | VKI_CLONE_FILES:
    503       /* thread creation */
    504       SET_STATUS_from_SysRes(
    505          do_clone(tid,
    506                   (Addr)ARG1,   /* child SP */
    507                   ARG2,         /* flags */
    508                   (Int *)ARG3,  /* parent_tidptr */
    509                   (Int *)ARG4, /* child_tidptr */
    510                   (Addr)ARG5)); /*  tlsaddr */
    511       break;
    512 
    513    case VKI_CLONE_VFORK | VKI_CLONE_VM: /* vfork */
    514       /* FALLTHROUGH - assume vfork == fork */
    515       cloneflags &= ~(VKI_CLONE_VFORK | VKI_CLONE_VM);
    516 
    517    case 0: /* plain fork */
    518       SET_STATUS_from_SysRes(
    519          ML_(do_fork_clone)(tid,
    520                        cloneflags,      /* flags */
    521                        (Int *)ARG3,     /* parent_tidptr */
    522                        (Int *)ARG4));   /* child_tidptr */
    523       break;
    524 
    525    default:
    526       /* should we just ENOSYS? */
    527       VG_(message)(Vg_UserMsg, "Unsupported clone() flags: 0x%lx\n", ARG2);
    528       VG_(message)(Vg_UserMsg, "\n");
    529       VG_(message)(Vg_UserMsg, "The only supported clone() uses are:\n");
    530       VG_(message)(Vg_UserMsg, " - via a threads library (NPTL)\n");
    531       VG_(message)(Vg_UserMsg, " - via the implementation of fork or vfork\n");
    532       VG_(unimplemented)
    533          ("Valgrind does not support general clone().");
    534    }
    535 
    536    if (SUCCESS) {
    537       if (ARG2 & VKI_CLONE_PARENT_SETTID)
    538          POST_MEM_WRITE(ARG3, sizeof(Int));
    539       if (ARG2 & (VKI_CLONE_CHILD_SETTID | VKI_CLONE_CHILD_CLEARTID))
    540          POST_MEM_WRITE(ARG4, sizeof(Int));
    541 
    542       /* Thread creation was successful; let the child have the chance
    543          to run */
    544       *flags |= SfYieldAfter;
    545    }
    546 }
    547 
    548 PRE(sys_sigreturn)
    549 {
    550    ThreadState* tst;
    551    PRINT("sys_sigreturn ( )");
    552 
    553    vg_assert(VG_(is_valid_tid)(tid));
    554    vg_assert(tid >= 1 && tid < VG_N_THREADS);
    555    vg_assert(VG_(is_running_thread)(tid));
    556 
    557    tst = VG_(get_ThreadState)(tid);
    558 
    559    /* This is only so that the IA is (might be) useful to report if
    560       something goes wrong in the sigreturn */
    561    ML_(fixup_guest_state_to_restart_syscall)(&tst->arch);
    562 
    563    /* Restore register state from frame and remove it */
    564    VG_(sigframe_destroy)(tid, False);
    565 
    566    /* Tell the driver not to update the guest state with the "result",
    567       and set a bogus result to keep it happy. */
    568    *flags |= SfNoWriteResult;
    569    SET_STATUS_Success(0);
    570 
    571    /* Check to see if any signals arose as a result of this. */
    572    *flags |= SfPollAfter;
    573 }
    574 
    575 
    576 PRE(sys_rt_sigreturn)
    577 {
    578    /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for
    579       an explanation of what follows. */
    580 
    581    ThreadState* tst;
    582    PRINT("sys_rt_sigreturn ( )");
    583 
    584    vg_assert(VG_(is_valid_tid)(tid));
    585    vg_assert(tid >= 1 && tid < VG_N_THREADS);
    586    vg_assert(VG_(is_running_thread)(tid));
    587 
    588    tst = VG_(get_ThreadState)(tid);
    589 
    590    /* This is only so that the IA is (might be) useful to report if
    591       something goes wrong in the sigreturn */
    592    ML_(fixup_guest_state_to_restart_syscall)(&tst->arch);
    593 
    594    /* Restore register state from frame and remove it */
    595    VG_(sigframe_destroy)(tid, True);
    596 
    597    /* Tell the driver not to update the guest state with the "result",
    598       and set a bogus result to keep it happy. */
    599    *flags |= SfNoWriteResult;
    600    SET_STATUS_Success(0);
    601 
    602    /* Check to see if any signals arose as a result of this. */
    603    *flags |= SfPollAfter;
    604 }
    605 
    606 /* we cant use the LINX_ version for 64 bit */
    607 PRE(sys_fadvise64)
    608 {
    609    PRINT("sys_fadvise64 ( %ld, %ld, %ld, %ld )", SARG1, SARG2, SARG3, SARG4);
    610    PRE_REG_READ4(long, "fadvise64",
    611                  int, fd, vki_loff_t, offset, vki_loff_t, len, int, advice);
    612 }
    613 
    614 #undef PRE
    615 #undef POST
    616 
    617 /* ---------------------------------------------------------------------
    618    The s390x/Linux syscall table
    619    ------------------------------------------------------------------ */
    620 
    621 /* Add an s390x-linux specific wrapper to a syscall table. */
    622 #define PLAX_(sysno, name)    WRAPPER_ENTRY_X_(s390x_linux, sysno, name)
    623 #define PLAXY(sysno, name)    WRAPPER_ENTRY_XY(s390x_linux, sysno, name)
    624 
    625 // This table maps from __NR_xxx syscall numbers from
    626 // linux/arch/s390/kernel/syscalls.S to the appropriate PRE/POST sys_foo()
    627 // wrappers on s390x. There are several unused numbers, which are only
    628 // defined on s390 (31bit mode) but no longer available on s390x (64 bit).
    629 // For those syscalls not handled by Valgrind, the annotation indicate its
    630 // arch/OS combination, eg. */* (generic), */Linux (Linux only), ?/?
    631 // (unknown).
    632 
    633 static SyscallTableEntry syscall_table[] = {
    634    GENX_(0, sys_ni_syscall), /* unimplemented (by the kernel) */      // 0
    635    GENX_(__NR_exit,  sys_exit),                                       // 1
    636    GENX_(__NR_fork,  sys_fork),                                       // 2
    637    GENXY(__NR_read,  sys_read),                                       // 3
    638    GENX_(__NR_write,  sys_write),                                     // 4
    639 
    640    GENXY(__NR_open,  sys_open),                                       // 5
    641    GENXY(__NR_close,  sys_close),                                     // 6
    642 // ?????(__NR_restart_syscall, ),                                     // 7
    643    GENXY(__NR_creat,  sys_creat),                                     // 8
    644    GENX_(__NR_link,  sys_link),                                       // 9
    645 
    646    GENX_(__NR_unlink,  sys_unlink),                                   // 10
    647    GENX_(__NR_execve,  sys_execve),                                   // 11
    648    GENX_(__NR_chdir,  sys_chdir),                                     // 12
    649    GENX_(13, sys_ni_syscall), /* unimplemented (by the kernel) */     // 13
    650    GENX_(__NR_mknod,  sys_mknod),                                     // 14
    651 
    652    GENX_(__NR_chmod,  sys_chmod),                                     // 15
    653    GENX_(16, sys_ni_syscall), /* unimplemented (by the kernel) */     // 16
    654    GENX_(17, sys_ni_syscall), /* unimplemented (by the kernel) */     // 17
    655    GENX_(18, sys_ni_syscall), /* unimplemented (by the kernel) */     // 18
    656    LINX_(__NR_lseek,  sys_lseek),                                     // 19
    657 
    658    GENX_(__NR_getpid,  sys_getpid),                                   // 20
    659    LINX_(__NR_mount,  sys_mount),                                     // 21
    660    LINX_(__NR_umount, sys_oldumount),                                 // 22
    661    GENX_(23, sys_ni_syscall), /* unimplemented (by the kernel) */     // 23
    662    GENX_(24, sys_ni_syscall), /* unimplemented (by the kernel) */     // 24
    663 
    664    GENX_(25, sys_ni_syscall), /* unimplemented (by the kernel) */     // 25
    665    PLAXY(__NR_ptrace, sys_ptrace),                                    // 26
    666    GENX_(__NR_alarm,  sys_alarm),                                     // 27
    667    GENX_(28, sys_ni_syscall), /* unimplemented (by the kernel) */     // 28
    668    GENX_(__NR_pause,  sys_pause),                                     // 29
    669 
    670    LINX_(__NR_utime,  sys_utime),                                     // 30
    671    GENX_(31, sys_ni_syscall), /* unimplemented (by the kernel) */     // 31
    672    GENX_(32, sys_ni_syscall), /* unimplemented (by the kernel) */     // 32
    673    GENX_(__NR_access,  sys_access),                                   // 33
    674    GENX_(__NR_nice, sys_nice),                                        // 34
    675 
    676    GENX_(35, sys_ni_syscall), /* unimplemented (by the kernel) */     // 35
    677    GENX_(__NR_sync, sys_sync),                                        // 36
    678    GENX_(__NR_kill,  sys_kill),                                       // 37
    679    GENX_(__NR_rename,  sys_rename),                                   // 38
    680    GENX_(__NR_mkdir,  sys_mkdir),                                     // 39
    681 
    682    GENX_(__NR_rmdir, sys_rmdir),                                      // 40
    683    GENXY(__NR_dup,  sys_dup),                                         // 41
    684    LINXY(__NR_pipe,  sys_pipe),                                       // 42
    685    GENXY(__NR_times,  sys_times),                                     // 43
    686    GENX_(44, sys_ni_syscall), /* unimplemented (by the kernel) */     // 44
    687 
    688    GENX_(__NR_brk,  sys_brk),                                         // 45
    689    GENX_(46, sys_ni_syscall), /* unimplemented (by the kernel) */     // 46
    690    GENX_(47, sys_ni_syscall), /* unimplemented (by the kernel) */     // 47
    691 // ?????(__NR_signal, ),                                              // 48
    692    GENX_(49, sys_ni_syscall), /* unimplemented (by the kernel) */     // 49
    693 
    694    GENX_(50, sys_ni_syscall), /* unimplemented (by the kernel) */     // 50
    695    GENX_(__NR_acct, sys_acct),                                        // 51
    696    LINX_(__NR_umount2, sys_umount),                                   // 52
    697    GENX_(53, sys_ni_syscall), /* unimplemented (by the kernel) */     // 53
    698    LINXY(__NR_ioctl,  sys_ioctl),                                     // 54
    699 
    700    LINXY(__NR_fcntl,  sys_fcntl),                                     // 55
    701    GENX_(56, sys_ni_syscall), /* unimplemented (by the kernel) */     // 56
    702    GENX_(__NR_setpgid,  sys_setpgid),                                 // 57
    703    GENX_(58, sys_ni_syscall), /* unimplemented (by the kernel) */     // 58
    704    GENX_(59, sys_ni_syscall), /* unimplemented (by the kernel) */     // 59
    705 
    706    GENX_(__NR_umask,  sys_umask),                                     // 60
    707    GENX_(__NR_chroot,  sys_chroot),                                   // 61
    708 // ?????(__NR_ustat, sys_ustat), /* deprecated in favor of statfs */  // 62
    709    GENXY(__NR_dup2,  sys_dup2),                                       // 63
    710    GENX_(__NR_getppid,  sys_getppid),                                 // 64
    711 
    712    GENX_(__NR_getpgrp,  sys_getpgrp),                                 // 65
    713    GENX_(__NR_setsid,  sys_setsid),                                   // 66
    714 // ?????(__NR_sigaction, ),   /* userspace uses rt_sigaction */       // 67
    715    GENX_(68, sys_ni_syscall), /* unimplemented (by the kernel) */     // 68
    716    GENX_(69, sys_ni_syscall), /* unimplemented (by the kernel) */     // 69
    717 
    718    GENX_(70, sys_ni_syscall), /* unimplemented (by the kernel) */     // 70
    719    GENX_(71, sys_ni_syscall), /* unimplemented (by the kernel) */     // 71
    720 // ?????(__NR_sigsuspend, ),                                          // 72
    721 // ?????(__NR_sigpending, ),                                          // 73
    722 // ?????(__NR_sethostname, ),                                         // 74
    723 
    724    GENX_(__NR_setrlimit,  sys_setrlimit),                             // 75
    725    GENXY(76,  sys_getrlimit), /* see also 191 */                      // 76
    726    GENXY(__NR_getrusage,  sys_getrusage),                             // 77
    727    GENXY(__NR_gettimeofday,  sys_gettimeofday),                       // 78
    728    GENX_(__NR_settimeofday, sys_settimeofday),                        // 79
    729 
    730    GENX_(80, sys_ni_syscall), /* unimplemented (by the kernel) */     // 80
    731    GENX_(81, sys_ni_syscall), /* unimplemented (by the kernel) */     // 81
    732    GENX_(82, sys_ni_syscall), /* unimplemented (by the kernel) */     // 82
    733    GENX_(__NR_symlink,  sys_symlink),                                 // 83
    734    GENX_(84, sys_ni_syscall), /* unimplemented (by the kernel) */     // 84
    735 
    736    GENX_(__NR_readlink,  sys_readlink),                               // 85
    737 // ?????(__NR_uselib, ),                                              // 86
    738 // ?????(__NR_swapon, ),                                              // 87
    739 // ?????(__NR_reboot, ),                                              // 88
    740    GENX_(89, sys_ni_syscall), /* unimplemented (by the kernel) */     // 89
    741 
    742    PLAX_(__NR_mmap, sys_mmap ),                                       // 90
    743    GENXY(__NR_munmap,  sys_munmap),                                   // 91
    744    GENX_(__NR_truncate,  sys_truncate),                               // 92
    745    GENX_(__NR_ftruncate,  sys_ftruncate),                             // 93
    746    GENX_(__NR_fchmod,  sys_fchmod),                                   // 94
    747 
    748    GENX_(95, sys_ni_syscall), /* unimplemented (by the kernel) */     // 95
    749    GENX_(__NR_getpriority, sys_getpriority),                          // 96
    750    GENX_(__NR_setpriority, sys_setpriority),                          // 97
    751    GENX_(98, sys_ni_syscall), /* unimplemented (by the kernel) */     // 98
    752    GENXY(__NR_statfs,  sys_statfs),                                   // 99
    753 
    754    GENXY(__NR_fstatfs,  sys_fstatfs),                                 // 100
    755    GENX_(101, sys_ni_syscall), /* unimplemented (by the kernel) */    // 101
    756    LINXY(__NR_socketcall, sys_socketcall),                            // 102
    757    LINXY(__NR_syslog,  sys_syslog),                                   // 103
    758    GENXY(__NR_setitimer,  sys_setitimer),                             // 104
    759 
    760    GENXY(__NR_getitimer,  sys_getitimer),                             // 105
    761    GENXY(__NR_stat, sys_newstat),                                     // 106
    762    GENXY(__NR_lstat, sys_newlstat),                                   // 107
    763    GENXY(__NR_fstat, sys_newfstat),                                   // 108
    764    GENX_(109, sys_ni_syscall), /* unimplemented (by the kernel) */    // 109
    765 
    766    LINXY(__NR_lookup_dcookie, sys_lookup_dcookie),                    // 110
    767    LINX_(__NR_vhangup, sys_vhangup),                                  // 111
    768    GENX_(112, sys_ni_syscall), /* unimplemented (by the kernel) */    // 112
    769    GENX_(113, sys_ni_syscall), /* unimplemented (by the kernel) */    // 113
    770    GENXY(__NR_wait4,  sys_wait4),                                     // 114
    771 
    772 // ?????(__NR_swapoff, ),                                             // 115
    773    LINXY(__NR_sysinfo,  sys_sysinfo),                                 // 116
    774    LINXY(__NR_ipc, sys_ipc),                                          // 117
    775    GENX_(__NR_fsync,  sys_fsync),                                     // 118
    776    PLAX_(__NR_sigreturn, sys_sigreturn),                              // 119
    777 
    778    PLAX_(__NR_clone,  sys_clone),                                     // 120
    779 // ?????(__NR_setdomainname, ),                                       // 121
    780    GENXY(__NR_uname, sys_newuname),                                   // 122
    781    GENX_(123, sys_ni_syscall), /* unimplemented (by the kernel) */    // 123
    782 // ?????(__NR_adjtimex, ),                                            // 124
    783 
    784    GENXY(__NR_mprotect,  sys_mprotect),                               // 125
    785 // LINXY(__NR_sigprocmask, sys_sigprocmask),                          // 126
    786    GENX_(127, sys_ni_syscall), /* unimplemented (by the kernel) */    // 127
    787    LINX_(__NR_init_module,  sys_init_module),                         // 128
    788    LINX_(__NR_delete_module,  sys_delete_module),                     // 129
    789 
    790    GENX_(130, sys_ni_syscall), /* unimplemented (by the kernel) */    // 130
    791    LINX_(__NR_quotactl, sys_quotactl),                                // 131
    792    GENX_(__NR_getpgid,  sys_getpgid),                                 // 132
    793    GENX_(__NR_fchdir,  sys_fchdir),                                   // 133
    794 // ?????(__NR_bdflush, ),                                             // 134
    795 
    796 // ?????(__NR_sysfs, ),                                               // 135
    797    LINX_(__NR_personality, sys_personality),                          // 136
    798    GENX_(137, sys_ni_syscall), /* unimplemented (by the kernel) */    // 137
    799    GENX_(138, sys_ni_syscall), /* unimplemented (by the kernel) */    // 138
    800    GENX_(139, sys_ni_syscall), /* unimplemented (by the kernel) */    // 139
    801 
    802 // LINXY(__NR__llseek, sys_llseek), /* 64 bit --> lseek */            // 140
    803    GENXY(__NR_getdents,  sys_getdents),                               // 141
    804    GENX_(__NR_select, sys_select),                                    // 142
    805    GENX_(__NR_flock,  sys_flock),                                     // 143
    806    GENX_(__NR_msync,  sys_msync),                                     // 144
    807 
    808    GENXY(__NR_readv,  sys_readv),                                     // 145
    809    GENX_(__NR_writev,  sys_writev),                                   // 146
    810    GENX_(__NR_getsid, sys_getsid),                                    // 147
    811    GENX_(__NR_fdatasync,  sys_fdatasync),                             // 148
    812    LINXY(__NR__sysctl, sys_sysctl),                                   // 149
    813 
    814    GENX_(__NR_mlock,  sys_mlock),                                     // 150
    815    GENX_(__NR_munlock,  sys_munlock),                                 // 151
    816    GENX_(__NR_mlockall,  sys_mlockall),                               // 152
    817    LINX_(__NR_munlockall,  sys_munlockall),                           // 153
    818    LINXY(__NR_sched_setparam,  sys_sched_setparam),                   // 154
    819 
    820    LINXY(__NR_sched_getparam,  sys_sched_getparam),                   // 155
    821    LINX_(__NR_sched_setscheduler,  sys_sched_setscheduler),           // 156
    822    LINX_(__NR_sched_getscheduler,  sys_sched_getscheduler),           // 157
    823    LINX_(__NR_sched_yield,  sys_sched_yield),                         // 158
    824    LINX_(__NR_sched_get_priority_max,  sys_sched_get_priority_max),   // 159
    825 
    826    LINX_(__NR_sched_get_priority_min,  sys_sched_get_priority_min),   // 160
    827    LINXY(__NR_sched_rr_get_interval, sys_sched_rr_get_interval),      // 162
    828    GENXY(__NR_nanosleep,  sys_nanosleep),                             // 162
    829    GENX_(__NR_mremap,  sys_mremap),                                   // 163
    830    GENX_(164, sys_ni_syscall), /* unimplemented (by the kernel) */    // 164
    831 
    832    GENX_(165, sys_ni_syscall), /* unimplemented (by the kernel) */    // 165
    833    GENX_(166, sys_ni_syscall), /* unimplemented (by the kernel) */    // 166
    834    GENX_(167, sys_ni_syscall), /* unimplemented (by the kernel) */    // 167
    835    GENXY(__NR_poll,  sys_poll),                                       // 168
    836 // ?????(__NR_nfsservctl, ),                                          // 169
    837 
    838    GENX_(170, sys_ni_syscall), /* unimplemented (by the kernel) */    // 170
    839    GENX_(171, sys_ni_syscall), /* unimplemented (by the kernel) */    // 171
    840    LINXY(__NR_prctl, sys_prctl),                                      // 172
    841    PLAX_(__NR_rt_sigreturn,  sys_rt_sigreturn),                       // 173
    842    LINXY(__NR_rt_sigaction,  sys_rt_sigaction),                       // 174
    843 
    844    LINXY(__NR_rt_sigprocmask,  sys_rt_sigprocmask),                   // 175
    845    LINXY(__NR_rt_sigpending, sys_rt_sigpending),                      // 176
    846    LINXY(__NR_rt_sigtimedwait,  sys_rt_sigtimedwait),                 // 177
    847    LINXY(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo),                  // 178
    848    LINX_(__NR_rt_sigsuspend, sys_rt_sigsuspend),                      // 179
    849 
    850    GENXY(__NR_pread64,  sys_pread64),                                 // 180
    851    GENX_(__NR_pwrite64, sys_pwrite64),                                // 181
    852    GENX_(182, sys_ni_syscall), /* unimplemented (by the kernel) */    // 182
    853    GENXY(__NR_getcwd,  sys_getcwd),                                   // 183
    854    LINXY(__NR_capget,  sys_capget),                                   // 184
    855 
    856    LINX_(__NR_capset,  sys_capset),                                   // 185
    857    GENXY(__NR_sigaltstack,  sys_sigaltstack),                         // 186
    858    LINXY(__NR_sendfile, sys_sendfile),                                // 187
    859    GENX_(188, sys_ni_syscall), /* unimplemented (by the kernel) */    // 188
    860    GENX_(189, sys_ni_syscall), /* unimplemented (by the kernel) */    // 189
    861 
    862    GENX_(__NR_vfork,  sys_fork),                                      // 190
    863    GENXY(__NR_getrlimit,  sys_getrlimit),                             // 191
    864    GENX_(192, sys_ni_syscall), /* not exported on 64bit*/             // 192
    865    GENX_(193, sys_ni_syscall), /* unimplemented (by the kernel) */    // 193
    866    GENX_(194, sys_ni_syscall), /* unimplemented (by the kernel) */    // 194
    867 
    868    GENX_(195, sys_ni_syscall), /* unimplemented (by the kernel) */    // 195
    869    GENX_(196, sys_ni_syscall), /* unimplemented (by the kernel) */    // 196
    870    GENX_(197, sys_ni_syscall), /* unimplemented (by the kernel) */    // 197
    871    GENX_(__NR_lchown, sys_lchown),                                    // 198
    872    GENX_(__NR_getuid, sys_getuid),                                    // 199
    873 
    874    GENX_(__NR_getgid, sys_getgid),                                    // 200
    875    GENX_(__NR_geteuid, sys_geteuid),                                  // 201
    876    GENX_(__NR_getegid, sys_getegid),                                  // 202
    877    GENX_(__NR_setreuid, sys_setreuid),                                // 203
    878    GENX_(__NR_setregid, sys_setregid),                                // 204
    879 
    880    GENXY(__NR_getgroups, sys_getgroups),                              // 205
    881    GENX_(__NR_setgroups, sys_setgroups),                              // 206
    882    GENX_(__NR_fchown, sys_fchown),                                    // 207
    883    LINX_(__NR_setresuid, sys_setresuid),                              // 208
    884    LINXY(__NR_getresuid, sys_getresuid),                              // 209
    885 
    886    LINX_(__NR_setresgid, sys_setresgid),                              // 210
    887    LINXY(__NR_getresgid, sys_getresgid),                              // 211
    888    GENX_(__NR_chown, sys_chown),                                      // 212
    889    GENX_(__NR_setuid, sys_setuid),                                    // 213
    890    GENX_(__NR_setgid, sys_setgid),                                    // 214
    891 
    892    LINX_(__NR_setfsuid, sys_setfsuid),                                // 215
    893    LINX_(__NR_setfsgid, sys_setfsgid),                                // 216
    894    LINX_(__NR_pivot_root, sys_pivot_root),                            // 217
    895    GENXY(__NR_mincore, sys_mincore),                                  // 218
    896    GENX_(__NR_madvise,  sys_madvise),                                 // 219
    897 
    898    GENXY(__NR_getdents64,  sys_getdents64),                           // 220
    899    GENX_(221, sys_ni_syscall), /* unimplemented (by the kernel) */    // 221
    900    LINX_(__NR_readahead, sys_readahead),                              // 222
    901    GENX_(223, sys_ni_syscall), /* unimplemented (by the kernel) */    // 223
    902    LINX_(__NR_setxattr, sys_setxattr),                                // 224
    903 
    904    LINX_(__NR_lsetxattr, sys_lsetxattr),                              // 225
    905    LINX_(__NR_fsetxattr, sys_fsetxattr),                              // 226
    906    LINXY(__NR_getxattr,  sys_getxattr),                               // 227
    907    LINXY(__NR_lgetxattr,  sys_lgetxattr),                             // 228
    908    LINXY(__NR_fgetxattr,  sys_fgetxattr),                             // 229
    909 
    910    LINXY(__NR_listxattr,  sys_listxattr),                             // 230
    911    LINXY(__NR_llistxattr,  sys_llistxattr),                           // 231
    912    LINXY(__NR_flistxattr,  sys_flistxattr),                           // 232
    913    LINX_(__NR_removexattr,  sys_removexattr),                         // 233
    914    LINX_(__NR_lremovexattr,  sys_lremovexattr),                       // 234
    915 
    916    LINX_(__NR_fremovexattr,  sys_fremovexattr),                       // 235
    917    LINX_(__NR_gettid,  sys_gettid),                                   // 236
    918    LINXY(__NR_tkill, sys_tkill),                                      // 237
    919    LINXY(__NR_futex,  sys_futex),                                     // 238
    920    LINX_(__NR_sched_setaffinity,  sys_sched_setaffinity),             // 239
    921 
    922    LINXY(__NR_sched_getaffinity,  sys_sched_getaffinity),             // 240
    923    LINXY(__NR_tgkill, sys_tgkill),                                    // 241
    924    GENX_(242, sys_ni_syscall), /* unimplemented (by the kernel) */    // 242
    925    LINXY(__NR_io_setup, sys_io_setup),                                // 243
    926    LINX_(__NR_io_destroy,  sys_io_destroy),                           // 244
    927 
    928    LINXY(__NR_io_getevents,  sys_io_getevents),                       // 245
    929    LINX_(__NR_io_submit,  sys_io_submit),                             // 246
    930    LINXY(__NR_io_cancel,  sys_io_cancel),                             // 247
    931    LINX_(__NR_exit_group,  sys_exit_group),                           // 248
    932    LINXY(__NR_epoll_create,  sys_epoll_create),                       // 249
    933 
    934    LINX_(__NR_epoll_ctl,  sys_epoll_ctl),                             // 250
    935    LINXY(__NR_epoll_wait,  sys_epoll_wait),                           // 251
    936    LINX_(__NR_set_tid_address,  sys_set_tid_address),                 // 252
    937    PLAX_(__NR_fadvise64, sys_fadvise64),                              // 253
    938    LINXY(__NR_timer_create,  sys_timer_create),                       // 254
    939 
    940    LINXY(__NR_timer_settime,  sys_timer_settime),                     // 255
    941    LINXY(__NR_timer_gettime,  sys_timer_gettime),                     // 256
    942    LINX_(__NR_timer_getoverrun,  sys_timer_getoverrun),               // 257
    943    LINX_(__NR_timer_delete,  sys_timer_delete),                       // 258
    944    LINX_(__NR_clock_settime,  sys_clock_settime),                     // 259
    945 
    946    LINXY(__NR_clock_gettime,  sys_clock_gettime),                     // 260
    947    LINXY(__NR_clock_getres,  sys_clock_getres),                       // 261
    948    LINXY(__NR_clock_nanosleep,  sys_clock_nanosleep),                 // 262
    949    GENX_(263, sys_ni_syscall), /* unimplemented (by the kernel) */    // 263
    950    GENX_(264, sys_ni_syscall), /* unimplemented (by the kernel) */    // 264
    951 
    952    GENXY(__NR_statfs64, sys_statfs64),                                // 265
    953    GENXY(__NR_fstatfs64, sys_fstatfs64),                              // 266
    954 // ?????(__NR_remap_file_pages, ),
    955    GENX_(268, sys_ni_syscall), /* unimplemented (by the kernel) */    // 268
    956    GENX_(269, sys_ni_syscall), /* unimplemented (by the kernel) */    // 269
    957 
    958    GENX_(270, sys_ni_syscall), /* unimplemented (by the kernel) */    // 270
    959    LINXY(__NR_mq_open,  sys_mq_open),                                 // 271
    960    LINX_(__NR_mq_unlink,  sys_mq_unlink),                             // 272
    961    LINX_(__NR_mq_timedsend,  sys_mq_timedsend),                       // 273
    962    LINXY(__NR_mq_timedreceive, sys_mq_timedreceive),                  // 274
    963 
    964    LINX_(__NR_mq_notify,  sys_mq_notify),                             // 275
    965    LINXY(__NR_mq_getsetattr,  sys_mq_getsetattr),                     // 276
    966 // ?????(__NR_kexec_load, ),
    967    LINX_(__NR_add_key,  sys_add_key),                                 // 278
    968    LINX_(__NR_request_key,  sys_request_key),                         // 279
    969 
    970    LINXY(__NR_keyctl,  sys_keyctl),                                   // 280
    971    LINXY(__NR_waitid, sys_waitid),                                    // 281
    972    LINX_(__NR_ioprio_set,  sys_ioprio_set),                           // 282
    973    LINX_(__NR_ioprio_get,  sys_ioprio_get),                           // 283
    974    LINX_(__NR_inotify_init,  sys_inotify_init),                       // 284
    975 
    976    LINX_(__NR_inotify_add_watch,  sys_inotify_add_watch),             // 285
    977    LINX_(__NR_inotify_rm_watch,  sys_inotify_rm_watch),               // 286
    978    GENX_(287, sys_ni_syscall), /* unimplemented (by the kernel) */    // 287
    979    LINXY(__NR_openat,  sys_openat),                                   // 288
    980    LINX_(__NR_mkdirat,  sys_mkdirat),                                 // 289
    981 
    982    LINX_(__NR_mknodat,  sys_mknodat),                                 // 290
    983    LINX_(__NR_fchownat,  sys_fchownat),                               // 291
    984    LINX_(__NR_futimesat,  sys_futimesat),                             // 292
    985    LINXY(__NR_newfstatat, sys_newfstatat),                            // 293
    986    LINX_(__NR_unlinkat,  sys_unlinkat),                               // 294
    987 
    988    LINX_(__NR_renameat,  sys_renameat),                               // 295
    989    LINX_(__NR_linkat,  sys_linkat),                                   // 296
    990    LINX_(__NR_symlinkat,  sys_symlinkat),                             // 297
    991    LINX_(__NR_readlinkat,  sys_readlinkat),                           // 298
    992    LINX_(__NR_fchmodat,  sys_fchmodat),                               // 299
    993 
    994    LINX_(__NR_faccessat,  sys_faccessat),                             // 300
    995    LINX_(__NR_pselect6, sys_pselect6),                                // 301
    996    LINXY(__NR_ppoll, sys_ppoll),                                      // 302
    997    LINX_(__NR_unshare, sys_unshare),                                  // 303
    998    LINX_(__NR_set_robust_list,  sys_set_robust_list),                 // 304
    999 
   1000    LINXY(__NR_get_robust_list,  sys_get_robust_list),                 // 305
   1001    LINX_(__NR_splice, sys_splice),                                    // 306
   1002    LINX_(__NR_sync_file_range, sys_sync_file_range),                  // 307
   1003    LINX_(__NR_tee, sys_tee),                                          // 308
   1004    LINXY(__NR_vmsplice, sys_vmsplice),                                // 309
   1005 
   1006    GENX_(310, sys_ni_syscall), /* unimplemented (by the kernel) */    // 310
   1007    LINXY(__NR_getcpu, sys_getcpu),                                    // 311
   1008    LINXY(__NR_epoll_pwait,  sys_epoll_pwait),                         // 312
   1009    GENX_(__NR_utimes, sys_utimes),                                    // 313
   1010    LINX_(__NR_fallocate, sys_fallocate),                              // 314
   1011 
   1012    LINX_(__NR_utimensat,  sys_utimensat),                             // 315
   1013    LINXY(__NR_signalfd,  sys_signalfd),                               // 316
   1014    GENX_(317, sys_ni_syscall), /* unimplemented (by the kernel) */    // 317
   1015    LINXY(__NR_eventfd,  sys_eventfd),                                 // 318
   1016    LINXY(__NR_timerfd_create,  sys_timerfd_create),                   // 319
   1017 
   1018    LINXY(__NR_timerfd_settime,  sys_timerfd_settime),                 // 320
   1019    LINXY(__NR_timerfd_gettime,  sys_timerfd_gettime),                 // 321
   1020    LINXY(__NR_signalfd4,  sys_signalfd4),                             // 322
   1021    LINXY(__NR_eventfd2,  sys_eventfd2),                               // 323
   1022    LINXY(__NR_inotify_init1,  sys_inotify_init1),                     // 324
   1023 
   1024    LINXY(__NR_pipe2,  sys_pipe2),                                     // 325
   1025    LINXY(__NR_dup3,  sys_dup3),                                       // 326
   1026    LINXY(__NR_epoll_create1,  sys_epoll_create1),                     // 327
   1027    LINXY(__NR_preadv, sys_preadv),                                    // 328
   1028    LINX_(__NR_pwritev, sys_pwritev),                                  // 329
   1029 
   1030    LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo),              // 330
   1031    LINXY(__NR_perf_event_open, sys_perf_event_open),                  // 331
   1032    LINXY(__NR_fanotify_init, sys_fanotify_init),                      // 332
   1033    LINX_(__NR_fanotify_mark, sys_fanotify_mark),                      // 333
   1034    LINXY(__NR_prlimit64, sys_prlimit64),                              // 334
   1035 
   1036    LINXY(__NR_name_to_handle_at, sys_name_to_handle_at),              // 335
   1037    LINXY(__NR_open_by_handle_at, sys_open_by_handle_at),              // 336
   1038    LINXY(__NR_clock_adjtime, sys_clock_adjtime),                      // 337
   1039    LINX_(__NR_syncfs, sys_syncfs),                                    // 338
   1040 // ?????(__NR_setns, ),                                               // 339
   1041 
   1042    LINXY(__NR_process_vm_readv, sys_process_vm_readv),                // 340
   1043    LINX_(__NR_process_vm_writev, sys_process_vm_writev),              // 341
   1044 // ?????(__NR_s390_runtime_instr, ),                                  // 342
   1045    LINX_(__NR_kcmp, sys_kcmp),                                        // 343
   1046 // ?????(__NR_finit_module, ),                                        // 344
   1047 
   1048 // ?????(__NR_sched_setattr, ),                                       // 345
   1049 // ?????(__NR_sched_getattr, ),                                       // 346
   1050 // ?????(__NR_renameat2, ),                                           // 347
   1051 // ?????(__NR_seccomp, ),                                             // 348
   1052    LINXY(__NR_getrandom, sys_getrandom),                              // 349
   1053 
   1054    LINXY(__NR_memfd_create, sys_memfd_create)                         // 350
   1055 };
   1056 
   1057 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
   1058 {
   1059    const UInt syscall_table_size
   1060       = sizeof(syscall_table) / sizeof(syscall_table[0]);
   1061 
   1062    /* Is it in the contiguous initial section of the table? */
   1063    if (sysno < syscall_table_size) {
   1064       SyscallTableEntry* sys = &syscall_table[sysno];
   1065       if (sys->before == NULL)
   1066          return NULL; /* no entry */
   1067       else
   1068          return sys;
   1069    }
   1070 
   1071    /* Can't find a wrapper */
   1072    return NULL;
   1073 }
   1074 
   1075 #endif
   1076 
   1077 /*--------------------------------------------------------------------*/
   1078 /*--- end                                                          ---*/
   1079 /*--------------------------------------------------------------------*/
   1080