gem5 v24.0.0.0
Loading...
Searching...
No Matches
se_workload.cc
Go to the documentation of this file.
1/*
2 * Copyright 2003-2005 The Regents of The University of Michigan
3 * Copyright 2007-2008 The Florida State University
4 * Copyright 2009 The University of Edinburgh
5 * Copyright 2020 Google Inc.
6 * Copyright 2021 IBM Corporation
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met: redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer;
12 * redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution;
15 * neither the name of the copyright holders nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
33
34#include <sys/syscall.h>
35
36#include "arch/power/process.hh"
38#include "base/trace.hh"
39#include "cpu/thread_context.hh"
40#include "sim/syscall_emul.hh"
41
42namespace gem5
43{
44
45namespace
46{
47
48class LinuxLoader : public Process::Loader
49{
50 public:
51 Process *
52 load(const ProcessParams &params, loader::ObjectFile *obj) override
53 {
54 auto arch = obj->getArch();
55
56 if (arch != loader::Power && arch != loader::Power64)
57 return nullptr;
58
59 auto opsys = obj->getOpSys();
60
61 if (opsys == loader::UnknownOpSys) {
62 warn("Unknown operating system; assuming Linux.");
63 opsys = loader::Linux;
64 }
65
66 if ((arch == loader::Power && opsys != loader::Linux) ||
67 (arch == loader::Power64 &&
70 return nullptr;
71
72 return new PowerProcess(params, obj);
73 }
74};
75
76LinuxLoader linuxLoader;
77
78} // anonymous namespace
79
80namespace PowerISA
81{
82
83void
85{
86 Process *process = tc->getProcessPtr();
87 // Call the syscall function in the base Process class to update stats.
88 // This will move into the base SEWorkload function at some point.
89 process->Process::syscall(tc);
90
91 syscallDescs.get(tc->getReg(int_reg::R0))->doSyscall(tc);
92}
93
95static SyscallReturn
97{
98 auto process = tc->getProcessPtr();
99
100 strcpy(name->sysname, "Linux");
101 strcpy(name->nodename, "sim.gem5.org");
102 strcpy(name->release, process->release.c_str());
103 strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003");
104 strcpy(name->machine, "power");
105
106 return 0;
107}
108
110 { 0, "syscall" },
111 { 1, "exit", exitFunc },
112 { 2, "fork" },
113 { 3, "read", readFunc<PowerLinux> },
114 { 4, "write", writeFunc<PowerLinux> },
115 { 5, "open", openFunc<PowerLinux> },
116 { 6, "close", closeFunc },
117 { 7, "waitpid" }, //???
118 { 8, "creat" },
119 { 9, "link" },
120 { 10, "unlink", unlinkFunc },
121 { 11, "execve" },
122 { 12, "chdir" },
123 { 13, "time", timeFunc<PowerLinux> },
124 { 14, "mknod" },
125 { 15, "chmod", chmodFunc<PowerLinux> },
126 { 16, "lchown", chownFunc },
127 { 17, "break", brkFunc }, //???
128 { 18, "unused#18" }, //???
129 { 19, "lseek", lseekFunc },
130 { 20, "getpid", getpidFunc },
131 { 21, "mount" },
132 { 22, "umount" },
133 { 23, "setuid", ignoreFunc },
134 { 24, "getuid", getuidFunc },
135 { 25, "stime" },
136 { 26, "ptrace" },
137 { 27, "alarm" },
138 { 28, "unused#28" },
139 { 29, "pause" },
140 { 30, "utime" },
141 { 31, "stty" },
142 { 32, "gtty" },
143 { 33, "access" },
144 { 34, "nice" },
145 { 35, "ftime" },
146 { 36, "sync" },
147 { 37, "kill", ignoreFunc },
148 { 38, "rename", renameFunc },
149 { 39, "mkdir" },
150 { 40, "rmdir" },
151 { 41, "dup", dupFunc },
152 { 42, "pipe" },
153 { 43, "times", timesFunc<PowerLinux> },
154 { 44, "prof" },
155 { 45, "brk", brkFunc },
156 { 46, "setgid" },
157 { 47, "getgid", getgidFunc },
158 { 48, "signal", ignoreFunc },
159 { 49, "geteuid", geteuidFunc },
160 { 50, "getegid", getegidFunc },
161 { 51, "acct" },
162 { 52, "umount2" },
163 { 53, "lock" },
164 { 54, "ioctl", ioctlFunc<PowerLinux> },
165 { 55, "fcntl", fcntlFunc },
166 { 56, "mpx" },
167 { 57, "setpgid" },
168 { 58, "ulimit" },
169 { 59, "unused#59" },
170 { 60, "umask", umaskFunc },
171 { 61, "chroot" },
172 { 62, "ustat" },
173 { 63, "dup2" },
174 { 64, "getppid", getpagesizeFunc },
175 { 65, "getpgrp" },
176 { 66, "setsid" },
177 { 67, "sigaction" },
178 { 68, "sgetmask" },
179 { 69, "ssetmask" },
180 { 70, "setreuid" },
181 { 71, "setregid" },
182 { 72, "sigsuspend" },
183 { 73, "sigpending" },
184 { 74, "sethostname", ignoreFunc },
185 { 75, "setrlimit", ignoreFunc },
186 { 76, "getrlimit" },
187 { 77, "getrusage", ignoreFunc },
188 { 78, "gettimeofday" },
189 { 79, "settimeofday" },
190 { 80, "getgroups" },
191 { 81, "setgroups" },
192 { 82, "reserved#82" },
193 { 83, "symlink" },
194 { 84, "unused#84" },
195 { 85, "readlink", readlinkFunc<PowerLinux> },
196 { 86, "uselib" },
197 { 87, "swapon", gethostnameFunc },
198 { 88, "reboot" },
199 { 89, "readdir" },
200 { 90, "mmap", mmapFunc<PowerLinux> },
201 { 91, "munmap",munmapFunc<PowerLinux> },
202 { 92, "truncate", truncateFunc<PowerLinux> },
203 { 93, "ftruncate", ftruncateFunc<PowerLinux> },
204 { 94, "fchmod" },
205 { 95, "fchown" },
206 { 96, "getpriority" },
207 { 97, "setpriority" },
208 { 98, "profil" },
209 { 99, "statfs" },
210 { 100, "fstatfs" },
211 { 101, "ioperm" },
212 { 102, "socketcall" },
213 { 103, "syslog" },
214 { 104, "setitimer" },
215 { 105, "getitimer" },
216 { 106, "stat", statFunc<PowerLinux> },
217 { 107, "lstat" },
218 { 108, "fstat", fstatFunc<PowerLinux> },
219 { 109, "unused#109" },
220 { 110, "iopl" },
221 { 111, "vhangup" },
222 { 112, "idle", ignoreFunc },
223 { 113, "vm86" },
224 { 114, "wait4" },
225 { 115, "swapoff" },
226 { 116, "sysinfo" },
227 { 117, "ipc" },
228 { 118, "fsync" },
229 { 119, "sigreturn" },
230 { 120, "clone", cloneBackwardsFunc<PowerLinux> },
231 { 121, "setdomainname" },
232 { 122, "uname", unameFunc },
233 { 123, "modify_ldt" },
234 { 124, "adjtimex" },
235 { 125, "mprotect", ignoreFunc },
236 { 126, "sigprocmask" },
237 { 127, "create_module" },
238 { 128, "init_module" },
239 { 129, "delete_module" },
240 { 130, "get_kernel_syms" },
241 { 131, "quotactl" },
242 { 132, "getpgid" },
243 { 133, "fchdir" },
244 { 134, "bdflush" },
245 { 135, "sysfs" },
246 { 136, "personality" },
247 { 137, "afs_syscall" },
248 { 138, "setfsuid" },
249 { 139, "setfsgid" },
250 { 140, "llseek", _llseekFunc },
251 { 141, "getdents" },
252 { 142, "newselect" },
253 { 143, "flock" },
254 { 144, "msync" },
255 { 145, "readv" },
256 { 146, "writev", writevFunc<PowerLinux> },
257 { 147, "getsid" },
258 { 148, "fdatasync" },
259 { 149, "sysctl" },
260 { 150, "mlock" },
261 { 151, "munlock" },
262 { 152, "mlockall" },
263 { 153, "munlockall" },
264 { 154, "sched_setparam" },
265 { 155, "sched_getparam" },
266 { 156, "sched_setscheduler" },
267 { 157, "sched_getscheduler" },
268 { 158, "sched_yield" },
269 { 159, "sched_get_priority_max" },
270 { 160, "sched_get_priority_min" },
271 { 161, "sched_rr_get_interval" },
272 { 162, "nanosleep" },
273 { 163, "mremap" },
274 { 164, "setresuid" },
275 { 165, "getresuid" },
276 { 166, "vm862" },
277 { 167, "query_module" },
278 { 168, "poll" },
279 { 169, "nfsservctl" },
280 { 170, "setresgid" },
281 { 171, "getresgid" },
282 { 172, "prctl" },
283 { 173, "rt_sigaction", ignoreFunc },
284 { 174, "rt_sigprocmask" },
285 { 175, "unknown#175" },
286 { 176, "rt_sigpending" },
287 { 177, "rt_sigtimedwait" },
288 { 178, "rt_sigqueueinfo", ignoreFunc },
289 { 179, "rt_sigsuspend" },
290 { 180, "pread64" },
291 { 181, "pwrite64" },
292 { 182, "chown" },
293 { 183, "getcwd" },
294 { 184, "capget" },
295 { 185, "capset" },
296 { 186, "sigaltstack" },
297 { 187, "sendfile" },
298 { 188, "getpmsg" },
299 { 189, "putpmsg" },
300 { 190, "ugetrlimit", ignoreFunc },
301 { 191, "getrlimit" },
302 { 192, "mmap2", mmapFunc<PowerLinux> },
303 { 193, "truncate64" },
304 { 194, "ftruncate64", ftruncate64Func },
305 { 195, "stat64", stat64Func<PowerLinux> },
306 { 196, "lstat64", lstat64Func<PowerLinux> },
307 { 197, "fstat64", fstat64Func<PowerLinux> },
308 { 198, "lchown" },
309 { 199, "getuid", getuidFunc },
310 { 200, "getgid", getgidFunc },
311 { 201, "geteuid", geteuidFunc },
312 { 202, "getegid", getegidFunc },
313 { 203, "setreuid" },
314 { 204, "fcntl64", fcntl64Func },
315 { 205, "getgroups" },
316 { 206, "setgroups" },
317 { 207, "fchown" },
318 { 208, "setresuid" },
319 { 209, "getresuid" },
320 { 210, "setresgid" },
321 { 211, "getresgid" },
322 { 212, "chown" },
323 { 213, "setuid" },
324 { 214, "setgid" },
325 { 215, "setfsuid" },
326 { 216, "setfsgid" },
327 { 217, "getdents64" },
328 { 218, "pivot_root" },
329 { 219, "mincore" },
330 { 220, "madvise" },
331 { 221, "unknown#221" },
332 { 222, "tux" },
333 { 223, "unknown#223" },
334 { 224, "gettid" },
335 { 225, "readahead" },
336 { 226, "setxattr" },
337 { 227, "lsetxattr" },
338 { 228, "fsetxattr" },
339 { 229, "getxattr" },
340 { 230, "lgetxattr" },
341 { 231, "fgetxattr" },
342 { 232, "listxattr" },
343 { 233, "llistxattr" },
344 { 234, "exit_group", exitGroupFunc },
345 { 235, "removexattr" },
346 { 236, "lremovexattr" },
347 { 237, "fremovexattr" },
348 { 238, "tkill" },
349 { 239, "sendfile64" },
350 { 240, "futex" },
351 { 241, "sched_setaffinity" },
352 { 242, "sched_getaffinity" },
353 { 243, "io_setup" },
354 { 244, "io_destory" },
355 { 245, "io_getevents" },
356 { 246, "io_submit" },
357 { 247, "io_cancel" },
358 { 248, "unknown#248" },
359 { 249, "lookup_dcookie" },
360 { 250, "epoll_create" },
361 { 251, "epoll_ctl" },
362 { 252, "epoll_wait" },
363 { 253, "remap_file_pages" },
364 { 254, "set_thread_area" },
365 { 255, "get_thread_area" },
366 { 256, "set_tid_address" },
367 { 257, "timer_create" },
368 { 258, "timer_settime" },
369 { 259, "timer_gettime" },
370 { 260, "timer_getoverrun" },
371 { 261, "timer_delete" },
372 { 262, "clock_settime" },
373 { 263, "clock_gettime" },
374 { 264, "clock_getres" },
375 { 265, "clock_nanosleep" },
376 { 266, "statfs64" },
377 { 267, "fstatfs64" },
378 { 268, "tgkill" },
379 { 269, "utimes" },
380 { 270, "arm_fadvise64_64" },
381 { 271, "pciconfig_iobase" },
382 { 272, "pciconfig_read" },
383 { 273, "pciconfig_write" },
384 { 274, "mq_open" },
385 { 275, "mq_unlink" },
386 { 276, "mq_timedsend" },
387 { 277, "mq_timedreceive" },
388 { 278, "mq_notify" },
389 { 279, "mq_getsetattr" },
390 { 280, "waitid" },
391 { 281, "socket" },
392 { 282, "bind" },
393 { 283, "connect" },
394 { 284, "listen" },
395 { 285, "accept" },
396 { 286, "getsockname" },
397 { 287, "getpeername" },
398 { 288, "socketpair" },
399 { 289, "send" },
400 { 290, "sendto" },
401 { 291, "recv" },
402 { 292, "recvfrom" },
403 { 293, "shutdown" },
404 { 294, "setsockopt" },
405 { 295, "getsockopt" },
406 { 296, "sendmsg" },
407 { 297, "rcvmsg" },
408 { 298, "semop" },
409 { 299, "semget" },
410 { 300, "semctl" },
411 { 301, "msgsend" },
412 { 302, "msgrcv" },
413 { 303, "msgget" },
414 { 304, "msgctl" },
415 { 305, "shmat" },
416 { 306, "shmdt" },
417 { 307, "shmget" },
418 { 308, "shmctl" },
419 { 309, "add_key" },
420 { 310, "request_key" },
421 { 311, "keyctl" },
422 { 312, "semtimedop" },
423 { 313, "vserver" },
424 { 314, "ioprio_set" },
425 { 315, "ioprio_get" },
426 { 316, "inotify_init" },
427 { 317, "inotify_add_watch" },
428 { 318, "inotify_rm_watch" },
429 { 319, "mbind" },
430 { 320, "get_mempolicy" },
431 { 321, "set_mempolicy" },
432 { 322, "openat" },
433 { 323, "mkdirat" },
434 { 324, "mknodat" },
435 { 325, "fchownat" },
436 { 326, "futimesat" },
437 { 327, "fstatat64" },
438 { 328, "unlinkat" },
439 { 329, "renameat" },
440 { 330, "linkat" },
441 { 331, "symlinkat" },
442 { 332, "readlinkat" },
443 { 333, "fchmodat" },
444 { 334, "faccessat" },
445 { 335, "pselect6" },
446 { 336, "ppoll" },
447 { 337, "unshare" },
448 { 338, "set_robust_list" },
449 { 339, "get_robust_list" },
450 { 340, "splice" },
451 { 341, "arm_sync_file_range" },
452 { 342, "tee" },
453 { 343, "vmsplice" },
454 { 344, "move_pages" },
455 { 345, "getcpu" },
456 { 346, "epoll_pwait" },
457};
458
459} // namespace PowerISA
460} // namespace gem5
static SyscallDescTable< SEWorkload::SyscallABI > syscallDescs
Syscall descriptors, indexed by call number.
void syscall(ThreadContext *tc) override
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.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal getReg(const RegId &reg) const
virtual Process * getProcessPtr()=0
#define warn(...)
Definition logging.hh:256
constexpr RegId R0
Definition int.hh:105
static SyscallReturn unameFunc(SyscallDesc *desc, ThreadContext *tc, VPtr< Linux::utsname > name)
Target uname() handler.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
SyscallReturn exitGroupFunc(SyscallDesc *desc, ThreadContext *tc, int status)
Target exit_group() handler: terminate simulation. (exit all threads)
SyscallReturn fstat64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr< typename OS::tgt_stat64 > tgt_stat)
Target fstat64() handler.
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 getpidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpid() handler.
SyscallReturn fstatFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr< typename OS::tgt_stat > tgt_stat)
Target fstat() handler.
SyscallReturn getuidFunc(SyscallDesc *desc, ThreadContext *tc)
SyscallReturn readFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, int nbytes)
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 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 _llseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offset_high, uint32_t offset_low, VPtr<> result_ptr, int whence)
Target _llseek() handler.
SyscallReturn 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 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 ftruncateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, typename OS::off_t length)
Target ftruncate() handler.
SyscallReturn getpagesizeFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpagesize() 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 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 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 getegidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getegid() handler.
SyscallReturn timeFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> taddr)
Target time() function.
SyscallReturn ioctlFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, unsigned req, VPtr<> addr)
Target ioctl() handler.
SyscallReturn writevFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t tiov_base, typename OS::size_t count)
Target writev() handler.
SyscallReturn lseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offs, int whence)
Target lseek() handler.
SyscallReturn gethostnameFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> buf_ptr, int name_len)
Target gethostname() handler.
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 ignoreFunc(SyscallDesc *desc, ThreadContext *tc)
Handler for unimplemented syscalls that we never intend to implement (signal handling,...
SyscallReturn stat64Func(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat64 > tgt_stat)
Target stat64() handler.
SyscallReturn exitFunc(SyscallDesc *desc, ThreadContext *tc, int status)
Target exit() handler: terminate current context.
SyscallReturn getgidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getgid() handler.
SyscallReturn writeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, int nbytes)
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 Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0