support pidfd_getfd
[valgrind.git] / coregrind / m_syswrap / syswrap-mips32-linux.c
blob0ef4f0bc1e82bb0469a8d76f7fc7a98f643469c7
2 /*--------------------------------------------------------------------*/
3 /*--- Platform-specific syscalls stuff. syswrap-mips32-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_mips32_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 "priv_syswrap-generic.h"
66 #include "config.h"
68 #include <errno.h>
70 /* ---------------------------------------------------------------------
71 clone() handling
72 ------------------------------------------------------------------ */
73 /* Call f(arg1), but first switch stacks, using 'stack' as the new
74 stack, and use 'retaddr' as f's return-to address. Also, clear all
75 the integer registers before entering f.*/
77 __attribute__ ((noreturn))
78 void ML_ (call_on_new_stack_0_1) (Addr stack, Addr retaddr,
79 void (*f) (Word), Word arg1);
80 // a0 = stack
81 // a1 = retaddr
82 // a2 = f
83 // a3 = arg1
84 asm (
85 ".text\n"
86 ".globl vgModuleLocal_call_on_new_stack_0_1\n"
87 "vgModuleLocal_call_on_new_stack_0_1:\n"
88 " move $29, $4\n\t" // stack to %sp
89 " move $31, $5\n\t" // retaddr to $ra
90 " move $25, $6\n\t" // f to t9/$25
91 " move $4, $7\n\t" // arg1 to $a0
92 " li $2, 0\n\t" // zero all GP regs
93 " li $3, 0\n\t"
94 " li $5, 0\n\t"
95 " li $6, 0\n\t"
96 " li $7, 0\n\t"
97 " li $12, 0\n\t"
98 " li $13, 0\n\t"
99 " li $14, 0\n\t"
100 " li $15, 0\n\t"
101 " li $16, 0\n\t"
102 " li $17, 0\n\t"
103 " li $18, 0\n\t"
104 " li $19, 0\n\t"
105 " li $20, 0\n\t"
106 " li $21, 0\n\t"
107 " li $22, 0\n\t"
108 " li $23, 0\n\t"
109 " li $24, 0\n\t"
110 " jr $25\n\t" // jump to dst
111 " break 0x7\n" // should never get here
112 ".previous\n"
116 Perform a clone system call. clone is strange because it has
117 fork()-like return-twice semantics, so it needs special
118 handling here.
119 Upon entry, we have:
120 int (fn)(void*) in $a0 0
121 void* child_stack in $a1 4
122 int flags in $a2 8
123 void* arg in $a3 12
124 pid_t* child_tid in stack 16
125 pid_t* parent_tid in stack 20
126 void* tls_ptr in stack 24
128 System call requires:
129 int $__NR_clone in $v0
130 int flags in $a0 0
131 void* child_stack in $a1 4
132 pid_t* parent_tid in $a2 8
133 void* tls_ptr in $a3 12
134 pid_t* child_tid in stack 16
136 int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
137 void *parent_tidptr, void *tls, void *child_tidptr)
139 Returns an Int encoded in the linux-mips way, not a SysRes.
141 #define __NR_CLONE VG_STRINGIFY(__NR_clone)
142 #define __NR_EXIT VG_STRINGIFY(__NR_exit)
144 // See priv_syswrap-linux.h for arg profile.
145 asm (
146 ".text\n"
147 " .globl do_syscall_clone_mips_linux\n"
148 " do_syscall_clone_mips_linux:\n"
149 " subu $29,$29,32\n\t"
150 " sw $31, 0($29)\n\t"
151 " sw $2, 4($29)\n\t"
152 " sw $3, 8($29)\n\t"
153 " sw $30, 12($29)\n\t"
154 " sw $28, 28($29)\n\t"
155 /* set up child stack with function and arg */
156 /* syscall arg 2 child_stack is already in a1 */
157 " subu $5, $5, 32\n\t" /* make space on stack */
158 " sw $4, 0($5)\n\t" /* fn */
159 " sw $7, 4($5)\n\t" /* fn arg */
160 " sw $6, 8($5)\n\t"
161 /* get other args to clone */
163 " move $4, $a2\n\t" /* a0 = flags */
164 " lw $6, 52($29)\n\t" /* a2 = parent_tid */
165 " lw $7, 48($29)\n\t" /* a3 = child_tid */
166 " sw $7, 16($29)\n\t" /* 16(sp) = child_tid */
167 " lw $7, 56($29)\n\t" /* a3 = tls_ptr */
168 /* do the system call */
170 " li $2, " __NR_CLONE "\n\t" /* __NR_clone */
171 " syscall\n\t"
172 " nop\n\t"
174 " bnez $7, .Lerror\n\t"
175 " nop\n\t"
176 " beqz $2, .Lstart\n\t"
177 " nop\n\t"
179 " lw $31, 0($sp)\n\t"
180 " nop\n\t"
181 " lw $30, 12($sp)\n\t"
182 " nop\n\t"
183 " addu $29,$29,32\n\t" /* free stack */
184 " nop\n\t"
185 " jr $31\n\t"
186 " nop\n\t"
188 ".Lerror:\n\t"
189 " li $31, 5\n\t"
190 " jr $31\n\t"
191 " nop\n\t"
193 ".Lstart:\n\t"
194 " lw $4, 4($29)\n\t"
195 " nop\n\t"
196 " lw $25, 0($29)\n\t"
197 " nop\n\t"
198 " jalr $25\n\t"
199 " nop\n\t"
201 " move $4, $2\n\t" /* retval from fn is in $v0 */
202 " li $2, " __NR_EXIT "\n\t" /* NR_exit */
203 " syscall\n\t"
204 " nop\n\t"
205 " .previous\n"
208 #undef __NR_CLONE
209 #undef __NR_EXIT
211 // forward declarations
212 static SysRes sys_set_tls (ThreadId tid, Addr tlsptr);
213 static SysRes mips_PRE_sys_mmap (ThreadId tid,
214 UWord arg1, UWord arg2, UWord arg3,
215 UWord arg4, UWord arg5, Off64T arg6);
216 /* ---------------------------------------------------------------------
217 More thread stuff
218 ------------------------------------------------------------------ */
220 // MIPS doesn't have any architecture specific thread stuff that
221 // needs to be cleaned up da li ????!!!!???
222 void
223 VG_ (cleanup_thread) (ThreadArchState * arch) { }
225 SysRes sys_set_tls ( ThreadId tid, Addr tlsptr )
227 VG_(threads)[tid].arch.vex.guest_ULR = tlsptr;
228 return VG_(mk_SysRes_Success)( 0 );
231 /* ---------------------------------------------------------------------
232 mips handler for mmap and mmap2
233 ------------------------------------------------------------------ */
234 static void notify_core_of_mmap(Addr a, SizeT len, UInt prot,
235 UInt flags, Int fd, Off64T offset)
237 Bool d;
239 /* 'a' is the return value from a real kernel mmap, hence: */
240 vg_assert(VG_IS_PAGE_ALIGNED(a));
241 /* whereas len is whatever the syscall supplied. So: */
242 len = VG_PGROUNDUP(len);
244 d = VG_(am_notify_client_mmap)( a, len, prot, flags, fd, offset );
246 if (d)
247 VG_(discard_translations)( a, (ULong)len,
248 "notify_core_of_mmap" );
251 static void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, ULong di_handle)
253 Bool rr, ww, xx;
255 /* 'a' is the return value from a real kernel mmap, hence: */
256 vg_assert(VG_IS_PAGE_ALIGNED(a));
257 /* whereas len is whatever the syscall supplied. So: */
258 len = VG_PGROUNDUP(len);
260 rr = toBool(prot & VKI_PROT_READ);
261 ww = toBool(prot & VKI_PROT_WRITE);
262 xx = toBool(prot & VKI_PROT_EXEC);
264 VG_TRACK( new_mem_mmap, a, len, rr, ww, xx, di_handle );
267 /* Based on ML_(generic_PRE_sys_mmap) from syswrap-generic.c.
268 If we are trying to do mmap with VKI_MAP_SHARED flag we need to align the
269 start address on VKI_SHMLBA like we did in
270 VG_(am_mmap_file_float_valgrind_flags)
272 static SysRes mips_PRE_sys_mmap(ThreadId tid,
273 UWord arg1, UWord arg2, UWord arg3,
274 UWord arg4, UWord arg5, Off64T arg6)
276 Addr advised;
277 SysRes sres;
278 MapRequest mreq;
279 Bool mreq_ok;
281 if (arg2 == 0) {
282 /* SuSV3 says: If len is zero, mmap() shall fail and no mapping
283 shall be established. */
284 return VG_(mk_SysRes_Error)( VKI_EINVAL );
287 if (!VG_IS_PAGE_ALIGNED(arg1)) {
288 /* zap any misaligned addresses. */
289 /* SuSV3 says misaligned addresses only cause the MAP_FIXED case
290 to fail. Here, we catch them all. */
291 return VG_(mk_SysRes_Error)( VKI_EINVAL );
294 if (!VG_IS_PAGE_ALIGNED(arg6)) {
295 /* zap any misaligned offsets. */
296 /* SuSV3 says: The off argument is constrained to be aligned and
297 sized according to the value returned by sysconf() when
298 passed _SC_PAGESIZE or _SC_PAGE_SIZE. */
299 return VG_(mk_SysRes_Error)( VKI_EINVAL );
302 /* Figure out what kind of allocation constraints there are
303 (fixed/hint/any), and ask aspacem what we should do. */
304 mreq.start = arg1;
305 mreq.len = arg2;
306 if (arg4 & VKI_MAP_FIXED) {
307 mreq.rkind = MFixed;
308 } else
309 if (arg1 != 0) {
310 mreq.rkind = MHint;
311 } else {
312 mreq.rkind = MAny;
315 if ((VKI_SHMLBA > VKI_PAGE_SIZE) && (VKI_MAP_SHARED & arg4)
316 && !(VKI_MAP_FIXED & arg4))
317 mreq.len = arg2 + VKI_SHMLBA - VKI_PAGE_SIZE;
319 /* Enquire ... */
320 advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok );
322 if ((VKI_SHMLBA > VKI_PAGE_SIZE) && (VKI_MAP_SHARED & arg4)
323 && !(VKI_MAP_FIXED & arg4))
324 advised = VG_ROUNDUP(advised, VKI_SHMLBA);
326 if (!mreq_ok) {
327 /* Our request was bounced, so we'd better fail. */
328 return VG_(mk_SysRes_Error)( VKI_EINVAL );
331 /* Otherwise we're OK (so far). Install aspacem's choice of
332 address, and let the mmap go through. */
333 sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3,
334 arg4 | VKI_MAP_FIXED,
335 arg5, arg6);
337 /* A refinement: it may be that the kernel refused aspacem's choice
338 of address. If we were originally asked for a hinted mapping,
339 there is still a last chance: try again at any address.
340 Hence: */
341 if (mreq.rkind == MHint && sr_isError(sres)) {
342 mreq.start = 0;
343 mreq.len = arg2;
344 mreq.rkind = MAny;
345 advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok );
346 if (!mreq_ok) {
347 /* Our request was bounced, so we'd better fail. */
348 return VG_(mk_SysRes_Error)( VKI_EINVAL );
350 /* and try again with the kernel */
351 sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3,
352 arg4 | VKI_MAP_FIXED,
353 arg5, arg6);
356 if (!sr_isError(sres)) {
357 ULong di_handle;
358 /* Notify aspacem. */
359 notify_core_of_mmap(
360 (Addr)sr_Res(sres), /* addr kernel actually assigned */
361 arg2, /* length */
362 arg3, /* prot */
363 arg4, /* the original flags value */
364 arg5, /* fd */
365 arg6 /* offset */
367 /* Load symbols? */
368 di_handle = VG_(di_notify_mmap)( (Addr)sr_Res(sres),
369 False/*allow_SkFileV*/, (Int)arg5 );
370 /* Notify the tool. */
371 notify_tool_of_mmap(
372 (Addr)sr_Res(sres), /* addr kernel actually assigned */
373 arg2, /* length */
374 arg3, /* prot */
375 di_handle /* so the tool can refer to the read debuginfo later,
376 if it wants. */
380 /* Stay sane */
381 if (!sr_isError(sres) && (arg4 & VKI_MAP_FIXED))
382 vg_assert(sr_Res(sres) == arg1);
384 return sres;
386 /* ---------------------------------------------------------------------
387 PRE/POST wrappers for mips/Linux-specific syscalls
388 ------------------------------------------------------------------ */
389 #define PRE(name) DEFN_PRE_TEMPLATE(mips_linux, name)
390 #define POST(name) DEFN_POST_TEMPLATE(mips_linux, name)
392 /* Add prototypes for the wrappers declared here, so that gcc doesn't
393 harass us for not having prototypes. Really this is a kludge --
394 the right thing to do is to make these wrappers 'static' since they
395 aren't visible outside this file, but that requires even more macro
396 magic. */
397 //DECL_TEMPLATE (mips_linux, sys_syscall);
398 DECL_TEMPLATE (mips_linux, sys_mmap);
399 DECL_TEMPLATE (mips_linux, sys_mmap2);
400 DECL_TEMPLATE (mips_linux, sys_stat64);
401 DECL_TEMPLATE (mips_linux, sys_lstat64);
402 DECL_TEMPLATE (mips_linux, sys_fadvise64);
403 DECL_TEMPLATE (mips_linux, sys_fstatat64);
404 DECL_TEMPLATE (mips_linux, sys_fstat64);
405 DECL_TEMPLATE (mips_linux, sys_sigreturn);
406 DECL_TEMPLATE (mips_linux, sys_rt_sigreturn);
407 DECL_TEMPLATE (mips_linux, sys_cacheflush);
408 DECL_TEMPLATE (mips_linux, sys_set_thread_area);
409 DECL_TEMPLATE (mips_linux, sys_pipe);
410 DECL_TEMPLATE (mips_linux, sys_prctl);
411 DECL_TEMPLATE (mips_linux, sys_ptrace);
412 DECL_TEMPLATE (mips_linux, sys_sync_file_range);
414 PRE(sys_mmap2)
416 /* Exactly like sys_mmap() except the file offset is specified in 4096 byte
417 units rather than bytes, so that it can be used for files bigger than
418 2^32 bytes. */
419 SysRes r;
420 PRINT("sys_mmap2 ( %#lx, %lu, %ld, %ld, %ld, %ld )",
421 ARG1, ARG2, SARG3, SARG4, SARG5, SARG6);
422 PRE_REG_READ6(long, "mmap2", unsigned long, start, unsigned long, length,
423 unsigned long, prot, unsigned long, flags,
424 unsigned long, fd, unsigned long, offset);
425 r = mips_PRE_sys_mmap(tid, ARG1, ARG2, ARG3, ARG4, ARG5,
426 4096 * (Off64T) ARG6);
427 SET_STATUS_from_SysRes(r);
430 PRE(sys_mmap)
432 SysRes r;
433 PRINT("sys_mmap ( %#lx, %lu, %ld, %ld, %ld, %lu )",
434 ARG1, ARG2, SARG3, SARG4, SARG5, ARG6);
435 PRE_REG_READ6(long, "mmap", unsigned long, start, vki_size_t, length,
436 int, prot, int, flags, int, fd, unsigned long, offset);
437 r = mips_PRE_sys_mmap(tid, ARG1, ARG2, ARG3, ARG4, ARG5, (Off64T) ARG6);
438 SET_STATUS_from_SysRes(r);
441 PRE(sys_ptrace)
443 PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )", SARG1, SARG2, ARG3, ARG4);
444 PRE_REG_READ4(int, "ptrace",
445 long, request, long, pid, unsigned long, addr,
446 unsigned long, data);
447 switch (ARG1) {
448 case VKI_PTRACE_PEEKTEXT:
449 case VKI_PTRACE_PEEKDATA:
450 case VKI_PTRACE_PEEKUSR:
451 PRE_MEM_WRITE("ptrace(peek)", ARG4, sizeof(long));
452 break;
453 case VKI_PTRACE_GETEVENTMSG:
454 PRE_MEM_WRITE("ptrace(geteventmsg)", ARG4, sizeof(unsigned long));
455 break;
456 case VKI_PTRACE_GETSIGINFO:
457 PRE_MEM_WRITE("ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t));
458 break;
459 case VKI_PTRACE_SETSIGINFO:
460 PRE_MEM_READ("ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
461 break;
462 case VKI_PTRACE_GETREGSET:
463 ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
464 break;
465 default:
466 break;
470 POST(sys_ptrace)
472 switch (ARG1) {
473 case VKI_PTRACE_TRACEME:
474 ML_(linux_POST_traceme)(tid);
475 break;
476 case VKI_PTRACE_PEEKTEXT:
477 case VKI_PTRACE_PEEKDATA:
478 case VKI_PTRACE_PEEKUSR:
479 POST_MEM_WRITE (ARG4, sizeof(long));
480 break;
481 case VKI_PTRACE_GETEVENTMSG:
482 POST_MEM_WRITE (ARG4, sizeof(unsigned long));
483 break;
484 case VKI_PTRACE_GETSIGINFO:
485 POST_MEM_WRITE (ARG4, sizeof(vki_siginfo_t));
486 break;
487 case VKI_PTRACE_GETREGSET:
488 ML_(linux_POST_getregset)(tid, ARG3, ARG4);
489 break;
490 default:
491 break;
495 // XXX: lstat64/fstat64/stat64 are generic, but not necessarily
496 // applicable to every architecture -- I think only to 32-bit archs.
497 // We're going to need something like linux/core_os32.h for such
498 // things, eventually, I think. --njn
500 PRE(sys_lstat64)
502 PRINT ("sys_lstat64 ( %#lx(%s), %#lx )", ARG1, (HChar *) ARG1, ARG2);
503 PRE_REG_READ2 (long, "lstat64", char *, file_name, struct stat64 *, buf);
504 PRE_MEM_RASCIIZ ("lstat64(file_name)", ARG1);
505 PRE_MEM_WRITE ("lstat64(buf)", ARG2, sizeof (struct vki_stat64));
508 POST(sys_lstat64)
510 vg_assert (SUCCESS);
511 if (RES == 0)
513 POST_MEM_WRITE (ARG2, sizeof (struct vki_stat64));
517 PRE(sys_stat64)
519 PRINT ("sys_stat64 ( %#lx(%s), %#lx )", ARG1, (HChar *) ARG1, ARG2);
520 PRE_REG_READ2 (long, "stat64", char *, file_name, struct stat64 *, buf);
521 PRE_MEM_RASCIIZ ("stat64(file_name)", ARG1);
522 PRE_MEM_WRITE ("stat64(buf)", ARG2, sizeof (struct vki_stat64));
525 POST(sys_stat64)
527 POST_MEM_WRITE (ARG2, sizeof (struct vki_stat64));
530 PRE(sys_fadvise64)
532 PRINT("sys_fadvise64 ( %ld, %llu, %llu, %ld )",
533 SARG1, MERGE64(ARG3,ARG4), MERGE64(ARG5, ARG6), SARG7);
535 if (VG_(tdict).track_pre_reg_read) {
536 PRRSN;
537 PRA1("fadvise64", int, fd);
538 PRA3("fadvise64", vki_u32, MERGE64_FIRST(offset));
539 PRA4("fadvise64", vki_u32, MERGE64_SECOND(offset));
540 PRA5("fadvise64", vki_u32, MERGE64_FIRST(len));
541 PRA6("fadvise64", vki_u32, MERGE64_SECOND(len));
542 PRA7("fadvise64", int, advice);
546 PRE(sys_fstatat64)
548 // ARG4 = int flags; Flags are or'ed together, therefore writing them
549 // as a hex constant is more meaningful.
550 PRINT("sys_fstatat64 ( %ld, %#lx(%s), %#lx, %#lx )",
551 SARG1, ARG2, (HChar*)ARG2, ARG3, ARG4);
552 PRE_REG_READ4(long, "fstatat64",
553 int, dfd, char *, file_name, struct stat64 *, buf, int, flags);
554 PRE_MEM_RASCIIZ ("fstatat64(file_name)", ARG2);
555 PRE_MEM_WRITE ("fstatat64(buf)", ARG3, sizeof (struct vki_stat64));
558 POST(sys_fstatat64)
560 POST_MEM_WRITE (ARG3, sizeof (struct vki_stat64));
563 PRE(sys_fstat64)
565 PRINT ("sys_fstat64 ( %ld, %#lx )", SARG1, ARG2);
566 PRE_REG_READ2 (long, "fstat64", unsigned long, fd, struct stat64 *, buf);
567 PRE_MEM_WRITE ("fstat64(buf)", ARG2, sizeof (struct vki_stat64));
570 POST(sys_fstat64)
572 POST_MEM_WRITE (ARG2, sizeof (struct vki_stat64));
575 PRE(sys_sigreturn)
577 PRINT ("sys_sigreturn ( )");
578 vg_assert (VG_ (is_valid_tid) (tid));
579 vg_assert (tid >= 1 && tid < VG_N_THREADS);
580 vg_assert (VG_ (is_running_thread) (tid));
581 VG_ (sigframe_destroy) (tid, False);
582 /* Tell the driver not to update the guest state with the "result",
583 and set a bogus result to keep it happy. */
584 *flags |= SfNoWriteResult;
585 SET_STATUS_Success (0);
586 /* Check to see if any signals arose as a result of this. */
587 *flags |= SfPollAfter;
590 PRE(sys_rt_sigreturn)
592 PRINT ("rt_sigreturn ( )");
593 vg_assert (VG_ (is_valid_tid) (tid));
594 vg_assert (tid >= 1 && tid < VG_N_THREADS);
595 vg_assert (VG_ (is_running_thread) (tid));
596 /* Restore register state from frame and remove it */
597 VG_ (sigframe_destroy) (tid, True);
598 /* Tell the driver not to update the guest state with the "result",
599 and set a bogus result to keep it happy. */
600 *flags |= SfNoWriteResult;
601 SET_STATUS_Success (0);
602 /* Check to see if any signals arose as a result of this. */
603 *flags |= SfPollAfter;
606 PRE(sys_set_thread_area)
608 PRINT ("set_thread_area (%lx)", ARG1);
609 PRE_REG_READ1(long, "set_thread_area", unsigned long, addr);
610 SET_STATUS_from_SysRes( sys_set_tls( tid, ARG1 ) );
613 /* Very much MIPS specific */
614 PRE(sys_cacheflush)
616 PRINT ("cacheflush (%lx, %ld, %ld)", ARG1, SARG2, SARG3);
617 PRE_REG_READ3(long, "cacheflush", unsigned long, addr,
618 int, nbytes, int, cache);
619 VG_ (discard_translations) ((Addr)ARG1, (ULong) ARG2,
620 "PRE(sys_cacheflush)");
621 SET_STATUS_Success (0);
624 PRE(sys_pipe)
626 PRINT("sys_pipe ( %#lx )", ARG1);
627 PRE_REG_READ1(int, "pipe", int *, filedes);
628 PRE_MEM_WRITE( "pipe(filedes)", ARG1, 2*sizeof(int) );
631 POST(sys_pipe)
633 Int p0, p1;
634 vg_assert(SUCCESS);
635 p0 = RES;
636 p1 = sr_ResEx(status->sres);
638 if (!ML_(fd_allowed)(p0, "pipe", tid, True) ||
639 !ML_(fd_allowed)(p1, "pipe", tid, True)) {
640 VG_(close)(p0);
641 VG_(close)(p1);
642 SET_STATUS_Failure( VKI_EMFILE );
643 } else {
644 if (VG_(clo_track_fds)) {
645 ML_(record_fd_open_nameless)(tid, p0);
646 ML_(record_fd_open_nameless)(tid, p1);
651 PRE(sys_prctl)
653 switch (ARG1) {
654 case VKI_PR_SET_FP_MODE:
656 VexArchInfo vai;
657 Int known_bits = VKI_PR_FP_MODE_FR | VKI_PR_FP_MODE_FRE;
658 VG_(machine_get_VexArchInfo)(NULL, &vai);
659 /* Reject unsupported modes */
660 if (ARG2 & ~known_bits) {
661 SET_STATUS_Failure(VKI_EOPNOTSUPP);
662 return;
664 if ((ARG2 & VKI_PR_FP_MODE_FR) && !VEX_MIPS_HOST_FP_MODE(vai.hwcaps)) {
665 SET_STATUS_Failure(VKI_EOPNOTSUPP);
666 return;
668 if ((ARG2 & VKI_PR_FP_MODE_FRE) && !VEX_MIPS_CPU_HAS_MIPSR6(vai.hwcaps)) {
669 SET_STATUS_Failure(VKI_EOPNOTSUPP);
670 return;
672 if (!(ARG2 & VKI_PR_FP_MODE_FR) && VEX_MIPS_CPU_HAS_MIPSR6(vai.hwcaps)) {
673 SET_STATUS_Failure(VKI_EOPNOTSUPP);
674 return;
677 if ((!(VG_(threads)[tid].arch.vex.guest_CP0_status &
678 MIPS_CP0_STATUS_FR) != !(ARG2 & VKI_PR_FP_MODE_FR)) ||
679 (!(VG_(threads)[tid].arch.vex.guest_CP0_Config5 &
680 MIPS_CONF5_FRE) != !(ARG2 & VKI_PR_FP_MODE_FRE))) {
681 ThreadId t;
682 for (t = 1; t < VG_N_THREADS; t++) {
683 if (VG_(threads)[t].status != VgTs_Empty) {
684 if (ARG2 & VKI_PR_FP_MODE_FRE) {
685 VG_(threads)[t].arch.vex.guest_CP0_Config5 |=
686 MIPS_CONF5_FRE;
687 } else {
688 VG_(threads)[t].arch.vex.guest_CP0_Config5 &=
689 ~MIPS_CONF5_FRE;
691 if (ARG2 & VKI_PR_FP_MODE_FR) {
692 VG_(threads)[t].arch.vex.guest_CP0_status |=
693 MIPS_CP0_STATUS_FR;
694 } else {
695 VG_(threads)[t].arch.vex.guest_CP0_status &=
696 ~MIPS_CP0_STATUS_FR;
699 /* Discard all translations */
700 VG_(discard_translations)(0, 0xfffffffful, "prctl(PR_SET_FP_MODE)");
702 SET_STATUS_Success(0);
704 break;
706 case VKI_PR_GET_FP_MODE:
708 UInt ret = 0;
709 if (VG_(threads)[tid].arch.vex.guest_CP0_status & MIPS_CP0_STATUS_FR)
710 ret |= VKI_PR_FP_MODE_FR;
711 if (VG_(threads)[tid].arch.vex.guest_CP0_Config5 & MIPS_CONF5_FRE)
712 ret |= VKI_PR_FP_MODE_FRE;
713 SET_STATUS_Success(ret);
714 break;
716 default:
717 WRAPPER_PRE_NAME(linux, sys_prctl)(tid, layout, arrghs, status, flags);
718 break;
722 POST(sys_prctl)
724 WRAPPER_POST_NAME(linux, sys_prctl)(tid, arrghs, status);
727 PRE(sys_sync_file_range)
729 *flags |= SfMayBlock;
731 PRINT("sys_sync_file_range ( %ld, %llu, %llu, %ld )",
732 SARG1, MERGE64(ARG3,ARG4), MERGE64(ARG5, ARG6), SARG7);
734 if (VG_(tdict).track_pre_reg_read) {
735 PRRSN;
736 PRA1("sync_file_range", int, fd);
737 PRA3("sync_file_range", vki_u32, MERGE64_FIRST(offset));
738 PRA4("sync_file_range", vki_u32, MERGE64_SECOND(offset));
739 PRA5("sync_file_range", vki_u32, MERGE64_FIRST(nbytes));
740 PRA6("sync_file_range", vki_u32, MERGE64_SECOND(nbytes));
741 PRA7("sync_file_range", int, flags);
744 if (!ML_(fd_allowed)(ARG1, "sync_file_range", tid, False)){
745 SET_STATUS_Failure( VKI_EBADF );
749 #undef PRE
750 #undef POST
752 /* ---------------------------------------------------------------------
753 The mips/Linux syscall table
754 ------------------------------------------------------------------ */
755 #define PLAX_(sysno, name) WRAPPER_ENTRY_X_(mips_linux, sysno, name)
756 #define PLAXY(sysno, name) WRAPPER_ENTRY_XY(mips_linux, sysno, name)
758 // This table maps from __NR_xxx syscall numbers (from
759 // linux/include/asm-mips/unistd.h) to the appropriate PRE/POST sys_foo()
760 // wrappers on mips (as per sys_call_table in linux/arch/mips/kernel/entry.S).
763 // For those syscalls not handled by Valgrind, the annotation indicate its
764 // arch/OS combination, eg. */* (generic), */Linux (Linux only), ?/?
765 // (unknown).
767 static SyscallTableEntry syscall_main_table[] = {
768 //.. PLAXY (__NR_syscall, sys_syscall), // 0
769 GENX_ (__NR_exit, sys_exit), // 1
770 GENX_ (__NR_fork, sys_fork), // 2
771 GENXY (__NR_read, sys_read), // 3
772 GENX_ (__NR_write, sys_write), // 4
773 GENXY (__NR_open, sys_open), // 5
774 GENXY (__NR_close, sys_close), // 6
775 GENXY (__NR_waitpid, sys_waitpid), // 7
776 GENXY (__NR_creat, sys_creat), // 8
777 GENX_ (__NR_link, sys_link), // 9
778 GENX_ (__NR_unlink, sys_unlink), // 10
779 GENX_ (__NR_execve, sys_execve), // 11
780 GENX_ (__NR_chdir, sys_chdir), // 12
781 GENXY (__NR_time, sys_time), // 13
782 GENX_ (__NR_mknod, sys_mknod), // 14
783 GENX_ (__NR_chmod, sys_chmod), // 15
784 GENX_ (__NR_lchown, sys_lchown), // 16
785 //..
786 LINX_ (__NR_lseek, sys_lseek), // 19
787 GENX_ (__NR_getpid, sys_getpid), // 20
788 LINX_ (__NR_mount, sys_mount), // 21
789 LINX_ (__NR_umount, sys_oldumount), // 22
790 GENX_ (__NR_setuid, sys_setuid), // 23
791 GENX_ (__NR_getuid, sys_getuid), // 24
792 LINX_ (__NR_stime, sys_stime), // 25
793 PLAXY(__NR_ptrace, sys_ptrace), // 26
794 GENX_ (__NR_alarm, sys_alarm), // 27
795 //.. // (__NR_oldfstat, sys_fstat), // 28
796 GENX_ (__NR_pause, sys_pause), // 29
797 LINX_ (__NR_utime, sys_utime), // 30
798 //.. GENX_(__NR_stty, sys_ni_syscall), // 31
799 //.. GENX_(__NR_gtty, sys_ni_syscall), // 32
800 GENX_ (__NR_access, sys_access), // 33
801 //.. GENX_(__NR_nice, sys_nice), // 34
802 //.. GENX_(__NR_ftime, sys_ni_syscall), // 35
803 //.. GENX_(__NR_sync, sys_sync), // 36
804 GENX_ (__NR_kill, sys_kill), // 37
805 GENX_ (__NR_rename, sys_rename), // 38
806 GENX_ (__NR_mkdir, sys_mkdir), // 39
807 GENX_ (__NR_rmdir, sys_rmdir), // 40
808 GENXY (__NR_dup, sys_dup), // 41
809 PLAXY (__NR_pipe, sys_pipe), // 42
810 GENXY (__NR_times, sys_times), // 43
811 //.. GENX_(__NR_prof, sys_ni_syscall), // 44
812 GENX_ (__NR_brk, sys_brk), // 45
813 GENX_ (__NR_setgid, sys_setgid), // 46
814 GENX_ (__NR_getgid, sys_getgid), // 47
815 //.. // (__NR_signal, sys_signal), // 48
816 GENX_ (__NR_geteuid, sys_geteuid), // 49
817 GENX_ (__NR_getegid, sys_getegid), // 50
818 GENX_ (__NR_acct, sys_acct), // 51
819 LINX_ (__NR_umount2, sys_umount), // 52
820 //.. GENX_(__NR_lock, sys_ni_syscall), // 53
821 LINXY (__NR_ioctl, sys_ioctl), // 54
822 LINXY (__NR_fcntl, sys_fcntl), // 55
823 //.. GENX_(__NR_mpx, sys_ni_syscall), // 56
824 GENX_ (__NR_setpgid, sys_setpgid), // 57
825 //.. GENX_(__NR_ulimit, sys_ni_syscall), // 58
826 //.. // (__NR_oldolduname, sys_olduname), // 59
827 GENX_ (__NR_umask, sys_umask), // 60
828 GENX_ (__NR_chroot, sys_chroot), // 61
829 //.. // (__NR_ustat, sys_ustat) // 62
830 GENXY (__NR_dup2, sys_dup2), // 63
831 GENX_ (__NR_getppid, sys_getppid), // 64
832 GENX_ (__NR_getpgrp, sys_getpgrp), // 65
833 GENX_ (__NR_setsid, sys_setsid), // 66
834 LINXY (__NR_sigaction, sys_sigaction), // 67
835 //.. // (__NR_sgetmask, sys_sgetmask), // 68
836 //.. // (__NR_ssetmask, sys_ssetmask), // 69
837 GENX_ (__NR_setreuid, sys_setreuid), // 70
838 GENX_ (__NR_setregid, sys_setregid), // 71
839 // PLAX_(__NR_sigsuspend, sys_sigsuspend), // 72
840 LINXY (__NR_sigpending, sys_sigpending), // 73
841 GENX_ (__NR_sethostname, sys_sethostname), // 74
842 GENX_ (__NR_setrlimit, sys_setrlimit), // 75
843 GENXY (__NR_getrlimit, sys_getrlimit), // 76
844 GENXY (__NR_getrusage, sys_getrusage), // 77
845 GENXY (__NR_gettimeofday, sys_gettimeofday), // 78
846 GENX_ (__NR_settimeofday, sys_settimeofday), // 79
847 GENXY (__NR_getgroups, sys_getgroups), // 80
848 GENX_ (__NR_setgroups, sys_setgroups), // 81
849 //.. PLAX_(__NR_select, old_select), // 82
850 GENX_ (__NR_symlink, sys_symlink), // 83
851 //.. // (__NR_oldlstat, sys_lstat), // 84
852 GENX_ (__NR_readlink, sys_readlink), // 85
853 //.. // (__NR_uselib, sys_uselib), // 86
854 //.. // (__NR_swapon, sys_swapon), // 87
855 //.. // (__NR_reboot, sys_reboot), // 88
856 //.. // (__NR_readdir, old_readdir), // 89
857 PLAX_ (__NR_mmap, sys_mmap), // 90
858 GENXY (__NR_munmap, sys_munmap), // 91
859 GENX_ (__NR_truncate, sys_truncate), // 92
860 GENX_ (__NR_ftruncate, sys_ftruncate), // 93
861 GENX_ (__NR_fchmod, sys_fchmod), // 94
862 GENX_ (__NR_fchown, sys_fchown), // 95
863 GENX_ (__NR_getpriority, sys_getpriority), // 96
864 GENX_ (__NR_setpriority, sys_setpriority), // 97
865 //.. GENX_(__NR_profil, sys_ni_syscall), // 98
866 GENXY (__NR_statfs, sys_statfs), // 99
867 GENXY (__NR_fstatfs, sys_fstatfs), // 100
868 //.. LINX_(__NR_ioperm, sys_ioperm), // 101
869 LINXY (__NR_socketcall, sys_socketcall), // 102
870 LINXY (__NR_syslog, sys_syslog), // 103
871 GENXY (__NR_setitimer, sys_setitimer), // 104
872 GENXY (__NR_getitimer, sys_getitimer), // 105
873 GENXY (__NR_stat, sys_newstat), // 106
874 GENXY (__NR_lstat, sys_newlstat), // 107
875 GENXY (__NR_fstat, sys_newfstat), // 108
876 //.. // (__NR_olduname, sys_uname), // 109
877 //.. GENX_(__NR_iopl, sys_iopl), // 110
878 LINX_ (__NR_vhangup, sys_vhangup), // 111
879 //.. GENX_(__NR_idle, sys_ni_syscall), // 112
880 //.. // (__NR_vm86old, sys_vm86old), // 113
881 GENXY (__NR_wait4, sys_wait4), // 114
882 //.. // (__NR_swapoff, sys_swapoff), // 115
883 LINXY (__NR_sysinfo, sys_sysinfo), // 116
884 LINXY (__NR_ipc, sys_ipc), // 117
885 GENX_ (__NR_fsync, sys_fsync), // 118
886 PLAX_ (__NR_sigreturn, sys_sigreturn), // 119
887 LINX_ (__NR_clone, sys_clone), // 120
888 //.. // (__NR_setdomainname, sys_setdomainname), // 121
889 GENXY (__NR_uname, sys_newuname), // 122
890 //.. PLAX_(__NR_modify_ldt, sys_modify_ldt), // 123
891 LINXY (__NR_adjtimex, sys_adjtimex), // 124
892 GENXY (__NR_mprotect, sys_mprotect), // 125
893 LINXY (__NR_sigprocmask, sys_sigprocmask), // 126
894 //.. GENX_(__NR_create_module, sys_ni_syscall), // 127
895 //.. GENX_(__NR_init_module, sys_init_module), // 128
896 //.. // (__NR_delete_module, sys_delete_module), // 129
897 //.. GENX_(__NR_get_kernel_syms, sys_ni_syscall), // 130
898 //.. LINX_(__NR_quotactl, sys_quotactl), // 131
899 GENX_ (__NR_getpgid, sys_getpgid), // 132
900 GENX_ (__NR_fchdir, sys_fchdir), // 133
901 //.. // (__NR_bdflush, sys_bdflush), // 134
902 //.. // (__NR_sysfs, sys_sysfs), // 135
903 LINX_ (__NR_personality, sys_personality), // 136
904 //.. GENX_(__NR_afs_syscall, sys_ni_syscall), // 137
905 LINX_ (__NR_setfsuid, sys_setfsuid), // 138
906 LINX_ (__NR_setfsgid, sys_setfsgid), // 139
907 LINXY (__NR__llseek, sys_llseek), // 140
908 GENXY (__NR_getdents, sys_getdents), // 141
909 GENX_ (__NR__newselect, sys_select), // 142
910 GENX_ (__NR_flock, sys_flock), // 143
911 GENX_ (__NR_msync, sys_msync), // 144
912 GENXY (__NR_readv, sys_readv), // 145
913 GENX_ (__NR_writev, sys_writev), // 146
914 PLAX_ (__NR_cacheflush, sys_cacheflush), // 147
915 GENX_ (__NR_getsid, sys_getsid), // 151
916 GENX_ (__NR_fdatasync, sys_fdatasync), // 152
917 LINXY (__NR__sysctl, sys_sysctl), // 153
918 GENX_ (__NR_mlock, sys_mlock), // 154
919 GENX_ (__NR_munlock, sys_munlock), // 155
920 GENX_ (__NR_mlockall, sys_mlockall), // 156
921 LINX_ (__NR_munlockall, sys_munlockall), // 157
922 LINXY (__NR_sched_setparam, sys_sched_setparam), // 158
923 LINXY (__NR_sched_getparam, sys_sched_getparam), // 159
924 LINX_ (__NR_sched_setscheduler, sys_sched_setscheduler), // 160
925 LINX_ (__NR_sched_getscheduler, sys_sched_getscheduler), // 161
926 LINX_ (__NR_sched_yield, sys_sched_yield), // 162
927 LINX_ (__NR_sched_get_priority_max, sys_sched_get_priority_max), // 163
928 LINX_ (__NR_sched_get_priority_min, sys_sched_get_priority_min), // 164
929 LINXY (__NR_sched_rr_get_interval, sys_sched_rr_get_interval), // 165
930 GENXY (__NR_nanosleep, sys_nanosleep), // 166
931 GENX_ (__NR_mremap, sys_mremap), // 167
932 LINXY (__NR_accept, sys_accept), // 168
933 LINX_ (__NR_bind, sys_bind), // 169
934 LINX_ (__NR_connect, sys_connect), // 170
935 LINXY (__NR_getpeername, sys_getpeername), // 171
936 LINXY (__NR_getsockname, sys_getsockname), // 172
937 LINXY (__NR_getsockopt, sys_getsockopt), // 173
938 LINX_ (__NR_listen, sys_listen), // 174
939 LINXY (__NR_recv, sys_recv), // 175
940 LINXY (__NR_recvfrom, sys_recvfrom), // 176
941 LINXY (__NR_recvmsg, sys_recvmsg), // 177
942 LINX_ (__NR_send, sys_send), // 178
943 LINX_ (__NR_sendmsg, sys_sendmsg), // 179
944 LINX_ (__NR_sendto, sys_sendto), // 180
945 LINX_ (__NR_setsockopt, sys_setsockopt), // 181
946 LINX_ (__NR_shutdown, sys_shutdown), // 182
947 LINXY (__NR_socket, sys_socket), // 183
948 LINXY (__NR_socketpair, sys_socketpair), // 184
949 LINX_ (__NR_setresuid, sys_setresuid), // 185
950 LINXY (__NR_getresuid, sys_getresuid), // 186
951 //.. GENX_(__NR_query_module, sys_ni_syscall), // 187
952 GENXY (__NR_poll, sys_poll), // 188
953 //..
954 LINX_ (__NR_setresgid, sys_setresgid), // 190
955 LINXY (__NR_getresgid, sys_getresgid), // 191
956 PLAXY (__NR_prctl, sys_prctl), // 192
957 PLAX_ (__NR_rt_sigreturn, sys_rt_sigreturn), // 193
958 LINXY (__NR_rt_sigaction, sys_rt_sigaction), // 194
959 LINXY (__NR_rt_sigprocmask, sys_rt_sigprocmask), // 195
960 LINXY (__NR_rt_sigpending, sys_rt_sigpending), // 196
961 LINXY (__NR_rt_sigtimedwait, sys_rt_sigtimedwait), // 197
962 LINXY (__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo), // 198
963 LINX_ (__NR_rt_sigsuspend, sys_rt_sigsuspend), // 199
964 GENXY (__NR_pread64, sys_pread64), // 200
965 GENX_ (__NR_pwrite64, sys_pwrite64), // 201
966 GENX_ (__NR_chown, sys_chown), // 202
967 GENXY (__NR_getcwd, sys_getcwd), // 203
968 LINXY (__NR_capget, sys_capget), // 204
969 //.. LINX_(__NR_capset, sys_capset), // 205
970 GENXY (__NR_sigaltstack, sys_sigaltstack), // 206
971 LINXY (__NR_sendfile, sys_sendfile), // 207
972 //.. GENXY(__NR_getpmsg, sys_getpmsg), // 208
973 //.. GENX_(__NR_putpmsg, sys_putpmsg), // 209
974 PLAX_ (__NR_mmap2, sys_mmap2), // 210
975 GENX_ (__NR_truncate64, sys_truncate64), // 211
976 GENX_ (__NR_ftruncate64, sys_ftruncate64), // 212
977 PLAXY (__NR_stat64, sys_stat64), // 213
978 PLAXY (__NR_lstat64, sys_lstat64), // 214
979 PLAXY (__NR_fstat64, sys_fstat64), // 215
980 //..
981 GENXY (__NR_mincore, sys_mincore), // 217
982 GENX_ (__NR_madvise, sys_madvise), // 218
983 GENXY (__NR_getdents64, sys_getdents64), // 219
984 LINXY (__NR_fcntl64, sys_fcntl64), // 220
985 //..
986 LINX_ (__NR_gettid, sys_gettid), // 222
987 //..
988 LINX_ (__NR_setxattr, sys_setxattr), // 224
989 LINX_ (__NR_lsetxattr, sys_lsetxattr), // 225
990 LINX_ (__NR_fsetxattr, sys_fsetxattr), // 226
991 LINXY (__NR_getxattr, sys_getxattr), // 227
992 LINXY (__NR_lgetxattr, sys_lgetxattr), // 228
993 LINXY (__NR_fgetxattr, sys_fgetxattr), // 229
994 LINXY (__NR_listxattr, sys_listxattr), // 230
995 LINXY (__NR_llistxattr, sys_llistxattr), // 231
996 LINXY (__NR_flistxattr, sys_flistxattr), // 232
997 LINX_ (__NR_removexattr, sys_removexattr), // 233
998 LINX_ (__NR_lremovexattr, sys_lremovexattr), // 234
999 LINX_ (__NR_fremovexattr, sys_fremovexattr), // 235
1000 //..
1001 LINXY (__NR_sendfile64, sys_sendfile64), // 237
1002 LINXY (__NR_futex, sys_futex), // 238
1003 LINX_ (__NR_sched_setaffinity, sys_sched_setaffinity), // 239
1004 LINXY (__NR_sched_getaffinity, sys_sched_getaffinity), // 240
1005 LINX_ (__NR_io_setup, sys_io_setup), // 241
1006 LINX_ (__NR_io_destroy, sys_io_destroy), // 242
1007 LINXY (__NR_io_getevents, sys_io_getevents), // 243
1008 LINX_ (__NR_io_submit, sys_io_submit), // 244
1009 LINXY (__NR_io_cancel, sys_io_cancel), // 245
1010 LINX_ (__NR_exit_group, sys_exit_group), // 246
1011 //..
1012 LINXY (__NR_epoll_create, sys_epoll_create), // 248
1013 LINX_ (__NR_epoll_ctl, sys_epoll_ctl), // 249
1014 LINXY (__NR_epoll_wait, sys_epoll_wait), // 250
1015 //..
1016 LINX_ (__NR_set_tid_address, sys_set_tid_address), // 252
1017 PLAX_ (__NR_fadvise64, sys_fadvise64), // 254
1018 GENXY (__NR_statfs64, sys_statfs64), // 255
1019 GENXY (__NR_fstatfs64, sys_fstatfs64), // 256
1020 //..
1021 LINXY (__NR_timer_create, sys_timer_create), // 257
1022 LINXY (__NR_timer_settime, sys_timer_settime), // 258
1023 LINXY (__NR_timer_gettime, sys_timer_gettime), // 259
1024 LINX_ (__NR_timer_getoverrun, sys_timer_getoverrun), // 260
1025 LINX_ (__NR_timer_delete, sys_timer_delete), // 261
1026 LINX_ (__NR_clock_settime, sys_clock_settime), // 262
1027 LINXY (__NR_clock_gettime, sys_clock_gettime), // 263
1028 LINXY (__NR_clock_getres, sys_clock_getres), // 264
1029 LINXY (__NR_clock_nanosleep, sys_clock_nanosleep), // 265
1030 LINXY (__NR_tgkill, sys_tgkill), // 266
1031 GENX_ (__NR_utimes, sys_utimes), // 267
1032 LINXY (__NR_get_mempolicy, sys_get_mempolicy), // 269
1033 LINX_ (__NR_set_mempolicy, sys_set_mempolicy), // 270
1034 LINXY (__NR_mq_open, sys_mq_open), // 271
1035 LINX_ (__NR_mq_unlink, sys_mq_unlink), // 272
1036 LINX_ (__NR_mq_timedsend, sys_mq_timedsend), // 273
1037 LINXY (__NR_mq_timedreceive, sys_mq_timedreceive), // 274
1038 LINX_ (__NR_mq_notify, sys_mq_notify), // 275
1039 LINXY (__NR_mq_getsetattr, sys_mq_getsetattr), // 276
1040 LINX_ (__NR_inotify_init, sys_inotify_init), // 275
1041 LINX_ (__NR_inotify_add_watch, sys_inotify_add_watch), // 276
1042 LINX_ (__NR_inotify_rm_watch, sys_inotify_rm_watch), // 277
1043 LINXY (__NR_waitid, sys_waitid), // 278
1044 //..
1045 PLAX_ (__NR_set_thread_area, sys_set_thread_area), // 283
1046 //..
1047 LINXY (__NR_openat, sys_openat), // 288
1048 LINX_ (__NR_mkdirat, sys_mkdirat), // 289
1049 LINX_ (__NR_mknodat, sys_mknodat), // 290
1050 LINX_ (__NR_fchownat, sys_fchownat), // 291
1051 LINX_ (__NR_futimesat, sys_futimesat), // 292
1052 PLAXY (__NR_fstatat64, sys_fstatat64), // 293
1053 LINX_ (__NR_unlinkat, sys_unlinkat), // 294
1054 LINX_ (__NR_renameat, sys_renameat), // 295
1055 LINX_ (__NR_linkat, sys_linkat), // 296
1056 LINX_ (__NR_symlinkat, sys_symlinkat), // 297
1057 LINX_ (__NR_readlinkat, sys_readlinkat), // 298
1058 LINX_ (__NR_fchmodat, sys_fchmodat), // 299
1059 LINX_ (__NR_faccessat, sys_faccessat), // 300
1060 LINXY (__NR_pselect6, sys_pselect6), // 301
1061 LINXY (__NR_ppoll, sys_ppoll), // 302
1062 LINX_ (__NR_unshare, sys_unshare), // 303
1063 LINX_ (__NR_splice, sys_splice), // 304
1064 PLAX_ (__NR_sync_file_range, sys_sync_file_range), // 305
1065 LINX_ (__NR_tee, sys_tee), // 306
1066 LINXY (__NR_vmsplice, sys_vmsplice), // 307
1067 //..
1068 LINX_ (__NR_set_robust_list, sys_set_robust_list), // 309
1069 LINXY (__NR_get_robust_list, sys_get_robust_list), // 310
1070 //..
1071 LINXY (__NR_getcpu, sys_getcpu), // 312
1072 LINXY (__NR_epoll_pwait, sys_epoll_pwait), // 313
1073 //..
1074 LINX_ (__NR_utimensat, sys_utimensat), // 316
1075 //..
1076 LINX_ (__NR_fallocate, sys_fallocate), // 320
1077 LINXY (__NR_timerfd_create, sys_timerfd_create), // 321
1078 LINXY (__NR_timerfd_gettime, sys_timerfd_gettime), // 322
1079 LINXY (__NR_timerfd_settime, sys_timerfd_settime), // 323
1080 LINXY (__NR_signalfd4, sys_signalfd4), // 324
1081 LINXY (__NR_eventfd2, sys_eventfd2), // 325
1082 //..
1083 LINXY (__NR_pipe2, sys_pipe2), // 328
1084 LINXY (__NR_inotify_init1, sys_inotify_init1), // 329
1085 LINXY (__NR_preadv, sys_preadv), // 330
1086 LINX_ (__NR_pwritev, sys_pwritev), // 331
1087 //..
1088 LINXY (__NR_prlimit64, sys_prlimit64), // 338
1089 //..
1090 LINXY (__NR_clock_adjtime, sys_clock_adjtime), // 341
1091 LINX_ (__NR_syncfs, sys_syncfs), // 342
1092 LINX_ (__NR_setns, sys_setns), // 343
1093 //..
1094 LINXY (__NR_process_vm_readv, sys_process_vm_readv), // 345
1095 LINX_ (__NR_process_vm_writev, sys_process_vm_writev), // 346
1096 //..
1097 LINX_(__NR_sched_setattr, sys_sched_setattr), // 349
1098 LINXY(__NR_sched_getattr, sys_sched_getattr), // 350
1099 //..
1100 LINXY (__NR_getrandom, sys_getrandom), // 353
1101 LINXY (__NR_memfd_create, sys_memfd_create), // 354
1102 //..
1103 LINX_ (__NR_execveat, sys_execveat), // 356
1104 //..
1105 LINX_ (__NR_membarrier, sys_membarrier), // 358
1106 //..
1107 LINX_ (__NR_copy_file_range, sys_copy_file_range), // 360
1108 LINXY (__NR_preadv2, sys_preadv2), // 361
1109 LINX_ (__NR_pwritev2, sys_pwritev2), // 362
1110 //..
1111 LINXY(__NR_statx, sys_statx), // 366
1113 LINXY(__NR_clock_gettime64, sys_clock_gettime64), // 403
1114 LINX_(__NR_clock_settime64, sys_clock_settime64), // 404
1116 LINXY(__NR_clock_getres_time64, sys_clock_getres_time64), // 406
1117 LINXY(__NR_clock_nanosleep_time64, sys_clock_nanosleep_time64), // 407
1118 LINXY(__NR_timer_gettime64, sys_timer_gettime64), // 408
1119 LINXY(__NR_timer_settime64, sys_timer_settime64), // 409
1120 LINXY(__NR_timerfd_gettime64, sys_timerfd_gettime64), // 410
1121 LINXY(__NR_timerfd_settime64, sys_timerfd_settime64), // 411
1122 LINX_(__NR_utimensat_time64, sys_utimensat_time64), // 412
1123 LINXY(__NR_pselect6_time64, sys_pselect6_time64), // 413
1124 LINXY(__NR_ppoll_time64, sys_ppoll_time64), // 414
1126 LINXY(__NR_recvmmsg_time64, sys_recvmmsg_time64), // 417
1127 LINX_(__NR_mq_timedsend_time64, sys_mq_timedsend_time64), // 418
1128 LINXY(__NR_mq_timedreceive_time64, sys_mq_timedreceive_time64), // 419
1129 LINX_(__NR_semtimedop_time64, sys_semtimedop_time64), // 420
1130 LINXY(__NR_rt_sigtimedwait_time64, sys_rt_sigtimedwait_time64), // 421
1131 LINXY(__NR_futex_time64, sys_futex_time64), // 422
1132 LINXY(__NR_sched_rr_get_interval_time64,
1133 sys_sched_rr_get_interval_time64), // 423
1135 LINXY(__NR_io_uring_setup, sys_io_uring_setup), // 425
1136 LINXY(__NR_io_uring_enter, sys_io_uring_enter), // 426
1137 LINXY(__NR_io_uring_register, sys_io_uring_register), // 427
1139 LINXY(__NR_pidfd_open, sys_pidfd_open), // 434
1140 GENX_(__NR_clone3, sys_ni_syscall), // 435
1141 LINXY(__NR_close_range, sys_close_range), // 436
1143 LINXY(__NR_pidfd_getfd, sys_pidfd_getfd), // 438
1144 LINX_ (__NR_faccessat2, sys_faccessat2), // 439
1146 LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441
1149 SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno)
1151 const UInt syscall_main_table_size
1152 = sizeof (syscall_main_table) / sizeof (syscall_main_table[0]);
1153 /* Is it in the contiguous initial section of the table? */
1154 if (sysno < syscall_main_table_size) {
1155 SyscallTableEntry * sys = &syscall_main_table[sysno];
1156 if (sys->before == NULL)
1157 return NULL; /* No entry. */
1158 else
1159 return sys;
1161 /* Can't find a wrapper. */
1162 return NULL;
1165 #endif // defined(VGP_mips32_linux)
1167 /*--------------------------------------------------------------------*/
1168 /*--- end syswrap-mips-linux.c ---*/
1169 /*--------------------------------------------------------------------*/