2 * Copyright (c) 2005 The Regents of The University of Michigan
3 * Copyright (c) 2007 MIPS Technologies, Inc.
4 * Copyright (c) 2016 The University of Virginia
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met: redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer;
11 * redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution;
14 * neither the name of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "arch/riscv/linux/process.hh"
35 #include "arch/riscv/isa_traits.hh"
36 #include "arch/riscv/linux/linux.hh"
37 #include "base/loader/object_file.hh"
38 #include "base/trace.hh"
39 #include "cpu/thread_context.hh"
40 #include "debug/SyscallVerbose.hh"
41 #include "kern/linux/linux.hh"
42 #include "sim/eventq.hh"
43 #include "sim/process.hh"
44 #include "sim/syscall_desc.hh"
45 #include "sim/syscall_emul.hh"
46 #include "sim/system.hh"
49 using namespace RiscvISA
;
54 class RiscvLinuxObjectFileLoader
: public Process::Loader
58 load(ProcessParams
*params
, ObjectFile
*obj_file
) override
60 auto arch
= obj_file
->getArch();
61 auto opsys
= obj_file
->getOpSys();
63 if (arch
!= ObjectFile::Riscv64
&& arch
!= ObjectFile::Riscv32
)
66 if (opsys
== ObjectFile::UnknownOpSys
) {
67 warn("Unknown operating system; assuming Linux.");
68 opsys
= ObjectFile::Linux
;
71 if (opsys
!= ObjectFile::Linux
)
74 if (arch
== ObjectFile::Riscv64
)
75 return new RiscvLinuxProcess64(params
, obj_file
);
77 return new RiscvLinuxProcess32(params
, obj_file
);
81 RiscvLinuxObjectFileLoader loader
;
83 } // anonymous namespace
85 /// Target uname() handler.
87 unameFunc64(SyscallDesc
*desc
, int callnum
, ThreadContext
*tc
)
90 auto process
= tc
->getProcessPtr();
91 TypedBufferArg
<Linux::utsname
> name(process
->getSyscallArg(tc
, index
));
93 strcpy(name
->sysname
, "Linux");
94 strcpy(name
->nodename
,"sim.gem5.org");
95 strcpy(name
->release
, process
->release
.c_str());
96 strcpy(name
->version
, "#1 Mon Aug 18 11:32:15 EDT 2003");
97 strcpy(name
->machine
, "riscv64");
99 name
.copyOut(tc
->getVirtProxy());
103 /// Target uname() handler.
105 unameFunc32(SyscallDesc
*desc
, int callnum
, ThreadContext
*tc
)
108 auto process
= tc
->getProcessPtr();
109 TypedBufferArg
<Linux::utsname
> name(process
->getSyscallArg(tc
, index
));
111 strcpy(name
->sysname
, "Linux");
112 strcpy(name
->nodename
,"sim.gem5.org");
113 strcpy(name
->release
, process
->release
.c_str());
114 strcpy(name
->version
, "#1 Mon Aug 18 11:32:15 EDT 2003");
115 strcpy(name
->machine
, "riscv32");
117 name
.copyOut(tc
->getVirtProxy());
121 std::map
<int, SyscallDescABI
<DefaultSyscallABI
>>
122 RiscvLinuxProcess64::syscallDescs
= {
124 {1, { "io_destroy" }},
125 {2, { "io_submit" }},
126 {3, { "io_cancel" }},
127 {4, { "io_getevents" }},
129 {6, { "lsetxattr" }},
130 {7, { "fsetxattr" }},
132 {9, { "lgetxattr" }},
133 {10, { "fgetxattr" }},
134 {11, { "listxattr" }},
135 {12, { "llistxattr" }},
136 {13, { "flistxattr" }},
137 {14, { "removexattr" }},
138 {15, { "lremovexattr" }},
139 {16, { "fremovexattr" }},
140 {17, { "getcwd", getcwdFunc
}},
141 {18, { "lookup_dcookie" }},
142 {19, { "eventfd2" }},
143 {20, { "epoll_create1" }},
144 {21, { "epoll_ctl" }},
145 {22, { "epoll_pwait" }},
146 {23, { "dup", dupFunc
}},
148 {25, { "fcntl", fcntl64Func
}},
149 {26, { "inotify_init1" }},
150 {27, { "inotify_add_watch" }},
151 {28, { "inotify_rm_watch" }},
152 {29, { "ioctl", ioctlFunc
<RiscvLinux64
> }},
153 {30, { "ioprio_get" }},
154 {31, { "ioprio_set" }},
158 {35, { "unlinkat", unlinkatFunc
<RiscvLinux64
> }},
159 {36, { "symlinkat" }},
161 {38, { "renameat", renameatFunc
<RiscvLinux64
> }},
164 {41, { "pivot_root" }},
165 {42, { "nfsservctl" }},
166 {43, { "statfs", statfsFunc
<RiscvLinux64
> }},
167 {44, { "fstatfs", fstatfsFunc
<RiscvLinux64
> }},
168 {45, { "truncate", truncateFunc
}},
169 {46, { "ftruncate", ftruncate64Func
}},
170 {47, { "fallocate", fallocateFunc
}},
171 {48, { "faccessat", faccessatFunc
<RiscvLinux64
> }},
175 {52, { "fchmod", fchmodFunc
<RiscvLinux64
> }},
176 {53, { "fchmodat" }},
177 {54, { "fchownat" }},
178 {55, { "fchown", fchownFunc
}},
179 {56, { "openat", openatFunc
<RiscvLinux64
> }},
180 {57, { "close", closeFunc
}},
183 {60, { "quotactl" }},
184 {61, { "getdents64" }},
185 {62, { "lseek", lseekFunc
}},
186 {63, { "read", readFunc
<RiscvLinux64
> }},
187 {64, { "write", writeFunc
<RiscvLinux64
> }},
188 {66, { "writev", writevFunc
<RiscvLinux64
> }},
190 {68, { "pwrite64", pwrite64Func
<RiscvLinux64
> }},
193 {71, { "sendfile" }},
194 {72, { "pselect6" }},
196 {74, { "signalfd64" }},
197 {75, { "vmsplice" }},
200 {78, { "readlinkat", readlinkatFunc
<RiscvLinux64
> }},
201 {79, { "fstatat", fstatat64Func
<RiscvLinux64
> }},
202 {80, { "fstat", fstat64Func
<RiscvLinux64
> }},
205 {83, { "fdatasync" }},
206 {84, { "sync_file_range2" }},
207 {85, { "timerfd_create" }},
208 {86, { "timerfd_settime" }},
209 {87, { "timerfd_gettime" }},
210 {88, { "utimensat" }},
214 {92, { "personality" }},
215 {93, { "exit", exitFunc
}},
216 {94, { "exit_group", exitGroupFunc
}},
218 {96, { "set_tid_address", setTidAddressFunc
}},
220 {98, { "futex", futexFunc
<RiscvLinux64
> }},
221 {99, { "set_robust_list", ignoreWarnOnceFunc
}},
222 {100, { "get_robust_list", ignoreWarnOnceFunc
}},
223 {101, { "nanosleep", ignoreWarnOnceFunc
}},
224 {102, { "getitimer" }},
225 {103, { "setitimer" }},
226 {104, { "kexec_load" }},
227 {105, { "init_module" }},
228 {106, { "delete_module" }},
229 {107, { "timer_create" }},
230 {108, { "timer_gettime" }},
231 {109, { "timer_getoverrun" }},
232 {110, { "timer_settime" }},
233 {111, { "timer_delete" }},
234 {112, { "clock_settime" }},
235 {113, { "clock_gettime", clock_gettimeFunc
<RiscvLinux64
> }},
236 {114, { "clock_getres", clock_getresFunc
<RiscvLinux64
> }},
237 {115, { "clock_nanosleep" }},
240 {118, { "sched_setparam" }},
241 {119, { "sched_setscheduler" }},
242 {120, { "sched_getscheduler" }},
243 {121, { "sched_getparam" }},
244 {122, { "sched_setaffinity" }},
245 {123, { "sched_getaffinity" }},
246 {124, { "sched_yield", ignoreWarnOnceFunc
}},
247 {125, { "sched_get_priority_max" }},
248 {126, { "sched_get_priority_min" }},
249 {127, { "scheD_rr_get_interval" }},
250 {128, { "restart_syscall" }},
253 {131, { "tgkill", tgkillFunc
<RiscvLinux64
> }},
254 {132, { "sigaltstack" }},
255 {133, { "rt_sigsuspend", ignoreWarnOnceFunc
}},
256 {134, { "rt_sigaction", ignoreWarnOnceFunc
}},
257 {135, { "rt_sigprocmask", ignoreWarnOnceFunc
}},
258 {136, { "rt_sigpending", ignoreWarnOnceFunc
}},
259 {137, { "rt_sigtimedwait", ignoreWarnOnceFunc
}},
260 {138, { "rt_sigqueueinfo", ignoreWarnOnceFunc
}},
261 {139, { "rt_sigreturn", ignoreWarnOnceFunc
}},
262 {140, { "setpriority" }},
263 {141, { "getpriority" }},
265 {143, { "setregid" }},
267 {145, { "setreuid" }},
268 {146, { "setuid", ignoreFunc
}},
269 {147, { "setresuid" }},
270 {148, { "getresuid" }},
271 {149, { "getresgid" }},
272 {150, { "getresgid" }},
273 {151, { "setfsuid" }},
274 {152, { "setfsgid" }},
275 {153, { "times", timesFunc
<RiscvLinux64
> }},
276 {154, { "setpgid", setpgidFunc
}},
277 {155, { "getpgid" }},
280 {158, { "getgroups" }},
281 {159, { "setgroups" }},
282 {160, { "uname", unameFunc64
}},
283 {161, { "sethostname" }},
284 {162, { "setdomainname" }},
285 {163, { "getrlimit", getrlimitFunc
<RiscvLinux64
> }},
286 {164, { "setrlimit", ignoreFunc
}},
287 {165, { "getrusage", getrusageFunc
<RiscvLinux64
> }},
288 {166, { "umask", umaskFunc
}},
291 {169, { "gettimeofday", gettimeofdayFunc
<RiscvLinux64
> }},
292 {170, { "settimeofday" }},
293 {171, { "adjtimex" }},
294 {172, { "getpid", getpidFunc
}},
295 {173, { "getppid", getppidFunc
}},
296 {174, { "getuid", getuidFunc
}},
297 {175, { "geteuid", geteuidFunc
}},
298 {176, { "getgid", getgidFunc
}},
299 {177, { "getegid", getegidFunc
}},
300 {178, { "gettid", gettidFunc
}},
301 {179, { "sysinfo", sysinfoFunc
<RiscvLinux64
> }},
302 {180, { "mq_open" }},
303 {181, { "mq_unlink" }},
304 {182, { "mq_timedsend" }},
305 {183, { "mq_timedrecieve" }},
306 {184, { "mq_notify" }},
307 {185, { "mq_getsetattr" }},
314 {192, { "semtimedop" }},
321 {199, { "socketpair" }},
325 {203, { "connect" }},
326 {204, { "getsockname" }},
327 {205, { "getpeername" }},
329 {207, { "recvfrom" }},
330 {208, { "setsockopt" }},
331 {209, { "getsockopt" }},
332 {210, { "shutdown" }},
333 {211, { "sendmsg" }},
334 {212, { "recvmsg" }},
335 {213, { "readahead" }},
336 {214, { "brk", brkFunc
}},
337 {215, { "munmap", munmapFunc
}},
338 {216, { "mremap", mremapFunc
<RiscvLinux64
> }},
339 {217, { "add_key" }},
340 {218, { "request_key" }},
342 {220, { "clone", cloneBackwardsFunc
<RiscvLinux64
> }},
343 {221, { "execve", execveFunc
<RiscvLinux64
> }},
344 {222, { "mmap", mmapFunc
<RiscvLinux64
> }},
345 {223, { "fadvise64" }},
347 {225, { "swapoff" }},
348 {226, { "mprotect", ignoreFunc
}},
349 {227, { "msync", ignoreFunc
}},
350 {228, { "mlock", ignoreFunc
}},
351 {229, { "munlock", ignoreFunc
}},
352 {230, { "mlockall", ignoreFunc
}},
353 {231, { "munlockall", ignoreFunc
}},
354 {232, { "mincore", ignoreFunc
}},
355 {233, { "madvise", ignoreFunc
}},
356 {234, { "remap_file_pages" }},
357 {235, { "mbind", ignoreFunc
}},
358 {236, { "get_mempolicy" }},
359 {237, { "set_mempolicy" }},
360 {238, { "migrate_pages" }},
361 {239, { "move_pages" }},
362 {240, { "tgsigqueueinfo" }},
363 {241, { "perf_event_open" }},
364 {242, { "accept4" }},
365 {243, { "recvmmsg" }},
367 {261, { "prlimit64", prlimitFunc
<RiscvLinux64
> }},
368 {262, { "fanotify_init" }},
369 {263, { "fanotify_mark" }},
370 {264, { "name_to_handle_at" }},
371 {265, { "open_by_handle_at" }},
372 {266, { "clock_adjtime" }},
375 {269, { "sendmmsg" }},
376 {270, { "process_vm_ready" }},
377 {271, { "process_vm_writev" }},
379 {273, { "finit_module" }},
380 {274, { "sched_setattr" }},
381 {275, { "sched_getattr" }},
382 {276, { "renameat2" }},
383 {277, { "seccomp" }},
384 {278, { "getrandom" }},
385 {279, { "memfd_create" }},
387 {281, { "execveat" }},
388 {282, { "userfaultid" }},
389 {283, { "membarrier" }},
391 {285, { "copy_file_range" }},
392 {286, { "preadv2" }},
393 {287, { "pwritev2" }},
394 {1024, { "open", openFunc
<RiscvLinux64
> }},
396 {1026, { "unlink", unlinkFunc
}},
398 {1028, { "chmod", chmodFunc
<RiscvLinux64
> }},
399 {1029, { "chown", chownFunc
}},
400 {1030, { "mkdir", mkdirFunc
}},
402 {1032, { "lchown" }},
403 {1033, { "access", accessFunc
}},
404 {1034, { "rename", renameFunc
}},
405 {1035, { "readlink", readlinkFunc
}},
406 {1036, { "symlink" }},
407 {1037, { "utimes", utimesFunc
<RiscvLinux64
> }},
408 {1038, { "stat", stat64Func
<RiscvLinux64
> }},
409 {1039, { "lstat", lstat64Func
<RiscvLinux64
> }},
410 {1040, { "pipe", pipeFunc
}},
411 {1041, { "dup2", dup2Func
}},
412 {1042, { "epoll_create" }},
413 {1043, { "inotifiy_init" }},
414 {1044, { "eventfd" }},
415 {1045, { "signalfd" }},
416 {1046, { "sendfile" }},
417 {1047, { "ftruncate", ftruncate64Func
}},
418 {1048, { "truncate", truncate64Func
}},
419 {1049, { "stat", stat64Func
<RiscvLinux64
> }},
420 {1050, { "lstat", lstat64Func
<RiscvLinux64
> }},
421 {1051, { "fstat", fstat64Func
<RiscvLinux64
> }},
422 {1052, { "fcntl", fcntl64Func
}},
423 {1053, { "fadvise64" }},
424 {1054, { "newfstatat" }},
425 {1055, { "fstatfs", fstatfsFunc
<RiscvLinux64
> }},
426 {1056, { "statfs", statfsFunc
<RiscvLinux64
> }},
427 {1057, { "lseek", lseekFunc
}},
428 {1058, { "mmap", mmapFunc
<RiscvLinux64
> }},
430 {1060, { "getpgrp" }},
432 {1062, { "time", timeFunc
<RiscvLinux64
> }},
435 {1065, { "getdents" }},
436 {1066, { "futimesat" }},
437 {1067, { "select" }},
439 {1069, { "epoll_wait" }},
442 {1072, { "oldwait4" }},
445 {1075, { "bdflush" }},
446 {1076, { "umount" }},
447 {1077, { "uselib" }},
448 {1078, { "sysctl" }},
450 {2011, { "getmainvars" }}
453 std::map
<int, SyscallDescABI
<DefaultSyscallABI
>>
454 RiscvLinuxProcess32::syscallDescs
= {
456 {1, { "io_destroy" }},
457 {2, { "io_submit" }},
458 {3, { "io_cancel" }},
459 {4, { "io_getevents" }},
461 {6, { "lsetxattr" }},
462 {7, { "fsetxattr" }},
464 {9, { "lgetxattr" }},
465 {10, { "fgetxattr" }},
466 {11, { "listxattr" }},
467 {12, { "llistxattr" }},
468 {13, { "flistxattr" }},
469 {14, { "removexattr" }},
470 {15, { "lremovexattr" }},
471 {16, { "fremovexattr" }},
472 {17, { "getcwd", getcwdFunc
}},
473 {18, { "lookup_dcookie" }},
474 {19, { "eventfd2" }},
475 {20, { "epoll_create1" }},
476 {21, { "epoll_ctl" }},
477 {22, { "epoll_pwait" }},
478 {23, { "dup", dupFunc
}},
480 {25, { "fcntl", fcntlFunc
}},
481 {26, { "inotify_init1" }},
482 {27, { "inotify_add_watch" }},
483 {28, { "inotify_rm_watch" }},
484 {29, { "ioctl", ioctlFunc
<RiscvLinux32
> }},
485 {30, { "ioprio_get" }},
486 {31, { "ioprio_set" }},
490 {35, { "unlinkat", unlinkatFunc
<RiscvLinux32
> }},
491 {36, { "symlinkat" }},
493 {38, { "renameat", renameatFunc
<RiscvLinux32
> }},
496 {41, { "pivot_root" }},
497 {42, { "nfsservctl" }},
498 {43, { "statfs", statfsFunc
<RiscvLinux32
> }},
499 {44, { "fstatfs", fstatfsFunc
<RiscvLinux32
> }},
500 {45, { "truncate", truncateFunc
}},
501 {46, { "ftruncate", ftruncateFunc
}},
502 {47, { "fallocate", fallocateFunc
}},
503 {48, { "faccessat", faccessatFunc
<RiscvLinux32
> }},
507 {52, { "fchmod", fchmodFunc
<RiscvLinux32
> }},
508 {53, { "fchmodat" }},
509 {54, { "fchownat" }},
510 {55, { "fchown", fchownFunc
}},
511 {56, { "openat", openatFunc
<RiscvLinux32
> }},
512 {57, { "close", closeFunc
}},
515 {60, { "quotactl" }},
516 {61, { "getdents64" }},
517 {62, { "lseek", lseekFunc
}},
518 {63, { "read", readFunc
<RiscvLinux32
> }},
519 {64, { "write", writeFunc
<RiscvLinux32
> }},
520 {66, { "writev", writevFunc
<RiscvLinux32
> }},
522 {68, { "pwrite64", pwrite64Func
<RiscvLinux32
> }},
525 {71, { "sendfile" }},
526 {72, { "pselect6" }},
528 {74, { "signalfd64" }},
529 {75, { "vmsplice" }},
532 {78, { "readlinkat", readlinkatFunc
<RiscvLinux32
> }},
534 {80, { "fstat", fstatFunc
<RiscvLinux32
> }},
537 {83, { "fdatasync" }},
538 {84, { "sync_file_range2" }},
539 {85, { "timerfd_create" }},
540 {86, { "timerfd_settime" }},
541 {87, { "timerfd_gettime" }},
542 {88, { "utimensat" }},
546 {92, { "personality" }},
547 {93, { "exit", exitFunc
}},
548 {94, { "exit_group", exitGroupFunc
}},
550 {96, { "set_tid_address", setTidAddressFunc
}},
552 {98, { "futex", futexFunc
<RiscvLinux32
> }},
553 {99, { "set_robust_list", ignoreWarnOnceFunc
}},
554 {100, { "get_robust_list", ignoreWarnOnceFunc
}},
555 {101, { "nanosleep" }},
556 {102, { "getitimer" }},
557 {103, { "setitimer" }},
558 {104, { "kexec_load" }},
559 {105, { "init_module" }},
560 {106, { "delete_module" }},
561 {107, { "timer_create" }},
562 {108, { "timer_gettime" }},
563 {109, { "timer_getoverrun" }},
564 {110, { "timer_settime" }},
565 {111, { "timer_delete" }},
566 {112, { "clock_settime" }},
567 {113, { "clock_gettime", clock_gettimeFunc
<RiscvLinux32
> }},
568 {114, { "clock_getres", clock_getresFunc
<RiscvLinux32
> }},
569 {115, { "clock_nanosleep" }},
572 {118, { "sched_setparam" }},
573 {119, { "sched_setscheduler" }},
574 {120, { "sched_getscheduler" }},
575 {121, { "sched_getparam" }},
576 {122, { "sched_setaffinity" }},
577 {123, { "sched_getaffinity" }},
578 {124, { "sched_yield", ignoreWarnOnceFunc
}},
579 {125, { "sched_get_priority_max" }},
580 {126, { "sched_get_priority_min" }},
581 {127, { "scheD_rr_get_interval" }},
582 {128, { "restart_syscall" }},
585 {131, { "tgkill", tgkillFunc
<RiscvLinux32
> }},
586 {132, { "sigaltstack" }},
587 {133, { "rt_sigsuspend", ignoreWarnOnceFunc
}},
588 {134, { "rt_sigaction", ignoreWarnOnceFunc
}},
589 {135, { "rt_sigprocmask", ignoreWarnOnceFunc
}},
590 {136, { "rt_sigpending", ignoreWarnOnceFunc
}},
591 {137, { "rt_sigtimedwait", ignoreWarnOnceFunc
}},
592 {138, { "rt_sigqueueinfo", ignoreWarnOnceFunc
}},
593 {139, { "rt_sigreturn", ignoreWarnOnceFunc
}},
594 {140, { "setpriority" }},
595 {141, { "getpriority" }},
597 {143, { "setregid" }},
599 {145, { "setreuid" }},
600 {146, { "setuid", ignoreFunc
}},
601 {147, { "setresuid" }},
602 {148, { "getresuid" }},
603 {149, { "getresgid" }},
604 {150, { "getresgid" }},
605 {151, { "setfsuid" }},
606 {152, { "setfsgid" }},
607 {153, { "times", timesFunc
<RiscvLinux32
> }},
608 {154, { "setpgid", setpgidFunc
}},
609 {155, { "getpgid" }},
612 {158, { "getgroups" }},
613 {159, { "setgroups" }},
614 {160, { "uname", unameFunc32
}},
615 {161, { "sethostname" }},
616 {162, { "setdomainname" }},
617 {163, { "getrlimit", getrlimitFunc
<RiscvLinux32
> }},
618 {164, { "setrlimit", ignoreFunc
}},
619 {165, { "getrusage", getrusageFunc
<RiscvLinux32
> }},
620 {166, { "umask", umaskFunc
}},
623 {169, { "gettimeofday", gettimeofdayFunc
<RiscvLinux32
> }},
624 {170, { "settimeofday" }},
625 {171, { "adjtimex" }},
626 {172, { "getpid", getpidFunc
}},
627 {173, { "getppid", getppidFunc
}},
628 {174, { "getuid", getuidFunc
}},
629 {175, { "geteuid", geteuidFunc
}},
630 {176, { "getgid", getgidFunc
}},
631 {177, { "getegid", getegidFunc
}},
632 {178, { "gettid", gettidFunc
}},
633 {179, { "sysinfo", sysinfoFunc
<RiscvLinux32
> }},
634 {180, { "mq_open" }},
635 {181, { "mq_unlink" }},
636 {182, { "mq_timedsend" }},
637 {183, { "mq_timedrecieve" }},
638 {184, { "mq_notify" }},
639 {185, { "mq_getsetattr" }},
646 {192, { "semtimedop" }},
653 {199, { "socketpair" }},
657 {203, { "connect" }},
658 {204, { "getsockname" }},
659 {205, { "getpeername" }},
661 {207, { "recvfrom" }},
662 {208, { "setsockopt" }},
663 {209, { "getsockopt" }},
664 {210, { "shutdown" }},
665 {211, { "sendmsg" }},
666 {212, { "recvmsg" }},
667 {213, { "readahead" }},
668 {214, { "brk", brkFunc
}},
669 {215, { "munmap", munmapFunc
}},
670 {216, { "mremap", mremapFunc
<RiscvLinux32
> }},
671 {217, { "add_key" }},
672 {218, { "request_key" }},
674 {220, { "clone", cloneBackwardsFunc
<RiscvLinux32
> }},
675 {221, { "execve", execveFunc
<RiscvLinux32
> }},
676 {222, { "mmap", mmapFunc
<RiscvLinux32
> }},
677 {223, { "fadvise64" }},
679 {225, { "swapoff" }},
680 {226, { "mprotect", ignoreFunc
}},
681 {227, { "msync", ignoreFunc
}},
682 {228, { "mlock", ignoreFunc
}},
683 {229, { "munlock", ignoreFunc
}},
684 {230, { "mlockall", ignoreFunc
}},
685 {231, { "munlockall", ignoreFunc
}},
686 {232, { "mincore", ignoreFunc
}},
687 {233, { "madvise", ignoreFunc
}},
688 {234, { "remap_file_pages" }},
689 {235, { "mbind", ignoreFunc
}},
690 {236, { "get_mempolicy" }},
691 {237, { "set_mempolicy" }},
692 {238, { "migrate_pages" }},
693 {239, { "move_pages" }},
694 {240, { "tgsigqueueinfo" }},
695 {241, { "perf_event_open" }},
696 {242, { "accept4" }},
697 {243, { "recvmmsg" }},
699 {261, { "prlimit64", prlimitFunc
<RiscvLinux32
> }},
700 {262, { "fanotify_init" }},
701 {263, { "fanotify_mark" }},
702 {264, { "name_to_handle_at" }},
703 {265, { "open_by_handle_at" }},
704 {266, { "clock_adjtime" }},
707 {269, { "sendmmsg" }},
708 {270, { "process_vm_ready" }},
709 {271, { "process_vm_writev" }},
711 {273, { "finit_module" }},
712 {274, { "sched_setattr" }},
713 {275, { "sched_getattr" }},
714 {276, { "renameat2" }},
715 {277, { "seccomp" }},
716 {278, { "getrandom" }},
717 {279, { "memfd_create" }},
719 {281, { "execveat" }},
720 {282, { "userfaultid" }},
721 {283, { "membarrier" }},
723 {285, { "copy_file_range" }},
724 {286, { "preadv2" }},
725 {287, { "pwritev2" }},
726 {1024, { "open", openFunc
<RiscvLinux32
> }},
728 {1026, { "unlink", unlinkFunc
}},
730 {1028, { "chmod", chmodFunc
<RiscvLinux32
> }},
731 {1029, { "chown", chownFunc
}},
732 {1030, { "mkdir", mkdirFunc
}},
734 {1032, { "lchown" }},
735 {1033, { "access", accessFunc
}},
736 {1034, { "rename", renameFunc
}},
737 {1035, { "readlink", readlinkFunc
}},
738 {1036, { "symlink" }},
739 {1037, { "utimes", utimesFunc
<RiscvLinux32
> }},
740 {1038, { "stat", statFunc
<RiscvLinux32
> }},
741 {1039, { "lstat", lstatFunc
<RiscvLinux32
> }},
742 {1040, { "pipe", pipeFunc
}},
743 {1041, { "dup2", dup2Func
}},
744 {1042, { "epoll_create" }},
745 {1043, { "inotifiy_init" }},
746 {1044, { "eventfd" }},
747 {1045, { "signalfd" }},
748 {1046, { "sendfile" }},
749 {1047, { "ftruncate", ftruncateFunc
}},
750 {1048, { "truncate", truncateFunc
}},
751 {1049, { "stat", statFunc
<RiscvLinux32
> }},
752 {1050, { "lstat", lstatFunc
<RiscvLinux32
> }},
753 {1051, { "fstat", fstatFunc
<RiscvLinux32
> }},
754 {1052, { "fcntl", fcntlFunc
}},
755 {1053, { "fadvise64" }},
756 {1054, { "newfstatat" }},
757 {1055, { "fstatfs", fstatfsFunc
<RiscvLinux32
> }},
758 {1056, { "statfs", statfsFunc
<RiscvLinux32
> }},
759 {1057, { "lseek", lseekFunc
}},
760 {1058, { "mmap", mmapFunc
<RiscvLinux32
> }},
762 {1060, { "getpgrp" }},
764 {1062, { "time", timeFunc
<RiscvLinux32
> }},
767 {1065, { "getdents" }},
768 {1066, { "futimesat" }},
769 {1067, { "select" }},
771 {1069, { "epoll_wait" }},
774 {1072, { "oldwait4" }},
777 {1075, { "bdflush" }},
778 {1076, { "umount" }},
779 {1077, { "uselib" }},
780 {1078, { "sysctl" }},
782 {2011, { "getmainvars" }}
785 RiscvLinuxProcess64::RiscvLinuxProcess64(ProcessParams
* params
,
786 ObjectFile
*objFile
) : RiscvProcess64(params
, objFile
)
790 RiscvLinuxProcess64::getDesc(int callnum
)
792 return syscallDescs
.find(callnum
) != syscallDescs
.end() ?
793 &syscallDescs
.at(callnum
) : nullptr;
797 RiscvLinuxProcess64::syscall(ThreadContext
*tc
, Fault
*fault
)
799 doSyscall(tc
->readIntReg(SyscallNumReg
), tc
, fault
);
802 RiscvLinuxProcess32::RiscvLinuxProcess32(ProcessParams
* params
,
803 ObjectFile
*objFile
) : RiscvProcess32(params
, objFile
)
807 RiscvLinuxProcess32::getDesc(int callnum
)
809 return syscallDescs
.find(callnum
) != syscallDescs
.end() ?
810 &syscallDescs
.at(callnum
) : nullptr;
814 RiscvLinuxProcess32::syscall(ThreadContext
*tc
, Fault
*fault
)
816 doSyscall(tc
->readIntReg(SyscallNumReg
), tc
, fault
);