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