2 /*--------------------------------------------------------------------*/
3 /*--- Platform-specific syscalls stuff. syswrap-s390x-linux.c ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright IBM Corp. 2010-2017
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.
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.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, see <http://www.gnu.org/licenses/>.
25 The GNU General Public License is contained in the file COPYING.
28 /* Contributed by Christian Borntraeger */
30 #if defined(VGP_s390x_linux)
32 #include "pub_core_basics.h"
33 #include "pub_core_vki.h"
34 #include "pub_core_vkiscnums.h"
35 #include "pub_core_threadstate.h"
36 #include "pub_core_aspacemgr.h"
37 #include "pub_core_debuglog.h"
38 #include "pub_core_libcbase.h"
39 #include "pub_core_libcassert.h"
40 #include "pub_core_libcprint.h"
41 #include "pub_core_libcproc.h"
42 #include "pub_core_libcsignal.h"
43 #include "pub_core_mallocfree.h"
44 #include "pub_core_options.h"
45 #include "pub_core_scheduler.h"
46 #include "pub_core_sigframe.h" // For VG_(sigframe_destroy)()
47 #include "pub_core_signals.h"
48 #include "pub_core_syscall.h"
49 #include "pub_core_syswrap.h"
50 #include "pub_core_tooliface.h"
52 #include "priv_types_n_macros.h"
53 #include "priv_syswrap-generic.h" /* for decls of generic wrappers */
54 #include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers */
55 #include "priv_syswrap-linux-variants.h" /* decls of linux variant wrappers */
56 #include "priv_syswrap-main.h"
59 /* ---------------------------------------------------------------------
61 ------------------------------------------------------------------ */
63 /* Call f(arg1), but first switch stacks, using 'stack' as the new
64 stack, and use 'retaddr' as f's return-to address. Also, clear all
65 the integer registers before entering f.
66 Thought: Why are we clearing the GPRs ? The callee pointed to by f
67 is a regular C function which will play by the ABI rules. So there is
68 no need to zero out the GPRs. If we assumed that f accesses registers at
69 will, then it would make sense to create a defined register state.
70 But then, why only for the GPRs and not the FPRs ? */
71 __attribute__((noreturn
))
72 void ML_(call_on_new_stack_0_1
) ( Addr stack
,
76 /* Upon entering this function we have the following setup:
85 ".globl vgModuleLocal_call_on_new_stack_0_1\n"
86 ".type vgModuleLocal_call_on_new_stack_0_1, @function\n"
87 "vgModuleLocal_call_on_new_stack_0_1:\n"
88 " lgr %r15,%r2\n" // stack to r15
89 " lgr %r14,%r3\n" // retaddr to r14
90 " lgr %r2,%r5\n" // arg1 to r2
91 // zero all gprs to get a defined state
94 // r2 holds the argument for the callee
96 // r4 holds the callee address
106 // r14 holds the return address for the callee
107 // r15 is the stack pointer
108 " br %r4\n" // jump to f
113 Perform a clone system call. clone is strange because it has
114 fork()-like return-twice semantics, so it needs special
118 void* child_stack in r2
120 int* parent_tid in r4
122 int* tls address in r6
123 Word (*fn)(void *) 160(r15)
126 System call requires:
127 void* child_stack in r2 (sc arg1)
128 long flags in r3 (sc arg2)
129 int* parent_tid in r4 (sc arg3)
130 int* child_tid in r5 (sc arg4)
131 void* tlsaddr in r6 (sc arg5)
133 Returns a ULong encoded as: top half is %cr following syscall,
134 low half is syscall return value (r3).
136 #define __NR_CLONE VG_STRINGIFY(__NR_clone)
137 #define __NR_EXIT VG_STRINGIFY(__NR_exit)
139 // See priv_syswrap-linux.h for arg profile.
143 ".globl do_syscall_clone_s390x_linux\n"
144 "do_syscall_clone_s390x_linux:\n"
145 " lg %r1, 160(%r15)\n" // save fn from parent stack into r1
146 " lg %r0, 168(%r15)\n" // save arg from parent stack into r0
147 " aghi %r2, -160\n" // create stack frame for child
148 // all syscall parameters are already in place (r2-r6)
149 " svc " __NR_CLONE
"\n" // clone()
150 " ltgr %r2,%r2\n" // child if retval == 0
153 // CHILD - call thread function
154 " lgr %r2, %r0\n" // get arg from r0
155 " basr %r14,%r1\n" // call fn
157 // exit. The result is already in r2
158 " svc " __NR_EXIT
"\n"
163 "1:\n" // PARENT or ERROR
171 void VG_(cleanup_thread
) ( ThreadArchState
* arch
)
173 /* only used on x86 for descriptor tables */
176 /* ---------------------------------------------------------------------
177 PRE/POST wrappers for s390x/Linux-specific syscalls
178 ------------------------------------------------------------------ */
180 #define PRE(name) DEFN_PRE_TEMPLATE(s390x_linux, name)
181 #define POST(name) DEFN_POST_TEMPLATE(s390x_linux, name)
183 /* Add prototypes for the wrappers declared here, so that gcc doesn't
184 harass us for not having prototypes. Really this is a kludge --
185 the right thing to do is to make these wrappers 'static' since they
186 aren't visible outside this file, but that requires even more macro
189 DECL_TEMPLATE(s390x_linux
, sys_ptrace
);
190 DECL_TEMPLATE(s390x_linux
, sys_mmap
);
191 DECL_TEMPLATE(s390x_linux
, sys_sigreturn
);
192 DECL_TEMPLATE(s390x_linux
, sys_rt_sigreturn
);
193 DECL_TEMPLATE(s390x_linux
, sys_fadvise64
);
195 /* PEEK TEXT,DATA and USER are common to all architectures.
196 PEEKUSR_AREA and POKEUSR_AREA are special, having a memory area
197 containing the real addr, data, and len field pointed to by ARG3
199 GETREGSET and SETREGSET use a struct iovec (pointed to by ARG4) for
200 the address and size of the user buffer. */
204 PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )", SARG1
, SARG2
, ARG3
, ARG4
);
205 PRE_REG_READ4(int, "ptrace",
206 long, request
, long, pid
, unsigned long, addr
,
207 unsigned long, data
);
209 case VKI_PTRACE_PEEKTEXT
:
210 case VKI_PTRACE_PEEKDATA
:
211 case VKI_PTRACE_PEEKUSR
:
212 PRE_MEM_WRITE( "ptrace(peek)", ARG4
,
215 case VKI_PTRACE_GETEVENTMSG
:
216 PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4
, sizeof(unsigned long));
218 case VKI_PTRACE_GETSIGINFO
:
219 PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4
, sizeof(vki_siginfo_t
));
221 case VKI_PTRACE_SETSIGINFO
:
222 PRE_MEM_READ( "ptrace(setsiginfo)", ARG4
, sizeof(vki_siginfo_t
));
224 case VKI_PTRACE_PEEKUSR_AREA
:
228 /* Reads a part of the user area into memory at pa->process_addr */
229 pa
= (vki_ptrace_area
*) ARG3
;
230 PRE_MEM_READ("ptrace(peekusrarea ptrace_area->len)",
231 (unsigned long) &pa
->vki_len
, sizeof(pa
->vki_len
));
232 PRE_MEM_READ("ptrace(peekusrarea ptrace_area->kernel_addr)",
233 (unsigned long) &pa
->vki_kernel_addr
, sizeof(pa
->vki_kernel_addr
));
234 PRE_MEM_READ("ptrace(peekusrarea ptrace_area->process_addr)",
235 (unsigned long) &pa
->vki_process_addr
, sizeof(pa
->vki_process_addr
));
236 PRE_MEM_WRITE("ptrace(peekusrarea *(ptrace_area->process_addr))",
237 pa
->vki_process_addr
, pa
->vki_len
);
240 case VKI_PTRACE_POKEUSR_AREA
:
244 /* Updates a part of the user area from memory at pa->process_addr */
245 pa
= (vki_ptrace_area
*) ARG3
;
246 PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->len)",
247 (unsigned long) &pa
->vki_len
, sizeof(pa
->vki_len
));
248 PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->kernel_addr)",
249 (unsigned long) &pa
->vki_kernel_addr
,
250 sizeof(pa
->vki_kernel_addr
));
251 PRE_MEM_READ("ptrace(pokeusrarea ptrace_area->process_addr)",
252 (unsigned long) &pa
->vki_process_addr
,
253 sizeof(pa
->vki_process_addr
));
254 PRE_MEM_READ("ptrace(pokeusrarea *(ptrace_area->process_addr))",
255 pa
->vki_process_addr
, pa
->vki_len
);
258 case VKI_PTRACE_GETREGSET
:
259 ML_(linux_PRE_getregset
)(tid
, ARG3
, ARG4
);
261 case VKI_PTRACE_SETREGSET
:
262 ML_(linux_PRE_setregset
)(tid
, ARG3
, ARG4
);
272 case VKI_PTRACE_TRACEME
:
273 ML_(linux_POST_traceme
)(tid
);
275 case VKI_PTRACE_PEEKTEXT
:
276 case VKI_PTRACE_PEEKDATA
:
277 case VKI_PTRACE_PEEKUSR
:
278 POST_MEM_WRITE( ARG4
, sizeof (long));
280 case VKI_PTRACE_GETEVENTMSG
:
281 POST_MEM_WRITE( ARG4
, sizeof(unsigned long));
283 case VKI_PTRACE_GETSIGINFO
:
284 /* XXX: This is a simplification. Different parts of the
285 * siginfo_t are valid depending on the type of signal.
287 POST_MEM_WRITE( ARG4
, sizeof(vki_siginfo_t
));
289 case VKI_PTRACE_PEEKUSR_AREA
:
293 pa
= (vki_ptrace_area
*) ARG3
;
294 POST_MEM_WRITE(pa
->vki_process_addr
, pa
->vki_len
);
297 case VKI_PTRACE_GETREGSET
:
298 ML_(linux_POST_getregset
)(tid
, ARG3
, ARG4
);
307 UWord a0
, a1
, a2
, a3
, a4
, a5
;
310 UWord
* args
= (UWord
*)ARG1
;
311 PRE_REG_READ1(long, "sys_mmap", struct mmap_arg_struct
*, args
);
312 PRE_MEM_READ( "sys_mmap(args)", (Addr
) args
, 6*sizeof(UWord
) );
321 PRINT("sys_mmap ( %#lx, %lu, %ld, %ld, %ld, %ld )",
322 a0
, a1
, (Word
)a2
, (Word
)a3
, (Word
)a4
, (Word
)a5
);
324 r
= ML_(generic_PRE_sys_mmap
)( tid
, a0
, a1
, a2
, a3
, a4
, (Off64T
)a5
);
325 SET_STATUS_from_SysRes(r
);
331 PRINT("sys_sigreturn ( )");
333 vg_assert(VG_(is_valid_tid
)(tid
));
334 vg_assert(tid
>= 1 && tid
< VG_N_THREADS
);
335 vg_assert(VG_(is_running_thread
)(tid
));
337 tst
= VG_(get_ThreadState
)(tid
);
339 /* This is only so that the IA is (might be) useful to report if
340 something goes wrong in the sigreturn */
341 ML_(fixup_guest_state_to_restart_syscall
)(&tst
->arch
);
343 /* Restore register state from frame and remove it */
344 VG_(sigframe_destroy
)(tid
, False
);
346 /* Tell the driver not to update the guest state with the "result",
347 and set a bogus result to keep it happy. */
348 *flags
|= SfNoWriteResult
;
349 SET_STATUS_Success(0);
351 /* Check to see if any signals arose as a result of this. */
352 *flags
|= SfPollAfter
;
356 PRE(sys_rt_sigreturn
)
358 /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for
359 an explanation of what follows. */
362 PRINT("sys_rt_sigreturn ( )");
364 vg_assert(VG_(is_valid_tid
)(tid
));
365 vg_assert(tid
>= 1 && tid
< VG_N_THREADS
);
366 vg_assert(VG_(is_running_thread
)(tid
));
368 tst
= VG_(get_ThreadState
)(tid
);
370 /* This is only so that the IA is (might be) useful to report if
371 something goes wrong in the sigreturn */
372 ML_(fixup_guest_state_to_restart_syscall
)(&tst
->arch
);
374 /* Restore register state from frame and remove it */
375 VG_(sigframe_destroy
)(tid
, True
);
377 /* Tell the driver not to update the guest state with the "result",
378 and set a bogus result to keep it happy. */
379 *flags
|= SfNoWriteResult
;
380 SET_STATUS_Success(0);
382 /* Check to see if any signals arose as a result of this. */
383 *flags
|= SfPollAfter
;
386 /* we cant use the LINX_ version for 64 bit */
389 PRINT("sys_fadvise64 ( %ld, %ld, %ld, %ld )", SARG1
, SARG2
, SARG3
, SARG4
);
390 PRE_REG_READ4(long, "fadvise64",
391 int, fd
, vki_loff_t
, offset
, vki_loff_t
, len
, int, advice
);
397 /* ---------------------------------------------------------------------
398 The s390x/Linux syscall table
399 ------------------------------------------------------------------ */
401 /* Add an s390x-linux specific wrapper to a syscall table. */
402 #define PLAX_(sysno, name) WRAPPER_ENTRY_X_(s390x_linux, sysno, name)
403 #define PLAXY(sysno, name) WRAPPER_ENTRY_XY(s390x_linux, sysno, name)
405 // This table maps from __NR_xxx syscall numbers from
406 // linux/arch/s390/kernel/syscalls.S to the appropriate PRE/POST sys_foo()
407 // wrappers on s390x. There are several unused numbers, which are only
408 // defined on s390 (31bit mode) but no longer available on s390x (64 bit).
409 // For those syscalls not handled by Valgrind, the annotation indicate its
410 // arch/OS combination, eg. */* (generic), */Linux (Linux only), ?/?
413 static SyscallTableEntry syscall_table
[] = {
414 GENX_(0, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 0
415 GENX_(__NR_exit
, sys_exit
), // 1
416 GENX_(__NR_fork
, sys_fork
), // 2
417 GENXY(__NR_read
, sys_read
), // 3
418 GENX_(__NR_write
, sys_write
), // 4
420 GENXY(__NR_open
, sys_open
), // 5
421 GENX_(__NR_close
, sys_close
), // 6
422 // ?????(__NR_restart_syscall, ), // 7
423 GENXY(__NR_creat
, sys_creat
), // 8
424 GENX_(__NR_link
, sys_link
), // 9
426 GENX_(__NR_unlink
, sys_unlink
), // 10
427 GENX_(__NR_execve
, sys_execve
), // 11
428 GENX_(__NR_chdir
, sys_chdir
), // 12
429 GENX_(13, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 13
430 GENX_(__NR_mknod
, sys_mknod
), // 14
432 GENX_(__NR_chmod
, sys_chmod
), // 15
433 GENX_(16, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 16
434 GENX_(17, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 17
435 GENX_(18, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 18
436 LINX_(__NR_lseek
, sys_lseek
), // 19
438 GENX_(__NR_getpid
, sys_getpid
), // 20
439 LINX_(__NR_mount
, sys_mount
), // 21
440 LINX_(__NR_umount
, sys_oldumount
), // 22
441 GENX_(23, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 23
442 GENX_(24, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 24
444 GENX_(25, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 25
445 PLAXY(__NR_ptrace
, sys_ptrace
), // 26
446 GENX_(__NR_alarm
, sys_alarm
), // 27
447 GENX_(28, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 28
448 GENX_(__NR_pause
, sys_pause
), // 29
450 LINX_(__NR_utime
, sys_utime
), // 30
451 GENX_(31, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 31
452 GENX_(32, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 32
453 GENX_(__NR_access
, sys_access
), // 33
454 GENX_(__NR_nice
, sys_nice
), // 34
456 GENX_(35, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 35
457 GENX_(__NR_sync
, sys_sync
), // 36
458 GENX_(__NR_kill
, sys_kill
), // 37
459 GENX_(__NR_rename
, sys_rename
), // 38
460 GENX_(__NR_mkdir
, sys_mkdir
), // 39
462 GENX_(__NR_rmdir
, sys_rmdir
), // 40
463 GENXY(__NR_dup
, sys_dup
), // 41
464 LINXY(__NR_pipe
, sys_pipe
), // 42
465 GENXY(__NR_times
, sys_times
), // 43
466 GENX_(44, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 44
468 GENX_(__NR_brk
, sys_brk
), // 45
469 GENX_(46, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 46
470 GENX_(47, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 47
471 // ?????(__NR_signal, ), // 48
472 GENX_(49, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 49
474 GENX_(50, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 50
475 GENX_(__NR_acct
, sys_acct
), // 51
476 LINX_(__NR_umount2
, sys_umount
), // 52
477 GENX_(53, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 53
478 LINXY(__NR_ioctl
, sys_ioctl
), // 54
480 LINXY(__NR_fcntl
, sys_fcntl
), // 55
481 GENX_(56, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 56
482 GENX_(__NR_setpgid
, sys_setpgid
), // 57
483 GENX_(58, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 58
484 GENX_(59, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 59
486 GENX_(__NR_umask
, sys_umask
), // 60
487 GENX_(__NR_chroot
, sys_chroot
), // 61
488 // ?????(__NR_ustat, sys_ustat), /* deprecated in favor of statfs */ // 62
489 GENXY(__NR_dup2
, sys_dup2
), // 63
490 GENX_(__NR_getppid
, sys_getppid
), // 64
492 GENX_(__NR_getpgrp
, sys_getpgrp
), // 65
493 GENX_(__NR_setsid
, sys_setsid
), // 66
494 // ?????(__NR_sigaction, ), /* userspace uses rt_sigaction */ // 67
495 GENX_(68, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 68
496 GENX_(69, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 69
498 GENX_(70, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 70
499 GENX_(71, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 71
500 // ?????(__NR_sigsuspend, ), // 72
501 // ?????(__NR_sigpending, ), // 73
502 // ?????(__NR_sethostname, ), // 74
504 GENX_(__NR_setrlimit
, sys_setrlimit
), // 75
505 GENXY(76, sys_getrlimit
), /* see also 191 */ // 76
506 GENXY(__NR_getrusage
, sys_getrusage
), // 77
507 GENXY(__NR_gettimeofday
, sys_gettimeofday
), // 78
508 GENX_(__NR_settimeofday
, sys_settimeofday
), // 79
510 GENX_(80, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 80
511 GENX_(81, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 81
512 GENX_(82, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 82
513 GENX_(__NR_symlink
, sys_symlink
), // 83
514 GENX_(84, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 84
516 GENXY(__NR_readlink
, sys_readlink
), // 85
517 // ?????(__NR_uselib, ), // 86
518 // ?????(__NR_swapon, ), // 87
519 // ?????(__NR_reboot, ), // 88
520 GENX_(89, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 89
522 PLAX_(__NR_mmap
, sys_mmap
), // 90
523 GENXY(__NR_munmap
, sys_munmap
), // 91
524 GENX_(__NR_truncate
, sys_truncate
), // 92
525 GENX_(__NR_ftruncate
, sys_ftruncate
), // 93
526 GENX_(__NR_fchmod
, sys_fchmod
), // 94
528 GENX_(95, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 95
529 GENX_(__NR_getpriority
, sys_getpriority
), // 96
530 GENX_(__NR_setpriority
, sys_setpriority
), // 97
531 GENX_(98, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 98
532 GENXY(__NR_statfs
, sys_statfs
), // 99
534 GENXY(__NR_fstatfs
, sys_fstatfs
), // 100
535 GENX_(101, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 101
536 LINXY(__NR_socketcall
, sys_socketcall
), // 102
537 LINXY(__NR_syslog
, sys_syslog
), // 103
538 GENXY(__NR_setitimer
, sys_setitimer
), // 104
540 GENXY(__NR_getitimer
, sys_getitimer
), // 105
541 GENXY(__NR_stat
, sys_newstat
), // 106
542 GENXY(__NR_lstat
, sys_newlstat
), // 107
543 GENXY(__NR_fstat
, sys_newfstat
), // 108
544 GENX_(109, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 109
546 LINXY(__NR_lookup_dcookie
, sys_lookup_dcookie
), // 110
547 LINX_(__NR_vhangup
, sys_vhangup
), // 111
548 GENX_(112, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 112
549 GENX_(113, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 113
550 GENXY(__NR_wait4
, sys_wait4
), // 114
552 // ?????(__NR_swapoff, ), // 115
553 LINXY(__NR_sysinfo
, sys_sysinfo
), // 116
554 LINXY(__NR_ipc
, sys_ipc
), // 117
555 GENX_(__NR_fsync
, sys_fsync
), // 118
556 PLAX_(__NR_sigreturn
, sys_sigreturn
), // 119
558 LINX_(__NR_clone
, sys_clone
), // 120
559 // ?????(__NR_setdomainname, ), // 121
560 GENXY(__NR_uname
, sys_newuname
), // 122
561 GENX_(123, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 123
562 // ?????(__NR_adjtimex, ), // 124
564 GENXY(__NR_mprotect
, sys_mprotect
), // 125
565 // LINXY(__NR_sigprocmask, sys_sigprocmask), // 126
566 GENX_(127, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 127
567 LINX_(__NR_init_module
, sys_init_module
), // 128
568 LINX_(__NR_delete_module
, sys_delete_module
), // 129
570 GENX_(130, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 130
571 LINX_(__NR_quotactl
, sys_quotactl
), // 131
572 GENX_(__NR_getpgid
, sys_getpgid
), // 132
573 GENX_(__NR_fchdir
, sys_fchdir
), // 133
574 // ?????(__NR_bdflush, ), // 134
576 // ?????(__NR_sysfs, ), // 135
577 LINX_(__NR_personality
, sys_personality
), // 136
578 GENX_(137, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 137
579 GENX_(138, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 138
580 GENX_(139, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 139
582 // LINXY(__NR__llseek, sys_llseek), /* 64 bit --> lseek */ // 140
583 GENXY(__NR_getdents
, sys_getdents
), // 141
584 GENX_(__NR_select
, sys_select
), // 142
585 GENX_(__NR_flock
, sys_flock
), // 143
586 GENX_(__NR_msync
, sys_msync
), // 144
588 GENXY(__NR_readv
, sys_readv
), // 145
589 GENX_(__NR_writev
, sys_writev
), // 146
590 GENX_(__NR_getsid
, sys_getsid
), // 147
591 GENX_(__NR_fdatasync
, sys_fdatasync
), // 148
592 LINXY(__NR__sysctl
, sys_sysctl
), // 149
594 GENX_(__NR_mlock
, sys_mlock
), // 150
595 GENX_(__NR_munlock
, sys_munlock
), // 151
596 GENX_(__NR_mlockall
, sys_mlockall
), // 152
597 LINX_(__NR_munlockall
, sys_munlockall
), // 153
598 LINXY(__NR_sched_setparam
, sys_sched_setparam
), // 154
600 LINXY(__NR_sched_getparam
, sys_sched_getparam
), // 155
601 LINX_(__NR_sched_setscheduler
, sys_sched_setscheduler
), // 156
602 LINX_(__NR_sched_getscheduler
, sys_sched_getscheduler
), // 157
603 LINX_(__NR_sched_yield
, sys_sched_yield
), // 158
604 LINX_(__NR_sched_get_priority_max
, sys_sched_get_priority_max
), // 159
606 LINX_(__NR_sched_get_priority_min
, sys_sched_get_priority_min
), // 160
607 LINXY(__NR_sched_rr_get_interval
, sys_sched_rr_get_interval
), // 162
608 GENXY(__NR_nanosleep
, sys_nanosleep
), // 162
609 GENX_(__NR_mremap
, sys_mremap
), // 163
610 GENX_(164, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 164
612 GENX_(165, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 165
613 GENX_(166, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 166
614 GENX_(167, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 167
615 GENXY(__NR_poll
, sys_poll
), // 168
616 // ?????(__NR_nfsservctl, ), // 169
618 GENX_(170, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 170
619 GENX_(171, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 171
620 LINXY(__NR_prctl
, sys_prctl
), // 172
621 PLAX_(__NR_rt_sigreturn
, sys_rt_sigreturn
), // 173
622 LINXY(__NR_rt_sigaction
, sys_rt_sigaction
), // 174
624 LINXY(__NR_rt_sigprocmask
, sys_rt_sigprocmask
), // 175
625 LINXY(__NR_rt_sigpending
, sys_rt_sigpending
), // 176
626 LINXY(__NR_rt_sigtimedwait
, sys_rt_sigtimedwait
), // 177
627 LINXY(__NR_rt_sigqueueinfo
, sys_rt_sigqueueinfo
), // 178
628 LINX_(__NR_rt_sigsuspend
, sys_rt_sigsuspend
), // 179
630 GENXY(__NR_pread64
, sys_pread64
), // 180
631 GENX_(__NR_pwrite64
, sys_pwrite64
), // 181
632 GENX_(182, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 182
633 GENXY(__NR_getcwd
, sys_getcwd
), // 183
634 LINXY(__NR_capget
, sys_capget
), // 184
636 LINX_(__NR_capset
, sys_capset
), // 185
637 GENXY(__NR_sigaltstack
, sys_sigaltstack
), // 186
638 LINXY(__NR_sendfile
, sys_sendfile
), // 187
639 GENX_(188, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 188
640 GENX_(189, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 189
642 GENX_(__NR_vfork
, sys_fork
), // 190
643 GENXY(__NR_getrlimit
, sys_getrlimit
), // 191
644 GENX_(192, sys_ni_syscall
), /* not exported on 64bit*/ // 192
645 GENX_(193, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 193
646 GENX_(194, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 194
648 GENX_(195, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 195
649 GENX_(196, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 196
650 GENX_(197, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 197
651 GENX_(__NR_lchown
, sys_lchown
), // 198
652 GENX_(__NR_getuid
, sys_getuid
), // 199
654 GENX_(__NR_getgid
, sys_getgid
), // 200
655 GENX_(__NR_geteuid
, sys_geteuid
), // 201
656 GENX_(__NR_getegid
, sys_getegid
), // 202
657 GENX_(__NR_setreuid
, sys_setreuid
), // 203
658 GENX_(__NR_setregid
, sys_setregid
), // 204
660 GENXY(__NR_getgroups
, sys_getgroups
), // 205
661 GENX_(__NR_setgroups
, sys_setgroups
), // 206
662 GENX_(__NR_fchown
, sys_fchown
), // 207
663 LINX_(__NR_setresuid
, sys_setresuid
), // 208
664 LINXY(__NR_getresuid
, sys_getresuid
), // 209
666 LINX_(__NR_setresgid
, sys_setresgid
), // 210
667 LINXY(__NR_getresgid
, sys_getresgid
), // 211
668 GENX_(__NR_chown
, sys_chown
), // 212
669 GENX_(__NR_setuid
, sys_setuid
), // 213
670 GENX_(__NR_setgid
, sys_setgid
), // 214
672 LINX_(__NR_setfsuid
, sys_setfsuid
), // 215
673 LINX_(__NR_setfsgid
, sys_setfsgid
), // 216
674 LINX_(__NR_pivot_root
, sys_pivot_root
), // 217
675 GENXY(__NR_mincore
, sys_mincore
), // 218
676 GENX_(__NR_madvise
, sys_madvise
), // 219
678 GENXY(__NR_getdents64
, sys_getdents64
), // 220
679 GENX_(221, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 221
680 LINX_(__NR_readahead
, sys_readahead
), // 222
681 GENX_(223, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 223
682 LINX_(__NR_setxattr
, sys_setxattr
), // 224
684 LINX_(__NR_lsetxattr
, sys_lsetxattr
), // 225
685 LINX_(__NR_fsetxattr
, sys_fsetxattr
), // 226
686 LINXY(__NR_getxattr
, sys_getxattr
), // 227
687 LINXY(__NR_lgetxattr
, sys_lgetxattr
), // 228
688 LINXY(__NR_fgetxattr
, sys_fgetxattr
), // 229
690 LINXY(__NR_listxattr
, sys_listxattr
), // 230
691 LINXY(__NR_llistxattr
, sys_llistxattr
), // 231
692 LINXY(__NR_flistxattr
, sys_flistxattr
), // 232
693 LINX_(__NR_removexattr
, sys_removexattr
), // 233
694 LINX_(__NR_lremovexattr
, sys_lremovexattr
), // 234
696 LINX_(__NR_fremovexattr
, sys_fremovexattr
), // 235
697 LINX_(__NR_gettid
, sys_gettid
), // 236
698 LINXY(__NR_tkill
, sys_tkill
), // 237
699 LINXY(__NR_futex
, sys_futex
), // 238
700 LINX_(__NR_sched_setaffinity
, sys_sched_setaffinity
), // 239
702 LINXY(__NR_sched_getaffinity
, sys_sched_getaffinity
), // 240
703 LINXY(__NR_tgkill
, sys_tgkill
), // 241
704 GENX_(242, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 242
705 LINXY(__NR_io_setup
, sys_io_setup
), // 243
706 LINX_(__NR_io_destroy
, sys_io_destroy
), // 244
708 LINXY(__NR_io_getevents
, sys_io_getevents
), // 245
709 LINX_(__NR_io_submit
, sys_io_submit
), // 246
710 LINXY(__NR_io_cancel
, sys_io_cancel
), // 247
711 LINX_(__NR_exit_group
, sys_exit_group
), // 248
712 LINXY(__NR_epoll_create
, sys_epoll_create
), // 249
714 LINX_(__NR_epoll_ctl
, sys_epoll_ctl
), // 250
715 LINXY(__NR_epoll_wait
, sys_epoll_wait
), // 251
716 LINX_(__NR_set_tid_address
, sys_set_tid_address
), // 252
717 PLAX_(__NR_fadvise64
, sys_fadvise64
), // 253
718 LINXY(__NR_timer_create
, sys_timer_create
), // 254
720 LINXY(__NR_timer_settime
, sys_timer_settime
), // 255
721 LINXY(__NR_timer_gettime
, sys_timer_gettime
), // 256
722 LINX_(__NR_timer_getoverrun
, sys_timer_getoverrun
), // 257
723 LINX_(__NR_timer_delete
, sys_timer_delete
), // 258
724 LINX_(__NR_clock_settime
, sys_clock_settime
), // 259
726 LINXY(__NR_clock_gettime
, sys_clock_gettime
), // 260
727 LINXY(__NR_clock_getres
, sys_clock_getres
), // 261
728 LINXY(__NR_clock_nanosleep
, sys_clock_nanosleep
), // 262
729 GENX_(263, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 263
730 GENX_(264, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 264
732 GENXY(__NR_statfs64
, sys_statfs64
), // 265
733 GENXY(__NR_fstatfs64
, sys_fstatfs64
), // 266
734 // ?????(__NR_remap_file_pages, ),
735 GENX_(268, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 268
736 GENX_(269, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 269
738 GENX_(270, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 270
739 LINXY(__NR_mq_open
, sys_mq_open
), // 271
740 LINX_(__NR_mq_unlink
, sys_mq_unlink
), // 272
741 LINX_(__NR_mq_timedsend
, sys_mq_timedsend
), // 273
742 LINXY(__NR_mq_timedreceive
, sys_mq_timedreceive
), // 274
744 LINX_(__NR_mq_notify
, sys_mq_notify
), // 275
745 LINXY(__NR_mq_getsetattr
, sys_mq_getsetattr
), // 276
746 // ?????(__NR_kexec_load, ),
747 LINX_(__NR_add_key
, sys_add_key
), // 278
748 LINX_(__NR_request_key
, sys_request_key
), // 279
750 LINXY(__NR_keyctl
, sys_keyctl
), // 280
751 LINXY(__NR_waitid
, sys_waitid
), // 281
752 LINX_(__NR_ioprio_set
, sys_ioprio_set
), // 282
753 LINX_(__NR_ioprio_get
, sys_ioprio_get
), // 283
754 LINXY(__NR_inotify_init
, sys_inotify_init
), // 284
756 LINX_(__NR_inotify_add_watch
, sys_inotify_add_watch
), // 285
757 LINX_(__NR_inotify_rm_watch
, sys_inotify_rm_watch
), // 286
758 GENX_(287, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 287
759 LINXY(__NR_openat
, sys_openat
), // 288
760 LINX_(__NR_mkdirat
, sys_mkdirat
), // 289
762 LINX_(__NR_mknodat
, sys_mknodat
), // 290
763 LINX_(__NR_fchownat
, sys_fchownat
), // 291
764 LINX_(__NR_futimesat
, sys_futimesat
), // 292
765 LINXY(__NR_newfstatat
, sys_newfstatat
), // 293
766 LINX_(__NR_unlinkat
, sys_unlinkat
), // 294
768 LINX_(__NR_renameat
, sys_renameat
), // 295
769 LINX_(__NR_linkat
, sys_linkat
), // 296
770 LINX_(__NR_symlinkat
, sys_symlinkat
), // 297
771 LINXY(__NR_readlinkat
, sys_readlinkat
), // 298
772 LINX_(__NR_fchmodat
, sys_fchmodat
), // 299
774 LINX_(__NR_faccessat
, sys_faccessat
), // 300
775 LINXY(__NR_pselect6
, sys_pselect6
), // 301
776 LINXY(__NR_ppoll
, sys_ppoll
), // 302
777 LINX_(__NR_unshare
, sys_unshare
), // 303
778 LINX_(__NR_set_robust_list
, sys_set_robust_list
), // 304
780 LINXY(__NR_get_robust_list
, sys_get_robust_list
), // 305
781 LINX_(__NR_splice
, sys_splice
), // 306
782 LINX_(__NR_sync_file_range
, sys_sync_file_range
), // 307
783 LINX_(__NR_tee
, sys_tee
), // 308
784 LINXY(__NR_vmsplice
, sys_vmsplice
), // 309
786 GENX_(310, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 310
787 LINXY(__NR_getcpu
, sys_getcpu
), // 311
788 LINXY(__NR_epoll_pwait
, sys_epoll_pwait
), // 312
789 GENX_(__NR_utimes
, sys_utimes
), // 313
790 LINX_(__NR_fallocate
, sys_fallocate
), // 314
792 LINX_(__NR_utimensat
, sys_utimensat
), // 315
793 LINXY(__NR_signalfd
, sys_signalfd
), // 316
794 GENX_(317, sys_ni_syscall
), /* unimplemented (by the kernel) */ // 317
795 LINXY(__NR_eventfd
, sys_eventfd
), // 318
796 LINXY(__NR_timerfd_create
, sys_timerfd_create
), // 319
798 LINXY(__NR_timerfd_settime
, sys_timerfd_settime
), // 320
799 LINXY(__NR_timerfd_gettime
, sys_timerfd_gettime
), // 321
800 LINXY(__NR_signalfd4
, sys_signalfd4
), // 322
801 LINXY(__NR_eventfd2
, sys_eventfd2
), // 323
802 LINXY(__NR_inotify_init1
, sys_inotify_init1
), // 324
804 LINXY(__NR_pipe2
, sys_pipe2
), // 325
805 LINXY(__NR_dup3
, sys_dup3
), // 326
806 LINXY(__NR_epoll_create1
, sys_epoll_create1
), // 327
807 LINXY(__NR_preadv
, sys_preadv
), // 328
808 LINX_(__NR_pwritev
, sys_pwritev
), // 329
810 LINXY(__NR_rt_tgsigqueueinfo
, sys_rt_tgsigqueueinfo
), // 330
811 LINXY(__NR_perf_event_open
, sys_perf_event_open
), // 331
812 LINXY(__NR_fanotify_init
, sys_fanotify_init
), // 332
813 LINX_(__NR_fanotify_mark
, sys_fanotify_mark
), // 333
814 LINXY(__NR_prlimit64
, sys_prlimit64
), // 334
816 LINXY(__NR_name_to_handle_at
, sys_name_to_handle_at
), // 335
817 LINXY(__NR_open_by_handle_at
, sys_open_by_handle_at
), // 336
818 LINXY(__NR_clock_adjtime
, sys_clock_adjtime
), // 337
819 LINX_(__NR_syncfs
, sys_syncfs
), // 338
820 LINX_(__NR_setns
, sys_setns
), // 339
822 LINXY(__NR_process_vm_readv
, sys_process_vm_readv
), // 340
823 LINX_(__NR_process_vm_writev
, sys_process_vm_writev
), // 341
824 // ?????(__NR_s390_runtime_instr, ), // 342
825 LINX_(__NR_kcmp
, sys_kcmp
), // 343
826 // ?????(__NR_finit_module, ), // 344
828 LINX_(__NR_sched_setattr
, sys_sched_setattr
), // 345
829 LINXY(__NR_sched_getattr
, sys_sched_getattr
), // 346
830 LINX_(__NR_renameat2
, sys_renameat2
), // 347
831 // ?????(__NR_seccomp, ), // 348
832 LINXY(__NR_getrandom
, sys_getrandom
), // 349
834 LINXY(__NR_memfd_create
, sys_memfd_create
), // 350
836 LINX_(__NR_execveat
, sys_execveat
), // 354
838 LINX_(__NR_membarrier
, sys_membarrier
), // 356
839 LINXY(__NR_recvmmsg
, sys_recvmmsg
), // 357
840 LINXY(__NR_sendmmsg
, sys_sendmmsg
), // 358
841 LINXY(__NR_socket
, sys_socket
), // 359
842 LINXY(__NR_socketpair
, sys_socketpair
), // 360
843 LINX_(__NR_bind
, sys_bind
), // 361
844 LINX_(__NR_connect
, sys_connect
), // 362
845 LINX_(__NR_listen
, sys_listen
), // 363
846 LINXY(__NR_accept4
, sys_accept4
), // 364
847 LINXY(__NR_getsockopt
, sys_getsockopt
), // 365
848 LINX_(__NR_setsockopt
, sys_setsockopt
), // 366
849 LINXY(__NR_getsockname
, sys_getsockname
), // 367
850 LINXY(__NR_getpeername
, sys_getpeername
), // 368
851 LINX_(__NR_sendto
, sys_sendto
), // 369
852 LINX_(__NR_sendmsg
, sys_sendmsg
), // 270
853 LINXY(__NR_recvfrom
, sys_recvfrom
), // 371
854 LINXY(__NR_recvmsg
, sys_recvmsg
), // 372
855 LINX_(__NR_shutdown
, sys_shutdown
), // 373
856 GENX_(__NR_mlock2
, sys_mlock2
), // 374
857 LINX_(__NR_copy_file_range
, sys_copy_file_range
), // 375
858 LINXY(__NR_preadv2
, sys_preadv2
), // 376
859 LINX_(__NR_pwritev2
, sys_pwritev2
), // 377
861 LINXY(__NR_statx
, sys_statx
), // 379
863 GENX_(__NR_rseq
, sys_ni_syscall
), // 381
865 LINXY(__NR_io_uring_setup
, sys_io_uring_setup
), // 425
866 LINXY(__NR_io_uring_enter
, sys_io_uring_enter
), // 426
867 LINXY(__NR_io_uring_register
, sys_io_uring_register
), // 427
868 LINXY(__NR_open_tree
, sys_open_tree
), // 428
869 LINX_(__NR_move_mount
, sys_move_mount
), // 429
870 LINXY(__NR_fsopen
, sys_fsopen
), // 430
871 LINX_(__NR_fsconfig
, sys_fsconfig
), // 431
872 LINXY(__NR_fsmount
, sys_fsmount
), // 432
873 LINXY(__NR_fspick
, sys_fspick
), // 433
874 LINXY(__NR_pidfd_open
, sys_pidfd_open
), // 434
875 GENX_(__NR_clone3
, sys_ni_syscall
), // 435
876 LINXY(__NR_close_range
, sys_close_range
), // 436
877 LINXY(__NR_openat2
, sys_openat2
), // 437
878 LINXY(__NR_pidfd_getfd
, sys_pidfd_getfd
), // 438
879 LINX_(__NR_faccessat2
, sys_faccessat2
), // 439
881 LINXY(__NR_epoll_pwait2
, sys_epoll_pwait2
), // 441
883 LINXY(__NR_landlock_create_ruleset
, sys_landlock_create_ruleset
), // 444
884 LINX_(__NR_landlock_add_rule
, sys_landlock_add_rule
), // 445
885 LINX_(__NR_landlock_restrict_self
, sys_landlock_restrict_self
), // 446
887 LINXY(__NR_memfd_secret
, sys_memfd_secret
), // 447
889 LINX_ (__NR_fchmodat2
, sys_fchmodat2
), // 452
892 SyscallTableEntry
* ML_(get_linux_syscall_entry
) ( UInt sysno
)
894 const UInt syscall_table_size
895 = sizeof(syscall_table
) / sizeof(syscall_table
[0]);
897 /* Is it in the contiguous initial section of the table? */
898 if (sysno
< syscall_table_size
) {
899 SyscallTableEntry
* sys
= &syscall_table
[sysno
];
900 if (sys
->before
== NULL
)
901 return NULL
; /* no entry */
906 /* Can't find a wrapper */
912 /*--------------------------------------------------------------------*/
914 /*--------------------------------------------------------------------*/