vgdb: Handle EAGAIN in read_buf
[valgrind.git] / coregrind / m_syswrap / syswrap-arm64-linux.c
blob9532360007be8df2d89bc87fd7ba2b2a4322c730
2 /*--------------------------------------------------------------------*/
3 /*--- Platform-specific syscalls stuff. syswrap-arm64-linux.c -----*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2013-2017 OpenWorks
11 info@open-works.net
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #if defined(VGP_arm64_linux)
31 #include "pub_core_basics.h"
32 #include "pub_core_vki.h"
33 #include "pub_core_vkiscnums.h"
34 #include "pub_core_threadstate.h"
35 #include "pub_core_aspacemgr.h"
36 #include "pub_core_libcbase.h"
37 #include "pub_core_libcassert.h"
38 #include "pub_core_libcprint.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_syscall.h"
44 #include "pub_core_syswrap.h"
45 #include "pub_core_tooliface.h"
47 #include "priv_types_n_macros.h"
48 #include "priv_syswrap-generic.h" /* for decls of generic wrappers */
49 #include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers */
52 /* ---------------------------------------------------------------------
53 clone() handling
54 ------------------------------------------------------------------ */
56 /* Call f(arg1), but first switch stacks, using 'stack' as the new
57 stack, and use 'retaddr' as f's return-to address. Also, clear all
58 the integer registers before entering f.*/
59 __attribute__((noreturn))
60 void ML_(call_on_new_stack_0_1) ( Addr stack,
61 Addr retaddr,
62 void (*f)(Word),
63 Word arg1 );
64 // r0 = stack
65 // r1 = retaddr
66 // r2 = f
67 // r3 = arg1
68 asm(
69 ".text\n"
70 ".globl vgModuleLocal_call_on_new_stack_0_1\n"
71 "vgModuleLocal_call_on_new_stack_0_1:\n"
72 " mov sp, x0\n\t" /* Stack pointer */
73 " mov x30, x1\n\t" /* Return address (x30 is LR) */
74 " mov x0, x3\n\t" /* First argument */
75 " mov x9, x2\n\t" /* 'f': x9 won't be zeroed at start of f. Oh well. */
76 " mov x1, #0\n\t" /* Clear our GPRs */
77 " mov x2, #0\n\t"
78 " mov x3, #0\n\t"
79 " mov x4, #0\n\t"
80 " mov x5, #0\n\t"
81 " mov x6, #0\n\t"
82 " mov x7, #0\n\t"
83 " mov x8, #0\n\t"
84 /* don't zero out x9 */
85 " mov x10, #0\n\t"
86 " mov x11, #0\n\t"
87 " mov x12, #0\n\t"
88 " mov x13, #0\n\t"
89 " mov x14, #0\n\t"
90 " mov x15, #0\n\t"
91 " mov x16, #0\n\t"
92 " mov x17, #0\n\t"
93 " mov x18, #0\n\t"
94 " mov x19, #0\n\t"
95 " mov x20, #0\n\t"
96 " mov x21, #0\n\t"
97 " mov x22, #0\n\t"
98 " mov x23, #0\n\t"
99 " mov x24, #0\n\t"
100 " mov x25, #0\n\t"
101 " mov x26, #0\n\t"
102 " mov x27, #0\n\t"
103 " mov x28, #0\n\t"
104 " mov x29, sp\n\t" /* FP = SP, in the absence of better suggestions */
105 " br x9\n\t"
106 ".previous\n"
111 Perform a clone system call. clone is strange because it has
112 fork()-like return-twice semantics, so it needs special
113 handling here.
115 Upon entry, we have:
117 Word (*fn)(void*) in x0
118 void* child_stack in x1
119 int flags in x2
120 void* arg in x3
121 pid_t* child_tid in x4
122 pid_t* parent_tid in x5
123 void* tls_ptr in x6
125 System call requires:
127 int $__NR_clone in x8
128 int flags in x0
129 void* child_stack in x1
130 pid_t* parent_tid in x2
131 void* tls_ptr in x3
132 pid_t* child_tid in x4
134 Returns a Long encoded in the linux-arm64 way, not a SysRes.
136 #define __NR_CLONE VG_STRINGIFY(__NR_clone)
137 #define __NR_EXIT VG_STRINGIFY(__NR_exit)
139 // See priv_syswrap-linux.h for arg profile.
140 asm(
141 ".text\n"
142 ".globl do_syscall_clone_arm64_linux\n"
143 "do_syscall_clone_arm64_linux:\n"
144 // set up child stack, temporarily preserving fn and arg
145 " sub x1, x1, #16\n" // make space on stack
146 " str x3, [x1, #8]\n" // save arg
147 " str x0, [x1, #0]\n" // save fn
149 // setup syscall
150 " mov x8, #"__NR_CLONE"\n" // syscall number
151 " mov x0, x2\n" // syscall arg1: flags
152 " mov x1, x1\n" // syscall arg2: child_stack
153 " mov x2, x5\n" // syscall arg3: parent_tid
154 " mov x3, x6\n" // syscall arg4: tls_ptr
155 " mov x4, x4\n" // syscall arg5: child_tid
157 " svc 0\n" // clone()
159 " cmp x0, #0\n" // child if retval == 0
160 " bne 1f\n"
162 // CHILD - call thread function
163 " ldr x1, [sp, #0]\n" // pop fn
164 " ldr x0, [sp, #8]\n" // pop fn arg1: arg
165 " add sp, sp, #16\n"
166 " blr x1\n" // call fn
168 // exit with result
169 " mov x0, x0\n" // arg1: return value from fn
170 " mov x8, #"__NR_EXIT"\n"
172 " svc 0\n"
174 // Exit returned?!
175 " .word 0xFFFFFFFF\n"
177 "1:\n" // PARENT or ERROR. x0 holds return value from the clone syscall.
178 " ret\n"
179 ".previous\n"
182 #undef __NR_CLONE
183 #undef __NR_EXIT
185 // forward declaration
186 //ZZ static SysRes sys_set_tls ( ThreadId tid, Addr tlsptr );
188 /* ---------------------------------------------------------------------
189 More thread stuff
190 ------------------------------------------------------------------ */
192 // ARM64 doesn't have any architecture specific thread stuff that
193 // needs to be cleaned up
194 void VG_(cleanup_thread) ( ThreadArchState* arch )
198 //ZZ /* Assigns tlsptr to the guest TPIDRURO.
199 //ZZ If needed for the specific hardware, really executes
200 //ZZ the set_tls syscall.
201 //ZZ */
202 //ZZ static SysRes sys_set_tls ( ThreadId tid, Addr tlsptr )
203 //ZZ {
204 //ZZ assign_guest_tls(tid, tlsptr);
205 //ZZ #if defined(ANDROID_HARDWARE_emulator)
206 //ZZ /* Android emulator does not provide an hw tls register.
207 //ZZ So, the tls register is emulated by the kernel.
208 //ZZ This emulated value is set by the __NR_ARM_set_tls syscall.
209 //ZZ The emulated value must be read by the kernel helper function
210 //ZZ located at 0xffff0fe0.
211 //ZZ
212 //ZZ The emulated tlsptr is located at 0xffff0ff0
213 //ZZ (so slightly after the kernel helper function).
214 //ZZ Note that applications are not supposed to read this directly.
215 //ZZ
216 //ZZ For compatibility : if there is a hw tls register, the kernel
217 //ZZ will put at 0xffff0fe0 the instructions to read it, so
218 //ZZ as to have old applications calling the kernel helper
219 //ZZ working properly.
220 //ZZ
221 //ZZ For having emulated guest TLS working correctly with
222 //ZZ Valgrind, it is needed to execute the syscall to set
223 //ZZ the emulated TLS value in addition to the assignment
224 //ZZ of TPIDRURO.
225 //ZZ
226 //ZZ Note: the below means that if we need thread local storage
227 //ZZ for Valgrind host, then there will be a conflict between
228 //ZZ the need of the guest tls and of the host tls.
229 //ZZ If all the guest code would cleanly call 0xffff0fe0,
230 //ZZ then we might maybe intercept this. However, at least
231 //ZZ __libc_preinit reads directly 0xffff0ff0.
232 //ZZ */
233 //ZZ /* ??? might call the below if auxv->u.a_val & VKI_HWCAP_TLS ???
234 //ZZ Unclear if real hardware having tls hw register sets
235 //ZZ VKI_HWCAP_TLS. */
236 //ZZ return VG_(do_syscall1) (__NR_ARM_set_tls, tlsptr);
237 //ZZ #else
238 //ZZ return VG_(mk_SysRes_Success)( 0 );
239 //ZZ #endif
240 //ZZ }
242 /* ---------------------------------------------------------------------
243 PRE/POST wrappers for arm/Linux-specific syscalls
244 ------------------------------------------------------------------ */
246 #define PRE(name) DEFN_PRE_TEMPLATE(arm64_linux, name)
247 #define POST(name) DEFN_POST_TEMPLATE(arm64_linux, name)
249 /* Add prototypes for the wrappers declared here, so that gcc doesn't
250 harass us for not having prototypes. Really this is a kludge --
251 the right thing to do is to make these wrappers 'static' since they
252 aren't visible outside this file, but that requires even more macro
253 magic. */
255 DECL_TEMPLATE(arm64_linux, sys_fadvise64);
256 DECL_TEMPLATE(arm64_linux, sys_mmap);
257 //ZZ DECL_TEMPLATE(arm_linux, sys_stat64);
258 //ZZ DECL_TEMPLATE(arm_linux, sys_lstat64);
259 //ZZ DECL_TEMPLATE(arm_linux, sys_fstatat64);
260 //ZZ DECL_TEMPLATE(arm_linux, sys_fstat64);
261 //ZZ DECL_TEMPLATE(arm_linux, sys_sigreturn);
262 DECL_TEMPLATE(arm64_linux, sys_rt_sigreturn);
263 //ZZ DECL_TEMPLATE(arm_linux, sys_sigsuspend);
264 //ZZ DECL_TEMPLATE(arm_linux, sys_set_tls);
265 //ZZ DECL_TEMPLATE(arm_linux, sys_cacheflush);
266 DECL_TEMPLATE(arm64_linux, sys_ptrace);
268 //ZZ PRE(sys_mmap2)
269 //ZZ {
270 //ZZ SysRes r;
271 //ZZ
272 //ZZ // Exactly like old_mmap() except:
273 //ZZ // - all 6 args are passed in regs, rather than in a memory-block.
274 //ZZ // - the file offset is specified in pagesize units rather than bytes,
275 //ZZ // so that it can be used for files bigger than 2^32 bytes.
276 //ZZ // pagesize or 4K-size units in offset? For ppc32/64-linux, this is
277 //ZZ // 4K-sized. Assert that the page size is 4K here for safety.
278 //ZZ vg_assert(VKI_PAGE_SIZE == 4096);
279 //ZZ PRINT("sys_mmap2 ( %#lx, %llu, %ld, %ld, %ld, %ld )",
280 //ZZ ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, ARG6 );
281 //ZZ PRE_REG_READ6(long, "mmap2",
282 //ZZ unsigned long, start, unsigned long, length,
283 //ZZ unsigned long, prot, unsigned long, flags,
284 //ZZ unsigned long, fd, unsigned long, offset);
285 //ZZ
286 //ZZ r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5,
287 //ZZ 4096 * (Off64T)ARG6 );
288 //ZZ SET_STATUS_from_SysRes(r);
289 //ZZ }
291 // ARM64 FIXME is this correct?
292 PRE(sys_fadvise64)
294 PRINT("sys_fadvise64 ( %ld, %ld, %lu, %ld )", SARG1, SARG2, ARG3, SARG4);
295 PRE_REG_READ4(long, "fadvise64",
296 int, fd, vki_loff_t, offset, vki_size_t, len, int, advice);
299 // ARM64 FIXME is this correct?
300 PRE(sys_mmap)
302 SysRes r;
304 PRINT("sys_mmap ( %#lx, %lu, %lu, %#lx, %lu, %lu )",
305 ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 );
306 PRE_REG_READ6(long, "mmap",
307 unsigned long, start, unsigned long, length,
308 unsigned long, prot, unsigned long, flags,
309 unsigned long, fd, unsigned long, offset);
311 r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6 );
312 SET_STATUS_from_SysRes(r);
315 //ZZ
316 //ZZ // XXX: lstat64/fstat64/stat64 are generic, but not necessarily
317 //ZZ // applicable to every architecture -- I think only to 32-bit archs.
318 //ZZ // We're going to need something like linux/core_os32.h for such
319 //ZZ // things, eventually, I think. --njn
320 //ZZ PRE(sys_lstat64)
321 //ZZ {
322 //ZZ PRINT("sys_lstat64 ( %#lx(%s), %#lx )",ARG1,(char*)ARG1,ARG2);
323 //ZZ PRE_REG_READ2(long, "lstat64", char *, file_name, struct stat64 *, buf);
324 //ZZ PRE_MEM_RASCIIZ( "lstat64(file_name)", ARG1 );
325 //ZZ PRE_MEM_WRITE( "lstat64(buf)", ARG2, sizeof(struct vki_stat64) );
326 //ZZ }
327 //ZZ
328 //ZZ POST(sys_lstat64)
329 //ZZ {
330 //ZZ vg_assert(SUCCESS);
331 //ZZ if (RES == 0) {
332 //ZZ POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) );
333 //ZZ }
334 //ZZ }
335 //ZZ
336 //ZZ PRE(sys_stat64)
337 //ZZ {
338 //ZZ PRINT("sys_stat64 ( %#lx(%s), %#lx )",ARG1,(char*)ARG1,ARG2);
339 //ZZ PRE_REG_READ2(long, "stat64", char *, file_name, struct stat64 *, buf);
340 //ZZ PRE_MEM_RASCIIZ( "stat64(file_name)", ARG1 );
341 //ZZ PRE_MEM_WRITE( "stat64(buf)", ARG2, sizeof(struct vki_stat64) );
342 //ZZ }
343 //ZZ
344 //ZZ POST(sys_stat64)
345 //ZZ {
346 //ZZ POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) );
347 //ZZ }
348 //ZZ
349 //ZZ PRE(sys_fstatat64)
350 //ZZ {
351 //ZZ PRINT("sys_fstatat64 ( %ld, %#lx(%s), %#lx )",ARG1,ARG2,(char*)ARG2,ARG3);
352 //ZZ PRE_REG_READ3(long, "fstatat64",
353 //ZZ int, dfd, char *, file_name, struct stat64 *, buf);
354 //ZZ PRE_MEM_RASCIIZ( "fstatat64(file_name)", ARG2 );
355 //ZZ PRE_MEM_WRITE( "fstatat64(buf)", ARG3, sizeof(struct vki_stat64) );
356 //ZZ }
357 //ZZ
358 //ZZ POST(sys_fstatat64)
359 //ZZ {
360 //ZZ POST_MEM_WRITE( ARG3, sizeof(struct vki_stat64) );
361 //ZZ }
362 //ZZ
363 //ZZ PRE(sys_fstat64)
364 //ZZ {
365 //ZZ PRINT("sys_fstat64 ( %ld, %#lx )",ARG1,ARG2);
366 //ZZ PRE_REG_READ2(long, "fstat64", unsigned long, fd, struct stat64 *, buf);
367 //ZZ PRE_MEM_WRITE( "fstat64(buf)", ARG2, sizeof(struct vki_stat64) );
368 //ZZ }
369 //ZZ
370 //ZZ POST(sys_fstat64)
371 //ZZ {
372 //ZZ POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) );
373 //ZZ }
375 //ZZ PRE(sys_sigreturn)
376 //ZZ {
377 //ZZ /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for
378 //ZZ an explanation of what follows. */
379 //ZZ
380 //ZZ PRINT("sys_sigreturn ( )");
381 //ZZ
382 //ZZ vg_assert(VG_(is_valid_tid)(tid));
383 //ZZ vg_assert(tid >= 1 && tid < VG_N_THREADS);
384 //ZZ vg_assert(VG_(is_running_thread)(tid));
385 //ZZ
386 //ZZ /* Restore register state from frame and remove it */
387 //ZZ VG_(sigframe_destroy)(tid, False);
388 //ZZ
389 //ZZ /* Tell the driver not to update the guest state with the "result",
390 //ZZ and set a bogus result to keep it happy. */
391 //ZZ *flags |= SfNoWriteResult;
392 //ZZ SET_STATUS_Success(0);
393 //ZZ
394 //ZZ /* Check to see if any signals arose as a result of this. */
395 //ZZ *flags |= SfPollAfter;
396 //ZZ }
398 PRE(sys_rt_sigreturn)
400 /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for
401 an explanation of what follows. */
403 PRINT("rt_sigreturn ( )");
405 vg_assert(VG_(is_valid_tid)(tid));
406 vg_assert(tid >= 1 && tid < VG_N_THREADS);
407 vg_assert(VG_(is_running_thread)(tid));
409 /* Restore register state from frame and remove it */
410 VG_(sigframe_destroy)(tid, True);
412 /* Tell the driver not to update the guest state with the "result",
413 and set a bogus result to keep it happy. */
414 *flags |= SfNoWriteResult;
415 SET_STATUS_Success(0);
417 /* Check to see if any signals arose as a result of this. */
418 *flags |= SfPollAfter;
421 //ZZ /* NB: clone of x86-linux version, and ppc32-linux has an almost
422 //ZZ identical one. */
423 //ZZ PRE(sys_sigsuspend)
424 //ZZ {
425 //ZZ /* The C library interface to sigsuspend just takes a pointer to
426 //ZZ a signal mask but this system call has three arguments - the first
427 //ZZ two don't appear to be used by the kernel and are always passed as
428 //ZZ zero by glibc and the third is the first word of the signal mask
429 //ZZ so only 32 signals are supported.
430 //ZZ
431 //ZZ In fact glibc normally uses rt_sigsuspend if it is available as
432 //ZZ that takes a pointer to the signal mask so supports more signals.
433 //ZZ */
434 //ZZ *flags |= SfMayBlock;
435 //ZZ PRINT("sys_sigsuspend ( %ld, %ld, %ld )", ARG1,ARG2,ARG3 );
436 //ZZ PRE_REG_READ3(int, "sigsuspend",
437 //ZZ int, history0, int, history1,
438 //ZZ vki_old_sigset_t, mask);
439 //ZZ }
440 //ZZ
441 //ZZ /* Very much ARM specific */
442 //ZZ
443 //ZZ PRE(sys_set_tls)
444 //ZZ {
445 //ZZ PRINT("set_tls (%lx)",ARG1);
446 //ZZ PRE_REG_READ1(long, "set_tls", unsigned long, addr);
447 //ZZ
448 //ZZ SET_STATUS_from_SysRes( sys_set_tls( tid, ARG1 ) );
449 //ZZ }
450 //ZZ
451 //ZZ PRE(sys_cacheflush)
452 //ZZ {
453 //ZZ PRINT("cacheflush (%lx, %#lx, %#lx)",ARG1,ARG2,ARG3);
454 //ZZ PRE_REG_READ3(long, "cacheflush", void*, addrlow,void*, addrhigh,int, flags);
455 //ZZ VG_(discard_translations)( (Addr)ARG1,
456 //ZZ ((ULong)ARG2) - ((ULong)ARG1) + 1ULL/*paranoia*/,
457 //ZZ "PRE(sys_cacheflush)" );
458 //ZZ SET_STATUS_Success(0);
459 //ZZ }
461 // ARG3 is only used for pointers into the traced process's address
462 // space and for offsets into the traced process's struct
463 // user_regs_struct. It is never a pointer into this process's memory
464 // space, and we should therefore not check anything it points to.
465 PRE(sys_ptrace)
467 PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )",
468 (Word)ARG1,(Word)ARG2,ARG3,ARG4);
469 PRE_REG_READ4(int, "ptrace",
470 long, request, long, pid, long, addr, long, data);
471 switch (ARG1) {
472 case VKI_PTRACE_PEEKTEXT:
473 case VKI_PTRACE_PEEKDATA:
474 case VKI_PTRACE_PEEKUSR:
475 PRE_MEM_WRITE( "ptrace(peek)", ARG4,
476 sizeof (long));
477 break;
478 case VKI_PTRACE_GETEVENTMSG:
479 PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4, sizeof(unsigned long));
480 break;
481 case VKI_PTRACE_GETSIGINFO:
482 PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t));
483 break;
484 case VKI_PTRACE_SETSIGINFO:
485 PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t));
486 break;
487 case VKI_PTRACE_GETREGSET:
488 ML_(linux_PRE_getregset)(tid, ARG3, ARG4);
489 break;
490 case VKI_PTRACE_SETREGSET:
491 ML_(linux_PRE_setregset)(tid, ARG3, ARG4);
492 break;
493 default:
494 break;
498 POST(sys_ptrace)
500 switch (ARG1) {
501 case VKI_PTRACE_TRACEME:
502 ML_(linux_POST_traceme)(tid);
503 break;
504 case VKI_PTRACE_PEEKTEXT:
505 case VKI_PTRACE_PEEKDATA:
506 case VKI_PTRACE_PEEKUSR:
507 POST_MEM_WRITE( ARG4, sizeof (long));
508 break;
509 case VKI_PTRACE_GETEVENTMSG:
510 POST_MEM_WRITE( ARG4, sizeof(unsigned long));
511 break;
512 case VKI_PTRACE_GETSIGINFO:
513 /* XXX: This is a simplification. Different parts of the
514 * siginfo_t are valid depending on the type of signal.
516 POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t));
517 break;
518 case VKI_PTRACE_GETREGSET:
519 ML_(linux_POST_getregset)(tid, ARG3, ARG4);
520 break;
521 default:
522 break;
526 #undef PRE
527 #undef POST
529 /* ---------------------------------------------------------------------
530 The arm64/Linux syscall table
531 ------------------------------------------------------------------ */
533 //ZZ #if 0
534 //ZZ #define __NR_OABI_SYSCALL_BASE 0x900000
535 //ZZ #else
536 //ZZ #define __NR_OABI_SYSCALL_BASE 0x0
537 //ZZ #endif
539 #define PLAX_(sysno, name) WRAPPER_ENTRY_X_(arm64_linux, sysno, name)
540 #define PLAXY(sysno, name) WRAPPER_ENTRY_XY(arm64_linux, sysno, name)
542 // This table maps from __NR_xxx syscall numbers (from
543 // linux/include/asm-arm/unistd.h) to the appropriate PRE/POST sys_foo()
544 // wrappers on arm64 (as per sys_call_table in linux/arch/arm/kernel/entry.S).
546 // For those syscalls not handled by Valgrind, the annotation indicate its
547 // arch/OS combination, eg. */* (generic), */Linux (Linux only), ?/?
548 // (unknown).
550 static SyscallTableEntry syscall_main_table[] = {
551 LINXY(__NR_io_setup, sys_io_setup), // 0
552 LINX_(__NR_io_destroy, sys_io_destroy), // 1
553 LINX_(__NR_io_submit, sys_io_submit), // 2
554 LINXY(__NR_io_cancel, sys_io_cancel), // 3
555 LINXY(__NR_io_getevents, sys_io_getevents), // 4
556 LINX_(__NR_setxattr, sys_setxattr), // 5
557 LINX_(__NR_lsetxattr, sys_lsetxattr), // 6
558 LINX_(__NR_fsetxattr, sys_fsetxattr), // 7
559 LINXY(__NR_getxattr, sys_getxattr), // 8
560 LINXY(__NR_lgetxattr, sys_lgetxattr), // 9
561 LINXY(__NR_fgetxattr, sys_fgetxattr), // 10
562 LINXY(__NR_listxattr, sys_listxattr), // 11
563 LINXY(__NR_llistxattr, sys_llistxattr), // 12
564 LINXY(__NR_flistxattr, sys_flistxattr), // 13
565 LINX_(__NR_removexattr, sys_removexattr), // 14
566 LINX_(__NR_lremovexattr, sys_lremovexattr), // 15
567 LINX_(__NR_fremovexattr, sys_fremovexattr), // 16
568 GENXY(__NR_getcwd, sys_getcwd), // 17
569 LINXY(__NR_lookup_dcookie, sys_lookup_dcookie), // 18
570 LINXY(__NR_eventfd2, sys_eventfd2), // 19
571 LINXY(__NR_epoll_create1, sys_epoll_create1), // 20
572 LINX_(__NR_epoll_ctl, sys_epoll_ctl), // 21
573 LINXY(__NR_epoll_pwait, sys_epoll_pwait), // 22
574 GENXY(__NR_dup, sys_dup), // 23
575 LINXY(__NR_dup3, sys_dup3), // 24
576 LINXY(__NR_fcntl, sys_fcntl), // 25
577 LINXY(__NR_inotify_init1, sys_inotify_init1), // 26
578 LINX_(__NR_inotify_add_watch, sys_inotify_add_watch), // 27
579 LINX_(__NR_inotify_rm_watch, sys_inotify_rm_watch), // 28
580 LINXY(__NR_ioctl, sys_ioctl), // 29
581 LINX_(__NR_ioprio_set, sys_ioprio_set), // 30
582 LINX_(__NR_ioprio_get, sys_ioprio_get), // 31
583 GENX_(__NR_flock, sys_flock), // 32
584 LINX_(__NR_mknodat, sys_mknodat), // 33
585 LINX_(__NR_mkdirat, sys_mkdirat), // 34
586 LINX_(__NR_unlinkat, sys_unlinkat), // 35
587 LINX_(__NR_symlinkat, sys_symlinkat), // 36
588 LINX_(__NR_linkat, sys_linkat), // 37
589 LINX_(__NR_renameat, sys_renameat), // 38
590 LINX_(__NR_umount2, sys_umount), // 39
591 LINX_(__NR_mount, sys_mount), // 40
592 LINX_(__NR_pivot_root, sys_pivot_root), // 41
593 // (__NR_nfsservctl, sys_ni_syscall), // 42
594 GENXY(__NR_statfs, sys_statfs), // 43
595 GENXY(__NR_fstatfs, sys_fstatfs), // 44
596 GENX_(__NR_truncate, sys_truncate), // 45
597 GENX_(__NR_ftruncate, sys_ftruncate), // 46
598 LINX_(__NR_fallocate, sys_fallocate), // 47
599 LINX_(__NR_faccessat, sys_faccessat), // 48
600 GENX_(__NR_chdir, sys_chdir), // 49
601 GENX_(__NR_fchdir, sys_fchdir), // 50
602 GENX_(__NR_chroot, sys_chroot), // 51
603 GENX_(__NR_fchmod, sys_fchmod), // 52
604 LINX_(__NR_fchmodat, sys_fchmodat), // 53
605 LINX_(__NR_fchownat, sys_fchownat), // 54
606 GENX_(__NR_fchown, sys_fchown), // 55
607 LINXY(__NR_openat, sys_openat), // 56
608 GENXY(__NR_close, sys_close), // 57
609 LINX_(__NR_vhangup, sys_vhangup), // 58
610 LINXY(__NR_pipe2, sys_pipe2), // 59
611 LINX_(__NR_quotactl, sys_quotactl), // 60
612 GENXY(__NR_getdents64, sys_getdents64), // 61
613 LINX_(__NR_lseek, sys_lseek), // 62
614 GENXY(__NR_read, sys_read), // 63
615 GENX_(__NR_write, sys_write), // 64
616 GENXY(__NR_readv, sys_readv), // 65
617 GENX_(__NR_writev, sys_writev), // 66
618 GENXY(__NR_pread64, sys_pread64), // 67
619 GENX_(__NR_pwrite64, sys_pwrite64), // 68
620 LINXY(__NR_preadv, sys_preadv), // 69
621 LINX_(__NR_pwritev, sys_pwritev), // 70
622 LINXY(__NR_sendfile, sys_sendfile), // 71
623 LINXY(__NR_pselect6, sys_pselect6), // 72
624 LINXY(__NR_ppoll, sys_ppoll), // 73
625 LINXY(__NR_signalfd4, sys_signalfd4), // 74
626 LINX_(__NR_vmsplice, sys_vmsplice), // 75
627 LINX_(__NR_splice, sys_splice), // 76
628 LINX_(__NR_tee, sys_tee), // 77
629 LINX_(__NR_readlinkat, sys_readlinkat), // 78
630 LINXY(__NR_newfstatat, sys_newfstatat), // 79
631 GENXY(__NR_fstat, sys_newfstat), // 80
632 GENX_(__NR_sync, sys_sync), // 81
633 GENX_(__NR_fsync, sys_fsync), // 82
634 GENX_(__NR_fdatasync, sys_fdatasync), // 83
635 LINX_(__NR_sync_file_range, sys_sync_file_range), // 84
636 LINXY(__NR_timerfd_create, sys_timerfd_create), // 85
637 LINXY(__NR_timerfd_settime, sys_timerfd_settime), // 86
638 LINXY(__NR_timerfd_gettime, sys_timerfd_gettime), // 87
639 LINX_(__NR_utimensat, sys_utimensat), // 88
640 GENX_(__NR_acct, sys_acct), // 89
641 LINXY(__NR_capget, sys_capget), // 90
642 LINX_(__NR_capset, sys_capset), // 91
643 LINX_(__NR_personality, sys_personality), // 92
644 GENX_(__NR_exit, sys_exit), // 93
645 LINX_(__NR_exit_group, sys_exit_group), // 94
646 LINXY(__NR_waitid, sys_waitid), // 95
647 LINX_(__NR_set_tid_address, sys_set_tid_address), // 96
648 LINX_(__NR_unshare, sys_unshare), // 97
649 LINXY(__NR_futex, sys_futex), // 98
650 LINX_(__NR_set_robust_list, sys_set_robust_list), // 99
651 LINXY(__NR_get_robust_list, sys_get_robust_list), // 100
652 GENXY(__NR_nanosleep, sys_nanosleep), // 101
653 GENXY(__NR_getitimer, sys_getitimer), // 102
654 GENXY(__NR_setitimer, sys_setitimer), // 103
655 GENX_(__NR_kexec_load, sys_ni_syscall), // 104
656 LINX_(__NR_init_module, sys_init_module), // 105
657 LINX_(__NR_delete_module, sys_delete_module), // 106
658 LINXY(__NR_timer_create, sys_timer_create), // 107
659 LINXY(__NR_timer_gettime, sys_timer_gettime), // 108
660 LINX_(__NR_timer_getoverrun, sys_timer_getoverrun), // 109
661 LINXY(__NR_timer_settime, sys_timer_settime), // 110
662 LINX_(__NR_timer_delete, sys_timer_delete), // 111
663 LINX_(__NR_clock_settime, sys_clock_settime), // 112
664 LINXY(__NR_clock_gettime, sys_clock_gettime), // 113
665 LINXY(__NR_clock_getres, sys_clock_getres), // 114
666 LINXY(__NR_clock_nanosleep, sys_clock_nanosleep), // 115
667 LINXY(__NR_syslog, sys_syslog), // 116
668 PLAXY(__NR_ptrace, sys_ptrace), // 117
669 LINXY(__NR_sched_setparam, sys_sched_setparam), // 118
670 LINX_(__NR_sched_setscheduler,sys_sched_setscheduler),// 119
671 LINX_(__NR_sched_getscheduler,sys_sched_getscheduler),// 120
672 LINXY(__NR_sched_getparam, sys_sched_getparam), // 121
673 LINX_(__NR_sched_setaffinity, sys_sched_setaffinity), // 122
674 LINXY(__NR_sched_getaffinity, sys_sched_getaffinity), // 123
675 LINX_(__NR_sched_yield, sys_sched_yield), // 124
676 LINX_(__NR_sched_get_priority_max, sys_sched_get_priority_max),// 125
677 LINX_(__NR_sched_get_priority_min, sys_sched_get_priority_min),// 126
678 LINXY(__NR_sched_rr_get_interval, sys_sched_rr_get_interval),// 127
679 // (__NR_restart_syscall, sys_ni_syscall), // 128
680 GENX_(__NR_kill, sys_kill), // 129
681 LINXY(__NR_tkill, sys_tkill), // 130
682 LINX_(__NR_tgkill, sys_tgkill), // 131
683 GENXY(__NR_sigaltstack, sys_sigaltstack), // 132
684 LINX_(__NR_rt_sigsuspend, sys_rt_sigsuspend), // 133
685 LINXY(__NR_rt_sigaction, sys_rt_sigaction), // 134
686 LINXY(__NR_rt_sigprocmask, sys_rt_sigprocmask), // 135
687 LINXY(__NR_rt_sigpending, sys_rt_sigpending), // 136
688 LINXY(__NR_rt_sigtimedwait, sys_rt_sigtimedwait), // 137
689 LINXY(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo), // 138
690 PLAX_(__NR_rt_sigreturn, sys_rt_sigreturn), // 139
691 GENX_(__NR_setpriority, sys_setpriority), // 140
692 GENX_(__NR_getpriority, sys_getpriority), // 141
693 // (__NR_reboot, sys_ni_syscall), // 142
694 GENX_(__NR_setregid, sys_setregid), // 143
695 GENX_(__NR_setgid, sys_setgid), // 144
696 GENX_(__NR_setreuid, sys_setreuid), // 145
697 GENX_(__NR_setuid, sys_setuid), // 146
698 LINX_(__NR_setresuid, sys_setresuid), // 147
699 LINXY(__NR_getresuid, sys_getresuid), // 148
700 LINX_(__NR_setresgid, sys_setresgid), // 149
701 LINXY(__NR_getresgid, sys_getresgid), // 150
702 LINX_(__NR_setfsuid, sys_setfsuid), // 151
703 LINX_(__NR_setfsgid, sys_setfsgid), // 152
704 GENXY(__NR_times, sys_times), // 153
705 GENX_(__NR_setpgid, sys_setpgid), // 154
706 GENX_(__NR_getpgid, sys_getpgid), // 155
707 GENX_(__NR_getsid, sys_getsid), // 156
708 GENX_(__NR_setsid, sys_setsid), // 157
709 GENXY(__NR_getgroups, sys_getgroups), // 158
710 GENX_(__NR_setgroups, sys_setgroups), // 159
711 GENXY(__NR_uname, sys_newuname), // 160
712 GENX_(__NR_sethostname, sys_sethostname), // 161
713 // (__NR_setdomainname, sys_ni_syscall), // 162
714 GENXY(__NR_getrlimit, sys_old_getrlimit), // 163
715 GENX_(__NR_setrlimit, sys_setrlimit), // 164
716 GENXY(__NR_getrusage, sys_getrusage), // 165
717 GENX_(__NR_umask, sys_umask), // 166
718 LINXY(__NR_prctl, sys_prctl), // 167
719 LINXY(__NR_getcpu, sys_getcpu), // 168
720 GENXY(__NR_gettimeofday, sys_gettimeofday), // 169
721 GENX_(__NR_settimeofday, sys_settimeofday), // 170
722 LINXY(__NR_adjtimex, sys_adjtimex), // 171
723 GENX_(__NR_getpid, sys_getpid), // 172
724 GENX_(__NR_getppid, sys_getppid), // 173
725 GENX_(__NR_getuid, sys_getuid), // 174
726 GENX_(__NR_geteuid, sys_geteuid), // 175
727 GENX_(__NR_getgid, sys_getgid), // 176
728 GENX_(__NR_getegid, sys_getegid), // 177
729 LINX_(__NR_gettid, sys_gettid), // 178
730 LINXY(__NR_sysinfo, sys_sysinfo), // 179
731 LINXY(__NR_mq_open, sys_mq_open), // 180
732 LINX_(__NR_mq_unlink, sys_mq_unlink), // 181
733 LINX_(__NR_mq_timedsend, sys_mq_timedsend), // 182
734 LINXY(__NR_mq_timedreceive, sys_mq_timedreceive), // 183
735 LINX_(__NR_mq_notify, sys_mq_notify), // 184
736 LINXY(__NR_mq_getsetattr, sys_mq_getsetattr), // 185
737 LINX_(__NR_msgget, sys_msgget), // 186
738 LINXY(__NR_msgctl, sys_msgctl), // 187
739 LINXY(__NR_msgrcv, sys_msgrcv), // 188
740 LINX_(__NR_msgsnd, sys_msgsnd), // 189
741 LINX_(__NR_semget, sys_semget), // 190
742 LINXY(__NR_semctl, sys_semctl), // 191
743 LINX_(__NR_semtimedop, sys_semtimedop), // 192
744 LINX_(__NR_semop, sys_semop), // 193
745 LINX_(__NR_shmget, sys_shmget), // 194
746 LINXY(__NR_shmctl, sys_shmctl), // 195
747 LINXY(__NR_shmat, sys_shmat), // 196
748 LINXY(__NR_shmdt, sys_shmdt), // 197
749 LINXY(__NR_socket, sys_socket), // 198
750 LINXY(__NR_socketpair, sys_socketpair), // 199
751 LINX_(__NR_bind, sys_bind), // 200
752 LINX_(__NR_listen, sys_listen), // 201
753 LINXY(__NR_accept, sys_accept), // 202
754 LINX_(__NR_connect, sys_connect), // 203
755 LINXY(__NR_getsockname, sys_getsockname), // 204
756 LINXY(__NR_getpeername, sys_getpeername), // 205
757 LINX_(__NR_sendto, sys_sendto), // 206
758 LINXY(__NR_recvfrom, sys_recvfrom), // 207
759 LINX_(__NR_setsockopt, sys_setsockopt), // 208
760 LINXY(__NR_getsockopt, sys_getsockopt), // 209
761 LINX_(__NR_shutdown, sys_shutdown), // 210
762 LINX_(__NR_sendmsg, sys_sendmsg), // 211
763 LINXY(__NR_recvmsg, sys_recvmsg), // 212
764 LINX_(__NR_readahead, sys_readahead), // 213
765 GENX_(__NR_brk, sys_brk), // 214
766 GENXY(__NR_munmap, sys_munmap), // 215
767 GENX_(__NR_mremap, sys_mremap), // 216
768 LINX_(__NR_add_key, sys_add_key), // 217
769 LINX_(__NR_request_key, sys_request_key), // 218
770 LINXY(__NR_keyctl, sys_keyctl), // 219
771 LINX_(__NR_clone, sys_clone), // 220
772 GENX_(__NR_execve, sys_execve), // 221
773 PLAX_(__NR_mmap, sys_mmap), // 222
774 PLAX_(__NR_fadvise64, sys_fadvise64), // 223
775 // (__NR_swapon, sys_swapon), // 224
776 // (__NR_swapoff, sys_swapoff), // 225
777 GENXY(__NR_mprotect, sys_mprotect), // 226
778 GENX_(__NR_msync, sys_msync), // 227
779 GENX_(__NR_mlock, sys_mlock), // 228
780 GENX_(__NR_munlock, sys_munlock), // 229
781 GENX_(__NR_mlockall, sys_mlockall), // 230
782 LINX_(__NR_munlockall, sys_munlockall), // 231
783 GENXY(__NR_mincore, sys_mincore), // 232
784 GENX_(__NR_madvise, sys_madvise), // 233
785 // (__NR_remap_file_pages, sys_ni_syscall) // 234
786 LINX_(__NR_mbind, sys_mbind), // 235
787 LINXY(__NR_get_mempolicy, sys_get_mempolicy), // 236
788 LINX_(__NR_set_mempolicy, sys_set_mempolicy), // 237
789 // (__NR_migrate_pages, sys_ni_syscall), // 238
790 LINXY(__NR_move_pages, sys_move_pages), // 239
791 LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo), // 240
792 LINXY(__NR_perf_event_open, sys_perf_event_open), // 241
793 LINXY(__NR_accept4, sys_accept4), // 242
794 LINXY(__NR_recvmmsg, sys_recvmmsg), // 243
795 GENXY(__NR_wait4, sys_wait4), // 260
796 LINXY(__NR_prlimit64, sys_prlimit64), // 261
797 LINXY(__NR_fanotify_init, sys_fanotify_init), // 262
798 LINX_(__NR_fanotify_mark, sys_fanotify_mark), // 263
799 LINXY(__NR_name_to_handle_at, sys_name_to_handle_at), // 264
800 LINXY(__NR_open_by_handle_at, sys_open_by_handle_at), // 265
801 LINXY(__NR_clock_adjtime, sys_clock_adjtime), // 266
802 LINX_(__NR_syncfs, sys_syncfs), // 267
803 LINX_(__NR_setns, sys_setns), // 268
804 LINXY(__NR_sendmmsg, sys_sendmmsg), // 269
805 LINXY(__NR_process_vm_readv, sys_process_vm_readv), // 270
806 LINX_(__NR_process_vm_writev, sys_process_vm_writev), // 271
807 LINX_(__NR_kcmp, sys_kcmp), // 272
808 LINX_(__NR_finit_module, sys_finit_module), // 273
809 LINX_(__NR_sched_setattr, sys_sched_setattr), // 274
810 LINXY(__NR_sched_getattr, sys_sched_getattr), // 275
811 LINX_(__NR_renameat2, sys_renameat2), // 276
812 // (__NR_seccomp, sys_ni_syscall), // 277
813 LINXY(__NR_getrandom, sys_getrandom), // 278
814 LINXY(__NR_memfd_create, sys_memfd_create), // 279
815 LINXY(__NR_bpf, sys_bpf), // 280
816 LINX_(__NR_execveat, sys_execveat), // 281
817 // (__NR_userfaultfd, sys_ni_syscall), // 282
818 LINX_(__NR_membarrier, sys_membarrier), // 283
819 // (__NR_mlock2, sys_ni_syscall), // 284
820 LINX_(__NR_copy_file_range, sys_copy_file_range), // 285
821 LINXY(__NR_preadv2, sys_preadv2), // 286
822 LINX_(__NR_pwritev2, sys_pwritev2), // 287
823 // (__NR_pkey_mprotect, sys_ni_syscall), // 288
824 // (__NR_pkey_alloc, sys_ni_syscall), // 289
825 // (__NR_pkey_free, sys_ni_syscall), // 290
826 LINXY(__NR_statx, sys_statx), // 291
828 GENX_(__NR_rseq, sys_ni_syscall), // 293
830 LINXY(__NR_io_uring_setup, sys_io_uring_setup), // 425
831 LINXY(__NR_io_uring_enter, sys_io_uring_enter), // 426
832 LINXY(__NR_io_uring_register, sys_io_uring_register), // 427
834 LINXY(__NR_pidfd_open, sys_pidfd_open), // 434
835 GENX_(__NR_clone3, sys_ni_syscall), // 435
836 LINXY(__NR_close_range, sys_close_range), // 436
838 LINX_(__NR_faccessat2, sys_faccessat2), // 439
840 LINXY(__NR_memfd_secret, sys_memfd_secret), // 447
844 //ZZ /* These are not in the main table because there indexes are not small
845 //ZZ integers, but rather values close to one million. So their
846 //ZZ inclusion would force the main table to be huge (about 8 MB). */
847 //ZZ
848 //ZZ static SyscallTableEntry ste___ARM_set_tls
849 //ZZ = { WRAPPER_PRE_NAME(arm_linux,sys_set_tls), NULL };
850 //ZZ
851 //ZZ static SyscallTableEntry ste___ARM_cacheflush
852 //ZZ = { WRAPPER_PRE_NAME(arm_linux,sys_cacheflush), NULL };
854 SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
856 const UInt syscall_main_table_size
857 = sizeof(syscall_main_table) / sizeof(syscall_main_table[0]);
859 /* Is it in the contiguous initial section of the table? */
860 if (sysno < syscall_main_table_size) {
861 SyscallTableEntry* sys = &syscall_main_table[sysno];
862 if (sys->before == NULL)
863 return NULL; /* no entry */
864 else
865 return sys;
868 //ZZ /* Check if it's one of the out-of-line entries. */
869 //ZZ switch (sysno) {
870 //ZZ case __NR_ARM_set_tls: return &ste___ARM_set_tls;
871 //ZZ case __NR_ARM_cacheflush: return &ste___ARM_cacheflush;
872 //ZZ default: break;
873 //ZZ }
875 /* Can't find a wrapper */
876 return NULL;
879 #endif // defined(VGP_arm64_linux)
881 /*--------------------------------------------------------------------*/
882 /*--- end syswrap-arm64-linux.c ---*/
883 /*--------------------------------------------------------------------*/