]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/coregrind/m_syswrap/syswrap-s390x-linux.c
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / coregrind / m_syswrap / syswrap-s390x-linux.c
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-2011
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_libcsetjmp.h"    // to keep _threadstate.h happy
38 #include "pub_core_threadstate.h"
39 #include "pub_core_aspacemgr.h"
40 #include "pub_core_debuglog.h"
41 #include "pub_core_libcbase.h"
42 #include "pub_core_libcassert.h"
43 #include "pub_core_libcprint.h"
44 #include "pub_core_libcproc.h"
45 #include "pub_core_libcsignal.h"
46 #include "pub_core_mallocfree.h"
47 #include "pub_core_options.h"
48 #include "pub_core_scheduler.h"
49 #include "pub_core_sigframe.h"      // For VG_(sigframe_destroy)()
50 #include "pub_core_signals.h"
51 #include "pub_core_syscall.h"
52 #include "pub_core_syswrap.h"
53 #include "pub_core_tooliface.h"
54 #include "pub_core_stacks.h"        // VG_(register_stack)
55
56 #include "priv_types_n_macros.h"
57 #include "priv_syswrap-generic.h"    /* for decls of generic wrappers */
58 #include "priv_syswrap-linux.h"      /* for decls of linux-ish wrappers */
59 #include "priv_syswrap-linux-variants.h" /* decls of linux variant wrappers */
60 #include "priv_syswrap-main.h"
61
62
63 /* ---------------------------------------------------------------------
64    clone() handling
65    ------------------------------------------------------------------ */
66
67 /* Call f(arg1), but first switch stacks, using 'stack' as the new
68    stack, and use 'retaddr' as f's return-to address.  Also, clear all
69    the integer registers before entering f.
70    Thought: Why are we clearing the GPRs ? The callee pointed to by f
71    is a regular C function which will play by the ABI rules. So there is
72    no need to zero out the GPRs. If we assumed that f accesses registers at
73    will, then it would make sense to create a defined register state.
74    But then, why only for the GPRs and not the FPRs ? */
75 __attribute__((noreturn))
76 void ML_(call_on_new_stack_0_1) ( Addr stack,
77                                   Addr retaddr,
78                                   void (*f)(Word),
79                                   Word arg1 );
80 /* Upon entering this function we have the following setup:
81      r2 = stack
82      r3 = retaddr
83      r4 = f_desc
84      r5 = arg1
85 */
86 asm(
87     ".text\n"
88     ".align 4\n"
89     ".globl vgModuleLocal_call_on_new_stack_0_1\n"
90     ".type vgModuleLocal_call_on_new_stack_0_1, @function\n"
91     "vgModuleLocal_call_on_new_stack_0_1:\n"
92     "   lgr %r15,%r2\n"     // stack to r15
93     "   lgr %r14,%r3\n"     // retaddr to r14
94     "   lgr %r2,%r5\n"      // arg1 to r2
95     // zero all gprs to get a defined state
96     "   lghi  %r0,0\n"
97     "   lghi  %r1,0\n"
98     // r2 holds the argument for the callee
99     "   lghi  %r3,0\n"
100     // r4 holds the callee address
101     "   lghi  %r5,0\n"
102     "   lghi  %r6,0\n"
103     "   lghi  %r7,0\n"
104     "   lghi  %r8,0\n"
105     "   lghi  %r9,0\n"
106     "   lghi  %r10,0\n"
107     "   lghi  %r11,0\n"
108     "   lghi  %r12,0\n"
109     "   lghi  %r13,0\n"
110     // r14 holds the return address for the callee
111     // r15 is the stack pointer
112     "   br  %r4\n"          // jump to f
113     ".previous\n"
114     );
115
116 /*
117         Perform a clone system call.  clone is strange because it has
118         fork()-like return-twice semantics, so it needs special
119         handling here.
120
121         Upon entry, we have:
122             void*  child_stack   in r2
123             long   flags         in r3
124             int*   parent_tid    in r4
125             int*   child_tid     in r5
126             int*   child_tid     in r6
127             Word   (*fn)(void *) 160(r15)
128             void   *arg          168(r15)
129
130         System call requires:
131             void*  child_stack  in r2  (sc arg1)
132             long   flags        in r3  (sc arg2)
133             int*   parent_tid   in r4  (sc arg3)
134             int*   child_tid    in r5  (sc arg4)
135             void*  tlsaddr      in r6  (sc arg5)
136
137         Returns a ULong encoded as: top half is %cr following syscall,
138         low half is syscall return value (r3).
139  */
140 #define __NR_CLONE        VG_STRINGIFY(__NR_clone)
141 #define __NR_EXIT         VG_STRINGIFY(__NR_exit)
142
143 extern
144 ULong do_syscall_clone_s390x_linux ( void  *stack,
145                                      ULong flags,
146                                      Int   *child_tid,
147                                      Int   *parent_tid,
148                                      Addr  tlsaddr,
149                                      Word (*fn)(void *),
150                                      void  *arg);
151 asm(
152    "   .text\n"
153    "   .align  4\n"
154    "do_syscall_clone_s390x_linux:\n"
155    "   lg    %r1, 160(%r15)\n"   // save fn from parent stack into r1
156    "   lg    %r0, 168(%r15)\n"   // save arg from parent stack into r0
157    "   aghi  %r2, -160\n"        // create stack frame for child
158    // all syscall parameters are already in place (r2-r6)
159    "   svc " __NR_CLONE"\n"        // clone()
160    "   ltgr  %r2,%r2\n"           // child if retval == 0
161    "   jne   1f\n"
162
163    // CHILD - call thread function
164    "   lgr   %r2, %r0\n"            // get arg from r0
165    "   basr  %r14,%r1\n"            // call fn
166
167    // exit. The result is already in r2
168    "   svc " __NR_EXIT"\n"
169
170    // Exit returned?!
171    "   j +2\n"
172
173    "1:\n"  // PARENT or ERROR
174    "   br %r14\n"
175    ".previous\n"
176 );
177
178 #undef __NR_CLONE
179 #undef __NR_EXIT
180
181 void VG_(cleanup_thread) ( ThreadArchState* arch )
182 {
183   /* only used on x86 for descriptor tables */
184 }
185
186 static void setup_child ( /*OUT*/ ThreadArchState *child,
187                    /*IN*/  ThreadArchState *parent )
188 {
189    /* We inherit our parent's guest state. */
190    child->vex = parent->vex;
191    child->vex_shadow1 = parent->vex_shadow1;
192    child->vex_shadow2 = parent->vex_shadow2;
193 }
194
195
196 /*
197    When a client clones, we need to keep track of the new thread.  This means:
198    1. allocate a ThreadId+ThreadState+stack for the the thread
199
200    2. initialize the thread's new VCPU state
201
202    3. create the thread using the same args as the client requested,
203    but using the scheduler entrypoint for IP, and a separate stack
204    for SP.
205  */
206 static SysRes do_clone ( ThreadId ptid,
207                          Addr sp, ULong flags,
208                          Int *parent_tidptr,
209                          Int *child_tidptr,
210                          Addr tlsaddr)
211 {
212    static const Bool debug = False;
213
214    ThreadId     ctid = VG_(alloc_ThreadState)();
215    ThreadState* ptst = VG_(get_ThreadState)(ptid);
216    ThreadState* ctst = VG_(get_ThreadState)(ctid);
217    UWord*       stack;
218    NSegment const* seg;
219    SysRes       res;
220    ULong        r2;
221    vki_sigset_t blockall, savedmask;
222
223    VG_(sigfillset)(&blockall);
224
225    vg_assert(VG_(is_running_thread)(ptid));
226    vg_assert(VG_(is_valid_tid)(ctid));
227
228    stack = (UWord*)ML_(allocstack)(ctid);
229    if (stack == NULL) {
230       res = VG_(mk_SysRes_Error)( VKI_ENOMEM );
231       goto out;
232    }
233
234    /* Copy register state
235
236       Both parent and child return to the same place, and the code
237       following the clone syscall works out which is which, so we
238       don't need to worry about it.
239
240       The parent gets the child's new tid returned from clone, but the
241       child gets 0.
242
243       If the clone call specifies a NULL sp for the new thread, then
244       it actually gets a copy of the parent's sp.
245    */
246    setup_child( &ctst->arch, &ptst->arch );
247
248    /* Make sys_clone appear to have returned Success(0) in the
249       child. */
250    ctst->arch.vex.guest_r2 = 0;
251
252    if (sp != 0)
253       ctst->arch.vex.guest_r15 = sp;
254
255    ctst->os_state.parent = ptid;
256
257    /* inherit signal mask */
258    ctst->sig_mask = ptst->sig_mask;
259    ctst->tmp_sig_mask = ptst->sig_mask;
260
261    /* have the parents thread group */
262    ctst->os_state.threadgroup = ptst->os_state.threadgroup;
263
264    /* We don't really know where the client stack is, because its
265       allocated by the client.  The best we can do is look at the
266       memory mappings and try to derive some useful information.  We
267       assume that esp starts near its highest possible value, and can
268       only go down to the start of the mmaped segment. */
269    seg = VG_(am_find_nsegment)((Addr)sp);
270    if (seg && seg->kind != SkResvn) {
271       ctst->client_stack_highest_word = (Addr)VG_PGROUNDUP(sp);
272       ctst->client_stack_szB = ctst->client_stack_highest_word - seg->start;
273
274       VG_(register_stack)(seg->start, ctst->client_stack_highest_word);
275
276       if (debug)
277          VG_(printf)("tid %d: guessed client stack range %#lx-%#lx\n",
278                      ctid, seg->start, VG_PGROUNDUP(sp));
279    } else {
280       VG_(message)(Vg_UserMsg,
281                    "!? New thread %d starts with SP(%#lx) unmapped\n",
282                    ctid, sp);
283       ctst->client_stack_szB  = 0;
284    }
285
286    /* Assume the clone will succeed, and tell any tool that wants to
287       know that this thread has come into existence.  If the clone
288       fails, we'll send out a ll_exit notification for it at the out:
289       label below, to clean up. */
290    VG_TRACK ( pre_thread_ll_create, ptid, ctid );
291
292    if (flags & VKI_CLONE_SETTLS) {
293       if (debug)
294          VG_(printf)("clone child has SETTLS: tls at %#lx\n", tlsaddr);
295       ctst->arch.vex.guest_a0 = (UInt) (tlsaddr >> 32);
296       ctst->arch.vex.guest_a1 = (UInt) tlsaddr;
297    }
298    flags &= ~VKI_CLONE_SETTLS;
299
300    /* start the thread with everything blocked */
301    VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, &savedmask);
302
303    /* Create the new thread */
304    r2 = do_syscall_clone_s390x_linux(
305             stack, flags, child_tidptr, parent_tidptr, tlsaddr,
306             ML_(start_thread_NORETURN), &VG_(threads)[ctid]);
307
308    res = VG_(mk_SysRes_s390x_linux)( r2 );
309
310    VG_(sigprocmask)(VKI_SIG_SETMASK, &savedmask, NULL);
311
312   out:
313    if (sr_isError(res)) {
314       /* clone failed */
315       ctst->status = VgTs_Empty;
316       /* oops.  Better tell the tool the thread exited in a hurry :-) */
317       VG_TRACK( pre_thread_ll_exit, ctid );
318    }
319
320    return res;
321
322 }
323
324
325
326 /* ---------------------------------------------------------------------
327    PRE/POST wrappers for s390x/Linux-specific syscalls
328    ------------------------------------------------------------------ */
329
330 #define PRE(name)       DEFN_PRE_TEMPLATE(s390x_linux, name)
331 #define POST(name)      DEFN_POST_TEMPLATE(s390x_linux, name)
332
333 /* Add prototypes for the wrappers declared here, so that gcc doesn't
334    harass us for not having prototypes.  Really this is a kludge --
335    the right thing to do is to make these wrappers 'static' since they
336    aren't visible outside this file, but that requires even more macro
337    magic. */
338
339 DECL_TEMPLATE(s390x_linux, sys_ptrace);
340 DECL_TEMPLATE(s390x_linux, sys_socketcall);
341 DECL_TEMPLATE(s390x_linux, sys_mmap);
342 DECL_TEMPLATE(s390x_linux, sys_ipc);
343 DECL_TEMPLATE(s390x_linux, sys_clone);
344 DECL_TEMPLATE(s390x_linux, sys_sigreturn);
345 DECL_TEMPLATE(s390x_linux, sys_rt_sigreturn);
346 DECL_TEMPLATE(s390x_linux, sys_fadvise64);
347
348 // PEEK TEXT,DATA and USER are common to all architectures
349 // PEEKUSR_AREA and POKEUSR_AREA are special, having a memory area
350 // containing the real addr, data, and len field pointed to by ARG3
351 // instead of ARG4
352 PRE(sys_ptrace)
353 {
354    PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )", ARG1,ARG2,ARG3,ARG4);
355    PRE_REG_READ4(int, "ptrace",
356                  long, request, long, pid, long, addr, long, data);
357    switch (ARG1) {
358    case VKI_PTRACE_PEEKTEXT:
359    case VKI_PTRACE_PEEKDATA:
360    case VKI_PTRACE_PEEKUSR:
361       PRE_MEM_WRITE( "ptrace(peek)", ARG4,
362                      sizeof (long));
363       break;
364    case VKI_PTRACE_GETEVENTMSG:
365       PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4, sizeof(unsigned long));
366       break;
367    case VKI_PTRACE_GETSIGINFO:
368       PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t));
369       break;
370    case VKI_PTRACE_SETSIGINFO:
371       PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
372       break;
373    case VKI_PTRACE_PEEKUSR_AREA:
374       {
375          vki_ptrace_area *pa;
376
377          /* Reads a part of the user area into memory at pa->process_addr */
378          pa = (vki_ptrace_area *) ARG3;
379          PRE_MEM_READ("ptrace(peekusrarea ptrace_area->len)",
380                       (unsigned long) &pa->vki_len, sizeof(pa->vki_len));
381          PRE_MEM_READ("ptrace(peekusrarea ptrace_area->kernel_addr)",
382                       (unsigned long) &pa->vki_kernel_addr, sizeof(pa->vki_kernel_addr));
383          PRE_MEM_READ("ptrace(peekusrarea ptrace_area->process_addr)",
384                       (unsigned long) &pa->vki_process_addr, sizeof(pa->vki_process_addr));
385          PRE_MEM_WRITE("ptrace(peekusrarea *(ptrace_area->process_addr))",
386                        pa->vki_process_addr, pa->vki_len);
387          break;
388       }
389    case VKI_PTRACE_POKEUSR_AREA:
390       {
391          vki_ptrace_area *pa;
392
393          /* Updates a part of the user area from memory at pa->process_addr */
394          pa = (vki_ptrace_area *) ARG3;
395          PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->len)",
396                       (unsigned long) &pa->vki_len, sizeof(pa->vki_len));
397          PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->kernel_addr)",
398                       (unsigned long) &pa->vki_kernel_addr,
399                       sizeof(pa->vki_kernel_addr));
400          PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->process_addr)",
401                       (unsigned long) &pa->vki_process_addr,
402                       sizeof(pa->vki_process_addr));
403          PRE_MEM_READ("ptrace(pokeusrarea *(ptrace_area->process_addr))",
404                        pa->vki_process_addr, pa->vki_len);
405          break;
406       }
407    default:
408       break;
409    }
410 }
411
412 POST(sys_ptrace)
413 {
414    switch (ARG1) {
415    case VKI_PTRACE_PEEKTEXT:
416    case VKI_PTRACE_PEEKDATA:
417    case VKI_PTRACE_PEEKUSR:
418       POST_MEM_WRITE( ARG4, sizeof (long));
419       break;
420    case VKI_PTRACE_GETEVENTMSG:
421       POST_MEM_WRITE( ARG4, sizeof(unsigned long));
422       break;
423    case VKI_PTRACE_GETSIGINFO:
424       /* XXX: This is a simplification. Different parts of the
425        * siginfo_t are valid depending on the type of signal.
426        */
427       POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t));
428       break;
429    case VKI_PTRACE_PEEKUSR_AREA:
430       {
431          vki_ptrace_area *pa;
432
433          pa = (vki_ptrace_area *) ARG3;
434          POST_MEM_WRITE(pa->vki_process_addr, pa->vki_len);
435       }
436    default:
437       break;
438    }
439 }
440
441
442 PRE(sys_socketcall)
443 {
444 #  define ARG2_0  (((UWord*)ARG2)[0])
445 #  define ARG2_1  (((UWord*)ARG2)[1])
446 #  define ARG2_2  (((UWord*)ARG2)[2])
447 #  define ARG2_3  (((UWord*)ARG2)[3])
448 #  define ARG2_4  (((UWord*)ARG2)[4])
449 #  define ARG2_5  (((UWord*)ARG2)[5])
450
451    *flags |= SfMayBlock;
452    PRINT("sys_socketcall ( %ld, %#lx )",ARG1,ARG2);
453    PRE_REG_READ2(long, "socketcall", int, call, unsigned long *, args);
454
455    switch (ARG1 /* request */) {
456
457    case VKI_SYS_SOCKETPAIR:
458      /* int socketpair(int d, int type, int protocol, int sv[2]); */
459       PRE_MEM_READ( "socketcall.socketpair(args)", ARG2, 4*sizeof(Addr) );
460       if (!ML_(valid_client_addr)(ARG2, 4*sizeof(Addr), tid, NULL)) {
461          SET_STATUS_Failure( VKI_EFAULT );
462          break;
463       }
464       ML_(generic_PRE_sys_socketpair)( tid, ARG2_0, ARG2_1, ARG2_2, ARG2_3 );
465       break;
466
467    case VKI_SYS_SOCKET:
468      /* int socket(int domain, int type, int protocol); */
469       PRE_MEM_READ( "socketcall.socket(args)", ARG2, 3*sizeof(Addr) );
470       if (!ML_(valid_client_addr)(ARG2, 3*sizeof(Addr), tid, NULL)) {
471          SET_STATUS_Failure( VKI_EFAULT );
472          break;
473       }
474       break;
475
476    case VKI_SYS_BIND:
477      /* int bind(int sockfd, struct sockaddr *my_addr,
478         int addrlen); */
479       PRE_MEM_READ( "socketcall.bind(args)", ARG2, 3*sizeof(Addr) );
480       if (!ML_(valid_client_addr)(ARG2, 3*sizeof(Addr), tid, NULL)) {
481          SET_STATUS_Failure( VKI_EFAULT );
482          break;
483       }
484       ML_(generic_PRE_sys_bind)( tid, ARG2_0, ARG2_1, ARG2_2 );
485       break;
486
487    case VKI_SYS_LISTEN:
488      /* int listen(int s, int backlog); */
489       PRE_MEM_READ( "socketcall.listen(args)", ARG2, 2*sizeof(Addr) );
490       if (!ML_(valid_client_addr)(ARG2, 2*sizeof(Addr), tid, NULL)) {
491          SET_STATUS_Failure( VKI_EFAULT );
492          break;
493       }
494       break;
495
496    case VKI_SYS_ACCEPT: {
497      /* int accept(int s, struct sockaddr *addr, int *addrlen); */
498       PRE_MEM_READ( "socketcall.accept(args)", ARG2, 3*sizeof(Addr) );
499       if (!ML_(valid_client_addr)(ARG2, 3*sizeof(Addr), tid, NULL)) {
500          SET_STATUS_Failure( VKI_EFAULT );
501          break;
502       }
503       ML_(generic_PRE_sys_accept)( tid, ARG2_0, ARG2_1, ARG2_2 );
504       break;
505    }
506
507    case VKI_SYS_SENDTO:
508      /* int sendto(int s, const void *msg, int len,
509                     unsigned int flags,
510                     const struct sockaddr *to, int tolen); */
511      PRE_MEM_READ( "socketcall.sendto(args)", ARG2, 6*sizeof(Addr) );
512      if (!ML_(valid_client_addr)(ARG2, 6*sizeof(Addr), tid, NULL)) {
513          SET_STATUS_Failure( VKI_EFAULT );
514          break;
515      }
516      ML_(generic_PRE_sys_sendto)( tid, ARG2_0, ARG2_1, ARG2_2,
517                                   ARG2_3, ARG2_4, ARG2_5 );
518      break;
519
520    case VKI_SYS_SEND:
521      /* int send(int s, const void *msg, size_t len, int flags); */
522      PRE_MEM_READ( "socketcall.send(args)", ARG2, 4*sizeof(Addr) );
523      if (!ML_(valid_client_addr)(ARG2, 4*sizeof(Addr), tid, NULL)) {
524          SET_STATUS_Failure( VKI_EFAULT );
525          break;
526      }
527      ML_(generic_PRE_sys_send)( tid, ARG2_0, ARG2_1, ARG2_2 );
528      break;
529
530    case VKI_SYS_RECVFROM:
531      /* int recvfrom(int s, void *buf, int len, unsigned int flags,
532         struct sockaddr *from, int *fromlen); */
533      PRE_MEM_READ( "socketcall.recvfrom(args)", ARG2, 6*sizeof(Addr) );
534      if (!ML_(valid_client_addr)(ARG2, 6*sizeof(Addr), tid, NULL)) {
535          SET_STATUS_Failure( VKI_EFAULT );
536          break;
537      }
538      ML_(generic_PRE_sys_recvfrom)( tid, ARG2_0, ARG2_1, ARG2_2,
539                                     ARG2_3, ARG2_4, ARG2_5 );
540      break;
541
542    case VKI_SYS_RECV:
543      /* int recv(int s, void *buf, int len, unsigned int flags); */
544      /* man 2 recv says:
545          The  recv call is normally used only on a connected socket
546          (see connect(2)) and is identical to recvfrom with a  NULL
547          from parameter.
548      */
549      PRE_MEM_READ( "socketcall.recv(args)", ARG2, 4*sizeof(Addr) );
550      if (!ML_(valid_client_addr)(ARG2, 4*sizeof(Addr), tid, NULL)) {
551          SET_STATUS_Failure( VKI_EFAULT );
552          break;
553      }
554      ML_(generic_PRE_sys_recv)( tid, ARG2_0, ARG2_1, ARG2_2 );
555      break;
556
557    case VKI_SYS_CONNECT:
558      /* int connect(int sockfd,
559         struct sockaddr *serv_addr, int addrlen ); */
560      PRE_MEM_READ( "socketcall.connect(args)", ARG2, 3*sizeof(Addr) );
561      if (!ML_(valid_client_addr)(ARG2, 3*sizeof(Addr), tid, NULL)) {
562          SET_STATUS_Failure( VKI_EFAULT );
563          break;
564      }
565      ML_(generic_PRE_sys_connect)( tid, ARG2_0, ARG2_1, ARG2_2 );
566      break;
567
568    case VKI_SYS_SETSOCKOPT:
569      /* int setsockopt(int s, int level, int optname,
570         const void *optval, int optlen); */
571      PRE_MEM_READ( "socketcall.setsockopt(args)", ARG2, 5*sizeof(Addr) );
572      if (!ML_(valid_client_addr)(ARG2, 5*sizeof(Addr), tid, NULL)) {
573          SET_STATUS_Failure( VKI_EFAULT );
574          break;
575      }
576      ML_(generic_PRE_sys_setsockopt)( tid, ARG2_0, ARG2_1, ARG2_2,
577                                       ARG2_3, ARG2_4 );
578      break;
579
580    case VKI_SYS_GETSOCKOPT:
581      /* int getsockopt(int s, int level, int optname,
582         void *optval, socklen_t *optlen); */
583      PRE_MEM_READ( "socketcall.getsockopt(args)", ARG2, 5*sizeof(Addr) );
584      if (!ML_(valid_client_addr)(ARG2, 5*sizeof(Addr), tid, NULL)) {
585          SET_STATUS_Failure( VKI_EFAULT );
586          break;
587      }
588      ML_(linux_PRE_sys_getsockopt)( tid, ARG2_0, ARG2_1, ARG2_2,
589                                       ARG2_3, ARG2_4 );
590      break;
591
592    case VKI_SYS_GETSOCKNAME:
593      /* int getsockname(int s, struct sockaddr* name, int* namelen) */
594      PRE_MEM_READ( "socketcall.getsockname(args)", ARG2, 3*sizeof(Addr) );
595      if (!ML_(valid_client_addr)(ARG2, 3*sizeof(Addr), tid, NULL)) {
596          SET_STATUS_Failure( VKI_EFAULT );
597          break;
598      }
599      ML_(generic_PRE_sys_getsockname)( tid, ARG2_0, ARG2_1, ARG2_2 );
600      break;
601
602    case VKI_SYS_GETPEERNAME:
603      /* int getpeername(int s, struct sockaddr* name, int* namelen) */
604      PRE_MEM_READ( "socketcall.getpeername(args)", ARG2, 3*sizeof(Addr) );
605      if (!ML_(valid_client_addr)(ARG2, 3*sizeof(Addr), tid, NULL)) {
606          SET_STATUS_Failure( VKI_EFAULT );
607          break;
608      }
609      ML_(generic_PRE_sys_getpeername)( tid, ARG2_0, ARG2_1, ARG2_2 );
610      break;
611
612    case VKI_SYS_SHUTDOWN:
613      /* int shutdown(int s, int how); */
614      PRE_MEM_READ( "socketcall.shutdown(args)", ARG2, 2*sizeof(Addr) );
615      if (!ML_(valid_client_addr)(ARG2, 2*sizeof(Addr), tid, NULL)) {
616          SET_STATUS_Failure( VKI_EFAULT );
617          break;
618      }
619      break;
620
621    case VKI_SYS_SENDMSG: {
622      /* int sendmsg(int s, const struct msghdr *msg, int flags); */
623      PRE_MEM_READ( "socketcall.sendmsg(args)", ARG2, 3*sizeof(Addr) );
624      if (!ML_(valid_client_addr)(ARG2, 3*sizeof(Addr), tid, NULL)) {
625          SET_STATUS_Failure( VKI_EFAULT );
626          break;
627      }
628      ML_(generic_PRE_sys_sendmsg)( tid, ARG2_0, ARG2_1 );
629      break;
630    }
631
632    case VKI_SYS_RECVMSG: {
633      /* int recvmsg(int s, struct msghdr *msg, int flags); */
634      PRE_MEM_READ("socketcall.recvmsg(args)", ARG2, 3*sizeof(Addr) );
635      if (!ML_(valid_client_addr)(ARG2, 3*sizeof(Addr), tid, NULL)) {
636          SET_STATUS_Failure( VKI_EFAULT );
637          break;
638      }
639      ML_(generic_PRE_sys_recvmsg)( tid, ARG2_0, ARG2_1 );
640      break;
641    }
642
643    default:
644      VG_(message)(Vg_DebugMsg,"Warning: unhandled socketcall 0x%lx\n",ARG1);
645      SET_STATUS_Failure( VKI_EINVAL );
646      break;
647    }
648 #  undef ARG2_0
649 #  undef ARG2_1
650 #  undef ARG2_2
651 #  undef ARG2_3
652 #  undef ARG2_4
653 #  undef ARG2_5
654 }
655
656 POST(sys_socketcall)
657 {
658 #  define ARG2_0  (((UWord*)ARG2)[0])
659 #  define ARG2_1  (((UWord*)ARG2)[1])
660 #  define ARG2_2  (((UWord*)ARG2)[2])
661 #  define ARG2_3  (((UWord*)ARG2)[3])
662 #  define ARG2_4  (((UWord*)ARG2)[4])
663 #  define ARG2_5  (((UWord*)ARG2)[5])
664
665   SysRes r;
666   vg_assert(SUCCESS);
667   switch (ARG1 /* request */) {
668
669   case VKI_SYS_SOCKETPAIR:
670     r = ML_(generic_POST_sys_socketpair)(
671                                          tid, VG_(mk_SysRes_Success)(RES),
672                                          ARG2_0, ARG2_1, ARG2_2, ARG2_3
673                                          );
674     SET_STATUS_from_SysRes(r);
675     break;
676
677   case VKI_SYS_SOCKET:
678     r = ML_(generic_POST_sys_socket)( tid, VG_(mk_SysRes_Success)(RES) );
679     SET_STATUS_from_SysRes(r);
680     break;
681
682   case VKI_SYS_BIND:
683     /* int bind(int sockfd, struct sockaddr *my_addr,
684        int addrlen); */
685     break;
686
687   case VKI_SYS_LISTEN:
688     /* int listen(int s, int backlog); */
689     break;
690
691   case VKI_SYS_ACCEPT:
692     /* int accept(int s, struct sockaddr *addr, int *addrlen); */
693     r = ML_(generic_POST_sys_accept)( tid, VG_(mk_SysRes_Success)(RES),
694                                       ARG2_0, ARG2_1, ARG2_2 );
695     SET_STATUS_from_SysRes(r);
696     break;
697
698   case VKI_SYS_SENDTO:
699     break;
700
701   case VKI_SYS_SEND:
702     break;
703
704   case VKI_SYS_RECVFROM:
705     ML_(generic_POST_sys_recvfrom)( tid, VG_(mk_SysRes_Success)(RES),
706                                     ARG2_0, ARG2_1, ARG2_2,
707                                     ARG2_3, ARG2_4, ARG2_5 );
708     break;
709
710   case VKI_SYS_RECV:
711     ML_(generic_POST_sys_recv)( tid, RES, ARG2_0, ARG2_1, ARG2_2 );
712     break;
713
714   case VKI_SYS_CONNECT:
715     break;
716
717   case VKI_SYS_SETSOCKOPT:
718     break;
719
720   case VKI_SYS_GETSOCKOPT:
721     ML_(linux_POST_sys_getsockopt)( tid, VG_(mk_SysRes_Success)(RES),
722                                       ARG2_0, ARG2_1,
723                                       ARG2_2, ARG2_3, ARG2_4 );
724     break;
725
726   case VKI_SYS_GETSOCKNAME:
727     ML_(generic_POST_sys_getsockname)( tid, VG_(mk_SysRes_Success)(RES),
728                                        ARG2_0, ARG2_1, ARG2_2 );
729     break;
730
731   case VKI_SYS_GETPEERNAME:
732     ML_(generic_POST_sys_getpeername)( tid, VG_(mk_SysRes_Success)(RES),
733                                        ARG2_0, ARG2_1, ARG2_2 );
734     break;
735
736   case VKI_SYS_SHUTDOWN:
737     break;
738
739   case VKI_SYS_SENDMSG:
740     break;
741
742   case VKI_SYS_RECVMSG:
743     ML_(generic_POST_sys_recvmsg)( tid, ARG2_0, ARG2_1 );
744     break;
745
746   default:
747     VG_(message)(Vg_DebugMsg,"FATAL: unhandled socketcall 0x%lx\n",ARG1);
748     VG_(core_panic)("... bye!\n");
749     break; /*NOTREACHED*/
750   }
751 #  undef ARG2_0
752 #  undef ARG2_1
753 #  undef ARG2_2
754 #  undef ARG2_3
755 #  undef ARG2_4
756 #  undef ARG2_5
757 }
758
759 PRE(sys_mmap)
760 {
761    UWord a0, a1, a2, a3, a4, a5;
762    SysRes r;
763
764    UWord* args = (UWord*)ARG1;
765    PRE_REG_READ1(long, "sys_mmap", struct mmap_arg_struct *, args);
766    PRE_MEM_READ( "sys_mmap(args)", (Addr) args, 6*sizeof(UWord) );
767
768    a0 = args[0];
769    a1 = args[1];
770    a2 = args[2];
771    a3 = args[3];
772    a4 = args[4];
773    a5 = args[5];
774
775    PRINT("sys_mmap ( %#lx, %llu, %ld, %ld, %ld, %ld )",
776          a0, (ULong)a1, a2, a3, a4, a5 );
777
778    r = ML_(generic_PRE_sys_mmap)( tid, a0, a1, a2, a3, a4, (Off64T)a5 );
779    SET_STATUS_from_SysRes(r);
780 }
781
782 static Addr deref_Addr ( ThreadId tid, Addr a, Char* s )
783 {
784    Addr* a_p = (Addr*)a;
785    PRE_MEM_READ( s, (Addr)a_p, sizeof(Addr) );
786    return *a_p;
787 }
788
789 PRE(sys_ipc)
790 {
791   PRINT("sys_ipc ( %ld, %ld, %ld, %ld, %#lx, %ld )",
792         ARG1,ARG2,ARG3,ARG4,ARG5,ARG6);
793   // XXX: this is simplistic -- some args are not used in all circumstances.
794   PRE_REG_READ6(int, "ipc",
795                 vki_uint, call, int, first, int, second, int, third,
796                 void *, ptr, long, fifth)
797
798     switch (ARG1 /* call */) {
799     case VKI_SEMOP:
800       ML_(generic_PRE_sys_semop)( tid, ARG2, ARG5, ARG3 );
801       *flags |= SfMayBlock;
802       break;
803     case VKI_SEMGET:
804       break;
805     case VKI_SEMCTL:
806       {
807         UWord arg = deref_Addr( tid, ARG5, "semctl(arg)" );
808         ML_(generic_PRE_sys_semctl)( tid, ARG2, ARG3, ARG4, arg );
809         break;
810       }
811     case VKI_SEMTIMEDOP:
812       ML_(generic_PRE_sys_semtimedop)( tid, ARG2, ARG5, ARG3, ARG6 );
813       *flags |= SfMayBlock;
814       break;
815     case VKI_MSGSND:
816       ML_(linux_PRE_sys_msgsnd)( tid, ARG2, ARG5, ARG3, ARG4 );
817       if ((ARG4 & VKI_IPC_NOWAIT) == 0)
818         *flags |= SfMayBlock;
819       break;
820     case VKI_MSGRCV:
821       {
822         Addr msgp;
823         Word msgtyp;
824
825         msgp = deref_Addr( tid,
826                            (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgp),
827                            "msgrcv(msgp)" );
828         msgtyp = deref_Addr( tid,
829                              (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgtyp),
830                              "msgrcv(msgp)" );
831
832         ML_(linux_PRE_sys_msgrcv)( tid, ARG2, msgp, ARG3, msgtyp, ARG4 );
833
834         if ((ARG4 & VKI_IPC_NOWAIT) == 0)
835           *flags |= SfMayBlock;
836         break;
837       }
838     case VKI_MSGGET:
839       break;
840     case VKI_MSGCTL:
841       ML_(linux_PRE_sys_msgctl)( tid, ARG2, ARG3, ARG5 );
842       break;
843     case VKI_SHMAT:
844       {
845         UWord w;
846         PRE_MEM_WRITE( "shmat(raddr)", ARG4, sizeof(Addr) );
847         w = ML_(generic_PRE_sys_shmat)( tid, ARG2, ARG5, ARG3 );
848         if (w == 0)
849           SET_STATUS_Failure( VKI_EINVAL );
850         else
851           ARG5 = w;
852         break;
853       }
854     case VKI_SHMDT:
855       if (!ML_(generic_PRE_sys_shmdt)(tid, ARG5))
856         SET_STATUS_Failure( VKI_EINVAL );
857       break;
858     case VKI_SHMGET:
859       break;
860     case VKI_SHMCTL: /* IPCOP_shmctl */
861       ML_(generic_PRE_sys_shmctl)( tid, ARG2, ARG3, ARG5 );
862       break;
863     default:
864       VG_(message)(Vg_DebugMsg, "FATAL: unhandled syscall(ipc) %ld", ARG1 );
865       VG_(core_panic)("... bye!\n");
866       break; /*NOTREACHED*/
867     }
868 }
869
870 POST(sys_ipc)
871 {
872   vg_assert(SUCCESS);
873   switch (ARG1 /* call */) {
874   case VKI_SEMOP:
875   case VKI_SEMGET:
876     break;
877   case VKI_SEMCTL:
878     {
879       UWord arg = deref_Addr( tid, ARG5, "semctl(arg)" );
880       ML_(generic_PRE_sys_semctl)( tid, ARG2, ARG3, ARG4, arg );
881       break;
882     }
883   case VKI_SEMTIMEDOP:
884   case VKI_MSGSND:
885     break;
886   case VKI_MSGRCV:
887     {
888       Addr msgp;
889       Word msgtyp;
890
891       msgp = deref_Addr( tid,
892                          (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgp),
893                          "msgrcv(msgp)" );
894       msgtyp = deref_Addr( tid,
895                            (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgtyp),
896                            "msgrcv(msgp)" );
897
898       ML_(linux_POST_sys_msgrcv)( tid, RES, ARG2, msgp, ARG3, msgtyp, ARG4 );
899       break;
900     }
901   case VKI_MSGGET:
902     break;
903   case VKI_MSGCTL:
904     ML_(linux_POST_sys_msgctl)( tid, RES, ARG2, ARG3, ARG5 );
905     break;
906   case VKI_SHMAT:
907     {
908       Addr addr;
909
910       /* force readability. before the syscall it is
911        * indeed uninitialized, as can be seen in
912        * glibc/sysdeps/unix/sysv/linux/shmat.c */
913       POST_MEM_WRITE( ARG4, sizeof( Addr ) );
914
915       addr = deref_Addr ( tid, ARG4, "shmat(addr)" );
916       ML_(generic_POST_sys_shmat)( tid, addr, ARG2, ARG5, ARG3 );
917       break;
918     }
919   case VKI_SHMDT:
920     ML_(generic_POST_sys_shmdt)( tid, RES, ARG5 );
921     break;
922   case VKI_SHMGET:
923     break;
924   case VKI_SHMCTL:
925     ML_(generic_POST_sys_shmctl)( tid, RES, ARG2, ARG3, ARG5 );
926     break;
927   default:
928     VG_(message)(Vg_DebugMsg,
929                  "FATAL: unhandled syscall(ipc) %ld",
930                  ARG1 );
931     VG_(core_panic)("... bye!\n");
932     break; /*NOTREACHED*/
933   }
934 }
935
936 PRE(sys_clone)
937 {
938    UInt cloneflags;
939
940    PRINT("sys_clone ( %lx, %#lx, %#lx, %#lx, %#lx )",ARG1,ARG2,ARG3,ARG4, ARG5);
941    PRE_REG_READ4(int, "clone",
942                  void *,        child_stack,
943                  unsigned long, flags,
944                  int *,         parent_tidptr,
945                  int *,         child_tidptr);
946
947    if (ARG2 & VKI_CLONE_PARENT_SETTID) {
948       PRE_MEM_WRITE("clone(parent_tidptr)", ARG3, sizeof(Int));
949       if (!VG_(am_is_valid_for_client)(ARG3, sizeof(Int),
950                                              VKI_PROT_WRITE)) {
951          SET_STATUS_Failure( VKI_EFAULT );
952          return;
953       }
954    }
955    if (ARG2 & (VKI_CLONE_CHILD_SETTID | VKI_CLONE_CHILD_CLEARTID)) {
956       PRE_MEM_WRITE("clone(child_tidptr)", ARG4, sizeof(Int));
957       if (!VG_(am_is_valid_for_client)(ARG4, sizeof(Int),
958                                              VKI_PROT_WRITE)) {
959          SET_STATUS_Failure( VKI_EFAULT );
960          return;
961       }
962    }
963
964    cloneflags = ARG2;
965
966    if (!ML_(client_signal_OK)(ARG2 & VKI_CSIGNAL)) {
967       SET_STATUS_Failure( VKI_EINVAL );
968       return;
969    }
970
971    /* Only look at the flags we really care about */
972    switch (cloneflags & (VKI_CLONE_VM | VKI_CLONE_FS
973                          | VKI_CLONE_FILES | VKI_CLONE_VFORK)) {
974    case VKI_CLONE_VM | VKI_CLONE_FS | VKI_CLONE_FILES:
975       /* thread creation */
976       SET_STATUS_from_SysRes(
977          do_clone(tid,
978                   (Addr)ARG1,   /* child SP */
979                   ARG2,         /* flags */
980                   (Int *)ARG3,  /* parent_tidptr */
981                   (Int *)ARG4, /* child_tidptr */
982                   (Addr)ARG5)); /*  tlsaddr */
983       break;
984
985    case VKI_CLONE_VFORK | VKI_CLONE_VM: /* vfork */
986       /* FALLTHROUGH - assume vfork == fork */
987       cloneflags &= ~(VKI_CLONE_VFORK | VKI_CLONE_VM);
988
989    case 0: /* plain fork */
990       SET_STATUS_from_SysRes(
991          ML_(do_fork_clone)(tid,
992                        cloneflags,      /* flags */
993                        (Int *)ARG3,     /* parent_tidptr */
994                        (Int *)ARG4));   /* child_tidptr */
995       break;
996
997    default:
998       /* should we just ENOSYS? */
999       VG_(message)(Vg_UserMsg, "Unsupported clone() flags: 0x%lx", ARG2);
1000       VG_(message)(Vg_UserMsg, "");
1001       VG_(message)(Vg_UserMsg, "The only supported clone() uses are:");
1002       VG_(message)(Vg_UserMsg, " - via a threads library (NPTL)");
1003       VG_(message)(Vg_UserMsg, " - via the implementation of fork or vfork");
1004       VG_(unimplemented)
1005          ("Valgrind does not support general clone().");
1006    }
1007
1008    if (SUCCESS) {
1009       if (ARG2 & VKI_CLONE_PARENT_SETTID)
1010          POST_MEM_WRITE(ARG3, sizeof(Int));
1011       if (ARG2 & (VKI_CLONE_CHILD_SETTID | VKI_CLONE_CHILD_CLEARTID))
1012          POST_MEM_WRITE(ARG4, sizeof(Int));
1013
1014       /* Thread creation was successful; let the child have the chance
1015          to run */
1016       *flags |= SfYieldAfter;
1017    }
1018 }
1019
1020 PRE(sys_sigreturn)
1021 {
1022    ThreadState* tst;
1023    PRINT("sys_sigreturn ( )");
1024
1025    vg_assert(VG_(is_valid_tid)(tid));
1026    vg_assert(tid >= 1 && tid < VG_N_THREADS);
1027    vg_assert(VG_(is_running_thread)(tid));
1028
1029    tst = VG_(get_ThreadState)(tid);
1030
1031    /* This is only so that the IA is (might be) useful to report if
1032       something goes wrong in the sigreturn */
1033    ML_(fixup_guest_state_to_restart_syscall)(&tst->arch);
1034
1035    /* Restore register state from frame and remove it */
1036    VG_(sigframe_destroy)(tid, False);
1037
1038    /* Tell the driver not to update the guest state with the "result",
1039       and set a bogus result to keep it happy. */
1040    *flags |= SfNoWriteResult;
1041    SET_STATUS_Success(0);
1042
1043    /* Check to see if any signals arose as a result of this. */
1044    *flags |= SfPollAfter;
1045 }
1046
1047
1048 PRE(sys_rt_sigreturn)
1049 {
1050    /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for
1051       an explanation of what follows. */
1052
1053    ThreadState* tst;
1054    PRINT("sys_rt_sigreturn ( )");
1055
1056    vg_assert(VG_(is_valid_tid)(tid));
1057    vg_assert(tid >= 1 && tid < VG_N_THREADS);
1058    vg_assert(VG_(is_running_thread)(tid));
1059
1060    tst = VG_(get_ThreadState)(tid);
1061
1062    /* This is only so that the IA is (might be) useful to report if
1063       something goes wrong in the sigreturn */
1064    ML_(fixup_guest_state_to_restart_syscall)(&tst->arch);
1065
1066    /* Restore register state from frame and remove it */
1067    VG_(sigframe_destroy)(tid, True);
1068
1069    /* Tell the driver not to update the guest state with the "result",
1070       and set a bogus result to keep it happy. */
1071    *flags |= SfNoWriteResult;
1072    SET_STATUS_Success(0);
1073
1074    /* Check to see if any signals arose as a result of this. */
1075    *flags |= SfPollAfter;
1076 }
1077
1078 /* we cant use the LINX_ version for 64 bit */
1079 PRE(sys_fadvise64)
1080 {
1081    PRINT("sys_fadvise64 ( %ld, %ld, %ld, %ld )", ARG1,ARG2,ARG3,ARG4);
1082    PRE_REG_READ4(long, "fadvise64",
1083                  int, fd, vki_loff_t, offset, vki_loff_t, len, int, advice);
1084 }
1085
1086 #undef PRE
1087 #undef POST
1088
1089 /* ---------------------------------------------------------------------
1090    The s390x/Linux syscall table
1091    ------------------------------------------------------------------ */
1092
1093 /* Add an s390x-linux specific wrapper to a syscall table. */
1094 #define PLAX_(sysno, name)    WRAPPER_ENTRY_X_(s390x_linux, sysno, name)
1095 #define PLAXY(sysno, name)    WRAPPER_ENTRY_XY(s390x_linux, sysno, name)
1096
1097 // This table maps from __NR_xxx syscall numbers from
1098 // linux/arch/s390/kernel/syscalls.S to the appropriate PRE/POST sys_foo()
1099 // wrappers on s390x. There are several unused numbers, which are only
1100 // defined on s390 (31bit mode) but no longer available on s390x (64 bit).
1101 // For those syscalls not handled by Valgrind, the annotation indicate its
1102 // arch/OS combination, eg. */* (generic), */Linux (Linux only), ?/?
1103 // (unknown).
1104
1105 static SyscallTableEntry syscall_table[] = {
1106    GENX_(0, sys_ni_syscall), /* unimplemented (by the kernel) */      // 0
1107    GENX_(__NR_exit,  sys_exit),                                       // 1
1108    GENX_(__NR_fork,  sys_fork),                                       // 2
1109    GENXY(__NR_read,  sys_read),                                       // 3
1110    GENX_(__NR_write,  sys_write),                                     // 4
1111
1112    GENXY(__NR_open,  sys_open),                                       // 5
1113    GENXY(__NR_close,  sys_close),                                     // 6
1114 // ?????(__NR_restart_syscall, ),                                     // 7
1115    GENXY(__NR_creat,  sys_creat),                                     // 8
1116    GENX_(__NR_link,  sys_link),                                       // 9
1117
1118    GENX_(__NR_unlink,  sys_unlink),                                   // 10
1119    GENX_(__NR_execve,  sys_execve),                                   // 11
1120    GENX_(__NR_chdir,  sys_chdir),                                     // 12
1121    GENX_(13, sys_ni_syscall), /* unimplemented (by the kernel) */     // 13
1122    GENX_(__NR_mknod,  sys_mknod),                                     // 14
1123
1124    GENX_(__NR_chmod,  sys_chmod),                                     // 15
1125    GENX_(16, sys_ni_syscall), /* unimplemented (by the kernel) */     // 16
1126    GENX_(17, sys_ni_syscall), /* unimplemented (by the kernel) */     // 17
1127    GENX_(18, sys_ni_syscall), /* unimplemented (by the kernel) */     // 18
1128    LINX_(__NR_lseek,  sys_lseek),                                     // 19
1129
1130    GENX_(__NR_getpid,  sys_getpid),                                   // 20
1131    LINX_(__NR_mount,  sys_mount),                                     // 21
1132    LINX_(__NR_umount, sys_oldumount),                                 // 22
1133    GENX_(23, sys_ni_syscall), /* unimplemented (by the kernel) */     // 23
1134    GENX_(24, sys_ni_syscall), /* unimplemented (by the kernel) */     // 24
1135
1136    GENX_(25, sys_ni_syscall), /* unimplemented (by the kernel) */     // 25
1137    PLAXY(__NR_ptrace, sys_ptrace),                                    // 26
1138    GENX_(__NR_alarm,  sys_alarm),                                     // 27
1139    GENX_(28, sys_ni_syscall), /* unimplemented (by the kernel) */     // 28
1140    GENX_(__NR_pause,  sys_pause),                                     // 29
1141
1142    LINX_(__NR_utime,  sys_utime),                                     // 30
1143    GENX_(31, sys_ni_syscall), /* unimplemented (by the kernel) */     // 31
1144    GENX_(32, sys_ni_syscall), /* unimplemented (by the kernel) */     // 32
1145    GENX_(__NR_access,  sys_access),                                   // 33
1146    GENX_(__NR_nice, sys_nice),                                        // 34
1147
1148    GENX_(35, sys_ni_syscall), /* unimplemented (by the kernel) */     // 35
1149    GENX_(__NR_sync, sys_sync),                                        // 36
1150    GENX_(__NR_kill,  sys_kill),                                       // 37
1151    GENX_(__NR_rename,  sys_rename),                                   // 38
1152    GENX_(__NR_mkdir,  sys_mkdir),                                     // 39
1153
1154    GENX_(__NR_rmdir, sys_rmdir),                                      // 40
1155    GENXY(__NR_dup,  sys_dup),                                         // 41
1156    LINXY(__NR_pipe,  sys_pipe),                                       // 42
1157    GENXY(__NR_times,  sys_times),                                     // 43
1158    GENX_(44, sys_ni_syscall), /* unimplemented (by the kernel) */     // 44
1159
1160    GENX_(__NR_brk,  sys_brk),                                         // 45
1161    GENX_(46, sys_ni_syscall), /* unimplemented (by the kernel) */     // 46
1162    GENX_(47, sys_ni_syscall), /* unimplemented (by the kernel) */     // 47
1163 // ?????(__NR_signal, ),                                              // 48
1164    GENX_(49, sys_ni_syscall), /* unimplemented (by the kernel) */     // 49
1165
1166    GENX_(50, sys_ni_syscall), /* unimplemented (by the kernel) */     // 50
1167    GENX_(__NR_acct, sys_acct),                                        // 51
1168    LINX_(__NR_umount2, sys_umount),                                   // 52
1169    GENX_(53, sys_ni_syscall), /* unimplemented (by the kernel) */     // 53
1170    LINXY(__NR_ioctl,  sys_ioctl),                                     // 54
1171
1172    LINXY(__NR_fcntl,  sys_fcntl),                                     // 55
1173    GENX_(56, sys_ni_syscall), /* unimplemented (by the kernel) */     // 56
1174    GENX_(__NR_setpgid,  sys_setpgid),                                 // 57
1175    GENX_(58, sys_ni_syscall), /* unimplemented (by the kernel) */     // 58
1176    GENX_(59, sys_ni_syscall), /* unimplemented (by the kernel) */     // 59
1177
1178    GENX_(__NR_umask,  sys_umask),                                     // 60
1179    GENX_(__NR_chroot,  sys_chroot),                                   // 61
1180 // ?????(__NR_ustat, sys_ustat), /* deprecated in favor of statfs */  // 62
1181    GENXY(__NR_dup2,  sys_dup2),                                       // 63
1182    GENX_(__NR_getppid,  sys_getppid),                                 // 64
1183
1184    GENX_(__NR_getpgrp,  sys_getpgrp),                                 // 65
1185    GENX_(__NR_setsid,  sys_setsid),                                   // 66
1186 // ?????(__NR_sigaction, ),   /* userspace uses rt_sigaction */       // 67
1187    GENX_(68, sys_ni_syscall), /* unimplemented (by the kernel) */     // 68
1188    GENX_(69, sys_ni_syscall), /* unimplemented (by the kernel) */     // 69
1189
1190    GENX_(70, sys_ni_syscall), /* unimplemented (by the kernel) */     // 70
1191    GENX_(71, sys_ni_syscall), /* unimplemented (by the kernel) */     // 71
1192 // ?????(__NR_sigsuspend, ),                                          // 72
1193 // ?????(__NR_sigpending, ),                                          // 73
1194 // ?????(__NR_sethostname, ),                                         // 74
1195
1196    GENX_(__NR_setrlimit,  sys_setrlimit),                             // 75
1197    GENXY(76,  sys_getrlimit), /* see also 191 */                      // 76
1198    GENXY(__NR_getrusage,  sys_getrusage),                             // 77
1199    GENXY(__NR_gettimeofday,  sys_gettimeofday),                       // 78
1200    GENX_(__NR_settimeofday, sys_settimeofday),                        // 79
1201
1202    GENX_(80, sys_ni_syscall), /* unimplemented (by the kernel) */     // 80
1203    GENX_(81, sys_ni_syscall), /* unimplemented (by the kernel) */     // 81
1204    GENX_(82, sys_ni_syscall), /* unimplemented (by the kernel) */     // 82
1205    GENX_(__NR_symlink,  sys_symlink),                                 // 83
1206    GENX_(84, sys_ni_syscall), /* unimplemented (by the kernel) */     // 84
1207
1208    GENX_(__NR_readlink,  sys_readlink),                               // 85
1209 // ?????(__NR_uselib, ),                                              // 86
1210 // ?????(__NR_swapon, ),                                              // 87
1211 // ?????(__NR_reboot, ),                                              // 88
1212    GENX_(89, sys_ni_syscall), /* unimplemented (by the kernel) */     // 89
1213
1214    PLAX_(__NR_mmap, sys_mmap ),                                       // 90
1215    GENXY(__NR_munmap,  sys_munmap),                                   // 91
1216    GENX_(__NR_truncate,  sys_truncate),                               // 92
1217    GENX_(__NR_ftruncate,  sys_ftruncate),                             // 93
1218    GENX_(__NR_fchmod,  sys_fchmod),                                   // 94
1219
1220    GENX_(95, sys_ni_syscall), /* unimplemented (by the kernel) */     // 95
1221    GENX_(__NR_getpriority, sys_getpriority),                          // 96
1222    GENX_(__NR_setpriority, sys_setpriority),                          // 97
1223    GENX_(98, sys_ni_syscall), /* unimplemented (by the kernel) */     // 98
1224    GENXY(__NR_statfs,  sys_statfs),                                   // 99
1225
1226    GENXY(__NR_fstatfs,  sys_fstatfs),                                 // 100
1227    GENX_(101, sys_ni_syscall), /* unimplemented (by the kernel) */    // 101
1228    PLAXY(__NR_socketcall, sys_socketcall),                            // 102
1229    LINXY(__NR_syslog,  sys_syslog),                                   // 103
1230    GENXY(__NR_setitimer,  sys_setitimer),                             // 104
1231
1232    GENXY(__NR_getitimer,  sys_getitimer),                             // 105
1233    GENXY(__NR_stat, sys_newstat),                                     // 106
1234    GENXY(__NR_lstat, sys_newlstat),                                   // 107
1235    GENXY(__NR_fstat, sys_newfstat),                                   // 108
1236    GENX_(109, sys_ni_syscall), /* unimplemented (by the kernel) */    // 109
1237
1238    LINXY(__NR_lookup_dcookie, sys_lookup_dcookie),                    // 110
1239    LINX_(__NR_vhangup, sys_vhangup),                                  // 111
1240    GENX_(112, sys_ni_syscall), /* unimplemented (by the kernel) */    // 112
1241    GENX_(113, sys_ni_syscall), /* unimplemented (by the kernel) */    // 113
1242    GENXY(__NR_wait4,  sys_wait4),                                     // 114
1243
1244 // ?????(__NR_swapoff, ),                                             // 115
1245    LINXY(__NR_sysinfo,  sys_sysinfo),                                 // 116
1246    PLAXY(__NR_ipc, sys_ipc),                                          // 117
1247    GENX_(__NR_fsync,  sys_fsync),                                     // 118
1248    PLAX_(__NR_sigreturn, sys_sigreturn),                              // 119
1249
1250    PLAX_(__NR_clone,  sys_clone),                                     // 120
1251 // ?????(__NR_setdomainname, ),                                       // 121
1252    GENXY(__NR_uname, sys_newuname),                                   // 122
1253    GENX_(123, sys_ni_syscall), /* unimplemented (by the kernel) */    // 123
1254 // ?????(__NR_adjtimex, ),                                            // 124
1255
1256    GENXY(__NR_mprotect,  sys_mprotect),                               // 125
1257 // LINXY(__NR_sigprocmask, sys_sigprocmask),                          // 126
1258    GENX_(127, sys_ni_syscall), /* unimplemented (by the kernel) */    // 127
1259    LINX_(__NR_init_module,  sys_init_module),                         // 128
1260    LINX_(__NR_delete_module,  sys_delete_module),                     // 129
1261
1262    GENX_(130, sys_ni_syscall), /* unimplemented (by the kernel) */    // 130
1263    LINX_(__NR_quotactl, sys_quotactl),                                // 131
1264    GENX_(__NR_getpgid,  sys_getpgid),                                 // 132
1265    GENX_(__NR_fchdir,  sys_fchdir),                                   // 133
1266 // ?????(__NR_bdflush, ),                                             // 134
1267
1268 // ?????(__NR_sysfs, ),                                               // 135
1269    LINX_(__NR_personality, sys_personality),                          // 136
1270    GENX_(137, sys_ni_syscall), /* unimplemented (by the kernel) */    // 137
1271    GENX_(138, sys_ni_syscall), /* unimplemented (by the kernel) */    // 138
1272    GENX_(139, sys_ni_syscall), /* unimplemented (by the kernel) */    // 139
1273
1274 // LINXY(__NR__llseek, sys_llseek), /* 64 bit --> lseek */            // 140
1275    GENXY(__NR_getdents,  sys_getdents),                               // 141
1276    GENX_(__NR_select, sys_select),                                    // 142
1277    GENX_(__NR_flock,  sys_flock),                                     // 143
1278    GENX_(__NR_msync,  sys_msync),                                     // 144
1279
1280    GENXY(__NR_readv,  sys_readv),                                     // 145
1281    GENX_(__NR_writev,  sys_writev),                                   // 146
1282    GENX_(__NR_getsid, sys_getsid),                                    // 147
1283    GENX_(__NR_fdatasync,  sys_fdatasync),                             // 148
1284    LINXY(__NR__sysctl, sys_sysctl),                                   // 149
1285
1286    GENX_(__NR_mlock,  sys_mlock),                                     // 150
1287    GENX_(__NR_munlock,  sys_munlock),                                 // 151
1288    GENX_(__NR_mlockall,  sys_mlockall),                               // 152
1289    LINX_(__NR_munlockall,  sys_munlockall),                           // 153
1290    LINXY(__NR_sched_setparam,  sys_sched_setparam),                   // 154
1291
1292    LINXY(__NR_sched_getparam,  sys_sched_getparam),                   // 155
1293    LINX_(__NR_sched_setscheduler,  sys_sched_setscheduler),           // 156
1294    LINX_(__NR_sched_getscheduler,  sys_sched_getscheduler),           // 157
1295    LINX_(__NR_sched_yield,  sys_sched_yield),                         // 158
1296    LINX_(__NR_sched_get_priority_max,  sys_sched_get_priority_max),   // 159
1297
1298    LINX_(__NR_sched_get_priority_min,  sys_sched_get_priority_min),   // 160
1299 // ?????(__NR_sched_rr_get_interval, ),                               // 161
1300    GENXY(__NR_nanosleep,  sys_nanosleep),                             // 162
1301    GENX_(__NR_mremap,  sys_mremap),                                   // 163
1302    GENX_(164, sys_ni_syscall), /* unimplemented (by the kernel) */    // 164
1303
1304    GENX_(165, sys_ni_syscall), /* unimplemented (by the kernel) */    // 165
1305    GENX_(166, sys_ni_syscall), /* unimplemented (by the kernel) */    // 166
1306    GENX_(167, sys_ni_syscall), /* unimplemented (by the kernel) */    // 167
1307    GENXY(__NR_poll,  sys_poll),                                       // 168
1308 // ?????(__NR_nfsservctl, ),                                          // 169
1309
1310    GENX_(170, sys_ni_syscall), /* unimplemented (by the kernel) */    // 170
1311    GENX_(171, sys_ni_syscall), /* unimplemented (by the kernel) */    // 171
1312    LINXY(__NR_prctl, sys_prctl),                                      // 172
1313    PLAX_(__NR_rt_sigreturn,  sys_rt_sigreturn),                       // 173
1314    LINXY(__NR_rt_sigaction,  sys_rt_sigaction),                       // 174
1315
1316    LINXY(__NR_rt_sigprocmask,  sys_rt_sigprocmask),                   // 175
1317    LINXY(__NR_rt_sigpending, sys_rt_sigpending),                      // 176
1318    LINXY(__NR_rt_sigtimedwait,  sys_rt_sigtimedwait),                 // 177
1319    LINXY(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo),                  // 178
1320    LINX_(__NR_rt_sigsuspend, sys_rt_sigsuspend),                      // 179
1321
1322    GENXY(__NR_pread64,  sys_pread64),                                 // 180
1323    GENX_(__NR_pwrite64, sys_pwrite64),                                // 181
1324    GENX_(182, sys_ni_syscall), /* unimplemented (by the kernel) */    // 182
1325    GENXY(__NR_getcwd,  sys_getcwd),                                   // 183
1326    LINXY(__NR_capget,  sys_capget),                                   // 184
1327
1328    LINX_(__NR_capset,  sys_capset),                                   // 185
1329    GENXY(__NR_sigaltstack,  sys_sigaltstack),                         // 186
1330    LINXY(__NR_sendfile, sys_sendfile),                                // 187
1331    GENX_(188, sys_ni_syscall), /* unimplemented (by the kernel) */    // 188
1332    GENX_(189, sys_ni_syscall), /* unimplemented (by the kernel) */    // 189
1333
1334    GENX_(__NR_vfork,  sys_fork),                                      // 190
1335    GENXY(__NR_getrlimit,  sys_getrlimit),                             // 191
1336    GENX_(192, sys_ni_syscall), /* not exported on 64bit*/             // 192
1337    GENX_(193, sys_ni_syscall), /* unimplemented (by the kernel) */    // 193
1338    GENX_(194, sys_ni_syscall), /* unimplemented (by the kernel) */    // 194
1339
1340    GENX_(195, sys_ni_syscall), /* unimplemented (by the kernel) */    // 195
1341    GENX_(196, sys_ni_syscall), /* unimplemented (by the kernel) */    // 196
1342    GENX_(197, sys_ni_syscall), /* unimplemented (by the kernel) */    // 197
1343    GENX_(__NR_lchown, sys_lchown),                                    // 198
1344    GENX_(__NR_getuid, sys_getuid),                                    // 199
1345
1346    GENX_(__NR_getgid, sys_getgid),                                    // 200
1347    GENX_(__NR_geteuid, sys_geteuid),                                  // 201
1348    GENX_(__NR_getegid, sys_getegid),                                  // 202
1349    GENX_(__NR_setreuid, sys_setreuid),                                // 203
1350    GENX_(__NR_setregid, sys_setregid),                                // 204
1351
1352    GENXY(__NR_getgroups, sys_getgroups),                              // 205
1353    GENX_(__NR_setgroups, sys_setgroups),                              // 206
1354    GENX_(__NR_fchown, sys_fchown),                                    // 207
1355    LINX_(__NR_setresuid, sys_setresuid),                              // 208
1356    LINXY(__NR_getresuid, sys_getresuid),                              // 209
1357
1358    LINX_(__NR_setresgid, sys_setresgid),                              // 210
1359    LINXY(__NR_getresgid, sys_getresgid),                              // 211
1360    GENX_(__NR_chown, sys_chown),                                      // 212
1361    GENX_(__NR_setuid, sys_setuid),                                    // 213
1362    GENX_(__NR_setgid, sys_setgid),                                    // 214
1363
1364    LINX_(__NR_setfsuid, sys_setfsuid),                                // 215
1365    LINX_(__NR_setfsgid, sys_setfsgid),                                // 216
1366 // ?????(__NR_pivot_root, ),
1367    GENX_(__NR_mincore, sys_mincore),                                  // 218
1368    GENX_(__NR_madvise,  sys_madvise),                                 // 219
1369
1370    GENXY(__NR_getdents64,  sys_getdents64),                           // 220
1371    GENX_(221, sys_ni_syscall), /* unimplemented (by the kernel) */    // 221
1372    LINX_(__NR_readahead, sys_readahead),                              // 222
1373    GENX_(223, sys_ni_syscall), /* unimplemented (by the kernel) */    // 223
1374    LINX_(__NR_setxattr, sys_setxattr),                                // 224
1375
1376    LINX_(__NR_lsetxattr, sys_lsetxattr),                              // 225
1377    LINX_(__NR_fsetxattr, sys_fsetxattr),                              // 226
1378    LINXY(__NR_getxattr,  sys_getxattr),                               // 227
1379    LINXY(__NR_lgetxattr,  sys_lgetxattr),                             // 228
1380    LINXY(__NR_fgetxattr,  sys_fgetxattr),                             // 229
1381
1382    LINXY(__NR_listxattr,  sys_listxattr),                             // 230
1383    LINXY(__NR_llistxattr,  sys_llistxattr),                           // 231
1384    LINXY(__NR_flistxattr,  sys_flistxattr),                           // 232
1385    LINX_(__NR_removexattr,  sys_removexattr),                         // 233
1386    LINX_(__NR_lremovexattr,  sys_lremovexattr),                       // 234
1387
1388    LINX_(__NR_fremovexattr,  sys_fremovexattr),                       // 235
1389    LINX_(__NR_gettid,  sys_gettid),                                   // 236
1390    LINXY(__NR_tkill, sys_tkill),                                      // 237
1391    LINXY(__NR_futex,  sys_futex),                                     // 238
1392    LINX_(__NR_sched_setaffinity,  sys_sched_setaffinity),             // 239
1393
1394    LINXY(__NR_sched_getaffinity,  sys_sched_getaffinity),             // 240
1395    LINXY(__NR_tgkill, sys_tgkill),                                    // 241
1396    GENX_(242, sys_ni_syscall), /* unimplemented (by the kernel) */    // 242
1397    LINXY(__NR_io_setup, sys_io_setup),                                // 243
1398    LINX_(__NR_io_destroy,  sys_io_destroy),                           // 244
1399
1400    LINXY(__NR_io_getevents,  sys_io_getevents),                       // 245
1401    LINX_(__NR_io_submit,  sys_io_submit),                             // 246
1402    LINXY(__NR_io_cancel,  sys_io_cancel),                             // 247
1403    LINX_(__NR_exit_group,  sys_exit_group),                           // 248
1404    LINXY(__NR_epoll_create,  sys_epoll_create),                       // 249
1405
1406    LINX_(__NR_epoll_ctl,  sys_epoll_ctl),                             // 250
1407    LINXY(__NR_epoll_wait,  sys_epoll_wait),                           // 251
1408    LINX_(__NR_set_tid_address,  sys_set_tid_address),                 // 252
1409    PLAX_(__NR_fadvise64, sys_fadvise64),                              // 253
1410    LINXY(__NR_timer_create,  sys_timer_create),                       // 254
1411
1412    LINXY(__NR_timer_settime,  sys_timer_settime),                     // 255
1413    LINXY(__NR_timer_gettime,  sys_timer_gettime),                     // 256
1414    LINX_(__NR_timer_getoverrun,  sys_timer_getoverrun),               // 257
1415    LINX_(__NR_timer_delete,  sys_timer_delete),                       // 258
1416    LINX_(__NR_clock_settime,  sys_clock_settime),                     // 259
1417
1418    LINXY(__NR_clock_gettime,  sys_clock_gettime),                     // 260
1419    LINXY(__NR_clock_getres,  sys_clock_getres),                       // 261
1420    LINXY(__NR_clock_nanosleep,  sys_clock_nanosleep),                 // 262
1421    GENX_(263, sys_ni_syscall), /* unimplemented (by the kernel) */    // 263
1422    GENX_(264, sys_ni_syscall), /* unimplemented (by the kernel) */    // 264
1423
1424    GENXY(__NR_statfs64, sys_statfs64),                                // 265
1425    GENXY(__NR_fstatfs64, sys_fstatfs64),                              // 266
1426 // ?????(__NR_remap_file_pages, ),
1427    GENX_(268, sys_ni_syscall), /* unimplemented (by the kernel) */    // 268
1428    GENX_(269, sys_ni_syscall), /* unimplemented (by the kernel) */    // 269
1429
1430    GENX_(270, sys_ni_syscall), /* unimplemented (by the kernel) */    // 270
1431    LINXY(__NR_mq_open,  sys_mq_open),                                 // 271
1432    LINX_(__NR_mq_unlink,  sys_mq_unlink),                             // 272
1433    LINX_(__NR_mq_timedsend,  sys_mq_timedsend),                       // 273
1434    LINXY(__NR_mq_timedreceive, sys_mq_timedreceive),                  // 274
1435
1436    LINX_(__NR_mq_notify,  sys_mq_notify),                             // 275
1437    LINXY(__NR_mq_getsetattr,  sys_mq_getsetattr),                     // 276
1438 // ?????(__NR_kexec_load, ),
1439    LINX_(__NR_add_key,  sys_add_key),                                 // 278
1440    LINX_(__NR_request_key,  sys_request_key),                         // 279
1441
1442    LINXY(__NR_keyctl,  sys_keyctl),                                   // 280
1443    LINXY(__NR_waitid, sys_waitid),                                    // 281
1444    LINX_(__NR_ioprio_set,  sys_ioprio_set),                           // 282
1445    LINX_(__NR_ioprio_get,  sys_ioprio_get),                           // 283
1446    LINX_(__NR_inotify_init,  sys_inotify_init),                       // 284
1447
1448    LINX_(__NR_inotify_add_watch,  sys_inotify_add_watch),             // 285
1449    LINX_(__NR_inotify_rm_watch,  sys_inotify_rm_watch),               // 286
1450    GENX_(287, sys_ni_syscall), /* unimplemented (by the kernel) */    // 287
1451    LINXY(__NR_openat,  sys_openat),                                   // 288
1452    LINX_(__NR_mkdirat,  sys_mkdirat),                                 // 289
1453
1454    LINX_(__NR_mknodat,  sys_mknodat),                                 // 290
1455    LINX_(__NR_fchownat,  sys_fchownat),                               // 291
1456    LINX_(__NR_futimesat,  sys_futimesat),                             // 292
1457    LINXY(__NR_newfstatat, sys_newfstatat),                            // 293
1458    LINX_(__NR_unlinkat,  sys_unlinkat),                               // 294
1459
1460    LINX_(__NR_renameat,  sys_renameat),                               // 295
1461    LINX_(__NR_linkat,  sys_linkat),                                   // 296
1462    LINX_(__NR_symlinkat,  sys_symlinkat),                             // 297
1463    LINX_(__NR_readlinkat,  sys_readlinkat),                           // 298
1464    LINX_(__NR_fchmodat,  sys_fchmodat),                               // 299
1465
1466    LINX_(__NR_faccessat,  sys_faccessat),                             // 300
1467    LINX_(__NR_pselect6, sys_pselect6),                                // 301
1468    LINXY(__NR_ppoll, sys_ppoll),                                      // 302
1469 // ?????(__NR_unshare, ),
1470    LINX_(__NR_set_robust_list,  sys_set_robust_list),                 // 304
1471
1472    LINXY(__NR_get_robust_list,  sys_get_robust_list),                 // 305
1473 // ?????(__NR_splice, ),
1474    LINX_(__NR_sync_file_range, sys_sync_file_range),                  // 307
1475 // ?????(__NR_tee, ),
1476 // ?????(__NR_vmsplice, ),
1477
1478    GENX_(310, sys_ni_syscall), /* unimplemented (by the kernel) */    // 310
1479 // ?????(__NR_getcpu, ),
1480    LINXY(__NR_epoll_pwait,  sys_epoll_pwait),                         // 312
1481    GENX_(__NR_utimes, sys_utimes),                                    // 313
1482    LINX_(__NR_fallocate, sys_fallocate),                              // 314
1483
1484    LINX_(__NR_utimensat,  sys_utimensat),                             // 315
1485    LINXY(__NR_signalfd,  sys_signalfd),                               // 316
1486    GENX_(317, sys_ni_syscall), /* unimplemented (by the kernel) */    // 317
1487    LINX_(__NR_eventfd,  sys_eventfd),                                 // 318
1488    LINXY(__NR_timerfd_create,  sys_timerfd_create),                   // 319
1489
1490    LINXY(__NR_timerfd_settime,  sys_timerfd_settime),                 // 320
1491    LINXY(__NR_timerfd_gettime,  sys_timerfd_gettime),                 // 321
1492    LINXY(__NR_signalfd4,  sys_signalfd4),                             // 322
1493    LINX_(__NR_eventfd2,  sys_eventfd2),                               // 323
1494    LINXY(__NR_inotify_init1,  sys_inotify_init1),                     // 324
1495
1496    LINXY(__NR_pipe2,  sys_pipe2),                                     // 325
1497    // (__NR_dup3,  ),
1498    LINXY(__NR_epoll_create1,  sys_epoll_create1),                     // 327
1499    LINXY(__NR_preadv, sys_preadv),                                    // 328
1500    LINX_(__NR_pwritev, sys_pwritev),                                  // 329
1501
1502 // ?????(__NR_rt_tgsigqueueinfo, ),
1503    LINXY(__NR_perf_event_open, sys_perf_counter_open),                // 331
1504 };
1505
1506 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
1507 {
1508    const UInt syscall_table_size
1509       = sizeof(syscall_table) / sizeof(syscall_table[0]);
1510
1511    /* Is it in the contiguous initial section of the table? */
1512    if (sysno < syscall_table_size) {
1513       SyscallTableEntry* sys = &syscall_table[sysno];
1514       if (sys->before == NULL)
1515          return NULL; /* no entry */
1516       else
1517          return sys;
1518    }
1519
1520    /* Can't find a wrapper */
1521    return NULL;
1522 }
1523
1524 #endif
1525
1526 /*--------------------------------------------------------------------*/
1527 /*--- end                                                          ---*/
1528 /*--------------------------------------------------------------------*/