gem5  v19.0.0.0
process.cc
Go to the documentation of this file.
1 /*
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
5  * All rights reserved.
6  *
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.
17  *
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.
29  *
30  * Authors: Gabe Black
31  * Korey Sewell
32  * Alec Roelke
33  */
34 
36 
37 #include <map>
38 
39 #include "arch/riscv/isa_traits.hh"
42 #include "base/trace.hh"
43 #include "cpu/thread_context.hh"
44 #include "debug/SyscallVerbose.hh"
45 #include "kern/linux/linux.hh"
46 #include "sim/eventq.hh"
47 #include "sim/process.hh"
48 #include "sim/syscall_desc.hh"
49 #include "sim/syscall_emul.hh"
50 #include "sim/system.hh"
51 
52 using namespace std;
53 using namespace RiscvISA;
54 
55 namespace
56 {
57 
58 class RiscvLinuxObjectFileLoader : public Process::Loader
59 {
60  public:
61  Process *
62  load(ProcessParams *params, ObjectFile *obj_file) override
63  {
64  auto arch = obj_file->getArch();
65  auto opsys = obj_file->getOpSys();
66 
67  if (arch != ObjectFile::Riscv64 && arch != ObjectFile::Riscv32)
68  return nullptr;
69 
70  if (opsys == ObjectFile::UnknownOpSys) {
71  warn("Unknown operating system; assuming Linux.");
72  opsys = ObjectFile::Linux;
73  }
74 
75  if (opsys != ObjectFile::Linux)
76  return nullptr;
77 
78  if (arch == ObjectFile::Riscv64)
79  return new RiscvLinuxProcess64(params, obj_file);
80  else
81  return new RiscvLinuxProcess32(params, obj_file);
82  }
83 };
84 
85 RiscvLinuxObjectFileLoader loader;
86 
87 } // anonymous namespace
88 
90 static SyscallReturn
91 unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc)
92 {
93  int index = 0;
94  auto process = tc->getProcessPtr();
95  TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
96 
97  strcpy(name->sysname, "Linux");
98  strcpy(name->nodename,"sim.gem5.org");
99  strcpy(name->release, process->release.c_str());
100  strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
101  strcpy(name->machine, "riscv64");
102 
103  name.copyOut(tc->getVirtProxy());
104  return 0;
105 }
106 
108 static SyscallReturn
109 unameFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc)
110 {
111  int index = 0;
112  auto process = tc->getProcessPtr();
113  TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
114 
115  strcpy(name->sysname, "Linux");
116  strcpy(name->nodename,"sim.gem5.org");
117  strcpy(name->release, process->release.c_str());
118  strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
119  strcpy(name->machine, "riscv32");
120 
121  name.copyOut(tc->getVirtProxy());
122  return 0;
123 }
124 
125 std::map<int, SyscallDescABI<DefaultSyscallABI>>
127  {0, { "io_setup" }},
128  {1, { "io_destroy" }},
129  {2, { "io_submit" }},
130  {3, { "io_cancel" }},
131  {4, { "io_getevents" }},
132  {5, { "setxattr" }},
133  {6, { "lsetxattr" }},
134  {7, { "fsetxattr" }},
135  {8, { "getxattr" }},
136  {9, { "lgetxattr" }},
137  {10, { "fgetxattr" }},
138  {11, { "listxattr" }},
139  {12, { "llistxattr" }},
140  {13, { "flistxattr" }},
141  {14, { "removexattr" }},
142  {15, { "lremovexattr" }},
143  {16, { "fremovexattr" }},
144  {17, { "getcwd", getcwdFunc }},
145  {18, { "lookup_dcookie" }},
146  {19, { "eventfd2" }},
147  {20, { "epoll_create1" }},
148  {21, { "epoll_ctl" }},
149  {22, { "epoll_pwait" }},
150  {23, { "dup", dupFunc }},
151  {24, { "dup3" }},
152  {25, { "fcntl", fcntl64Func }},
153  {26, { "inotify_init1" }},
154  {27, { "inotify_add_watch" }},
155  {28, { "inotify_rm_watch" }},
156  {29, { "ioctl", ioctlFunc<RiscvLinux64> }},
157  {30, { "ioprio_get" }},
158  {31, { "ioprio_set" }},
159  {32, { "flock" }},
160  {33, { "mknodat" }},
161  {34, { "mkdirat" }},
162  {35, { "unlinkat", unlinkatFunc<RiscvLinux64> }},
163  {36, { "symlinkat" }},
164  {37, { "linkat" }},
165  {38, { "renameat", renameatFunc<RiscvLinux64> }},
166  {39, { "umount2" }},
167  {40, { "mount" }},
168  {41, { "pivot_root" }},
169  {42, { "nfsservctl" }},
170  {43, { "statfs", statfsFunc<RiscvLinux64> }},
171  {44, { "fstatfs", fstatfsFunc<RiscvLinux64> }},
172  {45, { "truncate", truncateFunc }},
173  {46, { "ftruncate", ftruncate64Func }},
174  {47, { "fallocate", fallocateFunc }},
175  {48, { "faccessat", faccessatFunc<RiscvLinux64> }},
176  {49, { "chdir" }},
177  {50, { "fchdir" }},
178  {51, { "chroot" }},
179  {52, { "fchmod", fchmodFunc<RiscvLinux64> }},
180  {53, { "fchmodat" }},
181  {54, { "fchownat" }},
182  {55, { "fchown", fchownFunc }},
183  {56, { "openat", openatFunc<RiscvLinux64> }},
184  {57, { "close", closeFunc }},
185  {58, { "vhangup" }},
186  {59, { "pipe2" }},
187  {60, { "quotactl" }},
188  {61, { "getdents64" }},
189  {62, { "lseek", lseekFunc }},
190  {63, { "read", readFunc<RiscvLinux64> }},
191  {64, { "write", writeFunc<RiscvLinux64> }},
192  {66, { "writev", writevFunc<RiscvLinux64> }},
193  {67, { "pread64" }},
194  {68, { "pwrite64", pwrite64Func<RiscvLinux64> }},
195  {69, { "preadv" }},
196  {70, { "pwritev" }},
197  {71, { "sendfile" }},
198  {72, { "pselect6" }},
199  {73, { "ppoll" }},
200  {74, { "signalfd64" }},
201  {75, { "vmsplice" }},
202  {76, { "splice" }},
203  {77, { "tee" }},
204  {78, { "readlinkat", readlinkatFunc<RiscvLinux64> }},
205  {79, { "fstatat", fstatat64Func<RiscvLinux64> }},
206  {80, { "fstat", fstat64Func<RiscvLinux64> }},
207  {81, { "sync" }},
208  {82, { "fsync" }},
209  {83, { "fdatasync" }},
210  {84, { "sync_file_range2" }},
211  {85, { "timerfd_create" }},
212  {86, { "timerfd_settime" }},
213  {87, { "timerfd_gettime" }},
214  {88, { "utimensat" }},
215  {89, { "acct" }},
216  {90, { "capget" }},
217  {91, { "capset" }},
218  {92, { "personality" }},
219  {93, { "exit", exitFunc }},
220  {94, { "exit_group", exitGroupFunc }},
221  {95, { "waitid" }},
222  {96, { "set_tid_address", setTidAddressFunc }},
223  {97, { "unshare" }},
224  {98, { "futex", futexFunc<RiscvLinux64> }},
225  {99, { "set_robust_list", ignoreWarnOnceFunc }},
226  {100, { "get_robust_list", ignoreWarnOnceFunc }},
227  {101, { "nanosleep", ignoreWarnOnceFunc }},
228  {102, { "getitimer" }},
229  {103, { "setitimer" }},
230  {104, { "kexec_load" }},
231  {105, { "init_module" }},
232  {106, { "delete_module" }},
233  {107, { "timer_create" }},
234  {108, { "timer_gettime" }},
235  {109, { "timer_getoverrun" }},
236  {110, { "timer_settime" }},
237  {111, { "timer_delete" }},
238  {112, { "clock_settime" }},
239  {113, { "clock_gettime", clock_gettimeFunc<RiscvLinux64> }},
240  {114, { "clock_getres", clock_getresFunc<RiscvLinux64> }},
241  {115, { "clock_nanosleep" }},
242  {116, { "syslog" }},
243  {117, { "ptrace" }},
244  {118, { "sched_setparam" }},
245  {119, { "sched_setscheduler" }},
246  {120, { "sched_getscheduler" }},
247  {121, { "sched_getparam" }},
248  {122, { "sched_setaffinity" }},
249  {123, { "sched_getaffinity" }},
250  {124, { "sched_yield", ignoreWarnOnceFunc }},
251  {125, { "sched_get_priority_max" }},
252  {126, { "sched_get_priority_min" }},
253  {127, { "scheD_rr_get_interval" }},
254  {128, { "restart_syscall" }},
255  {129, { "kill" }},
256  {130, { "tkill" }},
257  {131, { "tgkill", tgkillFunc<RiscvLinux64> }},
258  {132, { "sigaltstack" }},
259  {133, { "rt_sigsuspend", ignoreWarnOnceFunc }},
260  {134, { "rt_sigaction", ignoreWarnOnceFunc }},
261  {135, { "rt_sigprocmask", ignoreWarnOnceFunc }},
262  {136, { "rt_sigpending", ignoreWarnOnceFunc }},
263  {137, { "rt_sigtimedwait", ignoreWarnOnceFunc }},
264  {138, { "rt_sigqueueinfo", ignoreWarnOnceFunc }},
265  {139, { "rt_sigreturn", ignoreWarnOnceFunc }},
266  {140, { "setpriority" }},
267  {141, { "getpriority" }},
268  {142, { "reboot" }},
269  {143, { "setregid" }},
270  {144, { "setgid" }},
271  {145, { "setreuid" }},
272  {146, { "setuid", ignoreFunc }},
273  {147, { "setresuid" }},
274  {148, { "getresuid" }},
275  {149, { "getresgid" }},
276  {150, { "getresgid" }},
277  {151, { "setfsuid" }},
278  {152, { "setfsgid" }},
279  {153, { "times", timesFunc<RiscvLinux64> }},
280  {154, { "setpgid", setpgidFunc }},
281  {155, { "getpgid" }},
282  {156, { "getsid" }},
283  {157, { "setsid" }},
284  {158, { "getgroups" }},
285  {159, { "setgroups" }},
286  {160, { "uname", unameFunc64 }},
287  {161, { "sethostname" }},
288  {162, { "setdomainname" }},
289  {163, { "getrlimit", getrlimitFunc<RiscvLinux64> }},
290  {164, { "setrlimit", ignoreFunc }},
291  {165, { "getrusage", getrusageFunc<RiscvLinux64> }},
292  {166, { "umask", umaskFunc }},
293  {167, { "prctl" }},
294  {168, { "getcpu" }},
295  {169, { "gettimeofday", gettimeofdayFunc<RiscvLinux64> }},
296  {170, { "settimeofday" }},
297  {171, { "adjtimex" }},
298  {172, { "getpid", getpidFunc }},
299  {173, { "getppid", getppidFunc }},
300  {174, { "getuid", getuidFunc }},
301  {175, { "geteuid", geteuidFunc }},
302  {176, { "getgid", getgidFunc }},
303  {177, { "getegid", getegidFunc }},
304  {178, { "gettid", gettidFunc }},
305  {179, { "sysinfo", sysinfoFunc<RiscvLinux64> }},
306  {180, { "mq_open" }},
307  {181, { "mq_unlink" }},
308  {182, { "mq_timedsend" }},
309  {183, { "mq_timedrecieve" }},
310  {184, { "mq_notify" }},
311  {185, { "mq_getsetattr" }},
312  {186, { "msgget" }},
313  {187, { "msgctl" }},
314  {188, { "msgrcv" }},
315  {189, { "msgsnd" }},
316  {190, { "semget" }},
317  {191, { "semctl" }},
318  {192, { "semtimedop" }},
319  {193, { "semop" }},
320  {194, { "shmget" }},
321  {195, { "shmctl" }},
322  {196, { "shmat" }},
323  {197, { "shmdt" }},
324  {198, { "socket" }},
325  {199, { "socketpair" }},
326  {200, { "bind" }},
327  {201, { "listen" }},
328  {202, { "accept" }},
329  {203, { "connect" }},
330  {204, { "getsockname" }},
331  {205, { "getpeername" }},
332  {206, { "sendo" }},
333  {207, { "recvfrom" }},
334  {208, { "setsockopt" }},
335  {209, { "getsockopt" }},
336  {210, { "shutdown" }},
337  {211, { "sendmsg" }},
338  {212, { "recvmsg" }},
339  {213, { "readahead" }},
340  {214, { "brk", brkFunc }},
341  {215, { "munmap", munmapFunc }},
342  {216, { "mremap", mremapFunc<RiscvLinux64> }},
343  {217, { "add_key" }},
344  {218, { "request_key" }},
345  {219, { "keyctl" }},
346  {220, { "clone", cloneFunc<RiscvLinux64> }},
347  {221, { "execve", execveFunc<RiscvLinux64> }},
348  {222, { "mmap", mmapFunc<RiscvLinux64> }},
349  {223, { "fadvise64" }},
350  {224, { "swapon" }},
351  {225, { "swapoff" }},
352  {226, { "mprotect", ignoreFunc }},
353  {227, { "msync", ignoreFunc }},
354  {228, { "mlock", ignoreFunc }},
355  {229, { "munlock", ignoreFunc }},
356  {230, { "mlockall", ignoreFunc }},
357  {231, { "munlockall", ignoreFunc }},
358  {232, { "mincore", ignoreFunc }},
359  {233, { "madvise", ignoreFunc }},
360  {234, { "remap_file_pages" }},
361  {235, { "mbind", ignoreFunc }},
362  {236, { "get_mempolicy" }},
363  {237, { "set_mempolicy" }},
364  {238, { "migrate_pages" }},
365  {239, { "move_pages" }},
366  {240, { "tgsigqueueinfo" }},
367  {241, { "perf_event_open" }},
368  {242, { "accept4" }},
369  {243, { "recvmmsg" }},
370  {260, { "wait4" }},
371  {261, { "prlimit64", prlimitFunc<RiscvLinux64> }},
372  {262, { "fanotify_init" }},
373  {263, { "fanotify_mark" }},
374  {264, { "name_to_handle_at" }},
375  {265, { "open_by_handle_at" }},
376  {266, { "clock_adjtime" }},
377  {267, { "syncfs" }},
378  {268, { "setns" }},
379  {269, { "sendmmsg" }},
380  {270, { "process_vm_ready" }},
381  {271, { "process_vm_writev" }},
382  {272, { "kcmp" }},
383  {273, { "finit_module" }},
384  {274, { "sched_setattr" }},
385  {275, { "sched_getattr" }},
386  {276, { "renameat2" }},
387  {277, { "seccomp" }},
388  {278, { "getrandom" }},
389  {279, { "memfd_create" }},
390  {280, { "bpf" }},
391  {281, { "execveat" }},
392  {282, { "userfaultid" }},
393  {283, { "membarrier" }},
394  {284, { "mlock2" }},
395  {285, { "copy_file_range" }},
396  {286, { "preadv2" }},
397  {287, { "pwritev2" }},
398  {1024, { "open", openFunc<RiscvLinux64> }},
399  {1025, { "link" }},
400  {1026, { "unlink", unlinkFunc }},
401  {1027, { "mknod" }},
402  {1028, { "chmod", chmodFunc<RiscvLinux64> }},
403  {1029, { "chown", chownFunc }},
404  {1030, { "mkdir", mkdirFunc }},
405  {1031, { "rmdir" }},
406  {1032, { "lchown" }},
407  {1033, { "access", accessFunc }},
408  {1034, { "rename", renameFunc }},
409  {1035, { "readlink", readlinkFunc }},
410  {1036, { "symlink" }},
411  {1037, { "utimes", utimesFunc<RiscvLinux64> }},
412  {1038, { "stat", stat64Func<RiscvLinux64> }},
413  {1039, { "lstat", lstat64Func<RiscvLinux64> }},
414  {1040, { "pipe", pipeFunc }},
415  {1041, { "dup2", dup2Func }},
416  {1042, { "epoll_create" }},
417  {1043, { "inotifiy_init" }},
418  {1044, { "eventfd" }},
419  {1045, { "signalfd" }},
420  {1046, { "sendfile" }},
421  {1047, { "ftruncate", ftruncate64Func }},
422  {1048, { "truncate", truncate64Func }},
423  {1049, { "stat", stat64Func<RiscvLinux64> }},
424  {1050, { "lstat", lstat64Func<RiscvLinux64> }},
425  {1051, { "fstat", fstat64Func<RiscvLinux64> }},
426  {1052, { "fcntl", fcntl64Func }},
427  {1053, { "fadvise64" }},
428  {1054, { "newfstatat" }},
429  {1055, { "fstatfs", fstatfsFunc<RiscvLinux64> }},
430  {1056, { "statfs", statfsFunc<RiscvLinux64> }},
431  {1057, { "lseek", lseekFunc }},
432  {1058, { "mmap", mmapFunc<RiscvLinux64> }},
433  {1059, { "alarm" }},
434  {1060, { "getpgrp" }},
435  {1061, { "pause" }},
436  {1062, { "time", timeFunc<RiscvLinux64> }},
437  {1063, { "utime" }},
438  {1064, { "creat" }},
439  {1065, { "getdents" }},
440  {1066, { "futimesat" }},
441  {1067, { "select" }},
442  {1068, { "poll" }},
443  {1069, { "epoll_wait" }},
444  {1070, { "ustat" }},
445  {1071, { "vfork" }},
446  {1072, { "oldwait4" }},
447  {1073, { "recv" }},
448  {1074, { "send" }},
449  {1075, { "bdflush" }},
450  {1076, { "umount" }},
451  {1077, { "uselib" }},
452  {1078, { "sysctl" }},
453  {1079, { "fork" }},
454  {2011, { "getmainvars" }}
455 };
456 
457 std::map<int, SyscallDescABI<DefaultSyscallABI>>
459  {0, { "io_setup" }},
460  {1, { "io_destroy" }},
461  {2, { "io_submit" }},
462  {3, { "io_cancel" }},
463  {4, { "io_getevents" }},
464  {5, { "setxattr" }},
465  {6, { "lsetxattr" }},
466  {7, { "fsetxattr" }},
467  {8, { "getxattr" }},
468  {9, { "lgetxattr" }},
469  {10, { "fgetxattr" }},
470  {11, { "listxattr" }},
471  {12, { "llistxattr" }},
472  {13, { "flistxattr" }},
473  {14, { "removexattr" }},
474  {15, { "lremovexattr" }},
475  {16, { "fremovexattr" }},
476  {17, { "getcwd", getcwdFunc }},
477  {18, { "lookup_dcookie" }},
478  {19, { "eventfd2" }},
479  {20, { "epoll_create1" }},
480  {21, { "epoll_ctl" }},
481  {22, { "epoll_pwait" }},
482  {23, { "dup", dupFunc }},
483  {24, { "dup3" }},
484  {25, { "fcntl", fcntlFunc }},
485  {26, { "inotify_init1" }},
486  {27, { "inotify_add_watch" }},
487  {28, { "inotify_rm_watch" }},
488  {29, { "ioctl", ioctlFunc<RiscvLinux32> }},
489  {30, { "ioprio_get" }},
490  {31, { "ioprio_set" }},
491  {32, { "flock" }},
492  {33, { "mknodat" }},
493  {34, { "mkdirat" }},
494  {35, { "unlinkat", unlinkatFunc<RiscvLinux32> }},
495  {36, { "symlinkat" }},
496  {37, { "linkat" }},
497  {38, { "renameat", renameatFunc<RiscvLinux32> }},
498  {39, { "umount2" }},
499  {40, { "mount" }},
500  {41, { "pivot_root" }},
501  {42, { "nfsservctl" }},
502  {43, { "statfs", statfsFunc<RiscvLinux32> }},
503  {44, { "fstatfs", fstatfsFunc<RiscvLinux32> }},
504  {45, { "truncate", truncateFunc }},
505  {46, { "ftruncate", ftruncateFunc }},
506  {47, { "fallocate", fallocateFunc }},
507  {48, { "faccessat", faccessatFunc<RiscvLinux32> }},
508  {49, { "chdir" }},
509  {50, { "fchdir" }},
510  {51, { "chroot" }},
511  {52, { "fchmod", fchmodFunc<RiscvLinux32> }},
512  {53, { "fchmodat" }},
513  {54, { "fchownat" }},
514  {55, { "fchown", fchownFunc }},
515  {56, { "openat", openatFunc<RiscvLinux32> }},
516  {57, { "close", closeFunc }},
517  {58, { "vhangup" }},
518  {59, { "pipe2" }},
519  {60, { "quotactl" }},
520  {61, { "getdents64" }},
521  {62, { "lseek", lseekFunc }},
522  {63, { "read", readFunc<RiscvLinux32> }},
523  {64, { "write", writeFunc<RiscvLinux32> }},
524  {66, { "writev", writevFunc<RiscvLinux32> }},
525  {67, { "pread64" }},
526  {68, { "pwrite64", pwrite64Func<RiscvLinux32> }},
527  {69, { "preadv" }},
528  {70, { "pwritev" }},
529  {71, { "sendfile" }},
530  {72, { "pselect6" }},
531  {73, { "ppoll" }},
532  {74, { "signalfd64" }},
533  {75, { "vmsplice" }},
534  {76, { "splice" }},
535  {77, { "tee" }},
536  {78, { "readlinkat", readlinkatFunc<RiscvLinux32> }},
537  {79, { "fstatat" }},
538  {80, { "fstat", fstatFunc<RiscvLinux32> }},
539  {81, { "sync" }},
540  {82, { "fsync" }},
541  {83, { "fdatasync" }},
542  {84, { "sync_file_range2" }},
543  {85, { "timerfd_create" }},
544  {86, { "timerfd_settime" }},
545  {87, { "timerfd_gettime" }},
546  {88, { "utimensat" }},
547  {89, { "acct" }},
548  {90, { "capget" }},
549  {91, { "capset" }},
550  {92, { "personality" }},
551  {93, { "exit", exitFunc }},
552  {94, { "exit_group", exitGroupFunc }},
553  {95, { "waitid" }},
554  {96, { "set_tid_address", setTidAddressFunc }},
555  {97, { "unshare" }},
556  {98, { "futex", futexFunc<RiscvLinux32> }},
557  {99, { "set_robust_list", ignoreWarnOnceFunc }},
558  {100, { "get_robust_list", ignoreWarnOnceFunc }},
559  {101, { "nanosleep" }},
560  {102, { "getitimer" }},
561  {103, { "setitimer" }},
562  {104, { "kexec_load" }},
563  {105, { "init_module" }},
564  {106, { "delete_module" }},
565  {107, { "timer_create" }},
566  {108, { "timer_gettime" }},
567  {109, { "timer_getoverrun" }},
568  {110, { "timer_settime" }},
569  {111, { "timer_delete" }},
570  {112, { "clock_settime" }},
571  {113, { "clock_gettime", clock_gettimeFunc<RiscvLinux32> }},
572  {114, { "clock_getres", clock_getresFunc<RiscvLinux32> }},
573  {115, { "clock_nanosleep" }},
574  {116, { "syslog" }},
575  {117, { "ptrace" }},
576  {118, { "sched_setparam" }},
577  {119, { "sched_setscheduler" }},
578  {120, { "sched_getscheduler" }},
579  {121, { "sched_getparam" }},
580  {122, { "sched_setaffinity" }},
581  {123, { "sched_getaffinity" }},
582  {124, { "sched_yield", ignoreWarnOnceFunc }},
583  {125, { "sched_get_priority_max" }},
584  {126, { "sched_get_priority_min" }},
585  {127, { "scheD_rr_get_interval" }},
586  {128, { "restart_syscall" }},
587  {129, { "kill" }},
588  {130, { "tkill" }},
589  {131, { "tgkill", tgkillFunc<RiscvLinux32> }},
590  {132, { "sigaltstack" }},
591  {133, { "rt_sigsuspend", ignoreWarnOnceFunc }},
592  {134, { "rt_sigaction", ignoreWarnOnceFunc }},
593  {135, { "rt_sigprocmask", ignoreWarnOnceFunc }},
594  {136, { "rt_sigpending", ignoreWarnOnceFunc }},
595  {137, { "rt_sigtimedwait", ignoreWarnOnceFunc }},
596  {138, { "rt_sigqueueinfo", ignoreWarnOnceFunc }},
597  {139, { "rt_sigreturn", ignoreWarnOnceFunc }},
598  {140, { "setpriority" }},
599  {141, { "getpriority" }},
600  {142, { "reboot" }},
601  {143, { "setregid" }},
602  {144, { "setgid" }},
603  {145, { "setreuid" }},
604  {146, { "setuid", ignoreFunc }},
605  {147, { "setresuid" }},
606  {148, { "getresuid" }},
607  {149, { "getresgid" }},
608  {150, { "getresgid" }},
609  {151, { "setfsuid" }},
610  {152, { "setfsgid" }},
611  {153, { "times", timesFunc<RiscvLinux32> }},
612  {154, { "setpgid", setpgidFunc }},
613  {155, { "getpgid" }},
614  {156, { "getsid" }},
615  {157, { "setsid" }},
616  {158, { "getgroups" }},
617  {159, { "setgroups" }},
618  {160, { "uname", unameFunc32 }},
619  {161, { "sethostname" }},
620  {162, { "setdomainname" }},
621  {163, { "getrlimit", getrlimitFunc<RiscvLinux32> }},
622  {164, { "setrlimit", ignoreFunc }},
623  {165, { "getrusage", getrusageFunc<RiscvLinux32> }},
624  {166, { "umask", umaskFunc }},
625  {167, { "prctl" }},
626  {168, { "getcpu" }},
627  {169, { "gettimeofday", gettimeofdayFunc<RiscvLinux32> }},
628  {170, { "settimeofday" }},
629  {171, { "adjtimex" }},
630  {172, { "getpid", getpidFunc }},
631  {173, { "getppid", getppidFunc }},
632  {174, { "getuid", getuidFunc }},
633  {175, { "geteuid", geteuidFunc }},
634  {176, { "getgid", getgidFunc }},
635  {177, { "getegid", getegidFunc }},
636  {178, { "gettid", gettidFunc }},
637  {179, { "sysinfo", sysinfoFunc<RiscvLinux32> }},
638  {180, { "mq_open" }},
639  {181, { "mq_unlink" }},
640  {182, { "mq_timedsend" }},
641  {183, { "mq_timedrecieve" }},
642  {184, { "mq_notify" }},
643  {185, { "mq_getsetattr" }},
644  {186, { "msgget" }},
645  {187, { "msgctl" }},
646  {188, { "msgrcv" }},
647  {189, { "msgsnd" }},
648  {190, { "semget" }},
649  {191, { "semctl" }},
650  {192, { "semtimedop" }},
651  {193, { "semop" }},
652  {194, { "shmget" }},
653  {195, { "shmctl" }},
654  {196, { "shmat" }},
655  {197, { "shmdt" }},
656  {198, { "socket" }},
657  {199, { "socketpair" }},
658  {200, { "bind" }},
659  {201, { "listen" }},
660  {202, { "accept" }},
661  {203, { "connect" }},
662  {204, { "getsockname" }},
663  {205, { "getpeername" }},
664  {206, { "sendo" }},
665  {207, { "recvfrom" }},
666  {208, { "setsockopt" }},
667  {209, { "getsockopt" }},
668  {210, { "shutdown" }},
669  {211, { "sendmsg" }},
670  {212, { "recvmsg" }},
671  {213, { "readahead" }},
672  {214, { "brk", brkFunc }},
673  {215, { "munmap", munmapFunc }},
674  {216, { "mremap", mremapFunc<RiscvLinux32> }},
675  {217, { "add_key" }},
676  {218, { "request_key" }},
677  {219, { "keyctl" }},
678  {220, { "clone", cloneFunc<RiscvLinux32> }},
679  {221, { "execve", execveFunc<RiscvLinux32> }},
680  {222, { "mmap", mmapFunc<RiscvLinux32> }},
681  {223, { "fadvise64" }},
682  {224, { "swapon" }},
683  {225, { "swapoff" }},
684  {226, { "mprotect", ignoreFunc }},
685  {227, { "msync", ignoreFunc }},
686  {228, { "mlock", ignoreFunc }},
687  {229, { "munlock", ignoreFunc }},
688  {230, { "mlockall", ignoreFunc }},
689  {231, { "munlockall", ignoreFunc }},
690  {232, { "mincore", ignoreFunc }},
691  {233, { "madvise", ignoreFunc }},
692  {234, { "remap_file_pages" }},
693  {235, { "mbind", ignoreFunc }},
694  {236, { "get_mempolicy" }},
695  {237, { "set_mempolicy" }},
696  {238, { "migrate_pages" }},
697  {239, { "move_pages" }},
698  {240, { "tgsigqueueinfo" }},
699  {241, { "perf_event_open" }},
700  {242, { "accept4" }},
701  {243, { "recvmmsg" }},
702  {260, { "wait4" }},
703  {261, { "prlimit64", prlimitFunc<RiscvLinux32> }},
704  {262, { "fanotify_init" }},
705  {263, { "fanotify_mark" }},
706  {264, { "name_to_handle_at" }},
707  {265, { "open_by_handle_at" }},
708  {266, { "clock_adjtime" }},
709  {267, { "syncfs" }},
710  {268, { "setns" }},
711  {269, { "sendmmsg" }},
712  {270, { "process_vm_ready" }},
713  {271, { "process_vm_writev" }},
714  {272, { "kcmp" }},
715  {273, { "finit_module" }},
716  {274, { "sched_setattr" }},
717  {275, { "sched_getattr" }},
718  {276, { "renameat2" }},
719  {277, { "seccomp" }},
720  {278, { "getrandom" }},
721  {279, { "memfd_create" }},
722  {280, { "bpf" }},
723  {281, { "execveat" }},
724  {282, { "userfaultid" }},
725  {283, { "membarrier" }},
726  {284, { "mlock2" }},
727  {285, { "copy_file_range" }},
728  {286, { "preadv2" }},
729  {287, { "pwritev2" }},
730  {1024, { "open", openFunc<RiscvLinux32> }},
731  {1025, { "link" }},
732  {1026, { "unlink", unlinkFunc }},
733  {1027, { "mknod" }},
734  {1028, { "chmod", chmodFunc<RiscvLinux32> }},
735  {1029, { "chown", chownFunc }},
736  {1030, { "mkdir", mkdirFunc }},
737  {1031, { "rmdir" }},
738  {1032, { "lchown" }},
739  {1033, { "access", accessFunc }},
740  {1034, { "rename", renameFunc }},
741  {1035, { "readlink", readlinkFunc }},
742  {1036, { "symlink" }},
743  {1037, { "utimes", utimesFunc<RiscvLinux32> }},
744  {1038, { "stat", statFunc<RiscvLinux32> }},
745  {1039, { "lstat", lstatFunc<RiscvLinux32> }},
746  {1040, { "pipe", pipeFunc }},
747  {1041, { "dup2", dup2Func }},
748  {1042, { "epoll_create" }},
749  {1043, { "inotifiy_init" }},
750  {1044, { "eventfd" }},
751  {1045, { "signalfd" }},
752  {1046, { "sendfile" }},
753  {1047, { "ftruncate", ftruncateFunc }},
754  {1048, { "truncate", truncateFunc }},
755  {1049, { "stat", statFunc<RiscvLinux32> }},
756  {1050, { "lstat", lstatFunc<RiscvLinux32> }},
757  {1051, { "fstat", fstatFunc<RiscvLinux32> }},
758  {1052, { "fcntl", fcntlFunc }},
759  {1053, { "fadvise64" }},
760  {1054, { "newfstatat" }},
761  {1055, { "fstatfs", fstatfsFunc<RiscvLinux32> }},
762  {1056, { "statfs", statfsFunc<RiscvLinux32> }},
763  {1057, { "lseek", lseekFunc }},
764  {1058, { "mmap", mmapFunc<RiscvLinux32> }},
765  {1059, { "alarm" }},
766  {1060, { "getpgrp" }},
767  {1061, { "pause" }},
768  {1062, { "time", timeFunc<RiscvLinux32> }},
769  {1063, { "utime" }},
770  {1064, { "creat" }},
771  {1065, { "getdents" }},
772  {1066, { "futimesat" }},
773  {1067, { "select" }},
774  {1068, { "poll" }},
775  {1069, { "epoll_wait" }},
776  {1070, { "ustat" }},
777  {1071, { "vfork" }},
778  {1072, { "oldwait4" }},
779  {1073, { "recv" }},
780  {1074, { "send" }},
781  {1075, { "bdflush" }},
782  {1076, { "umount" }},
783  {1077, { "uselib" }},
784  {1078, { "sysctl" }},
785  {1079, { "fork" }},
786  {2011, { "getmainvars" }}
787 };
788 
790  ObjectFile *objFile) : RiscvProcess64(params, objFile)
791 {}
792 
795 {
796  return syscallDescs.find(callnum) != syscallDescs.end() ?
797  &syscallDescs.at(callnum) : nullptr;
798 }
799 
800 void
802 {
803  doSyscall(tc->readIntReg(SyscallNumReg), tc, fault);
804 }
805 
807  ObjectFile *objFile) : RiscvProcess32(params, objFile)
808 {}
809 
812 {
813  return syscallDescs.find(callnum) != syscallDescs.end() ?
814  &syscallDescs.at(callnum) : nullptr;
815 }
816 
817 void
819 {
820  doSyscall(tc->readIntReg(SyscallNumReg), tc, fault);
821 }
const RegIndex SyscallNumReg
Definition: registers.hh:84
ObjectFile * objFile
Definition: process.hh:217
Bitfield< 30, 0 > index
Arch getArch() const
Definition: object_file.hh:124
const std::string & name()
Definition: trace.cc:54
SyscallReturn geteuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target geteuid() handler.
SyscallReturn ignoreFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Handler for unimplemented syscalls that we never intend to implement (signal handling, etc.) and should not affect the correct behavior of the program.
Definition: syscall_emul.cc:77
SyscallReturn dup2Func(SyscallDesc *desc, int num, ThreadContext *tc, int old_tgt_fd, int new_tgt_fd)
Target dup2() handler.
SyscallReturn getcwdFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr buf_ptr, unsigned long size)
Target getcwd() handler.
virtual RegVal readIntReg(RegIndex reg_idx) const =0
RiscvLinuxProcess32(ProcessParams *params, ObjectFile *objFile)
Constructor.
Definition: process.cc:806
A process with emulated Riscv/Linux syscalls.
Definition: process.hh:45
virtual PortProxy & getVirtProxy()=0
virtual Process * getProcessPtr()=0
SyscallReturn fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc)
Target fcntl() handler.
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:586
void doSyscall(int64_t callnum, ThreadContext *tc, Fault *fault)
Definition: process.cc:430
TypedBufferArg is a class template; instances of this template represent typed buffers in target user...
static std::map< int, SyscallDescABI< DefaultSyscallABI > > syscallDescs
Array of syscall descriptors, indexed by call number.
Definition: process.hh:82
SyscallReturn fallocateFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int tgt_fd, int mode, off_t offset, off_t len)
ThreadContext is the external interface to all thread state for anything outside of the CPU...
SyscallReturn closeFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd)
Target close() handler.
SyscallDesc * getDesc(int callnum) override
Definition: process.cc:811
SyscallReturn getegidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target getegid() handler.
SyscallReturn renameFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr oldpath, Addr newpath)
Target rename() handler.
SyscallReturn umaskFunc(SyscallDesc *desc, int num, ThreadContext *tc)
Target umask() handler.
SyscallReturn munmapFunc(SyscallDesc *desc, int num, ThreadContext *tc)
Target munmap() handler.
SyscallReturn getuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
SyscallReturn unlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname)
Target unlink() handler.
RiscvLinuxProcess64(ProcessParams *params, ObjectFile *objFile)
Constructor.
Definition: process.cc:789
SyscallReturn fchownFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd, uint32_t owner, uint32_t group)
Target fchown() handler.
SyscallReturn exitGroupFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int status)
Target exit_group() handler: terminate simulation. (exit all threads)
SyscallReturn mkdirFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, mode_t mode)
Target mkdir() handler.
static SyscallReturn unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target uname() handler.
Definition: process.cc:91
SyscallReturn readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, Addr buf_ptr, size_t bufsiz)
Target readlink() handler.
SyscallDesc * getDesc(int callnum) override
Definition: process.cc:794
SyscallReturn ftruncateFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd, off_t length)
Target ftruncate() handler.
SyscallReturn getppidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target getppid() handler.
static std::map< int, SyscallDescABI< DefaultSyscallABI > > syscallDescs
Array of syscall descriptors, indexed by call number.
Definition: process.hh:62
SyscallReturn brkFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr new_brk)
Target brk() handler: set brk address.
SyscallReturn ignoreWarnOnceFunc(SyscallDesc *desc, int num, ThreadContext *tc)
Like above, but only prints a warning once per syscall desc it&#39;s used with.
Definition: syscall_emul.cc:84
SyscallReturn dupFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd)
FIXME: The file description is not shared among file descriptors created with dup.
SyscallReturn getgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target getgid() handler.
static SyscallReturn unameFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target uname() handler.
Definition: process.cc:109
This class provides the wrapper interface for the system call implementations which are defined in th...
Definition: syscall_desc.hh:69
SyscallReturn gettidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target gettid() handler.
SyscallReturn truncateFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, off_t length)
Target truncate() handler.
SyscallReturn fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc)
Target fcntl64() handler.
SyscallReturn lseekFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd, uint64_t offs, int whence)
Target lseek() handler.
SyscallReturn pipeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target pipe() handler.
SyscallReturn accessFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr pathname, mode_t mode)
Target access() handler.
This file defines objects used to emulate syscalls from the target application on the host machine...
SyscallReturn setTidAddressFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, uint64_t tidPtr)
Target set_tid_address() handler.
SyscallReturn setpgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int pid, int pgid)
Target setpgid() handler.
OpSys getOpSys() const
Definition: object_file.hh:125
SyscallReturn chownFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, uint32_t owner, uint32_t group)
Target chown() handler.
SyscallReturn truncate64Func(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, int64_t length)
Target truncate64() handler.
void syscall(ThreadContext *tc, Fault *fault) override
Definition: process.cc:801
#define warn(...)
Definition: logging.hh:212
This class represents the return value from an emulated system call, including any errno setting...
Each instance of a Loader subclass will have a chance to try to load an object file when tryLoaders i...
Definition: process.hh:191
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
SyscallReturn getpidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target getpid() handler.
SyscallReturn exitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int status)
Target exit() handler: terminate current context.
SyscallReturn ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc)
Target ftruncate64() handler.
void syscall(ThreadContext *tc, Fault *fault) override
Definition: process.cc:818

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13