49 #include <sys/syscall.h> 72 load(ProcessParams *params,
ObjectFile *obj_file)
override 74 auto arch = obj_file->
getArch();
83 warn(
"Unknown operating system; assuming Linux.");
88 fatal(
"gem5 does not support ARM OABI binaries. Please recompile " 89 "with an EABI compiler.");
102 ArmLinuxObjectFileLoader loader;
114 strcpy(
name->sysname,
"Linux");
115 strcpy(
name->nodename,
"m5.eecs.umich.edu");
116 strcpy(
name->release, process->release.c_str());
117 strcpy(
name->version,
"#1 SMP Sat Dec 1 00:00:00 GMT 2012");
118 strcpy(
name->machine,
"armv7l");
132 strcpy(
name->sysname,
"Linux");
133 strcpy(
name->nodename,
"gem5");
134 strcpy(
name->release, process->release.c_str());
135 strcpy(
name->version,
"#1 SMP Sat Dec 1 00:00:00 GMT 2012");
136 strcpy(
name->machine,
"armv8l");
151 &tlsPtr,
sizeof(tlsPtr));
171 {
"read", readFunc<ArmLinux32> },
172 {
"write", writeFunc<ArmLinux32> },
173 {
"open", openFunc<ArmLinux32> },
179 {
"execve", execveFunc<ArmLinux32> },
181 {
"time", timeFunc<ArmLinux32> },
183 {
"chmod", chmodFunc<ArmLinux32> },
211 {
"times", timesFunc<ArmLinux32> },
222 {
"ioctl", ioctlFunc<ArmLinux32> },
244 {
"getrlimit", getrlimitFunc<ArmLinux32> },
245 {
"getrusage", getrusageFunc<ArmLinux32> },
246 {
"gettimeofday", gettimeofdayFunc<ArmLinux32> },
258 {
"mmap", mmapFunc<ArmLinux32> },
274 {
"stat", statFunc<ArmLinux32> },
276 {
"fstat", fstatFunc<ArmLinux32> },
284 {
"sysinfo", sysinfoFunc<ArmLinux32> },
288 {
"clone", cloneFunc<ArmLinux32> },
309 #if defined(SYS_getdents) 310 {
"getdents", getdentsFunc },
318 {
"writev", writevFunc<ArmLinux32> },
326 {
"sched_setparam" },
327 {
"sched_getparam" },
328 {
"sched_setscheduler" },
329 {
"sched_getscheduler" },
331 {
"sched_get_priority_max" },
332 {
"sched_get_priority_min" },
333 {
"sched_rr_get_interval" },
335 {
"mremap", mremapFunc<ArmLinux32> },
349 {
"rt_sigtimedwait" },
363 {
"getrlimit", getrlimitFunc<ArmLinux32> },
364 {
"mmap2", mmapFunc<ArmLinux32> },
367 {
"stat64", stat64Func<ArmLinux32> },
368 {
"lstat64", lstat64Func<ArmLinux32> },
369 {
"fstat64", fstat64Func<ArmLinux32> },
389 #if defined(SYS_getdents64) 390 {
"getdents64", getdents64Func },
416 {
"futex", futexFunc<ArmLinux32> },
417 {
"sched_setaffinity" },
425 {
"lookup_dcookie" },
429 {
"remap_file_pages" },
436 {
"timer_getoverrun" },
439 {
"clock_gettime", clock_gettimeFunc<ArmLinux32> },
440 {
"clock_getres", clock_getresFunc<ArmLinux32> },
441 {
"clock_nanosleep" },
444 {
"tgkill", tgkillFunc<ArmLinux32> },
446 {
"arm_fadvise64_64" },
447 {
"pciconfig_iobase" },
448 {
"pciconfig_read" },
449 {
"pciconfig_write" },
453 {
"mq_timedreceive" },
493 {
"inotify_add_watch" },
494 {
"inotify_rm_watch" },
498 {
"openat", openatFunc<ArmLinux32> },
515 {
"get_robust_list" },
517 {
"arm_sync_file_range" },
523 {
"sys_kexec_load" },
526 {
"sys_timerfd_create" },
529 {
"sys_timerfd_settime" },
530 {
"sys_timerfd_gettime" },
533 {
"sys_epoll_create1" },
536 {
"sys_inotify_init1" },
539 {
"sys_rt_tgsigqueueinfo" },
540 {
"sys_perf_event_open" },
563 {
"lookup_dcookie" },
572 {
"inotify_add_watch" },
573 {
"inotify_rm_watch" },
574 {
"ioctl", ioctlFunc<ArmLinux64> },
580 {
"unlinkat", unlinkatFunc<ArmLinux64> },
583 {
"renameat", renameatFunc<ArmLinux64> },
593 {
"faccessat", faccessatFunc<ArmLinux64> },
601 {
"openat", openatFunc<ArmLinux64> },
606 #if defined(SYS_getdents64) 607 {
"getdents64", getdents64Func },
612 {
"read", readFunc<ArmLinux64> },
613 {
"write", writeFunc<ArmLinux64> },
615 {
"writev", writevFunc<ArmLinux64> },
627 {
"readlinkat", readlinkatFunc<ArmLinux64> },
628 {
"fstatat64", fstatat64Func<ArmLinux64> },
629 {
"fstat64", fstat64Func<ArmLinux64> },
633 {
"sync_file_range" },
634 {
"timerfd_create" },
635 {
"timerfd_settime" },
636 {
"timerfd_gettime" },
647 {
"futex", futexFunc<ArmLinux64> },
649 {
"get_robust_list" },
658 {
"timer_getoverrun" },
662 {
"clock_gettime", clock_gettimeFunc<ArmLinux64> },
664 {
"clock_nanosleep" },
667 {
"sched_setparam" },
668 {
"sched_setscheduler" },
669 {
"sched_getscheduler" },
670 {
"sched_getparam" },
671 {
"sched_setaffinity" },
674 {
"sched_get_priority_max" },
675 {
"sched_get_priority_min" },
676 {
"sched_rr_get_interval" },
677 {
"restart_syscall" },
680 {
"tgkill", tgkillFunc<ArmLinux64> },
686 {
"rt_sigtimedwait" },
702 {
"times", timesFunc<ArmLinux64> },
712 {
"getrlimit", getrlimitFunc<ArmLinux64> },
714 {
"getrusage", getrusageFunc<ArmLinux64> },
718 {
"gettimeofday", gettimeofdayFunc<ArmLinux64> },
728 {
"sysinfo", sysinfoFunc<ArmLinux64> },
732 {
"mq_timedreceive" },
765 {
"mremap", mremapFunc<ArmLinux64> },
769 {
"clone", cloneFunc<ArmLinux64> },
770 {
"execve", execveFunc<ArmLinux64> },
771 {
"mmap2", mmapFunc<ArmLinux64> },
783 {
"remap_file_pages" },
789 {
"rt_tgsigqueueinfo" },
790 {
"perf_event_open" },
810 {
"prlimit64", prlimitFunc<ArmLinux64> },
813 {
"name_to_handle_at" },
814 {
"open_by_handle_at" },
819 {
"process_vm_readv" },
820 {
"process_vm_writev" },
1573 {
"open", openFunc<ArmLinux64> },
1577 {
"chmod", chmodFunc<ArmLinux64> },
1587 {
"stat64", stat64Func<ArmLinux64> },
1588 {
"lstat64", lstat64Func<ArmLinux64> },
1598 {
"stat", statFunc<ArmLinux64> },
1600 {
"fstat", fstatFunc<ArmLinux64> },
1607 {
"mmap", mmapFunc<ArmLinux64> },
1611 {
"time", timeFunc<ArmLinux64> },
1614 #if defined(SYS_getdents) 1615 {
"getdents", getdentsFunc },
1662 table.
base = 0x900000;
1667 table.
base = 0xf0001;
1681 table.
base = 0x900000;
1686 table.
base = 0x1001;
1696 if (callnum == 0x123456)
1697 panic(
"Attempt to execute an ANGEL_SWI system call (newlib-related)");
1710 if (offset < 0 || offset >= size)
1734 uint8_t swiNeg1[] = {
1735 0xff, 0xff, 0xff, 0xef
1741 swiNeg1,
sizeof(swiNeg1));
1744 uint8_t memory_barrier[] =
1746 0x5f, 0xf0, 0x7f, 0xf5,
1747 0x0e, 0xf0, 0xa0, 0xe1
1750 sizeof(memory_barrier));
1754 0x9f, 0x3f, 0x92, 0xe1,
1755 0x00, 0x30, 0x53, 0xe0,
1756 0x91, 0x3f, 0x82, 0x01,
1757 0x01, 0x00, 0x33, 0x03,
1758 0xfa, 0xff, 0xff, 0x0a,
1759 0x00, 0x00, 0x73, 0xe2,
1760 0x5f, 0xf0, 0x7f, 0xf5,
1761 0x0e, 0xf0, 0xa0, 0xe1
1768 0x70, 0x0f, 0x1d, 0xee,
1769 0x0e, 0xf0, 0xa0, 0xe1
#define panic(...)
This implements a cprintf based panic() function.
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
#define fatal(...)
This implements a cprintf based fatal() function.
const std::string & name()
SyscallReturn geteuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target geteuid() handler.
SyscallReturn ignoreFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Handler for unimplemented syscalls that we never intend to implement (signal handling, etc.) and should not affect the correct behavior of the program.
SyscallReturn getcwdFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr buf_ptr, unsigned long size)
Target getcwd() handler.
virtual RegVal readIntReg(RegIndex reg_idx) const =0
static SyscallReturn unameFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target uname() handler.
std::vector< ContextID > contextIds
A process with emulated Arm/Linux syscalls.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void allocateMem(Addr vaddr, int64_t size, bool clobber=false)
virtual PortProxy & getVirtProxy()=0
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
virtual Process * getProcessPtr()=0
SyscallReturn fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc)
Target fcntl() handler.
Overload hash function for BasicBlockRange type.
static SyscallDescABI< DefaultSyscallABI > syscallDescs32[]
void doSyscall(int64_t callnum, ThreadContext *tc, Fault *fault)
ArmLinuxProcess32(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch)
TypedBufferArg is a class template; instances of this template represent typed buffers in target user...
ThreadContext is the external interface to all thread state for anything outside of the CPU...
SyscallReturn closeFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd)
Target close() handler.
SyscallDesc * getLinuxDesc(int callnum)
static SyscallDescABI< DefaultSyscallABI > privSyscallDescs64[]
ThreadContext * getThreadContext(ContextID tid) const
SyscallReturn getegidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target getegid() handler.
SyscallReturn renameFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr oldpath, Addr newpath)
Target rename() handler.
SyscallReturn umaskFunc(SyscallDesc *desc, int num, ThreadContext *tc)
Target umask() handler.
static SyscallReturn setTLSFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc)
SyscallReturn munmapFunc(SyscallDesc *desc, int num, ThreadContext *tc)
Target munmap() handler.
SyscallReturn getuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
SyscallReturn unlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname)
Target unlink() handler.
void syscall(ThreadContext *tc, Fault *fault) override
SyscallReturn exitGroupFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int status)
Target exit_group() handler: terminate simulation. (exit all threads)
SyscallReturn mkdirFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, mode_t mode)
Target mkdir() handler.
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
SyscallReturn _llseekFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd, uint64_t offset_high, uint32_t offset_low, Addr result_ptr, int whence)
Target _llseek() handler.
SyscallReturn readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, Addr buf_ptr, size_t bufsiz)
Target readlink() handler.
virtual RegVal getSyscallArg(ThreadContext *tc, int &i)=0
SyscallReturn ftruncateFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd, off_t length)
Target ftruncate() handler.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
SyscallReturn getppidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target getppid() handler.
SyscallReturn brkFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr new_brk)
Target brk() handler: set brk address.
SyscallReturn ignoreWarnOnceFunc(SyscallDesc *desc, int num, ThreadContext *tc)
Like above, but only prints a warning once per syscall desc it's used with.
SyscallDesc * getDesc(int offset) const
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
A process with emulated Arm/Linux syscalls.
SyscallReturn dupFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd)
FIXME: The file description is not shared among file descriptors created with dup.
SyscallReturn getgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target getgid() handler.
void syscall(ThreadContext *tc, Fault *fault) override
This class provides the wrapper interface for the system call implementations which are defined in th...
static SyscallReturn setTLSFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target set_tls() handler.
SyscallReturn gettidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target gettid() handler.
SyscallReturn truncateFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, off_t length)
Target truncate() handler.
SyscallReturn fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc)
Target fcntl64() handler.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
SyscallReturn lseekFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd, uint64_t offs, int whence)
Target lseek() handler.
SyscallReturn accessFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr pathname, mode_t mode)
Target access() handler.
This file defines objects used to emulate syscalls from the target application on the host machine...
SyscallReturn setTidAddressFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, uint64_t tidPtr)
Target set_tid_address() handler.
SyscallDesc * getDesc(int callnum) override
static SyscallReturn unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target uname() handler.
ArmLinuxProcess64(ProcessParams *params, ObjectFile *objFile, ObjectFile::Arch _arch)
SyscallReturn chownFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname, uint32_t owner, uint32_t group)
Target chown() handler.
static SyscallDescABI< DefaultSyscallABI > syscallDescs64[]
std::vector< SyscallTable > syscallTables
static const Addr commPage
A page to hold "kernel" provided functions. The name might be wrong.
static SyscallDescABI< DefaultSyscallABI > privSyscallDescs32[]
SyscallReturn pipePseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Pseudo Funcs - These functions use a different return convension, returning a second value in a regis...
This class represents the return value from an emulated system call, including any errno setting...
SyscallDesc * getDesc(int callnum) override
Each instance of a Loader subclass will have a chance to try to load an object file when tryLoaders i...
std::shared_ptr< FaultBase > Fault
SyscallReturn getpidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
Target getpid() handler.
SyscallReturn exitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int status)
Target exit() handler: terminate current context.
SyscallReturn ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc)
Target ftruncate64() handler.