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