gem5 v24.1.0.1
Loading...
Searching...
No Matches
se_workload.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2013, 2015, 2020, 2024 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
52namespace gem5
53{
54
55namespace
56{
57
58class 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
92LinuxLoader linuxLoader;
93
94} // anonymous namespace
95
96namespace ArmISA
97{
98
100static 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
115static 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
130static SyscallReturn
131setTLSFunc32(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
139static SyscallReturn
140setTLSFunc64(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
141{
142 tc->setMiscReg(MISCREG_TPIDRRO_EL0, tlsPtr);
143 return 0;
144}
145
146class 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<ArmLinux32> },
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", ignoreFunc },
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", readvFunc<ArmLinux32> },
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", pollFunc<ArmLinux32> },
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", pread64Func<ArmLinux32> },
309 { base + 181, "pwrite64", pwrite64Func<ArmLinux32> },
310 { base + 182, "chown" },
311 { base + 183, "getcwd", getcwdFunc<ArmLinux32> },
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", truncate64Func },
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", ignoreFunc },
340 { base + 214, "setgid", ignoreFunc },
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 { base + 397, "sys_statx", ignoreFunc },
493 { base + 398, "sys_rseq", ignoreFunc }
494 })
495 {}
496};
497
499
500class SyscallTable64 : public SyscallDescTable<EmuLinux::SyscallABI64>
501{
502 public:
504 { base + 0, "io_setup" },
505 { base + 1, "io_destroy" },
506 { base + 2, "io_submit" },
507 { base + 3, "io_cancel" },
508 { base + 4, "io_getevents" },
509 { base + 5, "setxattr" },
510 { base + 6, "lsetxattr" },
511 { base + 7, "fsetxattr" },
512 { base + 8, "getxattr" },
513 { base + 9, "lgetxattr" },
514 { base + 10, "fgetxattr" },
515 { base + 11, "listxattr" },
516 { base + 12, "llistxattr" },
517 { base + 13, "flistxattr" },
518 { base + 14, "removexattr" },
519 { base + 15, "lremovexattr" },
520 { base + 16, "fremovexattr" },
521 { base + 17, "getcwd", getcwdFunc<ArmLinux64> },
522 { base + 18, "lookup_dcookie" },
523 { base + 19, "eventfd2" },
524 { base + 20, "epoll_create1" },
525 { base + 21, "epoll_ctl" },
526 { base + 22, "epoll_pwait" },
527 { base + 23, "dup", dupFunc },
528 { base + 24, "dup3" },
529 { base + 25, "fcntl64", fcntl64Func },
530 { base + 26, "inotify_init1" },
531 { base + 27, "inotify_add_watch" },
532 { base + 28, "inotify_rm_watch" },
533 { base + 29, "ioctl", ioctlFunc<ArmLinux64> },
534 { base + 30, "ioprio_set" },
535 { base + 31, "ioprio_get" },
536 { base + 32, "flock" },
537 { base + 33, "mknodat", mknodatFunc<ArmLinux64> },
538 { base + 34, "mkdirat", mkdiratFunc<ArmLinux64> },
539 { base + 35, "unlinkat", unlinkatFunc<ArmLinux64> },
540 { base + 36, "symlinkat" },
541 { base + 37, "linkat" },
542 { base + 38, "renameat", renameatFunc<ArmLinux64> },
543 { base + 39, "umount2" },
544 { base + 40, "mount" },
545 { base + 41, "pivot_root" },
546 { base + 42, "nfsservctl" },
547 { base + 43, "statfs64" },
548 { base + 44, "fstatfs64" },
549 { base + 45, "truncate64", truncate64Func },
550 { base + 46, "ftruncate64", ftruncate64Func },
551 { base + 47, "fallocate", fallocateFunc<ArmLinux64> },
552 { base + 48, "faccessat", faccessatFunc<ArmLinux64> },
553 { base + 49, "chdir", chdirFunc },
554 { base + 50, "fchdir" },
555 { base + 51, "chroot" },
556 { base + 52, "fchmod" },
557 { base + 53, "fchmodat", fchmodatFunc<ArmLinux64> },
558 { base + 54, "fchownat", fchownatFunc<ArmLinux64> },
559 { base + 55, "fchown", fchownFunc },
560 { base + 56, "openat", openatFunc<ArmLinux64> },
561 { base + 57, "close", closeFunc },
562 { base + 58, "vhangup" },
563 { base + 59, "pipe2" },
564 { base + 60, "quotactl" },
565#if defined(SYS_getdents64)
566 { base + 61, "getdents64", getdents64Func },
567#else
568 { base + 61, "getdents64" },
569#endif
570 { base + 62, "lseek", lseekFunc<ArmLinux64> },
571 { base + 63, "read", readFunc<ArmLinux64> },
572 { base + 64, "write", writeFunc<ArmLinux64> },
573 { base + 65, "readv", readvFunc<ArmLinux64> },
574 { base + 66, "writev", writevFunc<ArmLinux64> },
575 { base + 67, "pread64", pread64Func<ArmLinux64> },
576 { base + 68, "pwrite64", pwrite64Func<ArmLinux64> },
577 { base + 69, "preadv" },
578 { base + 70, "pwritev" },
579 { base + 71, "sendfile64" },
580 { base + 72, "pselect6" },
581 { base + 73, "ppoll" },
582 { base + 74, "signalfd4" },
583 { base + 75, "vmsplice" },
584 { base + 76, "splice" },
585 { base + 77, "tee" },
586 { base + 78, "readlinkat", readlinkatFunc<ArmLinux64> },
587 { base + 79, "fstatat64", fstatat64Func<ArmLinux64> },
588 { base + 80, "fstat64", fstat64Func<ArmLinux64> },
589 { base + 81, "sync" },
590 { base + 82, "fsync" },
591 { base + 83, "fdatasync" },
592 { base + 84, "sync_file_range" },
593 { base + 85, "timerfd_create" },
594 { base + 86, "timerfd_settime" },
595 { base + 87, "timerfd_gettime" },
596 { base + 88, "utimensat" },
597 { base + 89, "acct" },
598 { base + 90, "capget" },
599 { base + 91, "capset" },
600 { base + 92, "personality" },
601 { base + 93, "exit", exitFunc },
602 { base + 94, "exit_group", exitGroupFunc },
603 { base + 95, "waitid" },
604 { base + 96, "set_tid_address", setTidAddressFunc },
605 { base + 97, "unshare" },
606 { base + 98, "futex", futexFunc<ArmLinux64> },
607 { base + 99, "set_robust_list", ignoreFunc },
608 { base + 100, "get_robust_list" },
609 { base + 101, "nanosleep", ignoreWarnOnceFunc },
610 { base + 102, "getitimer" },
611 { base + 103, "setitimer" },
612 { base + 104, "kexec_load" },
613 { base + 105, "init_module" },
614 { base + 106, "delete_module" },
615 { base + 107, "timer_create" },
616 { base + 108, "timer_gettime" },
617 { base + 109, "timer_getoverrun" },
618 { base + 110, "timer_settime" },
619 { base + 111, "timer_delete" },
620 { base + 112, "clock_settime" },
621 { base + 113, "clock_gettime", clock_gettimeFunc<ArmLinux64> },
622 { base + 114, "clock_getres" },
623 { base + 115, "clock_nanosleep" },
624 { base + 116, "syslog" },
625 { base + 117, "ptrace" },
626 { base + 118, "sched_setparam", ignoreWarnOnceFunc },
627 { base + 119, "sched_setscheduler", ignoreWarnOnceFunc },
628 { base + 120, "sched_getscheduler", ignoreWarnOnceFunc },
629 { base + 121, "sched_getparam", ignoreWarnOnceFunc },
630 { base + 122, "sched_setaffinity", ignoreWarnOnceFunc },
631 { base + 123, "sched_getaffinity", ignoreFunc },
632 { base + 124, "sched_yield", ignoreWarnOnceFunc },
633 { base + 125, "sched_get_priority_max", ignoreWarnOnceFunc },
634 { base + 126, "sched_get_priority_min", ignoreWarnOnceFunc },
635 { base + 127, "sched_rr_get_interval", ignoreWarnOnceFunc },
636 { base + 128, "restart_syscall" },
637 { base + 129, "kill", ignoreFunc },
638 { base + 130, "tkill" },
639 { base + 131, "tgkill", tgkillFunc<ArmLinux64> },
640 { base + 132, "sigaltstack" },
641 { base + 133, "rt_sigsuspend" },
642 { base + 134, "rt_sigaction", ignoreFunc },
643 { base + 135, "rt_sigprocmask", ignoreWarnOnceFunc },
644 { base + 136, "rt_sigpending" },
645 { base + 137, "rt_sigtimedwait" },
646 { base + 138, "rt_sigqueueinfo", ignoreFunc },
647 { base + 139, "rt_sigreturn" },
648 { base + 140, "setpriority" },
649 { base + 141, "getpriority" },
650 { base + 142, "reboot" },
651 { base + 143, "setregid" },
652 { base + 144, "setgid" },
653 { base + 145, "setreuid" },
654 { base + 146, "setuid" },
655 { base + 147, "setresuid" },
656 { base + 148, "getresuid" },
657 { base + 149, "setresgid" },
658 { base + 150, "getresgid" },
659 { base + 151, "setfsuid" },
660 { base + 152, "setfsgid" },
661 { base + 153, "times", timesFunc<ArmLinux64> },
662 { base + 154, "setpgid" },
663 { base + 155, "getpgid" },
664 { base + 156, "getsid" },
665 { base + 157, "setsid" },
666 { base + 158, "getgroups" },
667 { base + 159, "setgroups" },
668 { base + 160, "uname", unameFunc64 },
669 { base + 161, "sethostname", ignoreFunc },
670 { base + 162, "setdomainname" },
671 { base + 163, "getrlimit", getrlimitFunc<ArmLinux64> },
672 { base + 164, "setrlimit", ignoreFunc },
673 { base + 165, "getrusage", getrusageFunc<ArmLinux64> },
674 { base + 166, "umask" },
675 { base + 167, "prctl" },
676 { base + 168, "getcpu", getcpuFunc },
677 { base + 169, "gettimeofday", gettimeofdayFunc<ArmLinux64> },
678 { base + 170, "settimeofday" },
679 { base + 171, "adjtimex" },
680 { base + 172, "getpid", getpidFunc },
681 { base + 173, "getppid", getppidFunc },
682 { base + 174, "getuid", getuidFunc },
683 { base + 175, "geteuid", geteuidFunc },
684 { base + 176, "getgid", getgidFunc },
685 { base + 177, "getegid", getegidFunc },
686 { base + 178, "gettid", gettidFunc },
687 { base + 179, "sysinfo", sysinfoFunc<ArmLinux64> },
688 { base + 180, "mq_open" },
689 { base + 181, "mq_unlink" },
690 { base + 182, "mq_timedsend" },
691 { base + 183, "mq_timedreceive" },
692 { base + 184, "mq_notify" },
693 { base + 185, "mq_getsetattr" },
694 { base + 186, "msgget" },
695 { base + 187, "msgctl" },
696 { base + 188, "msgrcv" },
697 { base + 189, "msgsnd" },
698 { base + 190, "semget" },
699 { base + 191, "semctl" },
700 { base + 192, "semtimedop" },
701 { base + 193, "semop" },
702 { base + 194, "shmget" },
703 { base + 195, "shmctl" },
704 { base + 196, "shmat" },
705 { base + 197, "shmdt" },
706 { base + 198, "socket" },
707 { base + 199, "socketpair" },
708 { base + 200, "bind" },
709 { base + 201, "listen" },
710 { base + 202, "accept" },
711 { base + 203, "connect" },
712 { base + 204, "getsockname" },
713 { base + 205, "getpeername" },
714 { base + 206, "sendto", sendtoFunc<ArmLinux64> },
715 { base + 207, "recvfrom", recvfromFunc<ArmLinux64> },
716 { base + 208, "setsockopt" },
717 { base + 209, "getsockopt" },
718 { base + 210, "shutdown" },
719 { base + 211, "sendmsg" },
720 { base + 212, "recvmsg" },
721 { base + 213, "readahead" },
722 { base + 214, "brk", brkFunc },
723 { base + 215, "munmap", munmapFunc<ArmLinux64> },
724 { base + 216, "mremap", mremapFunc<ArmLinux64> },
725 { base + 217, "add_key" },
726 { base + 218, "request_key" },
727 { base + 219, "keyctl" },
728 { base + 220, "clone", cloneBackwardsFunc<ArmLinux64> },
729 { base + 221, "execve", execveFunc<ArmLinux64> },
730 { base + 222, "mmap2", mmapFunc<ArmLinux64> },
731 { base + 223, "fadvise64_64" },
732 { base + 224, "swapon" },
733 { base + 225, "swapoff" },
734 { base + 226, "mprotect", ignoreFunc },
735 { base + 227, "msync" },
736 { base + 228, "mlock" },
737 { base + 229, "munlock" },
738 { base + 230, "mlockall" },
739 { base + 231, "munlockall" },
740 { base + 232, "mincore" },
741 { base + 233, "madvise", ignoreFunc },
742 { base + 234, "remap_file_pages" },
743 { base + 235, "mbind" },
744 { base + 236, "get_mempolicy" },
745 { base + 237, "set_mempolicy" },
746 { base + 238, "migrate_pages" },
747 { base + 239, "move_pages" },
748 { base + 240, "rt_tgsigqueueinfo" },
749 { base + 241, "perf_event_open" },
750 { base + 242, "accept4" },
751 { base + 243, "recvmmsg" },
752 { base + 260, "wait4" },
753 { base + 261, "prlimit64", prlimitFunc<ArmLinux64> },
754 { base + 262, "fanotify_init" },
755 { base + 263, "fanotify_mark" },
756 { base + 264, "name_to_handle_at" },
757 { base + 265, "open_by_handle_at" },
758 { base + 266, "clock_adjtime" },
759 { base + 267, "syncfs" },
760 { base + 268, "setns" },
761 { base + 269, "sendmmsg" },
762 { base + 270, "process_vm_readv" },
763 { base + 271, "process_vm_writev" },
764 { base + 272, "kcmp" },
765 { base + 273, "finit_module" },
766 { base + 274, "sched_setattr"},
767 { base + 275, "sched_getattr"},
768 { base + 276, "renameat2"},
769 { base + 277, "seccomp"},
770 { base + 278, "getrandom", getrandomFunc<ArmLinux64> },
771 { base + 279, "memfd_create" },
772 { base + 280, "bpf" },
773 { base + 281, "execveat"},
774 { base + 282, "userfaultfd"},
775 { base + 283, "membarrier"},
776 { base + 284, "mlock2"},
777 { base + 285, "copy_file_range"},
778 { base + 286, "preadv2"},
779 { base + 287, "pwritev2"},
780 { base + 288, "pkey_mprotect"},
781 { base + 289, "pkey_alloc"},
782 { base + 290, "pkey_free"},
783 { base + 291, "statx"},
784 { base + 292, "io_pgetevents"},
785 { base + 293, "rseq", ignoreWarnOnceFunc },
786 { base + 294, "kexec_file_load"},
787 { base + 1024, "open", openFunc<ArmLinux64> },
788 { base + 1025, "link" },
789 { base + 1026, "unlink", unlinkFunc },
790 { base + 1027, "mknod", mknodFunc },
791 { base + 1028, "chmod", chmodFunc<ArmLinux64> },
792 { base + 1029, "chown" },
793 { base + 1030, "mkdir", mkdirFunc },
794 { base + 1031, "rmdir" },
795 { base + 1032, "lchown" },
796 { base + 1033, "access", accessFunc },
797 { base + 1034, "rename", renameFunc },
798 { base + 1035, "readlink", readlinkFunc<ArmLinux64> },
799 { base + 1036, "symlink" },
800 { base + 1037, "utimes", utimesFunc<ArmLinux64> },
801 { base + 1038, "stat64", stat64Func<ArmLinux64> },
802 { base + 1039, "lstat64", lstat64Func<ArmLinux64> },
803 { base + 1040, "pipe", pipePseudoFunc },
804 { base + 1041, "dup2" },
805 { base + 1042, "epoll_create" },
806 { base + 1043, "inotify_init" },
807 { base + 1044, "eventfd" },
808 { base + 1045, "signalfd" },
809 { base + 1046, "sendfile" },
810 { base + 1047, "ftruncate", ftruncateFunc<ArmLinux64> },
811 { base + 1048, "truncate", truncateFunc<ArmLinux64> },
812 { base + 1049, "stat", statFunc<ArmLinux64> },
813 { base + 1050, "lstat" },
814 { base + 1051, "fstat", fstatFunc<ArmLinux64> },
815 { base + 1052, "fcntl", fcntlFunc },
816 { base + 1053, "fadvise64" },
817 { base + 1054, "newfstatat" },
818 { base + 1055, "fstatfs" },
819 { base + 1056, "statfs" },
820 { base + 1057, "lseek", lseekFunc<ArmLinux64> },
821 { base + 1058, "mmap", mmapFunc<ArmLinux64> },
822 { base + 1059, "alarm" },
823 { base + 1060, "getpgrp" },
824 { base + 1061, "pause" },
825 { base + 1062, "time", timeFunc<ArmLinux64> },
826 { base + 1063, "utime" },
827 { base + 1064, "creat" },
828#if defined(SYS_getdents)
829 { base + 1065, "getdents", getdentsFunc },
830#else
831 { base + 1065, "getdents" },
832#endif
833 { base + 1066, "futimesat", futimesatFunc<ArmLinux64> },
834 { base + 1067, "select" },
835 { base + 1068, "poll", pollFunc<ArmLinux64> },
836 { base + 1069, "epoll_wait" },
837 { base + 1070, "ustat" },
838 { base + 1071, "vfork" },
839 { base + 1072, "oldwait4" },
840 { base + 1073, "recv" },
841 { base + 1074, "send" },
842 { base + 1075, "bdflush" },
843 { base + 1076, "umount" },
844 { base + 1077, "uselib" },
845 { base + 1078, "_sysctl" },
846 { base + 1079, "fork" }
847 })
848 {}
849};
850
852
854 { 0xf0001, "breakpoint" },
855 { 0xf0002, "cacheflush" },
856 { 0xf0003, "usr26" },
857 { 0xf0004, "usr32" },
858 { 0xf0005, "set_tls", setTLSFunc32 },
859};
860
861// Indices 1, 3 and 4 are unallocated.
863 { 0x1002, "cacheflush" },
864 { 0x1005, "set_tls", setTLSFunc64 }
865};
866
867void
869{
870 Process *process = tc->getProcessPtr();
871 // Call the syscall function in the base Process class to update stats.
872 // This will move into the base SEWorkload function at some point.
873 process->Process::syscall(tc);
874
875 SyscallDesc *desc = nullptr;
876 if (dynamic_cast<ArmLinuxProcess64 *>(process)) {
877 int num = tc->getReg(int_reg::X8);
878 desc = syscallDescs64Low.get(num, false);
879 if (!desc)
880 desc = syscallDescs64Low.get(num, false);
881 if (!desc)
882 desc = privSyscallDescs64.get(num);
883 } else {
884 int num = tc->getReg(int_reg::R7);
885 desc = syscallDescs32Low.get(num, false);
886 if (!desc)
887 desc = syscallDescs32Low.get(num, false);
888 if (!desc)
889 desc = privSyscallDescs32.get(num);
890 }
891 assert(desc);
892 desc->doSyscall(tc);
893}
894
895} // namespace ArmISA
896} // namespace gem5
void syscall(ThreadContext *tc) override
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, uint64_t size) const
Same as tryWriteBlob, but insists on success.
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...
void doSyscall(ThreadContext *tc)
Interface for invoking the system call funcion pointer.
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:200
#define warn(...)
Definition logging.hh:256
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.
static SyscallReturn setTLSFunc64(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
static SyscallDescTable< EmuLinux::SyscallABI64 > privSyscallDescs64
static SyscallTable32 syscallDescs32High(0x900000)
static SyscallTable64 syscallDescs64Low(0)
static SyscallReturn setTLSFunc32(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
Target set_tls() handler.
@ MISCREG_TPIDRRO_EL0
Definition misc.hh:833
@ MISCREG_TPIDRURO
Definition misc.hh:435
static SyscallTable64 syscallDescs64High(0x900000)
static SyscallTable32 syscallDescs32Low(0)
static SyscallReturn unameFunc64(SyscallDesc *desc, ThreadContext *tc, VPtr< Linux::utsname > name)
Target uname() handler.
static SyscallDescTable< EmuLinux::SyscallABI32 > privSyscallDescs32
Bitfield< 51, 12 > base
Definition pagetable.hh:141
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
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 truncate64Func(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, int64_t length)
Target truncate64() 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 _llseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t offset_high, uint32_t offset_low, VPtr<> result_ptr, int whence)
Target _llseek() 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 geteuidFunc(SyscallDesc *desc, ThreadContext *tc)
Target geteuid() 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.
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 setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> tidPtr)
Target set_tid_address() 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 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,...
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:48

Generated on Mon Jan 13 2025 04:28:22 for gem5 by doxygen 1.9.8