gem5  v22.1.0.0
se_workload.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2013, 2015, 2020 ARM Limited
3  *
4  * The license below extends only to copyright in the software and shall
5  * not be construed as granting a license to any other intellectual
6  * property including but not limited to intellectual property relating
7  * to a hardware implementation of the functionality of the software
8  * licensed hereunder. You may use the software subject to the license
9  * terms below provided that you ensure that this notice is replicated
10  * unmodified and in its entirety in all distributions of the software,
11  * modified or unmodified, in source code or in binary form.
12  *
13  * Copyright 2003-2005 The Regents of The University of Michigan
14  * Copyright 2007-2008 The Florida State University
15  * Copyright 2020 Google Inc.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
42 
43 #include <sys/syscall.h>
44 
47 #include "base/trace.hh"
48 #include "cpu/thread_context.hh"
50 #include "sim/syscall_emul.hh"
51 
52 namespace gem5
53 {
54 
55 namespace
56 {
57 
58 class LinuxLoader : public Process::Loader
59 {
60  public:
61  Process *
62  load(const ProcessParams &params, loader::ObjectFile *obj) override
63  {
64  auto arch = obj->getArch();
65  auto opsys = obj->getOpSys();
66 
67  if (arch != loader::Arm && arch != loader::Thumb &&
68  arch != loader::Arm64) {
69  return nullptr;
70  }
71 
72  if (opsys == loader::UnknownOpSys) {
73  warn("Unknown operating system; assuming Linux.");
74  opsys = loader::Linux;
75  }
76 
77  if (opsys == loader::LinuxArmOABI) {
78  fatal("gem5 does not support ARM OABI binaries. Please recompile "
79  "with an EABI compiler.");
80  }
81 
82  if (opsys != loader::Linux)
83  return nullptr;
84 
85  if (arch == loader::Arm64)
86  return new ArmLinuxProcess64(params, obj, arch);
87  else
88  return new ArmLinuxProcess32(params, obj, arch);
89  }
90 };
91 
92 LinuxLoader linuxLoader;
93 
94 } // anonymous namespace
95 
96 namespace ArmISA
97 {
98 
100 static SyscallReturn
102 {
103  auto process = tc->getProcessPtr();
104 
105  strcpy(name->sysname, "Linux");
106  strcpy(name->nodename, "m5.eecs.umich.edu");
107  strcpy(name->release, process->release.c_str());
108  strcpy(name->version, "#1 SMP Sat Dec 1 00:00:00 GMT 2012");
109  strcpy(name->machine, "armv7l");
110 
111  return 0;
112 }
113 
115 static SyscallReturn
117 {
118  auto process = tc->getProcessPtr();
119 
120  strcpy(name->sysname, "Linux");
121  strcpy(name->nodename, "gem5");
122  strcpy(name->release, process->release.c_str());
123  strcpy(name->version, "#1 SMP Sat Dec 1 00:00:00 GMT 2012");
124  strcpy(name->machine, "armv8l");
125 
126  return 0;
127 }
128 
130 static SyscallReturn
131 setTLSFunc32(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
132 {
134  ArmLinuxProcess32::commPage + 0x0ff0, &tlsPtr, sizeof(tlsPtr));
135  tc->setMiscReg(MISCREG_TPIDRURO, tlsPtr);
136  return 0;
137 }
138 
139 static SyscallReturn
140 setTLSFunc64(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
141 {
142  tc->setMiscReg(MISCREG_TPIDRRO_EL0, tlsPtr);
143  return 0;
144 }
145 
146 class SyscallTable32 : public SyscallDescTable<EmuLinux::SyscallABI32>
147 {
148  public:
150  { base + 0, "syscall" },
151  { base + 1, "exit", exitFunc },
152  { base + 2, "fork" },
153  { base + 3, "read", readFunc<ArmLinux32> },
154  { base + 4, "write", writeFunc<ArmLinux32> },
155  { base + 5, "open", openFunc<ArmLinux32> },
156  { base + 6, "close", closeFunc },
157  { base + 8, "creat" },
158  { base + 9, "link" },
159  { base + 10, "unlink", unlinkFunc },
160  { base + 11, "execve", execveFunc<ArmLinux32> },
161  { base + 12, "chdir", chdirFunc },
162  { base + 13, "time", timeFunc<ArmLinux32> },
163  { base + 14, "mknod", mknodFunc },
164  { base + 15, "chmod", chmodFunc<ArmLinux32> },
165  { base + 16, "lchown", chownFunc },
166  { base + 19, "lseek", lseekFunc },
167  { base + 20, "getpid", getpidFunc },
168  { base + 21, "mount" },
169  { base + 22, "umount" },
170  { base + 23, "setuid", ignoreFunc },
171  { base + 24, "getuid", getuidFunc },
172  { base + 25, "stime" },
173  { base + 26, "ptrace" },
174  { base + 27, "alarm" },
175  { base + 29, "pause" },
176  { base + 30, "utime" },
177  { base + 33, "access", accessFunc },
178  { base + 34, "nice" },
179  { base + 36, "sync" },
180  { base + 37, "kill", ignoreFunc },
181  { base + 38, "rename", renameFunc },
182  { base + 39, "mkdir", mkdirFunc },
183  { base + 40, "rmdir" },
184  { base + 41, "dup", dupFunc },
185  { base + 42, "pipe", pipePseudoFunc },
186  { base + 43, "times", timesFunc<ArmLinux32> },
187  { base + 45, "brk", brkFunc },
188  { base + 46, "setgid" },
189  { base + 47, "getgid", getgidFunc },
190  { base + 49, "geteuid", geteuidFunc },
191  { base + 50, "getegid", getegidFunc },
192  { base + 51, "acct" },
193  { base + 52, "umount2" },
194  { base + 54, "ioctl", ioctlFunc<ArmLinux32> },
195  { base + 55, "fcntl", fcntlFunc },
196  { base + 57, "setpgid" },
197  { base + 60, "umask", umaskFunc },
198  { base + 61, "chroot" },
199  { base + 62, "ustat" },
200  { base + 63, "dup2" },
201  { base + 64, "getppid", getppidFunc },
202  { base + 65, "getpgrp" },
203  { base + 66, "setsid" },
204  { base + 67, "sigaction" },
205  { base + 70, "setreuid" },
206  { base + 71, "setregid" },
207  { base + 72, "sigsuspend" },
208  { base + 73, "sigpending" },
209  { base + 74, "sethostname", ignoreFunc },
210  { base + 75, "setrlimit", ignoreFunc },
211  { base + 76, "getrlimit", getrlimitFunc<ArmLinux32> },
212  { base + 77, "getrusage", getrusageFunc<ArmLinux32> },
213  { base + 78, "gettimeofday", gettimeofdayFunc<ArmLinux32> },
214  { base + 79, "settimeofday" },
215  { base + 80, "getgroups" },
216  { base + 81, "setgroups" },
217  { base + 82, "reserved#82" },
218  { base + 83, "symlink" },
219  { base + 85, "readlink", readlinkFunc<ArmLinux32> },
220  { base + 86, "uselib" },
221  { base + 87, "swapon" },
222  { base + 88, "reboot" },
223  { base + 89, "readdir" },
224  { base + 90, "mmap", mmapFunc<ArmLinux32> },
225  { base + 91, "munmap", munmapFunc<ArmLinux32> },
226  { base + 92, "truncate", truncateFunc<ArmLinux32> },
227  { base + 93, "ftruncate", ftruncateFunc<ArmLinux32> },
228  { base + 94, "fchmod" },
229  { base + 95, "fchown", fchownFunc },
230  { base + 96, "getpriority" },
231  { base + 97, "setpriority" },
232  { base + 99, "statfs" },
233  { base + 100, "fstatfs" },
234  { base + 102, "socketcall" },
235  { base + 103, "syslog" },
236  { base + 104, "setitimer" },
237  { base + 105, "getitimer" },
238  { base + 106, "stat", statFunc<ArmLinux32> },
239  { base + 107, "lstat" },
240  { base + 108, "fstat", fstatFunc<ArmLinux32> },
241  { base + 111, "vhangup" },
242  { base + 113, "syscall" },
243  { base + 114, "wait4" },
244  { base + 115, "swapoff" },
245  { base + 116, "sysinfo", sysinfoFunc<ArmLinux32> },
246  { base + 117, "ipc" },
247  { base + 118, "fsync" },
248  { base + 119, "sigreturn" },
249  { base + 120, "clone", cloneBackwardsFunc<ArmLinux32> },
250  { base + 121, "setdomainname" },
251  { base + 122, "uname", unameFunc32 },
252  { base + 124, "adjtimex" },
253  { base + 125, "mprotect", ignoreFunc },
254  { base + 126, "sigprocmask", ignoreWarnOnceFunc },
255  { base + 128, "init_module" },
256  { base + 129, "delete_module" },
257  { base + 131, "quotactl" },
258  { base + 132, "getpgid" },
259  { base + 133, "fchdir" },
260  { base + 134, "bdflush" },
261  { base + 135, "sysfs" },
262  { base + 136, "personality" },
263  { base + 137, "reserved#138" },
264  { base + 138, "setfsuid" },
265  { base + 139, "setfsgid" },
266  { base + 140, "llseek", _llseekFunc },
267 #if defined(SYS_getdents)
268  { base + 141, "getdents", getdentsFunc },
269 #else
270  { base + 141, "getdents" },
271 #endif
272  { base + 142, "newselect" },
273  { base + 143, "flock" },
274  { base + 144, "msync" },
275  { base + 145, "readv" },
276  { base + 146, "writev", writevFunc<ArmLinux32> },
277  { base + 147, "getsid" },
278  { base + 148, "fdatasync" },
279  { base + 149, "sysctl" },
280  { base + 150, "mlock" },
281  { base + 151, "munlock" },
282  { base + 152, "mlockall" },
283  { base + 153, "munlockall" },
284  { base + 154, "sched_setparam", ignoreWarnOnceFunc },
285  { base + 155, "sched_getparam", ignoreWarnOnceFunc },
286  { base + 156, "sched_setscheduler", ignoreWarnOnceFunc },
287  { base + 157, "sched_getscheduler", ignoreWarnOnceFunc },
288  { base + 158, "sched_yield", ignoreWarnOnceFunc },
289  { base + 159, "sched_get_priority_max", ignoreWarnOnceFunc },
290  { base + 160, "sched_get_priority_min", ignoreWarnOnceFunc },
291  { base + 161, "sched_rr_get_interval", ignoreWarnOnceFunc },
292  { base + 162, "nanosleep", ignoreWarnOnceFunc },
293  { base + 163, "mremap", mremapFunc<ArmLinux32> }, // ARM-specific
294  { base + 164, "setresuid" },
295  { base + 165, "getresuid" },
296  { base + 168, "poll" },
297  { base + 169, "nfsservctl" },
298  { base + 170, "setresgid" },
299  { base + 171, "getresgid" },
300  { base + 172, "prctl" },
301  { base + 173, "rt_sigreturn" },
302  { base + 174, "rt_sigaction", ignoreWarnOnceFunc },
303  { base + 175, "rt_sigprocmask", ignoreWarnOnceFunc },
304  { base + 176, "rt_sigpending" },
305  { base + 177, "rt_sigtimedwait" },
306  { base + 178, "rt_sigqueueinfo", ignoreFunc },
307  { base + 179, "rt_sigsuspend" },
308  { base + 180, "pread64" },
309  { base + 181, "pwrite64" },
310  { base + 182, "chown" },
311  { base + 183, "getcwd", getcwdFunc },
312  { base + 184, "capget" },
313  { base + 185, "capset" },
314  { base + 186, "sigaltstack" },
315  { base + 187, "sendfile" },
316  { base + 190, "vfork" },
317  { base + 191, "getrlimit", getrlimitFunc<ArmLinux32> },
318  { base + 192, "mmap2", mmapFunc<ArmLinux32> },
319  { base + 193, "truncate64" },
320  { base + 194, "ftruncate64", ftruncate64Func },
321  { base + 195, "stat64", stat64Func<ArmLinux32> },
322  { base + 196, "lstat64", lstat64Func<ArmLinux32> },
323  { base + 197, "fstat64", fstat64Func<ArmLinux32> },
324  { base + 198, "lchown" },
325  { base + 199, "getuid", getuidFunc },
326  { base + 200, "getgid", getgidFunc },
327  { base + 201, "geteuid", geteuidFunc },
328  { base + 202, "getegid", getegidFunc },
329  { base + 203, "setreuid" },
330  { base + 204, "setregid" },
331  { base + 205, "getgroups" },
332  { base + 206, "setgroups" },
333  { base + 207, "fchown", fchownFunc },
334  { base + 208, "setresuid" },
335  { base + 209, "getresuid" },
336  { base + 210, "setresgid" },
337  { base + 211, "getresgid" },
338  { base + 212, "chown" },
339  { base + 213, "setuid" },
340  { base + 214, "setgid" },
341  { base + 215, "setfsuid" },
342  { base + 216, "setfsgid" },
343 #if defined(SYS_getdents64)
344  { base + 217, "getdents64", getdents64Func },
345 #else
346  { base + 217, "getdents64" },
347 #endif
348  { base + 218, "pivot_root" },
349  { base + 219, "mincore" },
350  { base + 220, "madvise", ignoreFunc },
351  { base + 221, "fcntl64", fcntl64Func },
352  { base + 224, "gettid", gettidFunc },
353  { base + 225, "readahead" },
354  { base + 226, "setxattr" },
355  { base + 227, "lsetxattr" },
356  { base + 228, "fsetxattr" },
357  { base + 229, "getxattr" },
358  { base + 230, "lgetxattr" },
359  { base + 231, "fgetxattr" },
360  { base + 232, "listxattr" },
361  { base + 233, "llistxattr" },
362  { base + 234, "flistxattr" },
363  { base + 235, "removexattr" },
364  { base + 236, "lremovexattr" },
365  { base + 237, "fremovexattr" },
366  { base + 238, "tkill" },
367  { base + 239, "sendfile64" },
368  { base + 240, "futex", futexFunc<ArmLinux32> },
369  { base + 241, "sched_setaffinity", ignoreWarnOnceFunc },
370  { base + 242, "sched_getaffinity", ignoreFunc },
371  { base + 243, "io_setup" },
372  { base + 244, "io_destroy" },
373  { base + 245, "io_getevents" },
374  { base + 246, "io_submit" },
375  { base + 247, "io_cancel" },
376  { base + 248, "exit_group", exitGroupFunc },
377  { base + 249, "lookup_dcookie" },
378  { base + 250, "epoll_create" },
379  { base + 251, "epoll_ctl" },
380  { base + 252, "epoll_wait" },
381  { base + 253, "remap_file_pages" },
382  { base + 256, "set_tid_address", setTidAddressFunc },
383  { base + 257, "timer_create" },
384  { base + 258, "timer_settime" },
385  { base + 259, "timer_gettime" },
386  { base + 260, "timer_getoverrun" },
387  { base + 261, "timer_delete" },
388  { base + 262, "clock_settime" },
389  { base + 263, "clock_gettime", clock_gettimeFunc<ArmLinux32> },
390  { base + 264, "clock_getres", clock_getresFunc<ArmLinux32> },
391  { base + 265, "clock_nanosleep" },
392  { base + 266, "statfs64" },
393  { base + 267, "fstatfs64" },
394  { base + 268, "tgkill", tgkillFunc<ArmLinux32> },
395  { base + 269, "utimes", utimesFunc<ArmLinux32> },
396  { base + 270, "arm_fadvise64_64" },
397  { base + 271, "pciconfig_iobase" },
398  { base + 272, "pciconfig_read" },
399  { base + 273, "pciconfig_write" },
400  { base + 274, "mq_open" },
401  { base + 275, "mq_unlink" },
402  { base + 276, "mq_timedsend" },
403  { base + 277, "mq_timedreceive" },
404  { base + 278, "mq_notify" },
405  { base + 279, "mq_getsetattr" },
406  { base + 280, "waitid" },
407  { base + 281, "socket" },
408  { base + 282, "bind" },
409  { base + 283, "connect" },
410  { base + 284, "listen" },
411  { base + 285, "accept" },
412  { base + 286, "getsockname" },
413  { base + 287, "getpeername" },
414  { base + 288, "socketpair" },
415  { base + 289, "send" },
416  { base + 290, "sendto", sendtoFunc<ArmLinux32> },
417  { base + 291, "recv" },
418  { base + 292, "recvfrom", recvfromFunc<ArmLinux32> },
419  { base + 293, "shutdown" },
420  { base + 294, "setsockopt" },
421  { base + 295, "getsockopt" },
422  { base + 296, "sendmsg" },
423  { base + 297, "rcvmsg" },
424  { base + 298, "semop" },
425  { base + 299, "semget" },
426  { base + 300, "semctl" },
427  { base + 301, "msgsend" },
428  { base + 302, "msgrcv" },
429  { base + 303, "msgget" },
430  { base + 304, "msgctl" },
431  { base + 305, "shmat" },
432  { base + 306, "shmdt" },
433  { base + 307, "shmget" },
434  { base + 308, "shmctl" },
435  { base + 309, "add_key" },
436  { base + 310, "request_key" },
437  { base + 311, "keyctl" },
438  { base + 312, "semtimedop" },
439  { base + 314, "ioprio_set" },
440  { base + 315, "ioprio_get" },
441  { base + 316, "inotify_init" },
442  { base + 317, "inotify_add_watch" },
443  { base + 318, "inotify_rm_watch" },
444  { base + 319, "mbind" },
445  { base + 320, "get_mempolicy" },
446  { base + 321, "set_mempolicy" },
447  { base + 322, "openat", openatFunc<ArmLinux32> },
448  { base + 323, "mkdirat", mkdiratFunc<ArmLinux32> },
449  { base + 324, "mknodat", mknodatFunc<ArmLinux32> },
450  { base + 325, "fchownat", fchownatFunc<ArmLinux32> },
451  { base + 326, "futimesat", futimesatFunc<ArmLinux32> },
452  { base + 327, "fstatat64" },
453  { base + 328, "unlinkat", unlinkatFunc<ArmLinux32> },
454  { base + 329, "renameat", renameatFunc<ArmLinux32> },
455  { base + 330, "linkat" },
456  { base + 331, "symlinkat" },
457  { base + 332, "readlinkat", readlinkatFunc<ArmLinux32> },
458  { base + 333, "fchmodat", fchmodatFunc<ArmLinux32> },
459  { base + 334, "faccessat", faccessatFunc<ArmLinux32> },
460  { base + 335, "pselect6" },
461  { base + 336, "ppoll" },
462  { base + 337, "unshare" },
463  { base + 338, "set_robust_list", ignoreFunc },
464  { base + 339, "get_robust_list" },
465  { base + 340, "splice" },
466  { base + 341, "arm_sync_file_range" },
467  { base + 342, "tee" },
468  { base + 343, "vmsplice" },
469  { base + 344, "move_pages" },
470  { base + 345, "getcpu", getcpuFunc },
471  { base + 346, "epoll_pwait" },
472  { base + 347, "sys_kexec_load" },
473  { base + 348, "sys_utimensat" },
474  { base + 349, "sys_signalfd" },
475  { base + 350, "sys_timerfd_create" },
476  { base + 351, "sys_eventfd" },
477  { base + 352, "sys_fallocate" },
478  { base + 353, "sys_timerfd_settime" },
479  { base + 354, "sys_timerfd_gettime" },
480  { base + 355, "sys_signalfd4" },
481  { base + 356, "sys_eventfd2" },
482  { base + 357, "sys_epoll_create1" },
483  { base + 358, "sys_dup3" },
484  { base + 359, "sys_pipe2" },
485  { base + 360, "sys_inotify_init1" },
486  { base + 361, "sys_preadv" },
487  { base + 362, "sys_pwritev" },
488  { base + 363, "sys_rt_tgsigqueueinfo" },
489  { base + 364, "sys_perf_event_open" },
490  { base + 365, "sys_recvmmsg" },
491  { base + 384, "getrandom", getrandomFunc<ArmLinux32> }
492  })
493  {}
494 };
495 
497 
498 class SyscallTable64 : public SyscallDescTable<EmuLinux::SyscallABI64>
499 {
500  public:
502  { base + 0, "io_setup" },
503  { base + 1, "io_destroy" },
504  { base + 2, "io_submit" },
505  { base + 3, "io_cancel" },
506  { base + 4, "io_getevents" },
507  { base + 5, "setxattr" },
508  { base + 6, "lsetxattr" },
509  { base + 7, "fsetxattr" },
510  { base + 8, "getxattr" },
511  { base + 9, "lgetxattr" },
512  { base + 10, "fgetxattr" },
513  { base + 11, "listxattr" },
514  { base + 12, "llistxattr" },
515  { base + 13, "flistxattr" },
516  { base + 14, "removexattr" },
517  { base + 15, "lremovexattr" },
518  { base + 16, "fremovexattr" },
519  { base + 17, "getcwd", getcwdFunc },
520  { base + 18, "lookup_dcookie" },
521  { base + 19, "eventfd2" },
522  { base + 20, "epoll_create1" },
523  { base + 21, "epoll_ctl" },
524  { base + 22, "epoll_pwait" },
525  { base + 23, "dup", dupFunc },
526  { base + 24, "dup3" },
527  { base + 25, "fcntl64", fcntl64Func },
528  { base + 26, "inotify_init1" },
529  { base + 27, "inotify_add_watch" },
530  { base + 28, "inotify_rm_watch" },
531  { base + 29, "ioctl", ioctlFunc<ArmLinux64> },
532  { base + 30, "ioprio_set" },
533  { base + 31, "ioprio_get" },
534  { base + 32, "flock" },
535  { base + 33, "mknodat", mknodatFunc<ArmLinux64> },
536  { base + 34, "mkdirat", mkdiratFunc<ArmLinux64> },
537  { base + 35, "unlinkat", unlinkatFunc<ArmLinux64> },
538  { base + 36, "symlinkat" },
539  { base + 37, "linkat" },
540  { base + 38, "renameat", renameatFunc<ArmLinux64> },
541  { base + 39, "umount2" },
542  { base + 40, "mount" },
543  { base + 41, "pivot_root" },
544  { base + 42, "nfsservctl" },
545  { base + 43, "statfs64" },
546  { base + 44, "fstatfs64" },
547  { base + 45, "truncate64" },
548  { base + 46, "ftruncate64", ftruncate64Func },
549  { base + 47, "fallocate", fallocateFunc<ArmLinux64> },
550  { base + 48, "faccessat", faccessatFunc<ArmLinux64> },
551  { base + 49, "chdir", chdirFunc },
552  { base + 50, "fchdir" },
553  { base + 51, "chroot" },
554  { base + 52, "fchmod" },
555  { base + 53, "fchmodat", fchmodatFunc<ArmLinux64> },
556  { base + 54, "fchownat", fchownatFunc<ArmLinux64> },
557  { base + 55, "fchown", fchownFunc },
558  { base + 56, "openat", openatFunc<ArmLinux64> },
559  { base + 57, "close", closeFunc },
560  { base + 58, "vhangup" },
561  { base + 59, "pipe2" },
562  { base + 60, "quotactl" },
563 #if defined(SYS_getdents64)
564  { base + 61, "getdents64", getdents64Func },
565 #else
566  { base + 61, "getdents64" },
567 #endif
568  { base + 62, "llseek", lseekFunc },
569  { base + 63, "read", readFunc<ArmLinux64> },
570  { base + 64, "write", writeFunc<ArmLinux64> },
571  { base + 65, "readv" },
572  { base + 66, "writev", writevFunc<ArmLinux64> },
573  { base + 67, "pread64" },
574  { base + 68, "pwrite64" },
575  { base + 69, "preadv" },
576  { base + 70, "pwritev" },
577  { base + 71, "sendfile64" },
578  { base + 72, "pselect6" },
579  { base + 73, "ppoll" },
580  { base + 74, "signalfd4" },
581  { base + 75, "vmsplice" },
582  { base + 76, "splice" },
583  { base + 77, "tee" },
584  { base + 78, "readlinkat", readlinkatFunc<ArmLinux64> },
585  { base + 79, "fstatat64", fstatat64Func<ArmLinux64> },
586  { base + 80, "fstat64", fstat64Func<ArmLinux64> },
587  { base + 81, "sync" },
588  { base + 82, "fsync" },
589  { base + 83, "fdatasync" },
590  { base + 84, "sync_file_range" },
591  { base + 85, "timerfd_create" },
592  { base + 86, "timerfd_settime" },
593  { base + 87, "timerfd_gettime" },
594  { base + 88, "utimensat" },
595  { base + 89, "acct" },
596  { base + 90, "capget" },
597  { base + 91, "capset" },
598  { base + 92, "personality" },
599  { base + 93, "exit", exitFunc },
600  { base + 94, "exit_group", exitGroupFunc },
601  { base + 95, "waitid" },
602  { base + 96, "set_tid_address", setTidAddressFunc },
603  { base + 97, "unshare" },
604  { base + 98, "futex", futexFunc<ArmLinux64> },
605  { base + 99, "set_robust_list", ignoreFunc },
606  { base + 100, "get_robust_list" },
607  { base + 101, "nanosleep", ignoreWarnOnceFunc },
608  { base + 102, "getitimer" },
609  { base + 103, "setitimer" },
610  { base + 104, "kexec_load" },
611  { base + 105, "init_module" },
612  { base + 106, "delete_module" },
613  { base + 107, "timer_create" },
614  { base + 108, "timer_gettime" },
615  { base + 109, "timer_getoverrun" },
616  { base + 110, "timer_settime" },
617  { base + 111, "timer_delete" },
618  { base + 112, "clock_settime" },
619  { base + 113, "clock_gettime", clock_gettimeFunc<ArmLinux64> },
620  { base + 114, "clock_getres" },
621  { base + 115, "clock_nanosleep" },
622  { base + 116, "syslog" },
623  { base + 117, "ptrace" },
624  { base + 118, "sched_setparam", ignoreWarnOnceFunc },
625  { base + 119, "sched_setscheduler", ignoreWarnOnceFunc },
626  { base + 120, "sched_getscheduler", ignoreWarnOnceFunc },
627  { base + 121, "sched_getparam", ignoreWarnOnceFunc },
628  { base + 122, "sched_setaffinity", ignoreWarnOnceFunc },
629  { base + 123, "sched_getaffinity", ignoreFunc },
630  { base + 124, "sched_yield", ignoreWarnOnceFunc },
631  { base + 125, "sched_get_priority_max", ignoreWarnOnceFunc },
632  { base + 126, "sched_get_priority_min", ignoreWarnOnceFunc },
633  { base + 127, "sched_rr_get_interval", ignoreWarnOnceFunc },
634  { base + 128, "restart_syscall" },
635  { base + 129, "kill", ignoreFunc },
636  { base + 130, "tkill" },
637  { base + 131, "tgkill", tgkillFunc<ArmLinux64> },
638  { base + 132, "sigaltstack" },
639  { base + 133, "rt_sigsuspend" },
640  { base + 134, "rt_sigaction", ignoreFunc },
641  { base + 135, "rt_sigprocmask", ignoreWarnOnceFunc },
642  { base + 136, "rt_sigpending" },
643  { base + 137, "rt_sigtimedwait" },
644  { base + 138, "rt_sigqueueinfo", ignoreFunc },
645  { base + 139, "rt_sigreturn" },
646  { base + 140, "setpriority" },
647  { base + 141, "getpriority" },
648  { base + 142, "reboot" },
649  { base + 143, "setregid" },
650  { base + 144, "setgid" },
651  { base + 145, "setreuid" },
652  { base + 146, "setuid" },
653  { base + 147, "setresuid" },
654  { base + 148, "getresuid" },
655  { base + 149, "setresgid" },
656  { base + 150, "getresgid" },
657  { base + 151, "setfsuid" },
658  { base + 152, "setfsgid" },
659  { base + 153, "times", timesFunc<ArmLinux64> },
660  { base + 154, "setpgid" },
661  { base + 155, "getpgid" },
662  { base + 156, "getsid" },
663  { base + 157, "setsid" },
664  { base + 158, "getgroups" },
665  { base + 159, "setgroups" },
666  { base + 160, "uname", unameFunc64 },
667  { base + 161, "sethostname", ignoreFunc },
668  { base + 162, "setdomainname" },
669  { base + 163, "getrlimit", getrlimitFunc<ArmLinux64> },
670  { base + 164, "setrlimit", ignoreFunc },
671  { base + 165, "getrusage", getrusageFunc<ArmLinux64> },
672  { base + 166, "umask" },
673  { base + 167, "prctl" },
674  { base + 168, "getcpu", getcpuFunc },
675  { base + 169, "gettimeofday", gettimeofdayFunc<ArmLinux64> },
676  { base + 170, "settimeofday" },
677  { base + 171, "adjtimex" },
678  { base + 172, "getpid", getpidFunc },
679  { base + 173, "getppid", getppidFunc },
680  { base + 174, "getuid", getuidFunc },
681  { base + 175, "geteuid", geteuidFunc },
682  { base + 176, "getgid", getgidFunc },
683  { base + 177, "getegid", getegidFunc },
684  { base + 178, "gettid", gettidFunc },
685  { base + 179, "sysinfo", sysinfoFunc<ArmLinux64> },
686  { base + 180, "mq_open" },
687  { base + 181, "mq_unlink" },
688  { base + 182, "mq_timedsend" },
689  { base + 183, "mq_timedreceive" },
690  { base + 184, "mq_notify" },
691  { base + 185, "mq_getsetattr" },
692  { base + 186, "msgget" },
693  { base + 187, "msgctl" },
694  { base + 188, "msgrcv" },
695  { base + 189, "msgsnd" },
696  { base + 190, "semget" },
697  { base + 191, "semctl" },
698  { base + 192, "semtimedop" },
699  { base + 193, "semop" },
700  { base + 194, "shmget" },
701  { base + 195, "shmctl" },
702  { base + 196, "shmat" },
703  { base + 197, "shmdt" },
704  { base + 198, "socket" },
705  { base + 199, "socketpair" },
706  { base + 200, "bind" },
707  { base + 201, "listen" },
708  { base + 202, "accept" },
709  { base + 203, "connect" },
710  { base + 204, "getsockname" },
711  { base + 205, "getpeername" },
712  { base + 206, "sendto", sendtoFunc<ArmLinux64> },
713  { base + 207, "recvfrom", recvfromFunc<ArmLinux64> },
714  { base + 208, "setsockopt" },
715  { base + 209, "getsockopt" },
716  { base + 210, "shutdown" },
717  { base + 211, "sendmsg" },
718  { base + 212, "recvmsg" },
719  { base + 213, "readahead" },
720  { base + 214, "brk", brkFunc },
721  { base + 215, "munmap", munmapFunc<ArmLinux64> },
722  { base + 216, "mremap", mremapFunc<ArmLinux64> },
723  { base + 217, "add_key" },
724  { base + 218, "request_key" },
725  { base + 219, "keyctl" },
726  { base + 220, "clone", cloneBackwardsFunc<ArmLinux64> },
727  { base + 221, "execve", execveFunc<ArmLinux64> },
728  { base + 222, "mmap2", mmapFunc<ArmLinux64> },
729  { base + 223, "fadvise64_64" },
730  { base + 224, "swapon" },
731  { base + 225, "swapoff" },
732  { base + 226, "mprotect", ignoreFunc },
733  { base + 227, "msync" },
734  { base + 228, "mlock" },
735  { base + 229, "munlock" },
736  { base + 230, "mlockall" },
737  { base + 231, "munlockall" },
738  { base + 232, "mincore" },
739  { base + 233, "madvise", ignoreFunc },
740  { base + 234, "remap_file_pages" },
741  { base + 235, "mbind" },
742  { base + 236, "get_mempolicy" },
743  { base + 237, "set_mempolicy" },
744  { base + 238, "migrate_pages" },
745  { base + 239, "move_pages" },
746  { base + 240, "rt_tgsigqueueinfo" },
747  { base + 241, "perf_event_open" },
748  { base + 242, "accept4" },
749  { base + 243, "recvmmsg" },
750  { base + 260, "wait4" },
751  { base + 261, "prlimit64", prlimitFunc<ArmLinux64> },
752  { base + 262, "fanotify_init" },
753  { base + 263, "fanotify_mark" },
754  { base + 264, "name_to_handle_at" },
755  { base + 265, "open_by_handle_at" },
756  { base + 266, "clock_adjtime" },
757  { base + 267, "syncfs" },
758  { base + 268, "setns" },
759  { base + 269, "sendmmsg" },
760  { base + 270, "process_vm_readv" },
761  { base + 271, "process_vm_writev" },
762  { base + 272, "kcmp" },
763  { base + 273, "finit_module" },
764  { base + 274, "sched_setattr"},
765  { base + 275, "sched_getattr"},
766  { base + 276, "renameat2"},
767  { base + 277, "seccomp"},
768  { base + 278, "getrandom", getrandomFunc<ArmLinux64> },
769  { base + 279, "memfd_create" },
770  { base + 280, "bpf" },
771  { base + 281, "execveat"},
772  { base + 282, "userfaultfd"},
773  { base + 283, "membarrier"},
774  { base + 284, "mlock2"},
775  { base + 285, "copy_file_range"},
776  { base + 286, "preadv2"},
777  { base + 287, "pwritev2"},
778  { base + 288, "pkey_mprotect"},
779  { base + 289, "pkey_alloc"},
780  { base + 290, "pkey_free"},
781  { base + 291, "statx"},
782  { base + 292, "io_pgetevents"},
783  { base + 293, "rseq", ignoreWarnOnceFunc },
784  { base + 294, "kexec_file_load"},
785  { base + 1024, "open", openFunc<ArmLinux64> },
786  { base + 1025, "link" },
787  { base + 1026, "unlink", unlinkFunc },
788  { base + 1027, "mknod", mknodFunc },
789  { base + 1028, "chmod", chmodFunc<ArmLinux64> },
790  { base + 1029, "chown" },
791  { base + 1030, "mkdir", mkdirFunc },
792  { base + 1031, "rmdir" },
793  { base + 1032, "lchown" },
794  { base + 1033, "access", accessFunc },
795  { base + 1034, "rename", renameFunc },
796  { base + 1035, "readlink", readlinkFunc<ArmLinux64> },
797  { base + 1036, "symlink" },
798  { base + 1037, "utimes", utimesFunc<ArmLinux64> },
799  { base + 1038, "stat64", stat64Func<ArmLinux64> },
800  { base + 1039, "lstat64", lstat64Func<ArmLinux64> },
801  { base + 1040, "pipe", pipePseudoFunc },
802  { base + 1041, "dup2" },
803  { base + 1042, "epoll_create" },
804  { base + 1043, "inotify_init" },
805  { base + 1044, "eventfd" },
806  { base + 1045, "signalfd" },
807  { base + 1046, "sendfile" },
808  { base + 1047, "ftruncate", ftruncateFunc<ArmLinux64> },
809  { base + 1048, "truncate", truncateFunc<ArmLinux64> },
810  { base + 1049, "stat", statFunc<ArmLinux64> },
811  { base + 1050, "lstat" },
812  { base + 1051, "fstat", fstatFunc<ArmLinux64> },
813  { base + 1052, "fcntl", fcntlFunc },
814  { base + 1053, "fadvise64" },
815  { base + 1054, "newfstatat" },
816  { base + 1055, "fstatfs" },
817  { base + 1056, "statfs" },
818  { base + 1057, "lseek", lseekFunc },
819  { base + 1058, "mmap", mmapFunc<ArmLinux64> },
820  { base + 1059, "alarm" },
821  { base + 1060, "getpgrp" },
822  { base + 1061, "pause" },
823  { base + 1062, "time", timeFunc<ArmLinux64> },
824  { base + 1063, "utime" },
825  { base + 1064, "creat" },
826 #if defined(SYS_getdents)
827  { base + 1065, "getdents", getdentsFunc },
828 #else
829  { base + 1065, "getdents" },
830 #endif
831  { base + 1066, "futimesat", futimesatFunc<ArmLinux64> },
832  { base + 1067, "select" },
833  { base + 1068, "poll" },
834  { base + 1069, "epoll_wait" },
835  { base + 1070, "ustat" },
836  { base + 1071, "vfork" },
837  { base + 1072, "oldwait4" },
838  { base + 1073, "recv" },
839  { base + 1074, "send" },
840  { base + 1075, "bdflush" },
841  { base + 1076, "umount" },
842  { base + 1077, "uselib" },
843  { base + 1078, "_sysctl" },
844  { base + 1079, "fork" }
845  })
846  {}
847 };
848 
850 
852  { 0xf0001, "breakpoint" },
853  { 0xf0002, "cacheflush" },
854  { 0xf0003, "usr26" },
855  { 0xf0004, "usr32" },
856  { 0xf0005, "set_tls", setTLSFunc32 },
857 };
858 
859 // Indices 1, 3 and 4 are unallocated.
861  { 0x1002, "cacheflush" },
862  { 0x1005, "set_tls", setTLSFunc64 }
863 };
864 
865 void
867 {
868  Process *process = tc->getProcessPtr();
869  // Call the syscall function in the base Process class to update stats.
870  // This will move into the base SEWorkload function at some point.
871  process->Process::syscall(tc);
872 
873  SyscallDesc *desc = nullptr;
874  if (dynamic_cast<ArmLinuxProcess64 *>(process)) {
875  int num = tc->getReg(int_reg::X8);
876  desc = syscallDescs64Low.get(num, false);
877  if (!desc)
878  desc = syscallDescs64Low.get(num, false);
879  if (!desc)
880  desc = privSyscallDescs64.get(num);
881  } else {
882  int num = tc->getReg(int_reg::R7);
883  desc = syscallDescs32Low.get(num, false);
884  if (!desc)
885  desc = syscallDescs32Low.get(num, false);
886  if (!desc)
887  desc = privSyscallDescs32.get(num);
888  }
889  assert(desc);
890  desc->doSyscall(tc);
891 }
892 
893 } // namespace ArmISA
894 } // namespace gem5
void syscall(ThreadContext *tc) override
Definition: se_workload.cc:866
static const Addr commPage
A page to hold "kernel" provided functions. The name might be wrong.
Definition: process.hh:63
A process with emulated Arm/Linux syscalls.
Definition: process.hh:68
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
Definition: port_proxy.hh:192
SyscallDesc * get(int num, bool fatal_if_missing=true)
This class provides the wrapper interface for the system call implementations which are defined in th...
Definition: syscall_desc.hh:70
void doSyscall(ThreadContext *tc)
Interface for invoking the system call funcion pointer.
Definition: syscall_desc.cc:42
This class represents the return value from an emulated system call, including any errno setting.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
virtual RegVal getReg(const RegId &reg) const
virtual Process * getProcessPtr()=0
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:190
#define warn(...)
Definition: logging.hh:246
constexpr RegId R7
Definition: int.hh:193
constexpr RegId X8
Definition: int.hh:248
static SyscallReturn unameFunc32(SyscallDesc *desc, ThreadContext *tc, VPtr< Linux::utsname > name)
Target uname() handler.
Definition: se_workload.cc:101
static SyscallReturn setTLSFunc64(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
Definition: se_workload.cc:140
static SyscallDescTable< EmuLinux::SyscallABI64 > privSyscallDescs64
Definition: se_workload.cc:860
static SyscallTable32 syscallDescs32High(0x900000)
static SyscallTable64 syscallDescs64Low(0)
static SyscallReturn setTLSFunc32(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
Target set_tls() handler.
Definition: se_workload.cc:131
@ MISCREG_TPIDRRO_EL0
Definition: misc.hh:754
@ MISCREG_TPIDRURO
Definition: misc.hh:410
static SyscallTable64 syscallDescs64High(0x900000)
static SyscallTable32 syscallDescs32Low(0)
static SyscallReturn unameFunc64(SyscallDesc *desc, ThreadContext *tc, VPtr< Linux::utsname > name)
Target uname() handler.
Definition: se_workload.cc:116
static SyscallDescTable< EmuLinux::SyscallABI32 > privSyscallDescs32
Definition: se_workload.cc:851
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
SyscallReturn getppidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getppid() handler.
SyscallReturn exitGroupFunc(SyscallDesc *desc, ThreadContext *tc, int status)
Target exit_group() handler: terminate simulation. (exit all threads)
SyscallReturn gettidFunc(SyscallDesc *desc, ThreadContext *tc)
Target gettid() handler.
SyscallReturn brkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> new_brk)
Target brk() handler: set brk address.
SyscallReturn getpidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpid() handler.
SyscallReturn chdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
Target chdir() handler.
SyscallReturn getuidFunc(SyscallDesc *desc, ThreadContext *tc)
SyscallReturn pipePseudoFunc(SyscallDesc *desc, ThreadContext *tc)
Pseudo Funcs - These functions use a different return convension, returning a second value in a regis...
SyscallReturn chownFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, uint32_t owner, uint32_t group)
Target chown() handler.
SyscallReturn renameFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> oldpath, VPtr<> newpath)
Target rename() handler.
SyscallReturn mknodFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode, dev_t dev)
Target mknod() handler.
SyscallReturn _llseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offset_high, uint32_t offset_low, VPtr<> result_ptr, int whence)
Target _llseek() handler.
SyscallReturn setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc, uint64_t tidPtr)
Target set_tid_address() handler.
SyscallReturn geteuidFunc(SyscallDesc *desc, ThreadContext *tc)
Target geteuid() handler.
SyscallReturn getcwdFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> buf_ptr, unsigned long size)
Target getcwd() handler.
SyscallReturn unlinkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
Target unlink() handler.
SyscallReturn fcntl64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd)
Target fcntl64() handler.
SyscallReturn ignoreWarnOnceFunc(SyscallDesc *desc, ThreadContext *tc)
Like above, but only prints a warning once per syscall desc it's used with.
Definition: syscall_emul.cc:79
SyscallReturn mkdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
Target mkdir() handler.
SyscallReturn dupFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
FIXME: The file description is not shared among file descriptors created with dup.
SyscallReturn ftruncate64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int64_t length)
Target ftruncate64() handler.
SyscallReturn fchownFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t owner, uint32_t group)
Target fchown() handler.
SyscallReturn fcntlFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd, guest_abi::VarArgs< int > varargs)
Target fcntl() handler.
SyscallReturn getegidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getegid() handler.
SyscallReturn getcpuFunc(SyscallDesc *desc, ThreadContext *tc, VPtr< uint32_t > cpu, VPtr< uint32_t > node, VPtr< uint32_t > tcache)
SyscallReturn lseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offs, int whence)
Target lseek() handler.
SyscallReturn accessFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
Target access() handler.
SyscallReturn ignoreFunc(SyscallDesc *desc, ThreadContext *tc)
Handler for unimplemented syscalls that we never intend to implement (signal handling,...
Definition: syscall_emul.cc:72
SyscallReturn exitFunc(SyscallDesc *desc, ThreadContext *tc, int status)
Target exit() handler: terminate current context.
SyscallReturn getgidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getgid() handler.
SyscallReturn closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
Target close() handler.
SyscallReturn umaskFunc(SyscallDesc *desc, ThreadContext *tc)
Target umask() handler.
This file defines objects used to emulate syscalls from the target application on the host machine.
const std::string & name()
Definition: trace.cc:49

Generated on Wed Dec 21 2022 10:22:25 for gem5 by doxygen 1.9.1