gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
se_workload.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 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 2005 The Regents of The University of Michigan
14 * Copyright 2007 MIPS Technologies, Inc.
15 * Copyright 2016 The University of Virginia
16 * Copyright 2020 Google Inc.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
43
44#include <sys/syscall.h>
45
46#include "arch/riscv/process.hh"
50#include "base/trace.hh"
51#include "cpu/thread_context.hh"
52#include "sim/syscall_emul.hh"
53
54namespace gem5
55{
56
57namespace
58{
59
60class LinuxLoader : public Process::Loader
61{
62 public:
63 Process *
64 load(const ProcessParams &params, loader::ObjectFile *obj) override
65 {
66 auto arch = obj->getArch();
67 auto opsys = obj->getOpSys();
68
69 if (arch != loader::Riscv64 && arch != loader::Riscv32)
70 return nullptr;
71
72 if (opsys == loader::UnknownOpSys) {
73 warn("Unknown operating system; assuming Linux.");
74 opsys = loader::Linux;
75 }
76
77 if (opsys != loader::Linux)
78 return nullptr;
79
80 if (arch == loader::Riscv64)
81 return new RiscvProcess64(params, obj);
82 else
83 return new RiscvProcess32(params, obj);
84 }
85};
86
87LinuxLoader linuxLoader;
88
89} // anonymous namespace
90
91namespace RiscvISA
92{
93
94void
96{
97 Process *process = tc->getProcessPtr();
98 // Call the syscall function in the base Process class to update stats.
99 // This will move into the base SEWorkload function at some point.
100 process->Process::syscall(tc);
101
103 if (dynamic_cast<RiscvProcess64 *>(process))
104 syscallDescs64.get(num)->doSyscall(tc);
105 else
106 syscallDescs32.get(num)->doSyscall(tc);
107}
108
110static SyscallReturn
112{
113 auto process = tc->getProcessPtr();
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, "riscv64");
120
121 return 0;
122}
123
125static SyscallReturn
127{
128 auto process = tc->getProcessPtr();
129
130 strcpy(name->sysname, "Linux");
131 strcpy(name->nodename,"sim.gem5.org");
132 strcpy(name->release, process->release.c_str());
133 strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
134 strcpy(name->machine, "riscv32");
135
136 return 0;
137}
138
139static inline void
141{
142 assert(cpu < dstp->size * 8);
143 auto &bits = dstp->bits[cpu / sizeof(uint64_t)];
144 bits = insertBits(bits, cpu % sizeof(uint64_t), 1);
145}
146
147static inline void
149{
150 assert(cpu < dstp->size * 8);
151 auto &bits = dstp->bits[cpu / sizeof(uint64_t)];
152 bits = insertBits(bits, cpu % sizeof(uint64_t), 0);
153}
154
155static inline bool
156cpumask_test_cpu(unsigned int cpu, const RiscvLinux::cpumask_t *cpumask)
157{
158 assert(cpu < cpumask->size * 8);
159 return bits(cpumask->bits[cpu / sizeof(uint64_t)], cpu % sizeof(uint64_t)) != 0;
160}
161
162static inline void
164 const RiscvLinux::cpumask_t *src2p)
165{
166 assert(dstp->size == src1p->size);
167 assert(dstp->size == src2p->size);
168 for (size_t i = 0; i < dstp->size / sizeof(dstp->bits[0]); i++) {
169 dstp->bits[i] = src1p->bits[i] & src2p->bits[i];
170 }
171}
172
173static inline bool
175{
176 for (size_t i = 0; i < dstp->size / sizeof(dstp->bits[0]); i++) {
177 if (dstp->bits[i] != 0) {
178 return false;
179 }
180 }
181 return true;
182}
183
184static inline void
186{
187 assert(dstp->size == srcp->size);
188 memcpy(dstp->bits, srcp->bits, srcp->size);
189}
190
191static inline void
193{
194 memset(dstp->bits, 0, dstp->size);
195}
196
197static inline RiscvLinux::cpumask_t *
199{
200 RiscvLinux::cpumask_t *cpumask;
201
202 /* 8-bytes up-boundary alignment */
203 size_t size = (tc->getSystemPtr()->threads.size() + sizeof(cpumask->bits[0]) - 1) /
204 sizeof(cpumask->bits[0]) * sizeof(cpumask->bits[0]);
205 cpumask = (RiscvLinux::cpumask_t *)malloc(sizeof(cpumask->size) + size);
206 if (cpumask != nullptr) {
207 cpumask->size = size;
208 cpumask_clear(cpumask);
209 }
210
211 return cpumask;
212}
213
214static inline void
216{
217 free(cpu_online_mask);
218}
219
220static inline bool
222{
223 return key >= 0 && key <= RISCV_HWPROBE_MAX_KEY;
224}
225
226static inline bool
228{
229 switch (key) {
233 return true;
234 }
235
236 return false;
237}
238
239static inline bool
241 RiscvLinux::riscv_hwprobe *other_pair)
242{
243 if (pair->key != other_pair->key) {
244 return false;
245 }
246
247 if (hwprobe_key_is_bitmask(pair->key)) {
248 return (pair->value & other_pair->value) == other_pair->value;
249 }
250
251 return pair->value == other_pair->value;
252}
253
254static inline RiscvLinux::cpumask_t *
256{
257 RiscvLinux::cpumask_t *cpu_online_mask = cpumask_malloc(tc);
258 if (cpu_online_mask != nullptr) {
259 for (int i = 0; i < tc->getSystemPtr()->threads.size(); i++) {
260 #ifdef __linux__
261 CPU_SET(i, (cpu_set_t *)&cpu_online_mask->bits);
262 #else
263 // For non-Linux systems, we use cpumask_set_cpu.
264 // CPU_SET is a macro that is not available on all
265 // non-Linux systems.
266 cpumask_set_cpu(i, cpu_online_mask);
267 #endif
268 }
269 }
270
271 return cpu_online_mask;
272}
273
274static void
277{
278 switch (pair->key) {
280 pair->value = tc->readMiscRegNoEffect(CSRData.at(CSR_MVENDORID).physIndex);
281 break;
283 pair->value = tc->readMiscRegNoEffect(CSRData.at(CSR_MARCHID).physIndex);
284 break;
286 pair->value = tc->readMiscRegNoEffect(CSRData.at(CSR_MIMPID).physIndex);
287 break;
289 {
290 MISA misa = tc->readMiscRegNoEffect(MISCREG_ISA);
291 RiscvLinux::key_base_behavior_t *base_behavior =
292 (RiscvLinux::key_base_behavior_t *)&pair->value;
293 if (misa.rvi && misa.rvm && misa.rva) {
294 base_behavior->ima = 1;
295 }
296 }
297 break;
299 {
300 MISA misa = tc->readMiscRegNoEffect(MISCREG_ISA);
301 RiscvLinux::key_ima_ext_0_t *ext = (RiscvLinux::key_ima_ext_0_t *)&pair->value;
302 if (misa.rvf && misa.rvd) ext->FD = 1;
303 if (misa.rvc) ext->C = 1;
304 if (misa.rvv) ext->V = 1;
305 ext->ZBA = 1;
306 ext->ZBB = 1;
307 ext->ZBS = 1;
308 ext->ZICBOZ = 1;
309 ext->ZBC = 1;
310 ext->ZBKB = 1;
311 ext->ZBKC = 1;
312 ext->ZBKX = 1;
313 ext->ZKND = 1;
314 ext->ZKNE = 1;
315 ext->ZKNH = 1;
316 ext->ZKSED = 1;
317 ext->ZKSH = 1;
318 ext->ZKT = 1;
319 ext->ZFH = 1;
320 ext->ZFHMIN = 1;
321 ext->ZVFH = 1;
322 ext->ZVFHMIN = 1;
323 ext->ZFA = 1;
324 ext->ZICOND = 1;
325 ext->ZVE64D = 1;
326 ext->ZCB = 1;
327 ext->ZCD = 1;
328 ext->ZCF = 1;
329 }
330 break;
333 pair->value = RiscvLinux::Slow;
334 break;
336 pair->value = tc->getSystemPtr()->cacheLineSize();
337 break;
339 pair->value = tc->getProcessPtr()->memState->getMmapEnd();
340 break;
341
342 /*
343 * For forward compatibility, unknown keys don't fail the whole
344 * call, but get their element key set to -1 and value set to 0
345 * indicating they're unrecognized.
346 */
347 default:
348 pair->key = -1;
349 pair->value = 0;
350 break;
351 }
352}
353
354template <class OS>
355static int
356hwprobe_get_values(ThreadContext *tc, VPtr<> pairs, typename OS::size_t pair_count,
357 typename OS::size_t cpusetsize, VPtr<> cpus_user, unsigned int flags)
358{
359 /* Check the reserved flags. */
360 if (flags != 0) {
361 return -EINVAL;
362 }
363
364 RiscvLinux::cpumask_t *cpu_online_mask = get_cpu_online_mask(tc);
365 if (cpu_online_mask == nullptr) {
366 return -ENOMEM;
367 }
368
370 if (cpus == nullptr) {
371 cpumask_free(cpu_online_mask);
372 return -ENOMEM;
373 }
374
375 if (cpusetsize > cpu_online_mask->size) {
376 cpusetsize = cpu_online_mask->size;
377 }
378
380 BufferArg pairs_buf(pairs, sizeof(RiscvLinux::riscv_hwprobe) * pair_count);
381
382 /*
383 * The interface supports taking in a CPU mask, and returns values that
384 * are consistent across that mask. Allow userspace to specify NULL and
385 * 0 as a shortcut to all online CPUs.
386 */
387 if (cpusetsize == 0 && !cpus_user) {
388 cpumask_copy(cpus, cpu_online_mask);
389 cpusetsize = cpu_online_mask->size;
390 } else {
391 BufferArg cpus_user_buf(cpus_user, cpusetsize);
392 cpus_user_buf.copyIn(SETranslatingPortProxy(tc));
393
394 cpu_online_mask->size = cpusetsize;
395 cpus->size = cpusetsize;
396 memcpy(cpus->bits, cpus_user_buf.bufferPtr(), cpusetsize);
397
398 /*
399 * Userspace must provide at least one online CPU, without that
400 * there's no way to define what is supported.
401 */
402 cpumask_and(cpus, cpus, cpu_online_mask);
403 if (cpumask_empty(cpus)) {
404 cpumask_free(cpu_online_mask);
405 cpumask_free(cpus);
406 return -EINVAL;
407 }
408 }
409
410 pairs_buf.copyIn(SETranslatingPortProxy(tc));
411 pair = (RiscvLinux::riscv_hwprobe *)pairs_buf.bufferPtr();
412
413 for (size_t i = 0; i < pair_count; i++, pair++) {
414 pair->value = 0;
415 hwprobe_one_pair(tc, pair, cpus);
416 }
417
418 pairs_buf.copyOut(SETranslatingPortProxy(tc));
419
420 cpumask_free(cpu_online_mask);
421 cpumask_free(cpus);
422
423 return 0;
424}
425
426template <class OS>
427static int
428hwprobe_get_cpus(ThreadContext *tc, VPtr<> pairs, typename OS::size_t pair_count,
429 typename OS::size_t cpusetsize, VPtr<> cpus_user, unsigned int flags)
430{
431 if (flags != RISCV_HWPROBE_WHICH_CPUS) {
432 return -EINVAL;
433 }
434
435 if (cpusetsize == 0 || !cpus_user) {
436 return -EINVAL;
437 }
438
439 RiscvLinux::cpumask_t *cpu_online_mask = get_cpu_online_mask(tc);
440 if (cpu_online_mask == nullptr) {
441 return -ENOMEM;
442 }
443
445 if (cpus == nullptr) {
446 cpumask_free(cpu_online_mask);
447 return -ENOMEM;
448 }
449
451 if (one_cpu == nullptr) {
452 cpumask_free(cpu_online_mask);
453 cpumask_free(cpus);
454 return -ENOMEM;
455 }
456
457 if (cpusetsize > cpu_online_mask->size) {
458 cpusetsize = cpu_online_mask->size;
459 }
460
462 BufferArg cpus_user_buf(cpus_user, cpusetsize);
463 cpus_user_buf.copyIn(SETranslatingPortProxy(tc));
464 memcpy(cpus->bits, cpus_user_buf.bufferPtr(), cpusetsize);
465
466 if (cpumask_empty(cpus)) {
467 cpumask_copy(cpus, cpu_online_mask);
468 cpusetsize = cpu_online_mask->size;
469 }
470
471 cpumask_and(cpus, cpus, cpu_online_mask);
472
473 BufferArg pairs_buf(pairs, sizeof(RiscvLinux::riscv_hwprobe) * pair_count);
474 pairs_buf.copyIn(SETranslatingPortProxy(tc));
475 pair = (RiscvLinux::riscv_hwprobe *)pairs_buf.bufferPtr();
476
477 for (size_t i = 0; i < pair_count; i++, pair++) {
478 if (!riscv_hwprobe_key_is_valid(pair->key)) {
479 *pair = (RiscvLinux::riscv_hwprobe){ .key = -1, .value = 0 };
480 memset(cpus_user_buf.bufferPtr(), 0, cpusetsize);
481 break;
482 }
483
485 (RiscvLinux::riscv_hwprobe){ .key = pair->key, .value = 0 };
486
487 for (int cpu = 0; cpu < cpusetsize * 8; cpu++) {
488 if (!cpumask_test_cpu(cpu, cpus)) {
489 continue;
490 }
491
492 cpumask_set_cpu(cpu, one_cpu);
493
494 hwprobe_one_pair(tc, &tmp, one_cpu);
495
496 if (!riscv_hwprobe_pair_cmp(&tmp, pair)) {
497 cpumask_clear_cpu(cpu, cpus);
498 }
499
500 cpumask_clear_cpu(cpu, one_cpu);
501 }
502 }
503
504 pairs_buf.copyOut(SETranslatingPortProxy(tc));
505 cpus_user_buf.copyOut(SETranslatingPortProxy(tc));
506
507 cpumask_free(cpu_online_mask);
508 cpumask_free(cpus);
509 cpumask_free(one_cpu);
510
511 return 0;
512}
513
514template <class OS>
515static SyscallReturn
517 typename OS::size_t pair_count, typename OS::size_t cpusetsize,
518 VPtr<> cpus_user, unsigned int flags)
519{
520 if (flags & RISCV_HWPROBE_WHICH_CPUS) {
521 return hwprobe_get_cpus<OS>(tc, pairs, pair_count, cpusetsize,
522 cpus_user, flags);
523 }
524
525 return hwprobe_get_values<OS>(tc, pairs, pair_count, cpusetsize,
526 cpus_user, flags);
527}
528
530 { 0, "io_setup" },
531 { 1, "io_destroy" },
532 { 2, "io_submit" },
533 { 3, "io_cancel" },
534 { 4, "io_getevents" },
535 { 5, "setxattr" },
536 { 6, "lsetxattr" },
537 { 7, "fsetxattr" },
538 { 8, "getxattr" },
539 { 9, "lgetxattr" },
540 { 10, "fgetxattr" },
541 { 11, "listxattr" },
542 { 12, "llistxattr" },
543 { 13, "flistxattr" },
544 { 14, "removexattr" },
545 { 15, "lremovexattr" },
546 { 16, "fremovexattr" },
547 { 17, "getcwd", getcwdFunc<RiscvLinux64> },
548 { 18, "lookup_dcookie" },
549 { 19, "eventfd2" },
550 { 20, "epoll_create1" },
551 { 21, "epoll_ctl" },
552 { 22, "epoll_pwait" },
553 { 23, "dup", dupFunc },
554 { 24, "dup3" },
555 { 25, "fcntl", fcntl64Func },
556 { 26, "inotify_init1" },
557 { 27, "inotify_add_watch" },
558 { 28, "inotify_rm_watch" },
559 { 29, "ioctl", ioctlFunc<RiscvLinux64> },
560 { 30, "ioprio_get" },
561 { 31, "ioprio_set" },
562 { 32, "flock" },
563 { 33, "mknodat", mknodatFunc<RiscvLinux64> },
564 { 34, "mkdirat", mkdiratFunc<RiscvLinux64> },
565 { 35, "unlinkat", unlinkatFunc<RiscvLinux64> },
566 { 36, "symlinkat" },
567 { 37, "linkat" },
568 { 38, "renameat", renameatFunc<RiscvLinux64> },
569 { 39, "umount2" },
570 { 40, "mount" },
571 { 41, "pivot_root" },
572 { 42, "nfsservctl" },
573 { 43, "statfs", statfsFunc<RiscvLinux64> },
574 { 44, "fstatfs", fstatfsFunc<RiscvLinux64> },
575 { 45, "truncate", truncateFunc<RiscvLinux64> },
576 { 46, "ftruncate", ftruncate64Func },
577 { 47, "fallocate", fallocateFunc<RiscvLinux64> },
578 { 48, "faccessat", faccessatFunc<RiscvLinux64> },
579 { 49, "chdir", chdirFunc },
580 { 50, "fchdir" },
581 { 51, "chroot" },
582 { 52, "fchmod", fchmodFunc<RiscvLinux64> },
583 { 53, "fchmodat" },
584 { 54, "fchownat" },
585 { 55, "fchown", fchownFunc },
586 { 56, "openat", openatFunc<RiscvLinux64> },
587 { 57, "close", closeFunc },
588 { 58, "vhangup" },
589 { 59, "pipe2", pipe2Func },
590 { 60, "quotactl" },
591#if defined(SYS_getdents64)
592 { 61, "getdents64", getdents64Func },
593#else
594 { 61, "getdents64" },
595#endif
596 { 62, "lseek", lseekFunc<RiscvLinux64> },
597 { 63, "read", readFunc<RiscvLinux64> },
598 { 64, "write", writeFunc<RiscvLinux64> },
599 { 66, "writev", writevFunc<RiscvLinux64> },
600 { 67, "pread64", pread64Func<RiscvLinux64> },
601 { 68, "pwrite64", pwrite64Func<RiscvLinux64> },
602 { 69, "preadv" },
603 { 70, "pwritev" },
604 { 71, "sendfile" },
605 { 72, "pselect6" },
606 { 73, "ppoll" },
607 { 74, "signalfd64" },
608 { 75, "vmsplice" },
609 { 76, "splice" },
610 { 77, "tee" },
611 { 78, "readlinkat", readlinkatFunc<RiscvLinux64> },
612 { 79, "fstatat", fstatat64Func<RiscvLinux64> },
613 { 80, "fstat", fstat64Func<RiscvLinux64> },
614 { 81, "sync" },
615 { 82, "fsync" },
616 { 83, "fdatasync" },
617 { 84, "sync_file_range2" },
618 { 85, "timerfd_create" },
619 { 86, "timerfd_settime" },
620 { 87, "timerfd_gettime" },
621 { 88, "utimensat" },
622 { 89, "acct" },
623 { 90, "capget" },
624 { 91, "capset" },
625 { 92, "personality" },
626 { 93, "exit", exitFunc },
627 { 94, "exit_group", exitGroupFunc },
628 { 95, "waitid" },
629 { 96, "set_tid_address", setTidAddressFunc },
630 { 97, "unshare" },
631 { 98, "futex", futexFunc<RiscvLinux64> },
632 { 99, "set_robust_list", ignoreWarnOnceFunc },
633 { 100, "get_robust_list", ignoreWarnOnceFunc },
634 { 101, "nanosleep", ignoreWarnOnceFunc },
635 { 102, "getitimer" },
636 { 103, "setitimer" },
637 { 104, "kexec_load" },
638 { 105, "init_module" },
639 { 106, "delete_module" },
640 { 107, "timer_create" },
641 { 108, "timer_gettime" },
642 { 109, "timer_getoverrun" },
643 { 110, "timer_settime" },
644 { 111, "timer_delete" },
645 { 112, "clock_settime" },
646 { 113, "clock_gettime", clock_gettimeFunc<RiscvLinux64> },
647 { 114, "clock_getres", clock_getresFunc<RiscvLinux64> },
648 { 115, "clock_nanosleep" },
649 { 116, "syslog" },
650 { 117, "ptrace" },
651 { 118, "sched_setparam" },
652 { 119, "sched_setscheduler" },
653 { 120, "sched_getscheduler" },
654 { 121, "sched_getparam", sched_getparamFunc },
655 { 122, "sched_setaffinity" },
656 { 123, "sched_getaffinity", schedGetaffinityFunc<RiscvLinux64> },
657 { 124, "sched_yield", ignoreWarnOnceFunc },
658 { 125, "sched_get_priority_max" },
659 { 126, "sched_get_priority_min" },
660 { 127, "scheD_rr_get_interval" },
661 { 128, "restart_syscall" },
662 { 129, "kill" },
663 { 130, "tkill" },
664 { 131, "tgkill", tgkillFunc<RiscvLinux64> },
665 { 132, "sigaltstack" },
666 { 133, "rt_sigsuspend", ignoreWarnOnceFunc },
667 { 134, "rt_sigaction", ignoreWarnOnceFunc },
668 { 135, "rt_sigprocmask", ignoreWarnOnceFunc },
669 { 136, "rt_sigpending", ignoreWarnOnceFunc },
670 { 137, "rt_sigtimedwait", ignoreWarnOnceFunc },
671 { 138, "rt_sigqueueinfo", ignoreWarnOnceFunc },
672 { 139, "rt_sigreturn", ignoreWarnOnceFunc },
673 { 140, "setpriority" },
674 { 141, "getpriority" },
675 { 142, "reboot" },
676 { 143, "setregid" },
677 { 144, "setgid" },
678 { 145, "setreuid" },
679 { 146, "setuid", ignoreFunc },
680 { 147, "setresuid" },
681 { 148, "getresuid" },
682 { 149, "getresgid" },
683 { 150, "getresgid" },
684 { 151, "setfsuid" },
685 { 152, "setfsgid" },
686 { 153, "times", timesFunc<RiscvLinux64> },
687 { 154, "setpgid", setpgidFunc },
688 { 155, "getpgid" },
689 { 156, "getsid" },
690 { 157, "setsid" },
691 { 158, "getgroups" },
692 { 159, "setgroups" },
693 { 160, "uname", unameFunc64 },
694 { 161, "sethostname" },
695 { 162, "setdomainname" },
696 { 163, "getrlimit", getrlimitFunc<RiscvLinux64> },
697 { 164, "setrlimit", ignoreFunc },
698 { 165, "getrusage", getrusageFunc<RiscvLinux64> },
699 { 166, "umask", umaskFunc },
700 { 167, "prctl" },
701 { 168, "getcpu", getcpuFunc },
702 { 169, "gettimeofday", gettimeofdayFunc<RiscvLinux64> },
703 { 170, "settimeofday" },
704 { 171, "adjtimex" },
705 { 172, "getpid", getpidFunc },
706 { 173, "getppid", getppidFunc },
707 { 174, "getuid", getuidFunc },
708 { 175, "geteuid", geteuidFunc },
709 { 176, "getgid", getgidFunc },
710 { 177, "getegid", getegidFunc },
711 { 178, "gettid", gettidFunc },
712 { 179, "sysinfo", sysinfoFunc<RiscvLinux64> },
713 { 180, "mq_open" },
714 { 181, "mq_unlink" },
715 { 182, "mq_timedsend" },
716 { 183, "mq_timedrecieve" },
717 { 184, "mq_notify" },
718 { 185, "mq_getsetattr" },
719 { 186, "msgget" },
720 { 187, "msgctl" },
721 { 188, "msgrcv" },
722 { 189, "msgsnd" },
723 { 190, "semget" },
724 { 191, "semctl" },
725 { 192, "semtimedop" },
726 { 193, "semop" },
727 { 194, "shmget" },
728 { 195, "shmctl" },
729 { 196, "shmat" },
730 { 197, "shmdt" },
731 { 198, "socket", socketFunc<RiscvLinux64> },
732 { 199, "socketpair", socketpairFunc<RiscvLinux64> },
733 { 200, "bind", bindFunc },
734 { 201, "listen", listenFunc },
735 { 202, "accept", acceptFunc<RiscvLinux64> },
736 { 203, "connect", connectFunc },
737 { 204, "getsockname", getsocknameFunc },
738 { 205, "getpeername", getpeernameFunc },
739 { 206, "sendto", sendtoFunc<RiscvLinux64> },
740 { 207, "recvfrom", recvfromFunc<RiscvLinux64> },
741 { 208, "setsockopt", setsockoptFunc },
742 { 209, "getsockopt", getsockoptFunc },
743 { 210, "shutdown", shutdownFunc },
744 { 211, "sendmsg", sendmsgFunc },
745 { 212, "recvmsg", recvmsgFunc },
746 { 213, "readahead" },
747 { 214, "brk", brkFunc },
748 { 215, "munmap", munmapFunc<RiscvLinux64> },
749 { 216, "mremap", mremapFunc<RiscvLinux64> },
750 { 217, "add_key" },
751 { 218, "request_key" },
752 { 219, "keyctl" },
753 { 220, "clone", cloneBackwardsFunc<RiscvLinux64> },
754 { 221, "execve", execveFunc<RiscvLinux64> },
755 { 222, "mmap", mmapFunc<RiscvLinux64> },
756 { 223, "fadvise64" },
757 { 224, "swapon" },
758 { 225, "swapoff" },
759 { 226, "mprotect", ignoreFunc },
760 { 227, "msync", ignoreFunc },
761 { 228, "mlock", ignoreFunc },
762 { 229, "munlock", ignoreFunc },
763 { 230, "mlockall", ignoreFunc },
764 { 231, "munlockall", ignoreFunc },
765 { 232, "mincore", ignoreFunc },
766 { 233, "madvise", ignoreFunc },
767 { 234, "remap_file_pages" },
768 { 235, "mbind", ignoreFunc },
769 { 236, "get_mempolicy" },
770 { 237, "set_mempolicy" },
771 { 238, "migrate_pages" },
772 { 239, "move_pages" },
773 { 240, "tgsigqueueinfo" },
774 { 241, "perf_event_open" },
775 { 242, "accept4" },
776 { 243, "recvmmsg" },
777 { 258, "riscv_hwprobe", riscvHWProbeFunc<RiscvLinux64> },
778 { 260, "wait4", wait4Func<RiscvLinux64> },
779 { 261, "prlimit64", prlimitFunc<RiscvLinux64> },
780 { 262, "fanotify_init" },
781 { 263, "fanotify_mark" },
782 { 264, "name_to_handle_at" },
783 { 265, "open_by_handle_at" },
784 { 266, "clock_adjtime" },
785 { 267, "syncfs" },
786 { 268, "setns" },
787 { 269, "sendmmsg" },
788 { 270, "process_vm_ready" },
789 { 271, "process_vm_writev" },
790 { 272, "kcmp" },
791 { 273, "finit_module" },
792 { 274, "sched_setattr" },
793 { 275, "sched_getattr" },
794 { 276, "renameat2" },
795 { 277, "seccomp" },
796 { 278, "getrandom", getrandomFunc<RiscvLinux64> },
797 { 279, "memfd_create" },
798 { 280, "bpf" },
799 { 281, "execveat" },
800 { 282, "userfaultid" },
801 { 283, "membarrier" },
802 { 284, "mlock2" },
803 { 285, "copy_file_range" },
804 { 286, "preadv2" },
805 { 287, "pwritev2" },
806 { 424, "pidfd_send_signal" },
807 { 425, "io_uring_setup" },
808 { 426, "io_uring_enter" },
809 { 427, "io_uring_register" },
810 { 428, "open_tree" },
811 { 429, "move_mount" },
812 { 430, "fsopen" },
813 { 431, "fsconfig" },
814 { 432, "fsmount" },
815 { 433, "fspick" },
816 { 434, "pidfd_open" },
817 { 435, "clone3", clone3Func<RiscvLinux64> },
818 { 436, "close_range" },
819 { 437, "openat2" },
820 { 438, "pidfd_getfd" },
821 { 439, "faccessat2" },
822 { 440, "process_madvise" },
823 { 441, "epoll_pwait2" },
824 { 442, "mount_setattr" },
825 { 443, "quotactl_fd" },
826 { 444, "landlock_create_ruleset" },
827 { 445, "landlock_add_rule" },
828 { 446, "landlock_restrict_self" },
829 { 447, "memfd_secret" },
830 { 448, "process_mrelease" },
831 { 449, "futex_waitv" },
832 { 450, "set_mempolicy_home_node" },
833 { 1024, "open", openFunc<RiscvLinux64> },
834 { 1025, "link", linkFunc },
835 { 1026, "unlink", unlinkFunc },
836 { 1027, "mknod", mknodFunc },
837 { 1028, "chmod", chmodFunc<RiscvLinux64> },
838 { 1029, "chown", chownFunc },
839 { 1030, "mkdir", mkdirFunc },
840 { 1031, "rmdir", rmdirFunc },
841 { 1032, "lchown" },
842 { 1033, "access", accessFunc },
843 { 1034, "rename", renameFunc },
844 { 1035, "readlink", readlinkFunc<RiscvLinux64> },
845 { 1036, "symlink", symlinkFunc },
846 { 1037, "utimes", utimesFunc<RiscvLinux64> },
847 { 1038, "stat", stat64Func<RiscvLinux64> },
848 { 1039, "lstat", lstat64Func<RiscvLinux64> },
849 { 1040, "pipe", pipeFunc },
850 { 1041, "dup2", dup2Func },
851 { 1042, "epoll_create" },
852 { 1043, "inotifiy_init" },
853 { 1044, "eventfd", eventfdFunc<RiscvLinux64> },
854 { 1045, "signalfd" },
855 { 1046, "sendfile" },
856 { 1047, "ftruncate", ftruncate64Func },
857 { 1048, "truncate", truncate64Func },
858 { 1049, "stat", stat64Func<RiscvLinux64> },
859 { 1050, "lstat", lstat64Func<RiscvLinux64> },
860 { 1051, "fstat", fstat64Func<RiscvLinux64> },
861 { 1052, "fcntl", fcntl64Func },
862 { 1053, "fadvise64" },
863 { 1054, "newfstatat", newfstatatFunc<RiscvLinux64> },
864 { 1055, "fstatfs", fstatfsFunc<RiscvLinux64> },
865 { 1056, "statfs", statfsFunc<RiscvLinux64> },
866 { 1057, "lseek", lseekFunc<RiscvLinux64> },
867 { 1058, "mmap", mmapFunc<RiscvLinux64> },
868 { 1059, "alarm" },
869 { 1060, "getpgrp", getpgrpFunc },
870 { 1061, "pause" },
871 { 1062, "time", timeFunc<RiscvLinux64> },
872 { 1063, "utime" },
873 { 1064, "creat" },
874#if defined(SYS_getdents)
875 { 1065, "getdents", getdentsFunc },
876#else
877 { 1065, "getdents" },
878#endif
879 { 1066, "futimesat" },
880 { 1067, "select", selectFunc<RiscvLinux64> },
881 { 1068, "poll", pollFunc<RiscvLinux64> },
882 { 1069, "epoll_wait" },
883 { 1070, "ustat" },
884 { 1071, "vfork" },
885 { 1072, "oldwait4" },
886 { 1073, "recv" },
887 { 1074, "send" },
888 { 1075, "bdflush" },
889 { 1076, "umount" },
890 { 1077, "uselib" },
891 { 1078, "sysctl" },
892 { 1079, "fork" },
893 { 2011, "getmainvars" }
894};
895
896SyscallDescTable<SEWorkload::SyscallABI32> EmuLinux::syscallDescs32 = {
897 { 0, "io_setup" },
898 { 1, "io_destroy" },
899 { 2, "io_submit" },
900 { 3, "io_cancel" },
901 { 4, "io_getevents" },
902 { 5, "setxattr" },
903 { 6, "lsetxattr" },
904 { 7, "fsetxattr" },
905 { 8, "getxattr" },
906 { 9, "lgetxattr" },
907 { 10, "fgetxattr" },
908 { 11, "listxattr" },
909 { 12, "llistxattr" },
910 { 13, "flistxattr" },
911 { 14, "removexattr" },
912 { 15, "lremovexattr" },
913 { 16, "fremovexattr" },
914 { 17, "getcwd", getcwdFunc<RiscvLinux32> },
915 { 18, "lookup_dcookie" },
916 { 19, "eventfd2" },
917 { 20, "epoll_create1" },
918 { 21, "epoll_ctl" },
919 { 22, "epoll_pwait" },
920 { 23, "dup", dupFunc },
921 { 24, "dup3" },
922 { 25, "fcntl", fcntlFunc },
923 { 26, "inotify_init1" },
924 { 27, "inotify_add_watch" },
925 { 28, "inotify_rm_watch" },
926 { 29, "ioctl", ioctlFunc<RiscvLinux32> },
927 { 30, "ioprio_get" },
928 { 31, "ioprio_set" },
929 { 32, "flock" },
930 { 33, "mknodat", mknodatFunc<RiscvLinux32> },
931 { 34, "mkdirat", mkdiratFunc<RiscvLinux32> },
932 { 35, "unlinkat", unlinkatFunc<RiscvLinux32> },
933 { 36, "symlinkat" },
934 { 37, "linkat" },
935 { 38, "renameat", renameatFunc<RiscvLinux32> },
936 { 39, "umount2" },
937 { 40, "mount" },
938 { 41, "pivot_root" },
939 { 42, "nfsservctl" },
940 { 43, "statfs", statfsFunc<RiscvLinux32> },
941 { 44, "fstatfs", fstatfsFunc<RiscvLinux32> },
942 { 45, "truncate", truncateFunc<RiscvLinux32> },
943 { 46, "ftruncate", ftruncateFunc<RiscvLinux32> },
944 { 47, "fallocate", fallocateFunc<RiscvLinux32> },
945 { 48, "faccessat", faccessatFunc<RiscvLinux32> },
946 { 49, "chdir", chdirFunc },
947 { 50, "fchdir" },
948 { 51, "chroot" },
949 { 52, "fchmod", fchmodFunc<RiscvLinux32> },
950 { 53, "fchmodat" },
951 { 54, "fchownat" },
952 { 55, "fchown", fchownFunc },
953 { 56, "openat", openatFunc<RiscvLinux32> },
954 { 57, "close", closeFunc },
955 { 58, "vhangup" },
956 { 59, "pipe2", pipe2Func },
957 { 60, "quotactl" },
958#if defined(SYS_getdents64)
959 { 61, "getdents64", getdents64Func },
960#else
961 { 61, "getdents64" },
962#endif
963 { 62, "lseek", lseekFunc<RiscvLinux32> },
964 { 63, "read", readFunc<RiscvLinux32> },
965 { 64, "write", writeFunc<RiscvLinux32> },
966 { 66, "writev", writevFunc<RiscvLinux32> },
967 { 67, "pread64", pread64Func<RiscvLinux32> },
968 { 68, "pwrite64", pwrite64Func<RiscvLinux32> },
969 { 69, "preadv" },
970 { 70, "pwritev" },
971 { 71, "sendfile" },
972 { 72, "pselect6" },
973 { 73, "ppoll" },
974 { 74, "signalfd64" },
975 { 75, "vmsplice" },
976 { 76, "splice" },
977 { 77, "tee" },
978 { 78, "readlinkat", readlinkatFunc<RiscvLinux32> },
979 { 79, "fstatat" },
980 { 80, "fstat", fstatFunc<RiscvLinux32> },
981 { 81, "sync" },
982 { 82, "fsync" },
983 { 83, "fdatasync" },
984 { 84, "sync_file_range2" },
985 { 85, "timerfd_create" },
986 { 86, "timerfd_settime" },
987 { 87, "timerfd_gettime" },
988 { 88, "utimensat" },
989 { 89, "acct" },
990 { 90, "capget" },
991 { 91, "capset" },
992 { 92, "personality" },
993 { 93, "exit", exitFunc },
994 { 94, "exit_group", exitGroupFunc },
995 { 95, "waitid" },
996 { 96, "set_tid_address", setTidAddressFunc },
997 { 97, "unshare" },
998 { 98, "futex", futexFunc<RiscvLinux32> },
999 { 99, "set_robust_list", ignoreWarnOnceFunc },
1000 { 100, "get_robust_list", ignoreWarnOnceFunc },
1001 { 101, "nanosleep" },
1002 { 102, "getitimer" },
1003 { 103, "setitimer" },
1004 { 104, "kexec_load" },
1005 { 105, "init_module" },
1006 { 106, "delete_module" },
1007 { 107, "timer_create" },
1008 { 108, "timer_gettime" },
1009 { 109, "timer_getoverrun" },
1010 { 110, "timer_settime" },
1011 { 111, "timer_delete" },
1012 { 112, "clock_settime" },
1013 { 113, "clock_gettime", clock_gettimeFunc<RiscvLinux32> },
1014 { 114, "clock_getres", clock_getresFunc<RiscvLinux32> },
1015 { 115, "clock_nanosleep" },
1016 { 116, "syslog" },
1017 { 117, "ptrace" },
1018 { 118, "sched_setparam" },
1019 { 119, "sched_setscheduler" },
1020 { 120, "sched_getscheduler" },
1021 { 121, "sched_getparam", sched_getparamFunc },
1022 { 122, "sched_setaffinity" },
1023 { 123, "sched_getaffinity", schedGetaffinityFunc<RiscvLinux32> },
1024 { 124, "sched_yield", ignoreWarnOnceFunc },
1025 { 125, "sched_get_priority_max" },
1026 { 126, "sched_get_priority_min" },
1027 { 127, "scheD_rr_get_interval" },
1028 { 128, "restart_syscall" },
1029 { 129, "kill" },
1030 { 130, "tkill" },
1031 { 131, "tgkill", tgkillFunc<RiscvLinux32> },
1032 { 132, "sigaltstack" },
1033 { 133, "rt_sigsuspend", ignoreWarnOnceFunc },
1034 { 134, "rt_sigaction", ignoreWarnOnceFunc },
1035 { 135, "rt_sigprocmask", ignoreWarnOnceFunc },
1036 { 136, "rt_sigpending", ignoreWarnOnceFunc },
1037 { 137, "rt_sigtimedwait", ignoreWarnOnceFunc },
1038 { 138, "rt_sigqueueinfo", ignoreWarnOnceFunc },
1039 { 139, "rt_sigreturn", ignoreWarnOnceFunc },
1040 { 140, "setpriority" },
1041 { 141, "getpriority" },
1042 { 142, "reboot" },
1043 { 143, "setregid" },
1044 { 144, "setgid" },
1045 { 145, "setreuid" },
1046 { 146, "setuid", ignoreFunc },
1047 { 147, "setresuid" },
1048 { 148, "getresuid" },
1049 { 149, "getresgid" },
1050 { 150, "getresgid" },
1051 { 151, "setfsuid" },
1052 { 152, "setfsgid" },
1053 { 153, "times", timesFunc<RiscvLinux32> },
1054 { 154, "setpgid", setpgidFunc },
1055 { 155, "getpgid" },
1056 { 156, "getsid" },
1057 { 157, "setsid" },
1058 { 158, "getgroups" },
1059 { 159, "setgroups" },
1060 { 160, "uname", unameFunc32 },
1061 { 161, "sethostname" },
1062 { 162, "setdomainname" },
1063 { 163, "getrlimit", getrlimitFunc<RiscvLinux32> },
1064 { 164, "setrlimit", ignoreFunc },
1065 { 165, "getrusage", getrusageFunc<RiscvLinux32> },
1066 { 166, "umask", umaskFunc },
1067 { 167, "prctl" },
1068 { 168, "getcpu", getcpuFunc },
1069 { 169, "gettimeofday", gettimeofdayFunc<RiscvLinux32> },
1070 { 170, "settimeofday" },
1071 { 171, "adjtimex" },
1072 { 172, "getpid", getpidFunc },
1073 { 173, "getppid", getppidFunc },
1074 { 174, "getuid", getuidFunc },
1075 { 175, "geteuid", geteuidFunc },
1076 { 176, "getgid", getgidFunc },
1077 { 177, "getegid", getegidFunc },
1078 { 178, "gettid", gettidFunc },
1079 { 179, "sysinfo", sysinfoFunc<RiscvLinux32> },
1080 { 180, "mq_open" },
1081 { 181, "mq_unlink" },
1082 { 182, "mq_timedsend" },
1083 { 183, "mq_timedrecieve" },
1084 { 184, "mq_notify" },
1085 { 185, "mq_getsetattr" },
1086 { 186, "msgget" },
1087 { 187, "msgctl" },
1088 { 188, "msgrcv" },
1089 { 189, "msgsnd" },
1090 { 190, "semget" },
1091 { 191, "semctl" },
1092 { 192, "semtimedop" },
1093 { 193, "semop" },
1094 { 194, "shmget" },
1095 { 195, "shmctl" },
1096 { 196, "shmat" },
1097 { 197, "shmdt" },
1098 { 198, "socket", socketFunc<RiscvLinux32> },
1099 { 199, "socketpair", socketpairFunc<RiscvLinux32> },
1100 { 200, "bind", bindFunc },
1101 { 201, "listen", listenFunc },
1102 { 202, "accept", acceptFunc<RiscvLinux32> },
1103 { 203, "connect", connectFunc },
1104 { 204, "getsockname", getsocknameFunc },
1105 { 205, "getpeername", getpeernameFunc },
1106 { 206, "sendto", sendtoFunc<RiscvLinux32> },
1107 { 207, "recvfrom", recvfromFunc<RiscvLinux32> },
1108 { 208, "setsockopt", setsockoptFunc },
1109 { 209, "getsockopt", getsockoptFunc },
1110 { 210, "shutdown", shutdownFunc },
1111 { 211, "sendmsg", sendmsgFunc },
1112 { 212, "recvmsg", recvmsgFunc },
1113 { 213, "readahead" },
1114 { 214, "brk", brkFunc },
1115 { 215, "munmap", munmapFunc<RiscvLinux32> },
1116 { 216, "mremap", mremapFunc<RiscvLinux32> },
1117 { 217, "add_key" },
1118 { 218, "request_key" },
1119 { 219, "keyctl" },
1120 { 220, "clone", cloneBackwardsFunc<RiscvLinux32> },
1121 { 221, "execve", execveFunc<RiscvLinux32> },
1122 { 222, "mmap", mmapFunc<RiscvLinux32> },
1123 { 223, "fadvise64" },
1124 { 224, "swapon" },
1125 { 225, "swapoff" },
1126 { 226, "mprotect", ignoreFunc },
1127 { 227, "msync", ignoreFunc },
1128 { 228, "mlock", ignoreFunc },
1129 { 229, "munlock", ignoreFunc },
1130 { 230, "mlockall", ignoreFunc },
1131 { 231, "munlockall", ignoreFunc },
1132 { 232, "mincore", ignoreFunc },
1133 { 233, "madvise", ignoreFunc },
1134 { 234, "remap_file_pages" },
1135 { 235, "mbind", ignoreFunc },
1136 { 236, "get_mempolicy" },
1137 { 237, "set_mempolicy" },
1138 { 238, "migrate_pages" },
1139 { 239, "move_pages" },
1140 { 240, "tgsigqueueinfo" },
1141 { 241, "perf_event_open" },
1142 { 242, "accept4" },
1143 { 243, "recvmmsg" },
1144 { 258, "riscv_hwprobe", riscvHWProbeFunc<RiscvLinux32> },
1145 { 260, "wait4", wait4Func<RiscvLinux32> },
1146 { 261, "prlimit64", prlimitFunc<RiscvLinux32> },
1147 { 262, "fanotify_init" },
1148 { 263, "fanotify_mark" },
1149 { 264, "name_to_handle_at" },
1150 { 265, "open_by_handle_at" },
1151 { 266, "clock_adjtime" },
1152 { 267, "syncfs" },
1153 { 268, "setns" },
1154 { 269, "sendmmsg" },
1155 { 270, "process_vm_ready" },
1156 { 271, "process_vm_writev" },
1157 { 272, "kcmp" },
1158 { 273, "finit_module" },
1159 { 274, "sched_setattr" },
1160 { 275, "sched_getattr" },
1161 { 276, "renameat2" },
1162 { 277, "seccomp" },
1163 { 278, "getrandom", getrandomFunc<RiscvLinux32> },
1164 { 279, "memfd_create" },
1165 { 280, "bpf" },
1166 { 281, "execveat" },
1167 { 282, "userfaultid" },
1168 { 283, "membarrier" },
1169 { 284, "mlock2" },
1170 { 285, "copy_file_range" },
1171 { 286, "preadv2" },
1172 { 287, "pwritev2" },
1173 { 1024, "open", openFunc<RiscvLinux32> },
1174 { 1025, "link", linkFunc },
1175 { 1026, "unlink", unlinkFunc },
1176 { 1027, "mknod", mknodFunc },
1177 { 1028, "chmod", chmodFunc<RiscvLinux32> },
1178 { 1029, "chown", chownFunc },
1179 { 1030, "mkdir", mkdirFunc },
1180 { 1031, "rmdir", rmdirFunc },
1181 { 1032, "lchown" },
1182 { 1033, "access", accessFunc },
1183 { 1034, "rename", renameFunc },
1184 { 1035, "readlink", readlinkFunc<RiscvLinux32> },
1185 { 1036, "symlink", symlinkFunc },
1186 { 1037, "utimes", utimesFunc<RiscvLinux32> },
1187 { 1038, "stat", statFunc<RiscvLinux32> },
1188 { 1039, "lstat", lstatFunc<RiscvLinux32> },
1189 { 1040, "pipe", pipeFunc },
1190 { 1041, "dup2", dup2Func },
1191 { 1042, "epoll_create" },
1192 { 1043, "inotifiy_init" },
1193 { 1044, "eventfd", eventfdFunc<RiscvLinux32> },
1194 { 1045, "signalfd" },
1195 { 1046, "sendfile" },
1196 { 1047, "ftruncate", ftruncateFunc<RiscvLinux32> },
1197 { 1048, "truncate", truncateFunc<RiscvLinux32> },
1198 { 1049, "stat", statFunc<RiscvLinux32> },
1199 { 1050, "lstat", lstatFunc<RiscvLinux32> },
1200 { 1051, "fstat", fstatFunc<RiscvLinux32> },
1201 { 1052, "fcntl", fcntlFunc },
1202 { 1053, "fadvise64" },
1203 { 1054, "newfstatat", newfstatatFunc<RiscvLinux32> },
1204 { 1055, "fstatfs", fstatfsFunc<RiscvLinux32> },
1205 { 1056, "statfs", statfsFunc<RiscvLinux32> },
1206 { 1057, "lseek", lseekFunc<RiscvLinux32> },
1207 { 1058, "mmap", mmapFunc<RiscvLinux32> },
1208 { 1059, "alarm" },
1209 { 1060, "getpgrp", getpgrpFunc },
1210 { 1061, "pause" },
1211 { 1062, "time", timeFunc<RiscvLinux32> },
1212 { 1063, "utime" },
1213 { 1064, "creat" },
1214#if defined(SYS_getdents)
1215 { 1065, "getdents", getdentsFunc },
1216#else
1217 { 1065, "getdents" },
1218#endif
1219 { 1066, "futimesat" },
1220 { 1067, "select", selectFunc<RiscvLinux32> },
1221 { 1068, "poll", pollFunc<RiscvLinux32> },
1222 { 1069, "epoll_wait" },
1223 { 1070, "ustat" },
1224 { 1071, "vfork" },
1225 { 1072, "oldwait4" },
1226 { 1073, "recv" },
1227 { 1074, "send" },
1228 { 1075, "bdflush" },
1229 { 1076, "umount" },
1230 { 1077, "uselib" },
1231 { 1078, "sysctl" },
1232 { 1079, "fork" },
1233 { 2011, "getmainvars" }
1234};
1235
1236} // namespace RiscvISA
1237} // namespace gem5
#define RISCV_HWPROBE_WHICH_CPUS
Definition linux.hh:130
#define RISCV_HWPROBE_MAX_KEY
Definition linux.hh:62
bool copyIn(const PortProxy &memproxy)
copy data into simulator space (read from target memory)
bool copyOut(const PortProxy &memproxy)
copy data out of simulator space (write to target memory)
BufferArg represents an untyped buffer in target user space that is passed by reference to an (emulat...
void * bufferPtr()
Return a pointer to the internal simulator-space buffer.
Each instance of a Loader subclass will have a chance to try to load an object file when tryLoaders i...
Definition process.hh:208
std::shared_ptr< MemState > memState
Definition process.hh:301
static SyscallDescTable< SEWorkload::SyscallABI32 > syscallDescs32
32 bit syscall descriptors, indexed by call number.
void syscall(ThreadContext *tc) override
static SyscallDescTable< SEWorkload::SyscallABI64 > syscallDescs64
64 bit syscall descriptors, indexed by call number.
struct gem5::RiscvLinux::cpumask cpumask_t
@ MisalignedScalarPerf
Definition linux.hh:58
This class provides the wrapper interface for the system call implementations which are defined in th...
This class represents the return value from an emulated system call, including any errno setting.
Addr cacheLineSize() const
Get the cache line size of the system.
Definition system.hh:313
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal getReg(const RegId &reg) const
virtual System * getSystemPtr()=0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
virtual Process * getProcessPtr()=0
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition bitfield.hh:79
constexpr T insertBits(T val, unsigned first, unsigned last, B bit_val)
Returns val with bits first to last set to the LSBs of bit_val.
Definition bitfield.hh:185
#define warn(...)
Definition logging.hh:288
Bitfield< 12 > ext
static void cpumask_set_cpu(unsigned int cpu, RiscvLinux::cpumask_t *dstp)
static RiscvLinux::cpumask_t * get_cpu_online_mask(ThreadContext *tc)
static SyscallReturn riscvHWProbeFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pairs, typename OS::size_t pair_count, typename OS::size_t cpusetsize, VPtr<> cpus_user, unsigned int flags)
static int hwprobe_get_values(ThreadContext *tc, VPtr<> pairs, typename OS::size_t pair_count, typename OS::size_t cpusetsize, VPtr<> cpus_user, unsigned int flags)
static void cpumask_copy(RiscvLinux::cpumask_t *dstp, const RiscvLinux::cpumask_t *srcp)
static SyscallReturn unameFunc32(SyscallDesc *desc, ThreadContext *tc, VPtr< Linux::utsname > name)
Target uname() handler.
static void cpumask_free(RiscvLinux::cpumask_t *cpu_online_mask)
static void cpumask_and(RiscvLinux::cpumask_t *dstp, const RiscvLinux::cpumask_t *src1p, const RiscvLinux::cpumask_t *src2p)
Bitfield< 2 > i
static bool cpumask_test_cpu(unsigned int cpu, const RiscvLinux::cpumask_t *cpumask)
static void cpumask_clear_cpu(unsigned int cpu, RiscvLinux::cpumask_t *dstp)
static void cpumask_clear(RiscvLinux::cpumask_t *dstp)
static bool riscv_hwprobe_pair_cmp(RiscvLinux::riscv_hwprobe *pair, RiscvLinux::riscv_hwprobe *other_pair)
const std::unordered_map< int, CSRMetadata > CSRData
Definition misc.hh:554
static bool cpumask_empty(const RiscvLinux::cpumask_t *dstp)
static int hwprobe_get_cpus(ThreadContext *tc, VPtr<> pairs, typename OS::size_t pair_count, typename OS::size_t cpusetsize, VPtr<> cpus_user, unsigned int flags)
static void hwprobe_one_pair(ThreadContext *tc, RiscvLinux::riscv_hwprobe *pair, RiscvLinux::cpumask_t *cpus)
static bool hwprobe_key_is_bitmask(int64_t key)
static bool riscv_hwprobe_key_is_valid(int64_t key)
static RiscvLinux::cpumask_t * cpumask_malloc(ThreadContext *tc)
constexpr auto & SyscallNumReg
Definition int.hh:145
static SyscallReturn unameFunc64(SyscallDesc *desc, ThreadContext *tc, VPtr< Linux::utsname > name)
Target uname() handler.
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
SyscallReturn linkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr<> new_pathname)
Target link() handler.
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 getrandomFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> buf_ptr, typename OS::size_t count, unsigned int flags)
SyscallReturn recvmsgFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> msgPtr, int flags)
SyscallReturn fstat64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr< typename OS::tgt_stat64 > tgt_stat)
Target fstat64() handler.
SyscallReturn wait4Func(SyscallDesc *desc, ThreadContext *tc, pid_t pid, VPtr<> statPtr, int options, VPtr<> rusagePtr)
SyscallReturn clock_gettimeFunc(SyscallDesc *desc, ThreadContext *tc, int clk_id, VPtr< typename OS::timespec > tp)
Target clock_gettime() function.
SyscallReturn brkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> new_brk)
Target brk() handler: set brk address.
SyscallReturn mmapFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> start, typename OS::size_t length, int prot, int tgt_flags, int tgt_fd, typename OS::off_t offset)
Target mmap() handler.
SyscallReturn pipe2Func(SyscallDesc *desc, ThreadContext *tc, VPtr<> tgt_addr, int flags)
Target pipe() handler.
SyscallReturn getpidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpid() handler.
SyscallReturn chdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
Target chdir() handler.
SyscallReturn fstatFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr< typename OS::tgt_stat > tgt_stat)
Target fstat() handler.
SyscallReturn truncate64Func(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, int64_t length)
Target truncate64() handler.
SyscallReturn getuidFunc(SyscallDesc *desc, ThreadContext *tc)
SyscallReturn pwrite64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> bufPtr, typename OS::size_t nbytes, typename OS::off_t offset)
SyscallReturn getrusageFunc(SyscallDesc *desc, ThreadContext *tc, int who, VPtr< typename OS::rusage > rup)
Target getrusage() function.
uint64_t RegVal
Definition types.hh:173
SyscallReturn recvfromFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, typename OS::size_t buf_len, int flags, VPtr<> addr_ptr, VPtr<> addrlen_ptr)
SyscallReturn selectFunc(SyscallDesc *desc, ThreadContext *tc, int nfds, VPtr< typename OS::fd_set > readfds, VPtr< typename OS::fd_set > writefds, VPtr< typename OS::fd_set > errorfds, VPtr< typename OS::timeval > timeout)
SyscallReturn utimesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::timeval[2]> tp)
Target utimes() handler.
SyscallReturn socketFunc(SyscallDesc *desc, ThreadContext *tc, int domain, int type, int prot)
SyscallReturn chownFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, uint32_t owner, uint32_t group)
Target chown() handler.
SyscallReturn statFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat > tgt_stat)
Target stat() handler.
SyscallReturn writeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, typename OS::size_t nbytes)
SyscallReturn writevFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> tiov_base, typename OS::size_t count)
Target writev() handler.
SyscallReturn chmodFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
Target chmod() 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 setpgidFunc(SyscallDesc *desc, ThreadContext *tc, int pid, int pgid)
Target setpgid() handler.
SyscallReturn truncateFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, typename OS::off_t length)
Target truncate() handler.
SyscallReturn geteuidFunc(SyscallDesc *desc, ThreadContext *tc)
Target geteuid() handler.
SyscallReturn symlinkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr<> new_pathname)
Target symlink() handler.
ProxyPtr< T, SETranslatingPortProxy > VPtr
Definition proxy_ptr.hh:400
SyscallReturn unlinkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
Target unlink() handler.
SyscallReturn lseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, typename OS::off_t offs, int whence)
Target lseek() handler.
SyscallReturn sysinfoFunc(SyscallDesc *desc, ThreadContext *tc, VPtr< typename OS::tgt_sysinfo > sysinfo)
Target sysinfo() handler.
SyscallReturn gettimeofdayFunc(SyscallDesc *desc, ThreadContext *tc, VPtr< typename OS::timeval > tp, VPtr<> tz_ptr)
Target gettimeofday() handler.
SyscallReturn unlinkatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, int flags)
Target unlinkat() handler.
SyscallReturn pipeFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> tgt_addr)
Target pipe() handler.
SyscallReturn prlimitFunc(SyscallDesc *desc, ThreadContext *tc, int pid, int resource, VPtr<> n, VPtr< typename OS::rlimit > rlp)
SyscallReturn clock_getresFunc(SyscallDesc *desc, ThreadContext *tc, int clk_id, VPtr< typename OS::timespec > tp)
Target clock_getres() function.
SyscallReturn faccessatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, int mode)
Target facessat() handler.
SyscallReturn getsockoptFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, VPtr<> valPtr, VPtr<> lenPtr)
SyscallReturn getrlimitFunc(SyscallDesc *desc, ThreadContext *tc, unsigned resource, VPtr< typename OS::rlimit > rlp)
Target getrlimit() handler.
SyscallReturn mknodatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, mode_t mode, dev_t dev)
Target mknodat() handler.
SyscallReturn fallocateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int mode, typename OS::off_t offset, typename OS::off_t len)
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 socketpairFunc(SyscallDesc *desc, ThreadContext *tc, int domain, int type, int prot, VPtr<> svPtr)
SyscallReturn ftruncateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, typename OS::off_t length)
Target ftruncate() handler.
SyscallReturn statfsFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_statfs > tgt_stat)
Target statfs() handler.
SyscallReturn setsockoptFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, VPtr<> valPtr, socklen_t len)
SyscallReturn lstatFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat > tgt_stat)
Target lstat() handler.
SyscallReturn rmdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
SyscallReturn mkdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
Target mkdir() handler.
SyscallReturn readlinkatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, VPtr<> buf_ptr, typename OS::size_t bufsiz)
Target readlinkat() handler.
SyscallReturn getpgrpFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpgrpFunc() handler.
SyscallReturn eventfdFunc(SyscallDesc *desc, ThreadContext *tc, unsigned initval, int in_flags)
Target eventfd() function.
SyscallReturn dupFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
FIXME: The file description is not shared among file descriptors created with dup.
SyscallReturn listenFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int backlog)
SyscallReturn ftruncate64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int64_t length)
Target ftruncate64() handler.
SyscallReturn getcwdFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> buf_ptr, typename OS::size_t size)
Target getcwd() handler.
SyscallReturn openatFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_dirfd, VPtr<> pathname, int tgt_flags, int mode)
Target open() handler.
SyscallReturn fchownFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t owner, uint32_t group)
Target fchown() handler.
SyscallReturn munmapFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> start, typename OS::size_t length)
Target munmap() handler.
SyscallReturn readlinkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr<> buf_ptr, typename OS::size_t bufsiz)
Target readlink() handler.
SyscallReturn pread64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> bufPtr, typename OS::size_t nbytes, typename OS::off_t offset)
SyscallReturn setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> tidPtr)
Target set_tid_address() handler.
SyscallReturn timesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr< typename OS::tms > bufp)
Target times() function.
SyscallReturn fcntlFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd, guest_abi::VarArgs< int > varargs)
Target fcntl() handler.
SyscallReturn openFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, int tgt_flags, int mode)
Target open() handler.
SyscallReturn schedGetaffinityFunc(SyscallDesc *desc, ThreadContext *tc, pid_t pid, typename OS::size_t cpusetsize, VPtr<> cpu_set_mask)
Target sched_getaffinity.
SyscallReturn bindFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, int addrlen)
SyscallReturn pollFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> fdsPtr, int nfds, int tmout)
SyscallReturn getegidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getegid() handler.
SyscallReturn timeFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> taddr)
Target time() function.
SyscallReturn newfstatatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, VPtr< typename OS::tgt_stat64 > tgt_stat, int flags)
Target newfstatat() handler.
SyscallReturn fchmodFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t mode)
Target fchmod() handler.
SyscallReturn shutdownFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int how)
Target shutdown() handler.
SyscallReturn renameatFunc(SyscallDesc *desc, ThreadContext *tc, int olddirfd, VPtr<> oldpath, int newdirfd, VPtr<> newpath)
Target renameat() handler.
SyscallReturn getcpuFunc(SyscallDesc *desc, ThreadContext *tc, VPtr< uint32_t > cpu, VPtr< uint32_t > node, VPtr< uint32_t > tcache)
SyscallReturn getsocknameFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> addrPtr, VPtr<> lenPtr)
SyscallReturn clone3Func(SyscallDesc *desc, ThreadContext *tc, VPtr< typename OS::tgt_clone_args > cl_args, RegVal size)
SyscallReturn ioctlFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, unsigned req, VPtr<> addr)
Target ioctl() handler.
SyscallReturn getpeernameFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> sockAddrPtr, VPtr<> addrlenPtr)
SyscallReturn accessFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
Target access() handler.
SyscallReturn tgkillFunc(SyscallDesc *desc, ThreadContext *tc, int tgid, int tid, int sig)
SyscallReturn sendmsgFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> msgPtr, int flags)
SyscallReturn cloneBackwardsFunc(SyscallDesc *desc, ThreadContext *tc, RegVal flags, RegVal newStack, VPtr<> ptidPtr, VPtr<> tlsPtr, VPtr<> ctidPtr)
SyscallReturn lstat64Func(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat64 > tgt_stat)
Target lstat64() handler.
SyscallReturn fstatat64Func(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, VPtr< typename OS::tgt_stat64 > tgt_stat)
Target fstatat64() handler.
SyscallReturn ignoreFunc(SyscallDesc *desc, ThreadContext *tc)
Handler for unimplemented syscalls that we never intend to implement (signal handling,...
SyscallReturn acceptFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> addrPtr, VPtr<> lenPtr)
SyscallReturn futexFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> uaddr, int op, int val, int timeout, VPtr<> uaddr2, int val3)
Futex system call Implemented by Daniel Sanchez Used by printf's in multi-threaded apps.
SyscallReturn fstatfsFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr< typename OS::tgt_statfs > tgt_stat)
Target fstatfs() handler.
SyscallReturn mremapFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> start, typename OS::size_t old_length, typename OS::size_t new_length, int flags, guest_abi::VarArgs< uint64_t > varargs)
Target mremap() handler.
SyscallReturn stat64Func(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat64 > tgt_stat)
Target stat64() handler.
SyscallReturn connectFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, int addrlen)
SyscallReturn execveFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr<> argv_mem_loc, VPtr<> envp_mem_loc)
SyscallReturn sched_getparamFunc(SyscallDesc *desc, ThreadContext *tc, int pid, VPtr< int > paramPtr)
SyscallReturn exitFunc(SyscallDesc *desc, ThreadContext *tc, int status)
Target exit() handler: terminate current context.
SyscallReturn dup2Func(SyscallDesc *desc, ThreadContext *tc, int old_tgt_fd, int new_tgt_fd)
Target dup2() handler.
SyscallReturn getgidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getgid() handler.
SyscallReturn readFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, typename OS::size_t nbytes)
SyscallReturn closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
Target close() handler.
SyscallReturn umaskFunc(SyscallDesc *desc, ThreadContext *tc)
Target umask() handler.
SyscallReturn sendtoFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, typename OS::size_t buf_len, int flags, VPtr<> addr_ptr, socklen_t addr_len)
SyscallReturn mkdiratFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, mode_t mode)
Target mkdirat() 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 May 26 2025 09:19:05 for gem5 by doxygen 1.13.2