2 /*--------------------------------------------------------------------*/
3 /*--- Platform-specific syscalls stuff. syswrap-ppc64-linux.c ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2005-2017 Nicholas Nethercote <njn@valgrind.org>
11 Copyright (C) 2005-2017 Cerion Armour-Brown <cerion@open-works.co.uk>
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #if defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
31 #include "pub_core_basics.h"
32 #include "pub_core_vki.h"
33 #include "pub_core_vkiscnums.h"
34 #include "pub_core_threadstate.h"
35 #include "pub_core_aspacemgr.h"
36 #include "pub_core_debuglog.h"
37 #include "pub_core_libcbase.h"
38 #include "pub_core_libcassert.h"
39 #include "pub_core_libcprint.h"
40 #include "pub_core_libcproc.h"
41 #include "pub_core_libcsignal.h"
42 #include "pub_core_options.h"
43 #include "pub_core_scheduler.h"
44 #include "pub_core_sigframe.h" // For VG_(sigframe_destroy)()
45 #include "pub_core_signals.h"
46 #include "pub_core_syscall.h"
47 #include "pub_core_syswrap.h"
48 #include "pub_core_tooliface.h"
50 #include "priv_types_n_macros.h"
51 #include "priv_syswrap-generic.h" /* for decls of generic wrappers */
52 #include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers */
53 #include "priv_syswrap-main.h"
56 /* ---------------------------------------------------------------------
58 ------------------------------------------------------------------ */
60 /* Call f(arg1), but first switch stacks, using 'stack' as the new
61 stack, and use 'retaddr' as f's return-to address. Also, clear all
62 the integer registers before entering f.*/
63 __attribute__((noreturn
))
64 void ML_(call_on_new_stack_0_1
) ( Addr stack
,
70 // r5 = function descriptor
72 /* On PPC64, a func ptr is represented by a TOC entry ptr.
73 This TOC entry contains three words; the first word is the function
74 address, the second word is the TOC ptr (r2), and the third word is
75 the static chain value. */
77 #if defined(VGP_ppc64be_linux)
79 " .globl vgModuleLocal_call_on_new_stack_0_1\n"
80 " .section \".opd\",\"aw\"\n"
82 "vgModuleLocal_call_on_new_stack_0_1:\n"
83 " .quad .vgModuleLocal_call_on_new_stack_0_1,.TOC.@tocbase,0\n"
85 " .type .vgModuleLocal_call_on_new_stack_0_1,@function\n"
86 " .globl .vgModuleLocal_call_on_new_stack_0_1\n"
87 ".vgModuleLocal_call_on_new_stack_0_1:\n"
88 " mr %r1,%r3\n\t" // stack to %sp
89 " mtlr %r4\n\t" // retaddr to %lr
90 " ld 5,0(5)\n\t" // load f_ptr from f_desc[0]
91 " mtctr %r5\n\t" // f_ptr to count reg
92 " mr %r3,%r6\n\t" // arg1 to %r3
93 " li 0,0\n\t" // zero all GP regs
122 " mtxer 0\n\t" // CAB: Need this?
123 " mtcr 0\n\t" // CAB: Need this?
124 " bctr\n\t" // jump to dst
125 " trap\n" // should never get here
129 " .globl vgModuleLocal_call_on_new_stack_0_1\n"
130 "vgModuleLocal_call_on_new_stack_0_1:\n"
131 " .type .vgModuleLocal_call_on_new_stack_0_1,@function\n"
132 "#if _CALL_ELF == 2 \n"
133 "0: addis 2,12,.TOC.-0b@ha\n"
134 " addi 2,2,.TOC.-0b@l\n"
136 ".localentry vgModuleLocal_call_on_new_stack_0_1, .-vgModuleLocal_call_on_new_stack_0_1\n"
137 " mr %r1,%r3\n\t" // stack to %sp
138 " mtlr %r4\n\t" // retaddr to %lr
139 " mtctr %r5\n\t" // f_ptr to count reg
140 " mr %r3,%r6\n\t" // arg1 to %r3
141 " li 0,0\n\t" // zero all GP regs
170 " mtxer 0\n\t" // CAB: Need this?
171 " mtcr 0\n\t" // CAB: Need this?
172 " bctr\n\t" // jump to dst
173 " trap\n" // should never get here
179 Perform a clone system call. clone is strange because it has
180 fork()-like return-twice semantics, so it needs special
185 word (fn)(void*) in r3
186 void* child_stack in r4
189 pid_t* child_tid in r7
190 pid_t* parent_tid in r8
193 Note: r3 contains fn desc ptr, not fn ptr -- p_fn = p_fn_desc[0]
194 System call requires:
196 int $__NR_clone in r0 (sc number)
197 int flags in r3 (sc arg1)
198 void* child_stack in r4 (sc arg2)
199 pid_t* parent_tid in r5 (sc arg3)
200 ?? child_tls in r6 (sc arg4)
201 pid_t* child_tid in r7 (sc arg5)
202 void* ??? in r8 (sc arg6)
204 Returns a ULong encoded as: top half is %cr following syscall,
205 low half is syscall return value (r3).
207 #define __NR_CLONE VG_STRINGIFY(__NR_clone)
208 #define __NR_EXIT VG_STRINGIFY(__NR_exit)
210 // See priv_syswrap-linux.h for arg profile.
212 #if defined(VGP_ppc64be_linux)
214 " .globl do_syscall_clone_ppc64_linux\n"
215 " .section \".opd\",\"aw\"\n"
217 "do_syscall_clone_ppc64_linux:\n"
218 " .quad .do_syscall_clone_ppc64_linux,.TOC.@tocbase,0\n"
220 " .type .do_syscall_clone_ppc64_linux,@function\n"
221 " .globl .do_syscall_clone_ppc64_linux\n"
222 ".do_syscall_clone_ppc64_linux:\n"
227 " mr 30,3\n" // preserve fn
228 " mr 31,6\n" // preserve arg
231 " rldicr 4,4, 0,59\n" // trim sp to multiple of 16 bytes
234 " stdu 0,-32(4)\n" // make initial stack frame
235 " mr 29,4\n" // preserve sp
238 " li 0,"__NR_CLONE
"\n" // syscall number
239 " mr 3,5\n" // syscall arg1: flags
240 // r4 already setup // syscall arg2: child_stack
241 " mr 5,8\n" // syscall arg3: parent_tid
242 " mr 6,13\n" // syscall arg4: REAL THREAD tls
243 " mr 7,7\n" // syscall arg5: child_tid
244 " mr 8,8\n" // syscall arg6: ????
245 " mr 9,9\n" // syscall arg7: ????
249 " mfcr 4\n" // CR now in low half r4
250 " sldi 4,4,32\n" // CR now in hi half r4
253 " srdi 3,3,32\n" // zero out hi half r3
255 " or 3,3,4\n" // r3 = CR : syscall-retval
256 " cmpwi 3,0\n" // child if retval == 0 (note, cmpw)
257 " bne 1f\n" // jump if !child
259 /* CHILD - call thread function */
260 /* Note: 2.4 kernel doesn't set the child stack pointer,
262 That does leave a small window for a signal to be delivered
263 on the wrong stack, unfortunately. */
265 " ld 30, 0(30)\n" // convert fn desc ptr to fn ptr
266 " mtctr 30\n" // ctr reg = fn
267 " mr 3,31\n" // r3 = arg
268 " bctrl\n" // call fn()
271 " li 0,"__NR_EXIT
"\n"
277 // PARENT or ERROR - return
285 " .globl do_syscall_clone_ppc64_linux\n"
286 " .type do_syscall_clone_ppc64_linux,@function\n"
287 "do_syscall_clone_ppc64_linux:\n"
288 " .globl .do_syscall_clone_ppc64_linux\n"
289 ".do_syscall_clone_ppc64_linux:\n"
290 "#if _CALL_ELF == 2 \n"
291 "0: addis 2,12,.TOC.-0b@ha \n"
292 " addi 2,2,.TOC.-0b@l \n"
294 " .localentry do_syscall_clone_ppc64_linux, .-do_syscall_clone_ppc64_linux \n"
299 " mr 30,3\n" // preserve fn
300 " mr 31,6\n" // preserve arg
303 " rldicr 4,4, 0,59\n" // trim sp to multiple of 16 bytes
306 " stdu 0,-32(4)\n" // make initial stack frame
307 " mr 29,4\n" // preserve sp
310 " li 0,"__NR_CLONE
"\n" // syscall number
311 " mr 3,5\n" // syscall arg1: flags
312 // r4 already setup // syscall arg2: child_stack
313 " mr 5,8\n" // syscall arg3: parent_tid
314 " mr 6,13\n" // syscall arg4: REAL THREAD tls
315 " mr 7,7\n" // syscall arg5: child_tid
316 " mr 8,8\n" // syscall arg6: ????
317 " mr 9,9\n" // syscall arg7: ????
321 " mfcr 4\n" // CR now in low half r4
322 " sldi 4,4,32\n" // CR now in hi half r4
325 " srdi 3,3,32\n" // zero out hi half r3
327 " or 3,3,4\n" // r3 = CR : syscall-retval
328 " cmpwi 3,0\n" // child if retval == 0 (note, cmpw)
329 " bne 1f\n" // jump if !child
331 /* CHILD - call thread function */
332 /* Note: 2.4 kernel doesn't set the child stack pointer,
334 That does leave a small window for a signal to be delivered
335 on the wrong stack, unfortunately. */
337 " mtctr 30\n" // ctr reg = fn
338 " mr 3,31\n" // r3 = arg
339 " bctrl\n" // call fn()
342 " li 0,"__NR_EXIT
"\n"
348 // PARENT or ERROR - return
360 /* ---------------------------------------------------------------------
362 ------------------------------------------------------------------ */
364 void VG_(cleanup_thread
) ( ThreadArchState
* arch
)
368 /* ---------------------------------------------------------------------
369 PRE/POST wrappers for ppc64/Linux-specific syscalls
370 ------------------------------------------------------------------ */
372 #define PRE(name) DEFN_PRE_TEMPLATE(ppc64_linux, name)
373 #define POST(name) DEFN_POST_TEMPLATE(ppc64_linux, name)
375 /* Add prototypes for the wrappers declared here, so that gcc doesn't
376 harass us for not having prototypes. Really this is a kludge --
377 the right thing to do is to make these wrappers 'static' since they
378 aren't visible outside this file, but that requires even more macro
381 DECL_TEMPLATE(ppc64_linux
, sys_mmap
);
382 //zz DECL_TEMPLATE(ppc64_linux, sys_mmap2);
383 //zz DECL_TEMPLATE(ppc64_linux, sys_stat64);
384 //zz DECL_TEMPLATE(ppc64_linux, sys_lstat64);
385 //zz DECL_TEMPLATE(ppc64_linux, sys_fstat64);
386 //zz DECL_TEMPLATE(ppc64_linux, sys_sigreturn);
387 DECL_TEMPLATE(ppc64_linux
, sys_rt_sigreturn
);
388 DECL_TEMPLATE(ppc64_linux
, sys_fadvise64
);
389 DECL_TEMPLATE(ppc64_linux
, sys_ptrace
);
395 PRINT("sys_mmap ( %#lx, %lu, %lu, %lu, %lu, %lu )",
396 ARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
397 PRE_REG_READ6(long, "mmap",
398 unsigned long, start
, unsigned long, length
,
399 unsigned long, prot
, unsigned long, flags
,
400 unsigned long, fd
, unsigned long, offset
);
402 r
= ML_(generic_PRE_sys_mmap
)( tid
, ARG1
, ARG2
, ARG3
, ARG4
, ARG5
,
404 SET_STATUS_from_SysRes(r
);
411 //zz // Exactly like old_mmap() except:
412 //zz // - the file offset is specified in 4K units rather than bytes,
413 //zz // so that it can be used for files bigger than 2^32 bytes.
414 //zz PRINT("sys_mmap2 ( %p, %llu, %d, %d, %d, %d )",
415 //zz ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, ARG6 );
416 //zz PRE_REG_READ6(long, "mmap2",
417 //zz unsigned long, start, unsigned long, length,
418 //zz unsigned long, prot, unsigned long, flags,
419 //zz unsigned long, fd, unsigned long, offset);
421 //zz r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5,
422 //zz 4096 * (Off64T)ARG6 );
423 //zz SET_STATUS_from_SysRes(r);
426 //zz // XXX: lstat64/fstat64/stat64 are generic, but not necessarily
427 //zz // applicable to every architecture -- I think only to 32-bit archs.
428 //zz // We're going to need something like linux/core_os32.h for such
429 //zz // things, eventually, I think. --njn
432 //zz PRINT("sys_stat64 ( %p, %p )",ARG1,ARG2);
433 //zz PRE_REG_READ2(long, "stat64", char *, file_name, struct stat64 *, buf);
434 //zz PRE_MEM_RASCIIZ( "stat64(file_name)", ARG1 );
435 //zz PRE_MEM_WRITE( "stat64(buf)", ARG2, sizeof(struct vki_stat64) );
438 //zz POST(sys_stat64)
440 //zz POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) );
443 //zz PRE(sys_lstat64)
445 //zz PRINT("sys_lstat64 ( %p(%s), %p )",ARG1,ARG1,ARG2);
446 //zz PRE_REG_READ2(long, "lstat64", char *, file_name, struct stat64 *, buf);
447 //zz PRE_MEM_RASCIIZ( "lstat64(file_name)", ARG1 );
448 //zz PRE_MEM_WRITE( "lstat64(buf)", ARG2, sizeof(struct vki_stat64) );
451 //zz POST(sys_lstat64)
453 //zz vg_assert(SUCCESS);
455 //zz POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) );
459 //zz PRE(sys_fstat64)
461 //zz PRINT("sys_fstat64 ( %d, %p )",ARG1,ARG2);
462 //zz PRE_REG_READ2(long, "fstat64", unsigned long, fd, struct stat64 *, buf);
463 //zz PRE_MEM_WRITE( "fstat64(buf)", ARG2, sizeof(struct vki_stat64) );
466 //zz POST(sys_fstat64)
468 //zz POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) );
473 PRINT("sys_fadvise64 ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, "
474 "%" FMT_REGWORD
"u, %" FMT_REGWORD
"d )",
475 SARG1
, SARG2
, ARG3
, SARG4
);
476 PRE_REG_READ4(long, "fadvise64",
477 int, fd
, vki_loff_t
, offset
, vki_size_t
, len
, int, advice
);
480 PRE(sys_rt_sigreturn
)
482 /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for
483 an explanation of what follows. */
486 PRINT("sys_rt_sigreturn ( )");
488 vg_assert(VG_(is_valid_tid
)(tid
));
489 vg_assert(tid
>= 1 && tid
< VG_N_THREADS
);
490 vg_assert(VG_(is_running_thread
)(tid
));
492 ///* Adjust esp to point to start of frame; skip back up over handler
494 //tst = VG_(get_ThreadState)(tid);
495 //tst->arch.vex.guest_ESP -= sizeof(Addr);
496 // Should we do something equivalent on ppc64-linux? Who knows.
498 ///* This is only so that the EIP is (might be) useful to report if
499 // something goes wrong in the sigreturn */
500 //ML_(fixup_guest_state_to_restart_syscall)(&tst->arch);
501 // Should we do something equivalent on ppc64? Who knows.
503 /* Restore register state from frame and remove it */
504 VG_(sigframe_destroy
)(tid
, True
);
506 /* Tell the driver not to update the guest state with the "result",
507 and set a bogus result to keep it happy. */
508 *flags
|= SfNoWriteResult
;
509 SET_STATUS_Success(0);
511 /* Check to see if any signals arose as a result of this. */
512 *flags
|= SfPollAfter
;
515 // ARG3 is only used for pointers into the traced process's address
516 // space and for offsets into the traced process's struct
517 // user_regs_struct. It is never a pointer into this process's memory
518 // space, and we should therefore not check anything it points to.
519 // powerpc does have other ways to get/set registers, we only support
520 // GET/SETREGSET for now.
523 PRINT("sys_ptrace ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, "
524 "%#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
525 SARG1
, SARG2
, ARG3
, ARG4
);
526 PRE_REG_READ4(int, "ptrace",
527 long, request
, long, pid
, long, addr
, long, data
);
529 case VKI_PTRACE_PEEKTEXT
:
530 case VKI_PTRACE_PEEKDATA
:
531 case VKI_PTRACE_PEEKUSR
:
532 PRE_MEM_WRITE( "ptrace(peek)", ARG4
,
535 case VKI_PTRACE_GETEVENTMSG
:
536 PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4
, sizeof(unsigned long));
538 case VKI_PTRACE_GETSIGINFO
:
539 PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4
, sizeof(vki_siginfo_t
));
541 case VKI_PTRACE_SETSIGINFO
:
542 PRE_MEM_READ( "ptrace(setsiginfo)", ARG4
, sizeof(vki_siginfo_t
));
544 case VKI_PTRACE_GETREGSET
:
545 ML_(linux_PRE_getregset
)(tid
, ARG3
, ARG4
);
547 case VKI_PTRACE_SETREGSET
:
548 ML_(linux_PRE_setregset
)(tid
, ARG3
, ARG4
);
558 case VKI_PTRACE_TRACEME
:
559 ML_(linux_POST_traceme
)(tid
);
561 case VKI_PTRACE_PEEKTEXT
:
562 case VKI_PTRACE_PEEKDATA
:
563 case VKI_PTRACE_PEEKUSR
:
564 POST_MEM_WRITE( ARG4
, sizeof (long));
566 case VKI_PTRACE_GETEVENTMSG
:
567 POST_MEM_WRITE( ARG4
, sizeof(unsigned long));
569 case VKI_PTRACE_GETSIGINFO
:
570 /* XXX: This is a simplification. Different parts of the
571 * siginfo_t are valid depending on the type of signal.
573 POST_MEM_WRITE( ARG4
, sizeof(vki_siginfo_t
));
575 case VKI_PTRACE_GETREGSET
:
576 ML_(linux_POST_getregset
)(tid
, ARG3
, ARG4
);
586 /* ---------------------------------------------------------------------
587 The ppc64/Linux syscall table
588 ------------------------------------------------------------------ */
590 /* Add an ppc64-linux specific wrapper to a syscall table. */
591 #define PLAX_(sysno, name) WRAPPER_ENTRY_X_(ppc64_linux, sysno, name)
592 #define PLAXY(sysno, name) WRAPPER_ENTRY_XY(ppc64_linux, sysno, name)
594 // This table maps from __NR_xxx syscall numbers (from
595 // linux/include/asm-ppc/unistd.h) to the appropriate PRE/POST sys_foo()
596 // wrappers on ppc64 (as per sys_call_table in linux/arch/ppc/kernel/entry.S).
598 // For those syscalls not handled by Valgrind, the annotation indicate its
599 // arch/OS combination, eg. */* (generic), */Linux (Linux only), ?/?
602 static SyscallTableEntry syscall_table
[] = {
603 // _____(__NR_restart_syscall, sys_restart_syscall), // 0
604 GENX_(__NR_exit
, sys_exit
), // 1
605 GENX_(__NR_fork
, sys_fork
), // 2
606 GENXY(__NR_read
, sys_read
), // 3
607 GENX_(__NR_write
, sys_write
), // 4
609 GENXY(__NR_open
, sys_open
), // 5
610 GENXY(__NR_close
, sys_close
), // 6
611 GENXY(__NR_waitpid
, sys_waitpid
), // 7
612 GENXY(__NR_creat
, sys_creat
), // 8
613 GENX_(__NR_link
, sys_link
), // 9
615 GENX_(__NR_unlink
, sys_unlink
), // 10
616 GENX_(__NR_execve
, sys_execve
), // 11
617 GENX_(__NR_chdir
, sys_chdir
), // 12
618 GENXY(__NR_time
, sys_time
), // 13
619 GENX_(__NR_mknod
, sys_mknod
), // 14
621 GENX_(__NR_chmod
, sys_chmod
), // 15
622 GENX_(__NR_lchown
, sys_lchown
), // 16
623 // _____(__NR_break, sys_break), // 17
624 // _____(__NR_oldstat, sys_oldstat), // 18
625 LINX_(__NR_lseek
, sys_lseek
), // 19
627 GENX_(__NR_getpid
, sys_getpid
), // 20
628 LINX_(__NR_mount
, sys_mount
), // 21
629 // _____(__NR_umount, sys_umount), // 22
630 GENX_(__NR_setuid
, sys_setuid
), // 23
631 GENX_(__NR_getuid
, sys_getuid
), // 24
633 // _____(__NR_stime, sys_stime), // 25
634 PLAXY(__NR_ptrace
, sys_ptrace
), // 26
635 GENX_(__NR_alarm
, sys_alarm
), // 27
636 // _____(__NR_oldfstat, sys_oldfstat), // 28
637 GENX_(__NR_pause
, sys_pause
), // 29
639 LINX_(__NR_utime
, sys_utime
), // 30
640 // _____(__NR_stty, sys_stty), // 31
641 // _____(__NR_gtty, sys_gtty), // 32
642 GENX_(__NR_access
, sys_access
), // 33
643 // _____(__NR_nice, sys_nice), // 34
645 // _____(__NR_ftime, sys_ftime), // 35
646 GENX_(__NR_sync
, sys_sync
), // 36
647 GENX_(__NR_kill
, sys_kill
), // 37
648 GENX_(__NR_rename
, sys_rename
), // 38
649 GENX_(__NR_mkdir
, sys_mkdir
), // 39
651 GENX_(__NR_rmdir
, sys_rmdir
), // 40
652 GENXY(__NR_dup
, sys_dup
), // 41
653 LINXY(__NR_pipe
, sys_pipe
), // 42
654 GENXY(__NR_times
, sys_times
), // 43
655 // _____(__NR_prof, sys_prof), // 44
657 GENX_(__NR_brk
, sys_brk
), // 45
658 GENX_(__NR_setgid
, sys_setgid
), // 46
659 GENX_(__NR_getgid
, sys_getgid
), // 47
660 // _____(__NR_signal, sys_signal), // 48
661 GENX_(__NR_geteuid
, sys_geteuid
), // 49
663 GENX_(__NR_getegid
, sys_getegid
), // 50
664 GENX_(__NR_acct
, sys_acct
), // 51
665 LINX_(__NR_umount2
, sys_umount
), // 52
666 // _____(__NR_lock, sys_lock), // 53
667 LINXY(__NR_ioctl
, sys_ioctl
), // 54
669 LINXY(__NR_fcntl
, sys_fcntl
), // 55
670 // _____(__NR_mpx, sys_mpx), // 56
671 GENX_(__NR_setpgid
, sys_setpgid
), // 57
672 // _____(__NR_ulimit, sys_ulimit), // 58
673 // _____(__NR_oldolduname, sys_oldolduname), // 59
675 GENX_(__NR_umask
, sys_umask
), // 60
676 GENX_(__NR_chroot
, sys_chroot
), // 61
677 // _____(__NR_ustat, sys_ustat), // 62
678 GENXY(__NR_dup2
, sys_dup2
), // 63
679 GENX_(__NR_getppid
, sys_getppid
), // 64
681 GENX_(__NR_getpgrp
, sys_getpgrp
), // 65
682 GENX_(__NR_setsid
, sys_setsid
), // 66
683 // _____(__NR_sigaction, sys_sigaction), // 67
684 // _____(__NR_sgetmask, sys_sgetmask), // 68
685 // _____(__NR_ssetmask, sys_ssetmask), // 69
687 GENX_(__NR_setreuid
, sys_setreuid
), // 70
688 GENX_(__NR_setregid
, sys_setregid
), // 71
689 // _____(__NR_sigsuspend, sys_sigsuspend), // 72
690 // _____(__NR_sigpending, sys_sigpending), // 73
691 // _____(__NR_sethostname, sys_sethostname), // 74
693 GENX_(__NR_setrlimit
, sys_setrlimit
), // 75
694 // _____(__NR_getrlimit, sys_getrlimit), // 76
695 GENXY(__NR_getrusage
, sys_getrusage
), // 77
696 GENXY(__NR_gettimeofday
, sys_gettimeofday
), // 78
697 // _____(__NR_settimeofday, sys_settimeofday), // 79
699 GENXY(__NR_getgroups
, sys_getgroups
), // 80
700 GENX_(__NR_setgroups
, sys_setgroups
), // 81
701 // _____(__NR_select, sys_select), // 82
702 GENX_(__NR_symlink
, sys_symlink
), // 83
703 // _____(__NR_oldlstat, sys_oldlstat), // 84
705 GENX_(__NR_readlink
, sys_readlink
), // 85
706 // _____(__NR_uselib, sys_uselib), // 86
707 // _____(__NR_swapon, sys_swapon), // 87
708 // _____(__NR_reboot, sys_reboot), // 88
709 // _____(__NR_readdir, sys_readdir), // 89
711 PLAX_(__NR_mmap
, sys_mmap
), // 90
712 GENXY(__NR_munmap
, sys_munmap
), // 91
713 GENX_(__NR_truncate
, sys_truncate
), // 92
714 GENX_(__NR_ftruncate
, sys_ftruncate
), // 93
715 GENX_(__NR_fchmod
, sys_fchmod
), // 94
717 GENX_(__NR_fchown
, sys_fchown
), // 95
718 GENX_(__NR_getpriority
, sys_getpriority
), // 96
719 GENX_(__NR_setpriority
, sys_setpriority
), // 97
720 // _____(__NR_profil, sys_profil), // 98
721 GENXY(__NR_statfs
, sys_statfs
), // 99
723 GENXY(__NR_fstatfs
, sys_fstatfs
), // 100
724 // _____(__NR_ioperm, sys_ioperm), // 101
725 LINXY(__NR_socketcall
, sys_socketcall
), // 102
726 LINXY(__NR_syslog
, sys_syslog
), // 103
727 GENXY(__NR_setitimer
, sys_setitimer
), // 104
729 GENXY(__NR_getitimer
, sys_getitimer
), // 105
730 GENXY(__NR_stat
, sys_newstat
), // 106
731 GENXY(__NR_lstat
, sys_newlstat
), // 107
732 GENXY(__NR_fstat
, sys_newfstat
), // 108
733 // _____(__NR_olduname, sys_olduname), // 109
735 // _____(__NR_iopl, sys_iopl), // 110
736 LINX_(__NR_vhangup
, sys_vhangup
), // 111
737 // _____(__NR_idle, sys_idle), // 112
738 // _____(__NR_vm86, sys_vm86), // 113
739 GENXY(__NR_wait4
, sys_wait4
), // 114
741 // _____(__NR_swapoff, sys_swapoff), // 115
742 LINXY(__NR_sysinfo
, sys_sysinfo
), // 116
743 LINXY(__NR_ipc
, sys_ipc
), // 117
744 GENX_(__NR_fsync
, sys_fsync
), // 118
745 // _____(__NR_sigreturn, sys_sigreturn), // 119
747 LINX_(__NR_clone
, sys_clone
), // 120
748 // _____(__NR_setdomainname, sys_setdomainname), // 121
749 GENXY(__NR_uname
, sys_newuname
), // 122
750 // _____(__NR_modify_ldt, sys_modify_ldt), // 123
751 LINXY(__NR_adjtimex
, sys_adjtimex
), // 124
753 GENXY(__NR_mprotect
, sys_mprotect
), // 125
754 // _____(__NR_sigprocmask, sys_sigprocmask), // 126
755 GENX_(__NR_create_module
, sys_ni_syscall
), // 127
756 LINX_(__NR_init_module
, sys_init_module
), // 128
757 LINX_(__NR_delete_module
, sys_delete_module
), // 129
759 // _____(__NR_get_kernel_syms, sys_get_kernel_syms), // 130
760 LINX_(__NR_quotactl
, sys_quotactl
), // 131
761 GENX_(__NR_getpgid
, sys_getpgid
), // 132
762 GENX_(__NR_fchdir
, sys_fchdir
), // 133
763 // _____(__NR_bdflush, sys_bdflush), // 134
765 // _____(__NR_sysfs, sys_sysfs), // 135
766 LINX_(__NR_personality
, sys_personality
), // 136
767 // _____(__NR_afs_syscall, sys_afs_syscall), // 137
768 LINX_(__NR_setfsuid
, sys_setfsuid
), // 138
769 LINX_(__NR_setfsgid
, sys_setfsgid
), // 139
771 LINXY(__NR__llseek
, sys_llseek
), // 140
772 GENXY(__NR_getdents
, sys_getdents
), // 141
773 GENX_(__NR__newselect
, sys_select
), // 142
774 GENX_(__NR_flock
, sys_flock
), // 143
775 GENX_(__NR_msync
, sys_msync
), // 144
777 GENXY(__NR_readv
, sys_readv
), // 145
778 GENX_(__NR_writev
, sys_writev
), // 146
779 GENX_(__NR_getsid
, sys_getsid
), // 147
780 GENX_(__NR_fdatasync
, sys_fdatasync
), // 148
781 LINXY(__NR__sysctl
, sys_sysctl
), // 149
783 GENX_(__NR_mlock
, sys_mlock
), // 150
784 GENX_(__NR_munlock
, sys_munlock
), // 151
785 GENX_(__NR_mlockall
, sys_mlockall
), // 152
786 LINX_(__NR_munlockall
, sys_munlockall
), // 153
787 LINXY(__NR_sched_setparam
, sys_sched_setparam
), // 154
789 LINXY(__NR_sched_getparam
, sys_sched_getparam
), // 155
790 LINX_(__NR_sched_setscheduler
, sys_sched_setscheduler
), // 156
791 LINX_(__NR_sched_getscheduler
, sys_sched_getscheduler
), // 157
792 LINX_(__NR_sched_yield
, sys_sched_yield
), // 158
793 LINX_(__NR_sched_get_priority_max
, sys_sched_get_priority_max
),// 159
795 LINX_(__NR_sched_get_priority_min
, sys_sched_get_priority_min
),// 160
796 LINXY(__NR_sched_rr_get_interval
, sys_sched_rr_get_interval
), // 161
797 GENXY(__NR_nanosleep
, sys_nanosleep
), // 162
798 GENX_(__NR_mremap
, sys_mremap
), // 163
799 LINX_(__NR_setresuid
, sys_setresuid
), // 164
801 LINXY(__NR_getresuid
, sys_getresuid
), // 165
802 // _____(__NR_query_module, sys_query_module), // 166
803 GENXY(__NR_poll
, sys_poll
), // 167
804 // _____(__NR_nfsservctl, sys_nfsservctl), // 168
805 LINX_(__NR_setresgid
, sys_setresgid
), // 169
807 LINXY(__NR_getresgid
, sys_getresgid
), // 170
808 LINXY(__NR_prctl
, sys_prctl
), // 171
809 PLAX_(__NR_rt_sigreturn
, sys_rt_sigreturn
), // 172
810 LINXY(__NR_rt_sigaction
, sys_rt_sigaction
), // 173
811 LINXY(__NR_rt_sigprocmask
, sys_rt_sigprocmask
), // 174
813 LINXY(__NR_rt_sigpending
, sys_rt_sigpending
), // 175
814 LINXY(__NR_rt_sigtimedwait
, sys_rt_sigtimedwait
), // 176
815 LINXY(__NR_rt_sigqueueinfo
, sys_rt_sigqueueinfo
), // 177
816 LINX_(__NR_rt_sigsuspend
, sys_rt_sigsuspend
), // 178
817 GENXY(__NR_pread64
, sys_pread64
), // 179
819 GENX_(__NR_pwrite64
, sys_pwrite64
), // 180
820 GENX_(__NR_chown
, sys_chown
), // 181
821 GENXY(__NR_getcwd
, sys_getcwd
), // 182
822 LINXY(__NR_capget
, sys_capget
), // 183
823 LINX_(__NR_capset
, sys_capset
), // 184
825 GENXY(__NR_sigaltstack
, sys_sigaltstack
), // 185
826 LINXY(__NR_sendfile
, sys_sendfile
), // 186
827 // _____(__NR_getpmsg, sys_getpmsg), // 187
828 // _____(__NR_putpmsg, sys_putpmsg), // 188
829 GENX_(__NR_vfork
, sys_fork
), // 189 treat as fork
831 GENXY(__NR_ugetrlimit
, sys_getrlimit
), // 190
832 LINX_(__NR_readahead
, sys_readahead
), // 191
833 // /* #define __NR_mmap2 192 32bit only */
834 // /* #define __NR_truncate64 193 32bit only */
835 // /* #define __NR_ftruncate64 194 32bit only */
837 // /* #define __NR_stat64 195 32bit only */
838 // /* #define __NR_lstat64 196 32bit only */
839 // /* #define __NR_fstat64 197 32bit only */
840 // _____(__NR_pciconfig_read, sys_pciconfig_read), // 198
841 // _____(__NR_pciconfig_write, sys_pciconfig_write), // 199
843 // _____(__NR_pciconfig_iobase, sys_pciconfig_iobase), // 200
844 // _____(__NR_multiplexer, sys_multiplexer), // 201
845 GENXY(__NR_getdents64
, sys_getdents64
), // 202
846 LINX_(__NR_pivot_root
, sys_pivot_root
), // 203
847 LINXY(__NR_fcntl64
, sys_fcntl64
), // 204 !!!!?? 32bit only */
849 GENX_(__NR_madvise
, sys_madvise
), // 205
850 // _____(__NR_mincore, sys_mincore), // 206
851 LINX_(__NR_gettid
, sys_gettid
), // 207
852 // _____(__NR_tkill, sys_tkill), // 208
853 LINX_(__NR_setxattr
, sys_setxattr
), // 209
855 LINX_(__NR_lsetxattr
, sys_lsetxattr
), // 210
856 LINX_(__NR_fsetxattr
, sys_fsetxattr
), // 211
857 LINXY(__NR_getxattr
, sys_getxattr
), // 212
858 LINXY(__NR_lgetxattr
, sys_lgetxattr
), // 213
859 LINXY(__NR_fgetxattr
, sys_fgetxattr
), // 214
860 LINXY(__NR_listxattr
, sys_listxattr
), // 215
861 LINXY(__NR_llistxattr
, sys_llistxattr
), // 216
862 LINXY(__NR_flistxattr
, sys_flistxattr
), // 217
863 LINX_(__NR_removexattr
, sys_removexattr
), // 218
864 LINX_(__NR_lremovexattr
, sys_lremovexattr
), // 219
865 LINX_(__NR_fremovexattr
, sys_fremovexattr
), // 220
867 LINXY(__NR_futex
, sys_futex
), // 221
868 LINX_(__NR_sched_setaffinity
, sys_sched_setaffinity
), // 222
869 LINXY(__NR_sched_getaffinity
, sys_sched_getaffinity
), // 223
870 // /* 224 currently unused */
872 // _____(__NR_tuxcall, sys_tuxcall), // 225
873 // /* #define __NR_sendfile64 226 32bit only */
874 LINX_(__NR_io_setup
, sys_io_setup
), // 227
875 LINX_(__NR_io_destroy
, sys_io_destroy
), // 228
876 LINXY(__NR_io_getevents
, sys_io_getevents
), // 229
877 LINX_(__NR_io_submit
, sys_io_submit
), // 230
878 LINXY(__NR_io_cancel
, sys_io_cancel
), // 231
879 LINX_(__NR_set_tid_address
, sys_set_tid_address
), // 232
880 PLAX_(__NR_fadvise64
, sys_fadvise64
), // 233
881 LINX_(__NR_exit_group
, sys_exit_group
), // 234
883 // _____(__NR_lookup_dcookie, sys_lookup_dcookie), // 235
884 LINXY(__NR_epoll_create
, sys_epoll_create
), // 236
885 LINX_(__NR_epoll_ctl
, sys_epoll_ctl
), // 237
886 LINXY(__NR_epoll_wait
, sys_epoll_wait
), // 238
887 // _____(__NR_remap_file_pages, sys_remap_file_pages), // 239
889 LINXY(__NR_timer_create
, sys_timer_create
), // 240
890 LINXY(__NR_timer_settime
, sys_timer_settime
), // 241
891 LINXY(__NR_timer_gettime
, sys_timer_gettime
), // 242
892 LINX_(__NR_timer_getoverrun
, sys_timer_getoverrun
), // 243
893 LINX_(__NR_timer_delete
, sys_timer_delete
), // 244
894 LINX_(__NR_clock_settime
, sys_clock_settime
), // 245
895 LINXY(__NR_clock_gettime
, sys_clock_gettime
), // 246
896 LINXY(__NR_clock_getres
, sys_clock_getres
), // 247
897 LINXY(__NR_clock_nanosleep
, sys_clock_nanosleep
), // 248
899 // _____(__NR_swapcontext, sys_swapcontext), // 249
901 LINXY(__NR_tgkill
, sys_tgkill
), // 250
902 // _____(__NR_utimes, sys_utimes), // 251
903 GENXY(__NR_statfs64
, sys_statfs64
), // 252
904 GENXY(__NR_fstatfs64
, sys_fstatfs64
), // 253
905 // /* #define __NR_fadvise64_64 254 32bit only */
907 // _____(__NR_rtas, sys_rtas), // 255
908 // /* Number 256 is reserved for sys_debug_setcontext */
909 // /* Number 257 is reserved for vserver */
910 // /* 258 currently unused */
911 LINX_(__NR_mbind
, sys_mbind
), // 259
913 LINXY(__NR_get_mempolicy
, sys_get_mempolicy
), // 260
914 LINX_(__NR_set_mempolicy
, sys_set_mempolicy
), // 261
915 LINXY(__NR_mq_open
, sys_mq_open
), // 262
916 LINX_(__NR_mq_unlink
, sys_mq_unlink
), // 263
917 LINX_(__NR_mq_timedsend
, sys_mq_timedsend
), // 264
919 LINXY(__NR_mq_timedreceive
, sys_mq_timedreceive
), // 265
920 LINX_(__NR_mq_notify
, sys_mq_notify
), // 266
921 LINXY(__NR_mq_getsetattr
, sys_mq_getsetattr
), // 267
922 // _____(__NR_kexec_load, sys_kexec_load), // 268
923 LINX_(__NR_add_key
, sys_add_key
), // 269
925 LINX_(__NR_request_key
, sys_request_key
), // 270
926 LINXY(__NR_keyctl
, sys_keyctl
), // 271
927 LINXY(__NR_waitid
, sys_waitid
), // 272
928 LINX_(__NR_ioprio_set
, sys_ioprio_set
), // 273
929 LINX_(__NR_ioprio_get
, sys_ioprio_get
), // 274
931 LINX_(__NR_inotify_init
, sys_inotify_init
), // 275
932 LINX_(__NR_inotify_add_watch
, sys_inotify_add_watch
), // 276
933 LINX_(__NR_inotify_rm_watch
, sys_inotify_rm_watch
), // 277
935 LINXY(__NR_pselect6
, sys_pselect6
), // 280
936 LINXY(__NR_ppoll
, sys_ppoll
), // 281
938 LINXY(__NR_openat
, sys_openat
), // 286
939 LINX_(__NR_mkdirat
, sys_mkdirat
), // 287
940 LINX_(__NR_mknodat
, sys_mknodat
), // 288
941 LINX_(__NR_fchownat
, sys_fchownat
), // 289
942 LINX_(__NR_futimesat
, sys_futimesat
), // 290
943 LINXY(__NR_newfstatat
, sys_newfstatat
), // 291
944 LINX_(__NR_unlinkat
, sys_unlinkat
), // 292
945 LINX_(__NR_renameat
, sys_renameat
), // 293
946 LINX_(__NR_linkat
, sys_linkat
), // 294
947 LINX_(__NR_symlinkat
, sys_symlinkat
), // 295
948 LINX_(__NR_readlinkat
, sys_readlinkat
), // 296
949 LINX_(__NR_fchmodat
, sys_fchmodat
), // 297
950 LINX_(__NR_faccessat
, sys_faccessat
), // 298
951 LINX_(__NR_set_robust_list
, sys_set_robust_list
), // 299
952 LINXY(__NR_get_robust_list
, sys_get_robust_list
), // 300
953 LINXY(__NR_move_pages
, sys_move_pages
), // 301
954 LINXY(__NR_getcpu
, sys_getcpu
), // 302
955 LINXY(__NR_epoll_pwait
, sys_epoll_pwait
), // 303
956 LINX_(__NR_utimensat
, sys_utimensat
), // 304
957 LINXY(__NR_signalfd
, sys_signalfd
), // 305
958 LINXY(__NR_timerfd_create
, sys_timerfd_create
), // 306
959 LINXY(__NR_eventfd
, sys_eventfd
), // 307
960 LINX_(__NR_sync_file_range2
, sys_sync_file_range2
), // 308
961 LINX_(__NR_fallocate
, sys_fallocate
), // 309
962 // LINXY(__NR_subpage_prot, sys_ni_syscall), // 310
963 LINXY(__NR_timerfd_settime
, sys_timerfd_settime
), // 311
964 LINXY(__NR_timerfd_gettime
, sys_timerfd_gettime
), // 312
965 LINXY(__NR_signalfd4
, sys_signalfd4
), // 313
966 LINXY(__NR_eventfd2
, sys_eventfd2
), // 314
967 LINXY(__NR_epoll_create1
, sys_epoll_create1
), // 315
968 LINXY(__NR_dup3
, sys_dup3
), // 316
969 LINXY(__NR_pipe2
, sys_pipe2
), // 317
970 LINXY(__NR_inotify_init1
, sys_inotify_init1
), // 318
971 LINXY(__NR_perf_event_open
, sys_perf_event_open
), // 319
972 LINXY(__NR_preadv
, sys_preadv
), // 320
973 LINX_(__NR_pwritev
, sys_pwritev
), // 321
974 LINXY(__NR_rt_tgsigqueueinfo
, sys_rt_tgsigqueueinfo
),// 322
976 LINXY(__NR_prlimit64
, sys_prlimit64
), // 325
977 LINXY(__NR_socket
, sys_socket
), // 326
978 LINX_(__NR_bind
, sys_bind
), // 327
979 LINX_(__NR_connect
, sys_connect
), // 328
980 LINX_(__NR_listen
, sys_listen
), // 329
981 LINXY(__NR_accept
, sys_accept
), // 330
982 LINXY(__NR_getsockname
, sys_getsockname
), // 331
983 LINXY(__NR_getpeername
, sys_getpeername
), // 332
984 LINXY(__NR_socketpair
, sys_socketpair
), // 333
985 LINX_(__NR_send
, sys_send
), // 334
986 LINX_(__NR_sendto
, sys_sendto
), // 335
987 LINXY(__NR_recv
, sys_recv
), // 336
988 LINXY(__NR_recvfrom
, sys_recvfrom
), // 337
989 LINX_(__NR_shutdown
, sys_shutdown
), // 338
990 LINX_(__NR_setsockopt
, sys_setsockopt
), // 339
991 LINXY(__NR_getsockopt
, sys_getsockopt
), // 340
992 LINX_(__NR_sendmsg
, sys_sendmsg
), // 341
993 LINXY(__NR_recvmsg
, sys_recvmsg
), // 342
994 LINXY(__NR_recvmmsg
, sys_recvmmsg
), // 343
995 LINXY(__NR_accept4
, sys_accept4
), // 344
996 LINXY(__NR_name_to_handle_at
, sys_name_to_handle_at
),// 345
997 LINXY(__NR_open_by_handle_at
, sys_open_by_handle_at
),// 346
998 LINXY(__NR_clock_adjtime
, sys_clock_adjtime
), // 347
999 LINX_(__NR_syncfs
, sys_syncfs
), // 348
1000 LINXY(__NR_sendmmsg
, sys_sendmmsg
), // 349
1002 LINXY(__NR_process_vm_readv
, sys_process_vm_readv
), // 351
1003 LINX_(__NR_process_vm_writev
, sys_process_vm_writev
),// 352
1005 LINX_(__NR_sched_setattr
, sys_sched_setattr
), // 355
1006 LINXY(__NR_sched_getattr
, sys_sched_getattr
), // 356
1007 LINX_(__NR_renameat2
, sys_renameat2
), // 357
1009 LINXY(__NR_getrandom
, sys_getrandom
), // 359
1010 LINXY(__NR_memfd_create
, sys_memfd_create
), // 360
1012 LINX_(__NR_execveat
, sys_execveat
), // 362
1014 LINX_(__NR_membarrier
, sys_membarrier
), // 365
1016 LINX_(__NR_copy_file_range
, sys_copy_file_range
), // 379
1017 LINX_(__NR_preadv2
, sys_preadv2
), // 380
1018 LINX_(__NR_pwritev2
, sys_pwritev2
), // 381
1020 LINXY(__NR_statx
, sys_statx
), // 383
1022 GENX_(__NR_rseq
, sys_ni_syscall
), // 387
1024 LINXY(__NR_io_uring_setup
, sys_io_uring_setup
), // 425
1025 LINXY(__NR_io_uring_enter
, sys_io_uring_enter
), // 426
1026 LINXY(__NR_io_uring_register
, sys_io_uring_register
), // 427
1028 GENX_(__NR_clone3
, sys_ni_syscall
), // 435
1029 LINXY(__NR_close_range
, sys_close_range
), // 436
1031 LINX_(__NR_faccessat2
, sys_faccessat2
), // 439
1034 SyscallTableEntry
* ML_(get_linux_syscall_entry
) ( UInt sysno
)
1036 const UInt syscall_table_size
1037 = sizeof(syscall_table
) / sizeof(syscall_table
[0]);
1039 /* Is it in the contiguous initial section of the table? */
1040 if (sysno
< syscall_table_size
) {
1041 SyscallTableEntry
* sys
= &syscall_table
[sysno
];
1042 if (sys
->before
== NULL
)
1043 return NULL
; /* no entry */
1048 /* Can't find a wrapper */
1052 #endif // defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
1054 /*--------------------------------------------------------------------*/
1056 /*--------------------------------------------------------------------*/