drd/test: Fix most gcc 8 compiler warnings
[valgrind.git] / coregrind / m_syswrap / syswrap-mips64-linux.c
blob026a470f10090cd2a60fb0a062d544088e2ec968
2 /*--------------------------------------------------------------------*/
3 /*--- Platform-specific syscalls stuff. syswrap-mips64-linux.c ----*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2010-2017 RT-RK
11 mips-valgrind@rt-rk.com
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, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
28 The GNU General Public License is contained in the file COPYING.
31 #if defined(VGP_mips64_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_options.h"
44 #include "pub_core_scheduler.h"
45 #include "pub_core_sigframe.h" /* For VG_(sigframe_destroy)() */
46 #include "pub_core_signals.h"
47 #include "pub_core_syscall.h"
48 #include "pub_core_syswrap.h"
49 #include "pub_core_tooliface.h"
50 #include "pub_core_transtab.h" /* VG_(discard_translations) */
51 #include "priv_types_n_macros.h"
52 #include "priv_syswrap-generic.h" /* for decls of generic wrappers */
53 #include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers */
54 #include "priv_syswrap-main.h"
56 #include "pub_core_debuginfo.h" /* VG_(di_notify_*) */
57 #include "pub_core_xarray.h"
58 #include "pub_core_clientstate.h" /* VG_(brk_base), VG_(brk_limit) */
59 #include "pub_core_errormgr.h"
60 #include "pub_core_gdbserver.h" /* VG_(gdbserver) */
61 #include "pub_core_libcfile.h"
62 #include "pub_core_machine.h" /* VG_(get_SP) */
63 #include "pub_core_mallocfree.h"
64 #include "pub_core_stacktrace.h" /* For VG_(get_and_pp_StackTrace)() */
65 #include "pub_core_ume.h"
67 #include "config.h"
69 #include <errno.h>
71 /* ---------------------------------------------------------------------
72 clone() handling
73 ------------------------------------------------------------------ */
75 /* Call f(arg1), but first switch stacks, using 'stack' as the new stack, and
76 use 'retaddr' as f's return-to address. Also, clear all the integer registers
77 before entering f. */
78 __attribute__ ((noreturn))
79 void ML_(call_on_new_stack_0_1) ( Addr stack, /* $4 - $a0 */
80 Addr retaddr, /* $5 - $a1 */
81 void (*f_desc) (Word), /* $6 - $a2 */
82 Word arg1 ); /* $7 - $a3 */
83 asm (
84 ".text\n"
85 ".globl vgModuleLocal_call_on_new_stack_0_1\n"
86 "vgModuleLocal_call_on_new_stack_0_1:\n"
87 " move $29, $4\n" /* set stack */
88 " move $4, $7\n" /* arg1 to $4 */
89 " move $25, $6\n"
90 " move $31, $5\n" /* retaddr to $ra */
91 " li $2, 0\n\t" /* zero all GP regs */
92 " li $3, 0\n\t"
93 " li $5, 0\n\t"
94 " li $6, 0\n\t"
95 " li $7, 0\n\t"
96 " li $12, 0\n\t"
97 " li $13, 0\n\t"
98 " li $14, 0\n\t"
99 " li $15, 0\n\t"
100 " li $16, 0\n\t"
101 " li $17, 0\n\t"
102 " li $18, 0\n\t"
103 " li $19, 0\n\t"
104 " li $20, 0\n\t"
105 " li $21, 0\n\t"
106 " li $22, 0\n\t"
107 " li $23, 0\n\t"
108 " li $24, 0\n\t"
109 " jr $25\n" /* jump to f */
110 " break 0x7\n" /* should never get here */
111 ".previous\n"
114 /* Perform a clone system call. clone is strange because it has fork()-like
115 return-twice semantics, so it needs special handling here.
117 Upon entry, we have:
119 word (fn)(void*) in a0 = 4
120 void* child_stack in a1 = 5
121 word flags in a2 = 6
122 void* arg in a3 = 7
123 pid_t* parent_tid in a4 = 8
124 void* tls in a5 = 9
125 pid_t* child_tid in a6 = 10
127 System call requires:
129 int $__NR_clone in v0
130 int flags in a0 = 4
131 void* child_stack in a1 = 5
132 pid_t* parent_tid in a2 = 6
133 void* tls_ptr in a3 = 7
134 pid_t* child_tid in a4 = 8 */
136 #define __NR_CLONE __NR_clone
137 #define __NR_EXIT __NR_exit
139 // See priv_syswrap-linux.h for arg profile.
140 asm(
141 ".text\n"
142 ".set noreorder\n"
143 ".set nomacro\n"
144 ".globl do_syscall_clone_mips64_linux\n"
145 "do_syscall_clone_mips64_linux:\n"
146 " daddiu $29, $29, -32\n"
147 " sd $31, 0($29)\n"
148 " sd $30, 8($29)\n"
149 " sd $28, 16($29)\n"
151 " daddiu $5, $5, -32\n"
152 " sd $4, 0($5)\n" /* fn */
153 " sd $7, 8($5)\n" /* arg */
154 " sd $6, 16($5)\n" /* flags */
156 /* 1. arg for syscalls */
157 " move $4, $6\n" /* flags */
158 " move $6, $8\n" /* parent */
159 " move $7, $a5\n" /* tls */
160 " move $8, $a6\n" /* child */
162 /* 2. do a syscall to clone */
163 " li $2, 5055\n" /* syscall num for clone */
164 " syscall\n"
166 /* 3. See if we are a child, call fn and after that exit */
167 " bnez $7, p_or_error\n"
168 " nop\n"
170 " bnez $2, p_or_error\n"
171 " nop\n"
173 " ld $25,0($29)\n"
174 " jalr $25\n"
175 " ld $4,8($29)\n"
177 " move $4, $2\n\t" /* retval from fn is in $v0 */
178 " li $2, 5058\n\t" /* NR_exit */
179 " syscall\n\t"
180 " nop\n\t"
181 /* 4. If we are parent or error, just return to caller */
182 " p_or_error:\n"
183 " ld $31, 0($29)\n"
184 " ld $30, 8($29)\n"
185 " ld $28, 16($29)\n"
186 " jr $31\n"
187 " daddiu $29,$29, 32\n"
188 ".previous\n"
191 #undef __NR_CLONE
192 #undef __NR_EXIT
194 /* forward declarations */
195 static SysRes sys_set_tls ( ThreadId tid, Addr tlsptr);
197 /* ---------------------------------------------------------------------
198 More thread stuff
199 ------------------------------------------------------------------ */
200 void VG_(cleanup_thread) ( ThreadArchState * arch ) { };
202 SysRes sys_set_tls ( ThreadId tid, Addr tlsptr )
204 VG_(threads)[tid].arch.vex.guest_ULR = tlsptr;
205 return VG_(mk_SysRes_Success)( 0 );
208 /* ---------------------------------------------------------------------
209 PRE/POST wrappers for mips/Linux-specific syscalls
210 ------------------------------------------------------------------ */
212 #define PRE(name) DEFN_PRE_TEMPLATE(mips_linux, name)
213 #define POST(name) DEFN_POST_TEMPLATE(mips_linux, name)
215 /* Add prototypes for the wrappers declared here, so that gcc doesn't harass us
216 for not having prototypes. Really this is a kludge -- the right thing to do
217 is to make these wrappers 'static' since they aren't visible outside this
218 file, but that requires even more macro magic. */
220 DECL_TEMPLATE (mips_linux, sys_set_thread_area);
221 DECL_TEMPLATE (mips_linux, sys_tee);
222 DECL_TEMPLATE (mips_linux, sys_splice);
223 DECL_TEMPLATE (mips_linux, sys_vmsplice);
224 DECL_TEMPLATE (mips_linux, sys_ustat);
225 DECL_TEMPLATE (mips_linux, sys_sysfs);
226 DECL_TEMPLATE (mips_linux, sys_swapon);
227 DECL_TEMPLATE (mips_linux, sys_swapoff);
228 DECL_TEMPLATE (mips_linux, sys_setdomainname);
229 DECL_TEMPLATE (mips_linux, sys_sethostname);
230 DECL_TEMPLATE (mips_linux, sys_reboot);
231 DECL_TEMPLATE (mips_linux, sys_cacheflush);
232 DECL_TEMPLATE (mips_linux, sys_sched_rr_get_interval);
233 DECL_TEMPLATE (mips_linux, sys_unshare);
234 DECL_TEMPLATE (mips_linux, sys_prctl);
235 DECL_TEMPLATE (mips_linux, sys_ptrace);
236 DECL_TEMPLATE (mips_linux, sys_mmap);
237 DECL_TEMPLATE (mips_linux, sys_rt_sigreturn);
238 DECL_TEMPLATE (mips_linux, sys_pipe);
239 DECL_TEMPLATE (mips_linux, sys_fadvise64);
241 PRE(sys_tee)
243 PRINT("sys_tee ( %ld, %ld, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",
244 SARG1, SARG2, ARG3, ARG4);
245 PRE_REG_READ4(long, "sys_tee", int, fdin, int, fdout, vki_size_t, len,
246 int, flags);
249 PRE(sys_splice)
251 PRINT("sys_splice ( %ld, %#" FMT_REGWORD "x, %ld, %#" FMT_REGWORD
252 "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",
253 SARG1, ARG2, SARG3, ARG4, ARG5, ARG6);
255 PRE_REG_READ6(long, "sys_splice", int, fdin, vki_loff_t, sizein, int,
256 fdout, vki_loff_t, sizeout, vki_size_t, len, int, flags);
259 PRE(sys_vmsplice)
261 PRINT("sys_vmsplice ( %ld, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %ld )",
262 SARG1, ARG2, ARG3, SARG4);
263 PRE_REG_READ4(long, "sys_vmsplice", int, fdin, struct vki_iovec *, v,
264 vki_size_t, len, int, flags);
267 PRE(sys_unshare)
269 PRINT("sys_unshare ( %" FMT_REGWORD "u )", ARG1);
270 PRE_REG_READ1(long, "sys_unshare", unsigned long, flags);
273 PRE(sys_sched_rr_get_interval)
275 PRINT("sys_sched_rr_get_interval ( %ld, %#" FMT_REGWORD "x)", SARG1, ARG2);
276 PRE_REG_READ2(long, "sched_rr_get_interval", vki_pid_t, pid,
277 struct timespec *, timer);
278 *flags |= SfMayBlock;
281 PRE(sys_ustat)
283 PRINT("sys_ustat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG2);
284 PRE_REG_READ2(long, "ustat", int, flags, const void *, path);
287 PRE(sys_swapon)
289 PRINT("sys_swapon ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2);
290 PRE_REG_READ2(long, "swapon", const void *, path, int, flags);
293 PRE(sys_swapoff)
295 PRINT("sys_swapoff ( %#" FMT_REGWORD "x )", ARG1);
296 PRE_REG_READ1(long, "swapoff", const void *, path);
299 PRE(sys_sysfs)
301 PRINT("sys_sysfs ( %ld, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",
302 SARG1, ARG2, ARG3);
303 PRE_REG_READ3(long, "sysfs", int, flags, int, desc, const void *, path);
306 /* Very much MIPS specific */
307 PRE(sys_cacheflush)
309 PRINT("cacheflush (%" FMT_REGWORD "x, %" FMT_REGWORD "x, %" FMT_REGWORD
310 "x)", ARG1, ARG2, ARG3);
311 PRE_REG_READ3(long, "cacheflush", unsigned long, addr,
312 unsigned long, nbytes, unsigned int, cache);
313 VG_ (discard_translations) ((Addr)ARG1, (ULong) ARG2,
314 "PRE(sys_cacheflush)");
315 SET_STATUS_Success(0);
318 PRE(sys_reboot)
320 PRINT("sys_reboot ( %ld, %" FMT_REGWORD "d, %" FMT_REGWORD "u, %#"
321 FMT_REGWORD "x )", SARG1, ARG2, ARG3, ARG4);
322 // An approximation. ARG4 is only read conditionally by the kernel
323 PRE_REG_READ4(int, "reboot",
324 int, magic1, int, magic2, unsigned int, cmd,
325 void *, arg);
327 *flags |= SfMayBlock;
330 PRE(sys_setdomainname)
332 PRINT ("sys_setdomainname ( %#" FMT_REGWORD "x, %ld )", ARG1, SARG2);
333 PRE_REG_READ2 (long, "setdomainname", const void *, name, int, len);
336 PRE(sys_sethostname)
338 PRINT ("sys_sethostname ( %#" FMT_REGWORD "x, %ld )", ARG1, SARG2);
339 PRE_REG_READ2 (long, "sethostname", const void *, name, int, len);
342 PRE(sys_ptrace)
344 PRINT("sys_ptrace ( %ld, %ld, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",
345 SARG1, SARG2, ARG3, ARG4);
346 PRE_REG_READ4(int, "ptrace",
347 long, request, long, pid, unsigned long, addr,
348 unsigned long, data);
349 switch (ARG1) {
350 case VKI_PTRACE_PEEKTEXT:
351 case VKI_PTRACE_PEEKDATA:
352 case VKI_PTRACE_PEEKUSR:
353 PRE_MEM_WRITE("ptrace(peek)", ARG4, sizeof(long));
354 break;
355 case VKI_PTRACE_GETEVENTMSG:
356 PRE_MEM_WRITE("ptrace(geteventmsg)", ARG4, sizeof(unsigned long));
357 break;
358 case VKI_PTRACE_GETSIGINFO:
359 PRE_MEM_WRITE("ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t));
360 break;
361 case VKI_PTRACE_SETSIGINFO:
362 PRE_MEM_READ("ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
363 break;
364 case VKI_PTRACE_GETREGSET:
365 ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
366 break;
367 default:
368 break;
372 POST(sys_ptrace)
374 switch (ARG1) {
375 case VKI_PTRACE_TRACEME:
376 ML_(linux_POST_traceme)(tid);
377 break;
378 case VKI_PTRACE_PEEKTEXT:
379 case VKI_PTRACE_PEEKDATA:
380 case VKI_PTRACE_PEEKUSR:
381 POST_MEM_WRITE (ARG4, sizeof(long));
382 break;
383 case VKI_PTRACE_GETEVENTMSG:
384 POST_MEM_WRITE (ARG4, sizeof(unsigned long));
385 break;
386 case VKI_PTRACE_GETSIGINFO:
387 POST_MEM_WRITE (ARG4, sizeof(vki_siginfo_t));
388 break;
389 case VKI_PTRACE_GETREGSET:
390 ML_(linux_POST_getregset)(tid, ARG3, ARG4);
391 break;
392 default:
393 break;
397 PRE(sys_mmap)
399 SysRes r;
400 PRINT("sys_mmap ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %ld, %ld, %ld, %"
401 FMT_REGWORD "u )",
402 ARG1, ARG2, SARG3, SARG4, SARG5, ARG6);
403 PRE_REG_READ6(long, "mmap", unsigned long, start, vki_size_t, length,
404 int, prot, int, flags, int, fd, unsigned long, offset);
405 r = ML_(generic_PRE_sys_mmap)(tid, ARG1, ARG2, ARG3, ARG4, ARG5,
406 (Off64T) ARG6);
407 SET_STATUS_from_SysRes(r);
409 PRE(sys_rt_sigreturn)
411 /* See comments on PRE(sys_rt_sigreturn) in syswrap-s390x-linux.c for
412 an explanation of what follows. */
413 ThreadState* tst;
414 PRINT("sys_rt_sigreturn ( )");
416 vg_assert(VG_(is_valid_tid)(tid));
417 vg_assert(tid >= 1 && tid < VG_N_THREADS);
418 vg_assert(VG_(is_running_thread)(tid));
420 tst = VG_(get_ThreadState)(tid);
422 /* This is only so that the IA is (might be) useful to report if
423 something goes wrong in the sigreturn */
424 ML_(fixup_guest_state_to_restart_syscall)(&tst->arch);
426 /* Restore register state from frame and remove it */
427 VG_(sigframe_destroy)(tid, True);
429 /* Tell the driver not to update the guest state with the "result",
430 and set a bogus result to keep it happy. */
431 *flags |= SfNoWriteResult;
432 SET_STATUS_Success(0);
434 /* Check to see if any signals arose as a result of this. */
435 *flags |= SfPollAfter;
438 PRE(sys_set_thread_area)
440 PRINT("set_thread_area (%" FMT_REGWORD "x)", ARG1);
441 PRE_REG_READ1(long, "set_thread_area", unsigned long, addr);
442 SET_STATUS_from_SysRes(sys_set_tls(tid, ARG1));
445 PRE(sys_pipe)
447 PRINT("sys_pipe ( %#" FMT_REGWORD "x )", ARG1);
448 PRE_REG_READ1(int, "pipe", int *, filedes);
449 PRE_MEM_WRITE( "pipe(filedes)", ARG1, 2*sizeof(int) );
452 POST(sys_pipe)
454 Int p0, p1;
455 vg_assert(SUCCESS);
456 p0 = RES;
457 p1 = sr_ResEx(status->sres);
459 if (!ML_(fd_allowed)(p0, "pipe", tid, True) ||
460 !ML_(fd_allowed)(p1, "pipe", tid, True)) {
461 VG_(close)(p0);
462 VG_(close)(p1);
463 SET_STATUS_Failure( VKI_EMFILE );
464 } else {
465 if (VG_(clo_track_fds)) {
466 ML_(record_fd_open_nameless)(tid, p0);
467 ML_(record_fd_open_nameless)(tid, p1);
472 PRE(sys_prctl)
474 switch (ARG1) {
475 case VKI_PR_SET_FP_MODE:
477 VexArchInfo vai;
478 VG_(machine_get_VexArchInfo)(NULL, &vai);
479 /* Reject unsupported modes */
480 if ((ARG2 & ~VKI_PR_FP_MODE_FR) ||
481 ((ARG2 & VKI_PR_FP_MODE_FR) &&
482 !VEX_MIPS_HOST_FP_MODE(vai.hwcaps))) {
483 SET_STATUS_Failure(VKI_EOPNOTSUPP);
484 } else {
485 if (!(VG_(threads)[tid].arch.vex.guest_CP0_status &
486 MIPS_CP0_STATUS_FR) != !(ARG2 & VKI_PR_FP_MODE_FR)) {
487 ThreadId t;
488 for (t = 1; t < VG_N_THREADS; t++) {
489 if (VG_(threads)[t].status != VgTs_Empty) {
490 if (ARG2 & VKI_PR_FP_MODE_FR) {
491 VG_(threads)[t].arch.vex.guest_CP0_status |=
492 MIPS_CP0_STATUS_FR;
493 } else {
494 VG_(threads)[t].arch.vex.guest_CP0_status &=
495 ~MIPS_CP0_STATUS_FR;
499 /* Discard all translations */
500 VG_(discard_translations)(0, (ULong)(-1ll), "prctl(PR_SET_FP_MODE)");
502 SET_STATUS_Success(0);
504 break;
506 case VKI_PR_GET_FP_MODE:
507 if (VG_(threads)[tid].arch.vex.guest_CP0_status & MIPS_CP0_STATUS_FR)
508 SET_STATUS_Success(VKI_PR_FP_MODE_FR);
509 else
510 SET_STATUS_Success(0);
511 break;
512 default:
513 WRAPPER_PRE_NAME(linux, sys_prctl)(tid, layout, arrghs, status, flags);
514 break;
518 POST(sys_prctl)
520 WRAPPER_POST_NAME(linux, sys_prctl)(tid, arrghs, status);
523 PRE(sys_fadvise64)
525 PRINT("sys_fadvise64 ( %ld, %ld, %" FMT_REGWORD "u, %ld )", SARG1, SARG2,
526 ARG3, SARG4);
527 PRE_REG_READ4(long, "fadvise64",
528 int, fd, vki_loff_t, offset, vki_loff_t, len, int, advice);
531 #undef PRE
532 #undef POST
534 /* ---------------------------------------------------------------------
535 The mips64/Linux syscall table
536 ------------------------------------------------------------------ */
538 /* Add an mips64-linux specific wrapper to a syscall table. */
539 #define PLAX_(sysno, name) WRAPPER_ENTRY_X_(mips_linux, sysno, name)
540 #define PLAXY(sysno, name) WRAPPER_ENTRY_XY(mips_linux, sysno, name)
542 static SyscallTableEntry syscall_main_table[] = {
543 GENXY (__NR_read, sys_read), /* 5000 */
544 GENX_ (__NR_write, sys_write),
545 GENXY (__NR_open, sys_open),
546 GENXY (__NR_close, sys_close),
547 GENXY (__NR_stat, sys_newstat),
548 GENXY (__NR_fstat, sys_newfstat),
549 GENXY (__NR_lstat, sys_newlstat),
550 GENXY (__NR_poll, sys_poll),
551 LINX_ (__NR_lseek, sys_lseek),
552 PLAX_ (__NR_mmap, sys_mmap),
553 GENXY (__NR_mprotect, sys_mprotect),
554 GENXY (__NR_munmap, sys_munmap),
555 GENX_ (__NR_brk, sys_brk),
556 LINXY (__NR_rt_sigaction, sys_rt_sigaction),
557 LINXY (__NR_rt_sigprocmask, sys_rt_sigprocmask),
558 LINXY (__NR_ioctl, sys_ioctl),
559 LINXY (__NR_eventfd2, sys_eventfd2),
560 LINXY (__NR_signalfd4, sys_signalfd4),
561 GENXY (__NR_pread64, sys_pread64),
562 GENX_ (__NR_pwrite64, sys_pwrite64),
563 GENXY (__NR_readv, sys_readv),
564 GENX_ (__NR_writev, sys_writev),
565 GENX_ (__NR_access, sys_access),
566 PLAXY (__NR_pipe, sys_pipe),
567 LINXY (__NR_pipe2, sys_pipe2),
568 GENX_ (__NR__newselect,sys_select),
569 LINX_ (__NR_sched_yield, sys_sched_yield),
570 GENX_ (__NR_mremap, sys_mremap),
571 GENX_ (__NR_msync, sys_msync),
572 GENXY (__NR_mincore, sys_mincore),
573 GENX_ (__NR_madvise, sys_madvise),
574 LINX_ (__NR_shmget, sys_shmget),
575 LINXY (__NR_shmat, sys_shmat),
576 LINXY (__NR_shmctl, sys_shmctl),
577 GENXY (__NR_dup, sys_dup),
578 GENXY (__NR_dup2, sys_dup2),
579 LINXY (__NR_dup3, sys_dup3),
580 GENX_ (__NR_pause, sys_pause),
581 GENXY (__NR_nanosleep, sys_nanosleep),
582 GENXY (__NR_getitimer, sys_getitimer),
583 GENXY (__NR_setitimer, sys_setitimer),
584 GENX_ (__NR_alarm, sys_alarm),
585 GENX_ (__NR_getpid, sys_getpid),
586 /* LINX_(__NR_fallocate,sys_fallocate), */
587 LINXY (__NR_sendfile, sys_sendfile),
588 LINXY (__NR_socket, sys_socket),
589 LINX_ (__NR_connect, sys_connect),
590 LINXY (__NR_accept, sys_accept),
591 LINXY (__NR_accept4, sys_accept4),
592 LINX_ (__NR_sendto, sys_sendto),
593 LINXY (__NR_recvfrom, sys_recvfrom),
594 LINX_ (__NR_sendmsg, sys_sendmsg),
595 LINXY (__NR_recvmsg, sys_recvmsg),
596 LINX_ (__NR_shutdown, sys_shutdown),
597 LINX_ (__NR_bind, sys_bind),
598 LINX_ (__NR_listen, sys_listen),
599 LINXY (__NR_getsockname, sys_getsockname),
600 LINXY (__NR_getpeername, sys_getpeername),
601 LINXY (__NR_socketpair, sys_socketpair),
602 LINX_ (__NR_setsockopt, sys_setsockopt),
603 LINXY (__NR_getsockopt, sys_getsockopt),
604 LINX_ (__NR_clone, sys_clone),
605 GENX_ (__NR_fork, sys_fork),
606 GENX_ (__NR_execve, sys_execve),
607 GENX_ (__NR_exit, sys_exit),
608 GENXY (__NR_wait4, sys_wait4),
609 GENX_ (__NR_kill, sys_kill),
610 GENXY (__NR_uname, sys_newuname),
611 LINX_ (__NR_semget, sys_semget),
612 LINX_ (__NR_semop, sys_semop),
613 LINXY (__NR_semctl, sys_semctl),
614 LINXY (__NR_shmdt, sys_shmdt),
615 LINX_ (__NR_msgget, sys_msgget),
616 LINX_ (__NR_msgsnd, sys_msgsnd),
617 LINXY (__NR_msgrcv, sys_msgrcv),
618 LINXY (__NR_msgctl, sys_msgctl),
619 LINXY (__NR_fcntl, sys_fcntl),
620 GENX_ (__NR_flock, sys_flock),
621 GENX_ (__NR_fsync, sys_fsync),
622 GENX_ (__NR_fdatasync, sys_fdatasync),
623 GENX_ (__NR_truncate, sys_truncate),
624 GENX_ (__NR_ftruncate, sys_ftruncate),
625 GENXY (__NR_getdents, sys_getdents),
626 GENXY (__NR_getcwd, sys_getcwd),
627 GENX_ (__NR_chdir, sys_chdir),
628 GENX_ (__NR_fchdir, sys_fchdir),
629 GENX_ (__NR_rename, sys_rename),
630 GENX_ (__NR_mkdir, sys_mkdir),
631 GENX_ (__NR_rmdir, sys_rmdir),
632 GENXY (__NR_creat, sys_creat),
633 GENX_ (__NR_link, sys_link),
634 GENX_ (__NR_unlink, sys_unlink),
635 GENX_ (__NR_symlink, sys_symlink),
636 GENX_ (__NR_readlink, sys_readlink),
637 GENX_ (__NR_chmod, sys_chmod),
638 GENX_ (__NR_fchmod, sys_fchmod),
639 GENX_ (__NR_chown, sys_chown),
640 GENX_ (__NR_fchown, sys_fchown),
641 GENX_ (__NR_lchown, sys_lchown),
642 GENX_ (__NR_umask, sys_umask),
643 GENXY (__NR_gettimeofday, sys_gettimeofday),
644 GENXY (__NR_getrlimit, sys_getrlimit),
645 GENXY (__NR_getrusage, sys_getrusage),
646 LINXY (__NR_sysinfo, sys_sysinfo),
647 GENXY (__NR_times, sys_times),
648 PLAXY (__NR_ptrace, sys_ptrace),
649 GENX_ (__NR_getuid, sys_getuid),
650 LINXY (__NR_syslog, sys_syslog),
651 GENX_ (__NR_getgid, sys_getgid),
652 GENX_ (__NR_setuid, sys_setuid),
653 GENX_ (__NR_setgid, sys_setgid),
654 GENX_ (__NR_geteuid, sys_geteuid),
655 GENX_ (__NR_getegid, sys_getegid),
656 GENX_ (__NR_setpgid, sys_setpgid),
657 GENX_ (__NR_getppid, sys_getppid),
658 GENX_ (__NR_getpgrp, sys_getpgrp),
659 GENX_ (__NR_setsid, sys_setsid),
660 GENX_ (__NR_setreuid, sys_setreuid),
661 GENX_ (__NR_setregid, sys_setregid),
662 GENXY (__NR_getgroups, sys_getgroups),
663 GENX_ (__NR_setgroups, sys_setgroups),
664 LINX_ (__NR_setresuid, sys_setresuid),
665 LINXY (__NR_getresuid, sys_getresuid),
666 LINX_ (__NR_setresgid, sys_setresgid),
667 LINXY (__NR_getresgid, sys_getresgid),
668 GENX_ (__NR_getpgid, sys_getpgid),
669 LINX_ (__NR_setfsuid, sys_setfsuid),
670 LINX_ (__NR_setfsgid, sys_setfsgid),
671 GENX_ (__NR_getsid, sys_getsid),
672 LINXY (__NR_capget, sys_capget),
673 LINX_ (__NR_capset, sys_capset),
674 LINXY (__NR_rt_sigpending, sys_rt_sigpending),
675 LINXY (__NR_rt_sigtimedwait, sys_rt_sigtimedwait),
676 LINXY (__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo),
677 LINX_ (__NR_rt_sigsuspend, sys_rt_sigsuspend),
678 GENXY (__NR_sigaltstack, sys_sigaltstack),
679 LINX_ (__NR_utime, sys_utime),
680 GENX_ (__NR_mknod, sys_mknod),
681 LINX_ (__NR_personality, sys_personality),
682 PLAX_ (__NR_ustat, sys_ustat),
683 GENXY (__NR_statfs, sys_statfs),
684 GENXY (__NR_fstatfs, sys_fstatfs),
685 PLAX_ (__NR_sysfs, sys_sysfs),
686 GENX_ (__NR_getpriority, sys_getpriority),
687 GENX_ (__NR_setpriority, sys_setpriority),
688 LINXY (__NR_sched_setparam, sys_sched_setparam),
689 LINXY (__NR_sched_getparam, sys_sched_getparam),
690 LINX_ (__NR_sched_setscheduler, sys_sched_setscheduler),
691 LINX_ (__NR_sched_getscheduler, sys_sched_getscheduler),
692 LINX_ (__NR_sched_get_priority_max, sys_sched_get_priority_max),
693 LINX_ (__NR_sched_get_priority_min, sys_sched_get_priority_min),
694 PLAX_ (__NR_sched_rr_get_interval, sys_sched_rr_get_interval),
695 GENX_ (__NR_mlock, sys_mlock),
696 GENX_ (__NR_munlock, sys_munlock),
697 GENX_ (__NR_mlockall, sys_mlockall),
698 LINX_ (__NR_munlockall, sys_munlockall),
699 LINX_ (__NR_vhangup, sys_vhangup),
700 LINX_ (__NR_pivot_root,sys_pivot_root),
701 LINXY (__NR__sysctl, sys_sysctl),
702 PLAXY (__NR_prctl, sys_prctl),
703 LINXY (__NR_adjtimex, sys_adjtimex),
704 GENX_ (__NR_setrlimit, sys_setrlimit),
705 GENX_ (__NR_chroot, sys_chroot),
706 GENX_ (__NR_sync, sys_sync),
707 GENX_ (__NR_acct, sys_acct),
708 GENX_ (__NR_settimeofday, sys_settimeofday),
709 LINX_ (__NR_mount, sys_mount),
710 LINX_ (__NR_umount2, sys_umount),
711 PLAX_ (__NR_swapon, sys_swapon),
712 PLAX_ (__NR_swapoff, sys_swapoff),
713 PLAX_ (__NR_reboot, sys_reboot),
714 PLAX_ (__NR_sethostname, sys_sethostname),
715 PLAX_ (__NR_setdomainname, sys_setdomainname),
716 GENX_ (__NR_create_module, sys_ni_syscall),
717 LINX_ (__NR_init_module, sys_init_module),
718 LINX_ (__NR_delete_module, sys_delete_module),
719 GENX_ (__NR_get_kernel_syms, sys_ni_syscall),
720 GENX_ (__NR_query_module, sys_ni_syscall),
721 LINX_ (__NR_quotactl, sys_quotactl),
722 /* GENX_(__NR_nfsservctl,sys_nfsservctl), */
723 GENXY (__NR_getpmsg, sys_getpmsg),
724 GENX_ (__NR_putpmsg, sys_putpmsg),
725 GENX_ (__NR_afs_syscall, sys_ni_syscall),
726 /* GENX_(__NR_reserved177,sys_reserved177), */
727 LINX_ (__NR_gettid, sys_gettid),
728 /* GENX_(__NR_readahead,sys_readahead), */
729 LINX_ (__NR_setxattr, sys_setxattr),
730 LINX_ (__NR_lsetxattr, sys_lsetxattr),
731 LINX_ (__NR_fsetxattr, sys_fsetxattr),
732 LINXY (__NR_getxattr, sys_getxattr),
733 LINXY (__NR_lgetxattr, sys_lgetxattr),
734 LINXY (__NR_fgetxattr, sys_fgetxattr),
735 LINXY (__NR_listxattr, sys_listxattr),
736 LINXY (__NR_llistxattr, sys_llistxattr),
737 LINXY (__NR_flistxattr, sys_flistxattr),
738 LINX_ (__NR_removexattr, sys_removexattr),
739 LINX_ (__NR_lremovexattr, sys_lremovexattr),
740 LINX_ (__NR_fremovexattr, sys_fremovexattr),
741 LINXY (__NR_tkill, sys_tkill),
742 /* GENX_(__NR_reserved193,sys_reserved193), */
743 LINXY (__NR_futex, sys_futex),
744 LINX_ (__NR_sched_setaffinity, sys_sched_setaffinity),
745 LINXY (__NR_sched_getaffinity, sys_sched_getaffinity),
746 PLAX_ (__NR_cacheflush, sys_cacheflush),
747 LINXY (__NR_io_setup, sys_io_setup),
748 LINX_ (__NR_io_destroy, sys_io_destroy),
749 LINXY (__NR_io_getevents, sys_io_getevents),
750 LINX_ (__NR_io_submit, sys_io_submit),
751 LINXY (__NR_io_cancel, sys_io_cancel),
752 LINX_ (__NR_exit_group, sys_exit_group),
753 /* LINXY (__NR_lookup_dcookie, sys_lookup_dcookie), */
754 LINXY (__NR_epoll_create, sys_epoll_create),
755 LINXY (__NR_epoll_create1, sys_epoll_create1),
756 LINX_ (__NR_epoll_ctl, sys_epoll_ctl),
757 LINXY (__NR_epoll_wait, sys_epoll_wait),
758 PLAX_(__NR_rt_sigreturn,sys_rt_sigreturn),
759 #if defined(VGABI_N32)
760 LINXY(__NR_fcntl64, sys_fcntl64),
761 GENXY(__NR_statfs64, sys_statfs64),
762 #endif
763 LINX_ (__NR_set_tid_address, sys_set_tid_address),
764 LINX_ (__NR_semtimedop, sys_semtimedop),
765 PLAX_ (__NR_fadvise64, sys_fadvise64),
766 LINXY (__NR_timer_create, sys_timer_create),
767 LINXY (__NR_timer_settime, sys_timer_settime),
768 LINXY (__NR_timer_gettime, sys_timer_gettime),
769 LINX_ (__NR_timer_getoverrun, sys_timer_getoverrun),
770 LINX_ (__NR_timer_delete, sys_timer_delete),
771 LINX_ (__NR_clock_settime, sys_clock_settime),
772 LINXY (__NR_clock_gettime, sys_clock_gettime),
773 LINXY (__NR_clock_getres, sys_clock_getres),
774 LINXY (__NR_clock_nanosleep, sys_clock_nanosleep),
775 LINX_ (__NR_tgkill, sys_tgkill),
776 GENX_ (__NR_utimes, sys_utimes),
777 LINX_ (__NR_mbind, sys_mbind),
778 LINXY (__NR_get_mempolicy, sys_get_mempolicy),
779 LINX_ (__NR_set_mempolicy, sys_set_mempolicy),
780 LINXY (__NR_mq_open, sys_mq_open),
781 LINX_ (__NR_mq_unlink, sys_mq_unlink),
782 LINX_ (__NR_mq_timedsend, sys_mq_timedsend),
783 LINXY (__NR_mq_timedreceive, sys_mq_timedreceive),
784 LINX_ (__NR_mq_notify, sys_mq_notify),
785 LINXY (__NR_mq_getsetattr, sys_mq_getsetattr),
786 GENX_ (__NR_vserver, sys_ni_syscall),
787 LINXY (__NR_waitid, sys_waitid),
788 LINX_ (__NR_add_key, sys_add_key),
789 LINX_ (__NR_request_key, sys_request_key),
790 LINXY (__NR_keyctl, sys_keyctl),
791 PLAX_ (__NR_set_thread_area, sys_set_thread_area),
792 LINX_ (__NR_inotify_init, sys_inotify_init),
793 LINX_ (__NR_inotify_add_watch, sys_inotify_add_watch),
794 LINX_ (__NR_inotify_rm_watch, sys_inotify_rm_watch),
795 LINXY (__NR_openat, sys_openat),
796 LINX_ (__NR_mkdirat, sys_mkdirat),
797 LINX_ (__NR_mknodat, sys_mknodat),
798 LINX_ (__NR_fchownat, sys_fchownat),
799 LINX_ (__NR_futimesat, sys_futimesat),
800 LINX_ (__NR_unlinkat, sys_unlinkat),
801 LINX_ (__NR_renameat, sys_renameat),
802 LINX_ (__NR_linkat, sys_linkat),
803 LINX_ (__NR_symlinkat, sys_symlinkat),
804 LINX_ (__NR_readlinkat, sys_readlinkat),
805 LINX_ (__NR_fchmodat, sys_fchmodat),
806 LINX_ (__NR_faccessat, sys_faccessat),
807 LINXY (__NR_pselect6, sys_pselect6),
808 LINXY (__NR_ppoll, sys_ppoll),
809 PLAX_ (__NR_unshare, sys_unshare),
810 PLAX_ (__NR_splice, sys_splice),
811 LINX_ (__NR_sync_file_range, sys_sync_file_range),
812 PLAX_ (__NR_tee, sys_tee),
813 PLAX_ (__NR_vmsplice, sys_vmsplice),
814 LINX_ (__NR_set_robust_list, sys_set_robust_list),
815 LINXY (__NR_get_robust_list, sys_get_robust_list),
816 LINXY (__NR_epoll_pwait, sys_epoll_pwait),
817 LINX_ (__NR_ioprio_set, sys_ioprio_set),
818 LINX_ (__NR_ioprio_get, sys_ioprio_get),
819 LINX_ (__NR_utimensat, sys_utimensat),
820 LINXY (__NR_signalfd, sys_signalfd),
821 LINXY (__NR_eventfd, sys_eventfd),
822 LINX_ (__NR_fallocate, sys_fallocate),
823 LINXY (__NR_timerfd_create, sys_timerfd_create),
824 LINXY (__NR_timerfd_gettime, sys_timerfd_gettime),
825 LINXY (__NR_timerfd_settime, sys_timerfd_settime),
826 LINXY (__NR_newfstatat, sys_newfstatat),
827 LINXY (__NR_prlimit64, sys_prlimit64),
828 LINXY (__NR_clock_adjtime, sys_clock_adjtime),
829 LINXY (__NR_process_vm_readv, sys_process_vm_readv),
830 LINX_ (__NR_process_vm_writev, sys_process_vm_writev),
831 LINXY(__NR_getrandom, sys_getrandom),
832 LINXY(__NR_memfd_create, sys_memfd_create),
833 LINX_(__NR_membarrier, sys_membarrier),
834 LINX_(__NR_syncfs, sys_syncfs),
835 LINXY(__NR_statx, sys_statx),
838 SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno )
840 const UInt syscall_main_table_size
841 = sizeof(syscall_main_table) / sizeof(syscall_main_table[0]);
843 if (sysno < syscall_main_table_size) {
844 SyscallTableEntry * sys = &syscall_main_table[sysno];
845 if (sys->before == NULL)
846 return NULL; /* no entry */
847 else
848 return sys;
850 /* Can't find a wrapper */
851 return NULL;
854 #endif /* defined(VGP_mips64_linux) */
856 /*--------------------------------------------------------------------*/
857 /*--- end syswrap-mips64-linux.c ---*/
858 /*--------------------------------------------------------------------*/