gem5
v20.1.0.0
|
#include "sim/syscall_emul.hh"
#include <fcntl.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <csignal>
#include <iostream>
#include <mutex>
#include <string>
#include <unordered_map>
#include "arch/utility.hh"
#include "base/chunk_generator.hh"
#include "base/trace.hh"
#include "config/the_isa.hh"
#include "cpu/thread_context.hh"
#include "dev/net/dist_iface.hh"
#include "mem/page_table.hh"
#include "sim/byteswap.hh"
#include "sim/process.hh"
#include "sim/proxy_ptr.hh"
#include "sim/sim_exit.hh"
#include "sim/syscall_debug_macros.hh"
#include "sim/syscall_desc.hh"
#include "sim/system.hh"
Go to the source code of this file.
Functions | |
void | warnUnsupportedOS (std::string syscall_name) |
SyscallReturn | unimplementedFunc (SyscallDesc *desc, ThreadContext *tc) |
Handler for unimplemented syscalls that we haven't thought about. More... | |
SyscallReturn | ignoreFunc (SyscallDesc *desc, 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. More... | |
SyscallReturn | ignoreWarnOnceFunc (SyscallDesc *desc, ThreadContext *tc) |
Like above, but only prints a warning once per syscall desc it's used with. More... | |
static void | exitFutexWake (ThreadContext *tc, Addr addr, uint64_t tgid) |
static SyscallReturn | exitImpl (SyscallDesc *desc, ThreadContext *tc, bool group, int status) |
SyscallReturn | exitFunc (SyscallDesc *desc, ThreadContext *tc, int status) |
Target exit() handler: terminate current context. More... | |
SyscallReturn | exitGroupFunc (SyscallDesc *desc, ThreadContext *tc, int status) |
Target exit_group() handler: terminate simulation. (exit all threads) More... | |
SyscallReturn | getpagesizeFunc (SyscallDesc *desc, ThreadContext *tc) |
Target getpagesize() handler. More... | |
SyscallReturn | brkFunc (SyscallDesc *desc, ThreadContext *tc, Addr new_brk) |
Target brk() handler: set brk address. More... | |
SyscallReturn | setTidAddressFunc (SyscallDesc *desc, ThreadContext *tc, uint64_t tidPtr) |
Target set_tid_address() handler. More... | |
SyscallReturn | closeFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd) |
Target close() handler. More... | |
SyscallReturn | lseekFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offs, int whence) |
Target lseek() handler. More... | |
SyscallReturn | _llseekFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offset_high, uint32_t offset_low, Addr result_ptr, int whence) |
Target _llseek() handler. More... | |
SyscallReturn | munmapFunc (SyscallDesc *desc, ThreadContext *tc, Addr start, size_t length) |
Target munmap() handler. More... | |
SyscallReturn | gethostnameFunc (SyscallDesc *desc, ThreadContext *tc, Addr buf_ptr, int name_len) |
Target gethostname() handler. More... | |
SyscallReturn | getcwdFunc (SyscallDesc *desc, ThreadContext *tc, Addr buf_ptr, unsigned long size) |
Target getcwd() handler. More... | |
SyscallReturn | readlinkFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr buf_ptr, size_t bufsiz) |
Target readlink() handler. More... | |
SyscallReturn | unlinkFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname) |
Target unlink() handler. More... | |
SyscallReturn | linkFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr new_pathname) |
Target link() handler. More... | |
SyscallReturn | symlinkFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr new_pathname) |
Target symlink() handler. More... | |
SyscallReturn | mkdirFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode) |
Target mkdir() handler. More... | |
SyscallReturn | renameFunc (SyscallDesc *desc, ThreadContext *tc, Addr oldpath, Addr newpath) |
Target rename() handler. More... | |
SyscallReturn | truncateFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname, off_t length) |
Target truncate() handler. More... | |
SyscallReturn | ftruncateFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, off_t length) |
Target ftruncate() handler. More... | |
SyscallReturn | truncate64Func (SyscallDesc *desc, ThreadContext *tc, Addr pathname, int64_t length) |
Target truncate64() handler. More... | |
SyscallReturn | ftruncate64Func (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int64_t length) |
Target ftruncate64() handler. More... | |
SyscallReturn | umaskFunc (SyscallDesc *desc, ThreadContext *tc) |
Target umask() handler. More... | |
SyscallReturn | chownFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname, uint32_t owner, uint32_t group) |
Target chown() handler. More... | |
SyscallReturn | fchownFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t owner, uint32_t group) |
Target fchown() handler. More... | |
SyscallReturn | dupFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd) |
FIXME: The file description is not shared among file descriptors created with dup. More... | |
SyscallReturn | dup2Func (SyscallDesc *desc, ThreadContext *tc, int old_tgt_fd, int new_tgt_fd) |
Target dup2() handler. More... | |
SyscallReturn | fcntlFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd, GuestABI::VarArgs< int > varargs) |
Target fcntl() handler. More... | |
SyscallReturn | fcntl64Func (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd) |
Target fcntl64() handler. More... | |
SyscallReturn | pipePseudoFunc (SyscallDesc *desc, ThreadContext *tc) |
Pseudo Funcs - These functions use a different return convension, returning a second value in a register other than the normal return register. More... | |
SyscallReturn | pipeFunc (SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr) |
Target pipe() handler. More... | |
SyscallReturn | pipe2Func (SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr, int flags) |
Target pipe() handler. More... | |
SyscallReturn | getpgrpFunc (SyscallDesc *desc, ThreadContext *tc) |
Target getpgrpFunc() handler. More... | |
SyscallReturn | setpgidFunc (SyscallDesc *desc, ThreadContext *tc, int pid, int pgid) |
Target setpgid() handler. More... | |
SyscallReturn | getpidFunc (SyscallDesc *desc, ThreadContext *tc) |
Target getpid() handler. More... | |
SyscallReturn | gettidFunc (SyscallDesc *desc, ThreadContext *tc) |
Target gettid() handler. More... | |
SyscallReturn | getppidFunc (SyscallDesc *desc, ThreadContext *tc) |
Target getppid() handler. More... | |
SyscallReturn | getuidFunc (SyscallDesc *desc, ThreadContext *tc) |
SyscallReturn | geteuidFunc (SyscallDesc *desc, ThreadContext *tc) |
Target geteuid() handler. More... | |
SyscallReturn | getgidFunc (SyscallDesc *desc, ThreadContext *tc) |
Target getgid() handler. More... | |
SyscallReturn | getegidFunc (SyscallDesc *desc, ThreadContext *tc) |
Target getegid() handler. More... | |
SyscallReturn | fallocateFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int mode, off_t offset, off_t len) |
SyscallReturn | accessFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode) |
Target access() handler. More... | |
SyscallReturn | mknodFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode, dev_t dev) |
Target mknod() handler. More... | |
SyscallReturn | chdirFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname) |
Target chdir() handler. More... | |
SyscallReturn | rmdirFunc (SyscallDesc *desc, ThreadContext *tc, Addr pathname) |
SyscallReturn | shutdownFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int how) |
Target shutdown() handler. More... | |
SyscallReturn | bindFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr buf_ptr, int addrlen) |
SyscallReturn | listenFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int backlog) |
SyscallReturn | connectFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr buf_ptr, int addrlen) |
SyscallReturn | recvfromFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags, Addr addrPtr, Addr addrlenPtr) |
SyscallReturn | sendtoFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags, Addr addrPtr, socklen_t addrLen) |
SyscallReturn | recvmsgFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr msgPtr, int flags) |
SyscallReturn | sendmsgFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr msgPtr, int flags) |
SyscallReturn | getsockoptFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, Addr valPtr, Addr lenPtr) |
SyscallReturn | getsocknameFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr addrPtr, Addr lenPtr) |
SyscallReturn | getpeernameFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr sockAddrPtr, Addr addrlenPtr) |
SyscallReturn | setsockoptFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, Addr valPtr, socklen_t len) |
SyscallReturn | getcpuFunc (SyscallDesc *desc, ThreadContext *tc, VPtr< uint32_t > cpu, VPtr< uint32_t > node, VPtr< uint32_t > tcache) |
Variables | |
const char * | hostname = "m5.eecs.umich.edu" |
SyscallReturn _llseekFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
uint64_t | offset_high, | ||
uint32_t | offset_low, | ||
Addr | result_ptr, | ||
int | whence | ||
) |
Target _llseek() handler.
Definition at line 304 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyOut(), System::getGuestByteOrder(), ThreadContext::getProcessPtr(), ThreadContext::getSystemPtr(), ThreadContext::getVirtProxy(), htog(), ArmISA::offset, and MipsISA::p.
Referenced by SyscallTable32::SyscallTable32().
SyscallReturn accessFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
mode_t | mode | ||
) |
Target access() handler.
Definition at line 999 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), ArmISA::mode, MipsISA::p, and PortProxy::tryReadString().
Referenced by faccessatFunc(), SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn bindFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
Addr | buf_ptr, | ||
int | addrlen | ||
) |
Definition at line 1163 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyIn(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, and ArmISA::status.
SyscallReturn brkFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | new_brk | ||
) |
Target brk() handler: set brk address.
Definition at line 249 of file syscall_emul.cc.
References DPRINTF_SYSCALL, ThreadContext::getProcessPtr(), and MipsISA::p.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn chdirFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname | ||
) |
Target chdir() handler.
Definition at line 1030 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, startswith(), and PortProxy::tryReadString().
SyscallReturn chownFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
uint32_t | owner, | ||
uint32_t | group | ||
) |
Target chown() handler.
Definition at line 625 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, and PortProxy::tryReadString().
Referenced by SyscallTable32::SyscallTable32().
SyscallReturn closeFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd | ||
) |
Target close() handler.
Definition at line 280 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and MipsISA::p.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn connectFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
Addr | buf_ptr, | ||
int | addrlen | ||
) |
Definition at line 1199 of file syscall_emul.cc.
References addr, ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, and ArmISA::status.
SyscallReturn dup2Func | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | old_tgt_fd, | ||
int | new_tgt_fd | ||
) |
Target dup2() handler.
We need a valid host file descriptor number to be able to pass into the second parameter for dup2 (newfd), but we don't know what the viable numbers are; we execute the open call to retrieve one.
Definition at line 691 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and MipsISA::p.
SyscallReturn dupFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd | ||
) |
FIXME: The file description is not shared among file descriptors created with dup.
Target dup() handler.
Really, it's difficult to maintain fields like file offset or flags since an update to such a field won't be reflected in the metadata for the fd entries that we maintain for checkpoint restoration.
Definition at line 671 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and MipsISA::p.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn exitFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | status | ||
) |
Target exit() handler: terminate current context.
Definition at line 230 of file syscall_emul.cc.
References exitImpl(), and ArmISA::status.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
|
static |
Definition at line 95 of file syscall_emul.cc.
References addr, BufferArg::bufferPtr(), BaseBufferArg::copyOut(), System::futexMap, ThreadContext::getSystemPtr(), ThreadContext::getVirtProxy(), and FutexMap::wakeup().
Referenced by exitImpl().
SyscallReturn exitGroupFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | status | ||
) |
Target exit_group() handler: terminate simulation. (exit all threads)
Definition at line 236 of file syscall_emul.cc.
References exitImpl(), and ArmISA::status.
Referenced by SyscallTable32::SyscallTable32(), SyscallTable64::SyscallTable64(), and tgkillFunc().
|
static |
Threads in a thread group require special handing. For instance, we send the SIGCHLD signal so that it appears that it came from the head of the group. We also only delete file descriptors if we are the last thread in the thread group.
Check if we share thread group with the pointer; this denotes that we are not the last thread active in the thread group. Note that setting this to false also prevents further iterations of the loop.
If p is trying to exit_group and both walk and p are in the same thread group (i.e., sharing the same tgid), we need to halt walk's thread context. After all threads except p are halted, p becomes the last thread in the group.
If p is not doing exit_group and there exists another active thread context in the group, last_thread is set to false to prevent the parent thread from killing all threads in the group.
A corner case exists which involves execve(). After execve(), the execve will enable SIGCHLD in the process. The problem occurs when the exiting process is the root process in the system; there is no parent to receive the signal. We obviate this problem by setting the root process' ppid to zero in the Python configuration files. We really should handle the root/execve specific case more gracefully.
Run though FD array of the exiting process and close all file descriptors except for the standard file descriptors. (The standard file descriptors are shared with gem5.)
check to see if there is no more active thread in the system. If so, exit the simulation loop
Even though we are terminating the final thread context, dist-gem5 requires the simulation to remain active and provide synchronization messages to the switch process. So we just halt the last thread context and return. The simulation will be terminated by dist-gem5 in a coordinated manner once all nodes have signaled their readiness to exit. For non dist-gem5 simulations, readyToExit() always returns true.
Definition at line 109 of file syscall_emul.cc.
References exitFutexWake(), exitSimLoop(), ThreadContext::getProcessPtr(), ThreadContext::getSystemPtr(), ThreadContext::halt(), ThreadContext::Halted, ThreadContext::Halting, ArmISA::i, MipsISA::p, Process::pid(), DistIface::readyToExit(), System::signalList, System::Threads::size(), ThreadContext::status(), ArmISA::status, X86ISA::system, System::systemList, Process::tgid(), and System::threads.
Referenced by exitFunc(), and exitGroupFunc().
SyscallReturn fallocateFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
int | mode, | ||
off_t | offset, | ||
off_t | len | ||
) |
Definition at line 977 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ArmISA::len, ArmISA::mode, ArmISA::offset, MipsISA::p, and warnUnsupportedOS().
SyscallReturn fchownFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
uint32_t | owner, | ||
uint32_t | group | ||
) |
Target fchown() handler.
Definition at line 646 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and MipsISA::p.
SyscallReturn fcntl64Func | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
int | cmd | ||
) |
Target fcntl64() handler.
Definition at line 761 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), MipsISA::p, and warn.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn fcntlFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
int | cmd, | ||
GuestABI::VarArgs< int > | varargs | ||
) |
Target fcntl() handler.
Definition at line 719 of file syscall_emul.cc.
References GuestABI::VarArgs< Types >::get(), ThreadContext::getProcessPtr(), MipsISA::p, and warn.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn ftruncate64Func | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
int64_t | length | ||
) |
Target ftruncate64() handler.
Definition at line 595 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), length, and MipsISA::p.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn ftruncateFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
off_t | length | ||
) |
Target ftruncate() handler.
Definition at line 560 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), length, and MipsISA::p.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn getcpuFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
VPtr< uint32_t > | cpu, | ||
VPtr< uint32_t > | node, | ||
VPtr< uint32_t > | tcache | ||
) |
Definition at line 1639 of file syscall_emul.cc.
References ThreadContext::contextId(), System::getGuestByteOrder(), ThreadContext::getSystemPtr(), and htog().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn getcwdFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | buf_ptr, | ||
unsigned long | size | ||
) |
Target getcwd() handler.
Definition at line 364 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyOut(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), and MipsISA::p.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn getegidFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target getegid() handler.
Definition at line 970 of file syscall_emul.cc.
References Process::egid(), and ThreadContext::getProcessPtr().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn geteuidFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target geteuid() handler.
Definition at line 956 of file syscall_emul.cc.
References Process::euid(), and ThreadContext::getProcessPtr().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn getgidFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target getgid() handler.
Definition at line 963 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and Process::gid().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn gethostnameFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | buf_ptr, | ||
int | name_len | ||
) |
Target gethostname() handler.
Definition at line 354 of file syscall_emul.cc.
References ThreadContext::getVirtProxy(), hostname, and name().
SyscallReturn getpagesizeFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target getpagesize() handler.
Definition at line 242 of file syscall_emul.cc.
References System::getPageBytes(), and ThreadContext::getSystemPtr().
SyscallReturn getpeernameFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
Addr | sockAddrPtr, | ||
Addr | addrlenPtr | ||
) |
Definition at line 1592 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyIn(), BaseBufferArg::copyOut(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), and MipsISA::p.
SyscallReturn getpgrpFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target getpgrpFunc() handler.
Definition at line 887 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and Process::pgid().
SyscallReturn getpidFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target getpid() handler.
Definition at line 928 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and Process::tgid().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn getppidFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target getppid() handler.
Definition at line 942 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and Process::ppid().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn getsocknameFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
Addr | addrPtr, | ||
Addr | lenPtr | ||
) |
Definition at line 1555 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyIn(), BaseBufferArg::copyOut(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), ArmISA::len, MipsISA::p, ArmISA::sa, and ArmISA::status.
SyscallReturn getsockoptFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
int | level, | ||
int | optname, | ||
Addr | valPtr, | ||
Addr | lenPtr | ||
) |
Definition at line 1517 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyOut(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), ArmISA::len, X86ISA::level, MipsISA::p, ArmISA::status, and X86ISA::val.
SyscallReturn gettidFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target gettid() handler.
Definition at line 935 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and Process::pid().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn getuidFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Definition at line 949 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and Process::uid().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn ignoreFunc | ( | SyscallDesc * | desc, |
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.
Prints a warning. Return success to the target program.
Definition at line 73 of file syscall_emul.cc.
References SyscallDesc::name(), and warn.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn ignoreWarnOnceFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Like above, but only prints a warning once per syscall desc it's used with.
Definition at line 80 of file syscall_emul.cc.
References SyscallDesc::name(), and warn.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn linkFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
Addr | new_pathname | ||
) |
Target link() handler.
Definition at line 467 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), and MipsISA::p.
SyscallReturn listenFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
int | backlog | ||
) |
Definition at line 1184 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), MipsISA::p, and ArmISA::status.
SyscallReturn lseekFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
uint64_t | offs, | ||
int | whence | ||
) |
Target lseek() handler.
Definition at line 287 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and MipsISA::p.
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn mkdirFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
mode_t | mode | ||
) |
Target mkdir() handler.
Definition at line 509 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), ArmISA::mode, MipsISA::p, and PortProxy::tryReadString().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn mknodFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
mode_t | mode, | ||
dev_t | dev | ||
) |
Target mknod() handler.
Definition at line 1015 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), ArmISA::mode, MipsISA::p, and PortProxy::tryReadString().
SyscallReturn munmapFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | start, | ||
size_t | length | ||
) |
Target munmap() handler.
Definition at line 331 of file syscall_emul.cc.
References System::getPageBytes(), ThreadContext::getProcessPtr(), ThreadContext::getSystemPtr(), length, MipsISA::p, and roundUp().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn pipe2Func | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | tgt_addr, | ||
int | flags | ||
) |
Target pipe() handler.
Now patch the read object to record the target file descriptor chosen as the write end of the pipe.
On some architectures, it's possible to use more than one register for a return value. In those cases, pipe returns its values rather than write them into a buffer.
Copy the target file descriptors into buffer space and then copy the buffer space back into the target address space.
Definition at line 802 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyOut(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), and MipsISA::p.
Referenced by pipeFunc(), and pipePseudoFunc().
SyscallReturn pipeFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | tgt_addr | ||
) |
SyscallReturn pipePseudoFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Pseudo Funcs - These functions use a different return convension, returning a second value in a register other than the normal return register.
Definition at line 790 of file syscall_emul.cc.
References pipe2Func().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn readlinkFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
Addr | buf_ptr, | ||
size_t | bufsiz | ||
) |
Target readlink() handler.
Definition at line 394 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyOut(), fatal, ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, PortProxy::tryReadString(), and warn_once.
Referenced by readlinkatFunc(), SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn recvfromFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
Addr | bufrPtr, | ||
size_t | bufrLen, | ||
int | flags, | ||
Addr | addrPtr, | ||
Addr | addrlenPtr | ||
) |
Definition at line 1220 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyIn(), BaseBufferArg::copyOut(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, and ArmISA::sa.
SyscallReturn recvmsgFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
Addr | msgPtr, | ||
int | flags | ||
) |
struct msghdr { void *msg_name; // optional address socklen_t msg_namelen; // size of address struct iovec *msg_iov; // iovec array size_t msg_iovlen; // number entries in msg_iov i // entries correspond to buffer void *msg_control; // ancillary data size_t msg_controllen; // ancillary data buffer len int msg_flags; // flags on received message };
struct iovec { void *iov_base; // starting address size_t iov_len; // number of bytes to transfer };
The plan with this system call is to replace all of the pointers in the structure and the substructure with BufferArg class pointers. We will copy every field from the structures into our BufferArg classes.
We will use these address place holders to retain the pointers which we are going to replace with our own buffers in our simulator address space.
Record msg_name pointer then replace with buffer pointer.
Record msg_iov pointer then replace with buffer pointer. Also, setup an array of buffer pointers for the iovec structs record and replace their pointers with buffer pointers.
Record msg_control pointer then replace with buffer pointer.
Definition at line 1312 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyIn(), BaseBufferArg::copyOut(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), ArmISA::i, and MipsISA::p.
SyscallReturn renameFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | oldpath, | ||
Addr | newpath | ||
) |
Target rename() handler.
Definition at line 523 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, and PortProxy::tryReadString().
Referenced by renameatFunc(), SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn rmdirFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname | ||
) |
Definition at line 1057 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, and PortProxy::tryReadString().
SyscallReturn sendmsgFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
Addr | msgPtr, | ||
int | flags | ||
) |
Reserve buffer space.
Assuming msgHdr.msg_iovlen >= 1, then there is no point calling recvmsg without a buffer.
Cannot instantiate buffers till inside the loop. Create array to hold buffer addresses, to be used during copyIn of send data.
Iterate through the iovec structures: Get the base buffer addreses, reserve iov_len amount of space for each. Put the buf address into the bufferArray for later retrieval.
Free dynamically allocated memory.
Malloced above.
Definition at line 1450 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyIn(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), and MipsISA::p.
SyscallReturn sendtoFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
Addr | bufrPtr, | ||
size_t | bufrLen, | ||
int | flags, | ||
Addr | addrPtr, | ||
socklen_t | addrLen | ||
) |
Definition at line 1280 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyIn(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, and ArmISA::sa.
SyscallReturn setpgidFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | pid, | ||
int | pgid | ||
) |
Target setpgid() handler.
Definition at line 894 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getSystemPtr(), ThreadContext::Halted, Process::pgid(), Process::pid(), ThreadContext::status(), and System::threads.
SyscallReturn setsockoptFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
int | level, | ||
int | optname, | ||
Addr | valPtr, | ||
socklen_t | len | ||
) |
Definition at line 1619 of file syscall_emul.cc.
References BufferArg::bufferPtr(), BaseBufferArg::copyIn(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), ArmISA::len, X86ISA::level, MipsISA::p, and ArmISA::status.
SyscallReturn setTidAddressFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
uint64_t | tidPtr | ||
) |
Target set_tid_address() handler.
Definition at line 271 of file syscall_emul.cc.
References Process::childClearTID, and ThreadContext::getProcessPtr().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn shutdownFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
int | tgt_fd, | ||
int | how | ||
) |
Target shutdown() handler.
Definition at line 1148 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), and MipsISA::p.
SyscallReturn symlinkFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
Addr | new_pathname | ||
) |
Target symlink() handler.
Definition at line 488 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), and MipsISA::p.
SyscallReturn truncate64Func | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
int64_t | length | ||
) |
Target truncate64() handler.
Definition at line 574 of file syscall_emul.cc.
References Process::checkPathRedirect(), ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), length, and PortProxy::tryReadString().
SyscallReturn truncateFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname, | ||
off_t | length | ||
) |
Target truncate() handler.
Definition at line 544 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), length, MipsISA::p, and PortProxy::tryReadString().
Referenced by SyscallTable32::SyscallTable32(), and SyscallTable64::SyscallTable64().
SyscallReturn umaskFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Target umask() handler.
Definition at line 614 of file syscall_emul.cc.
Referenced by SyscallTable32::SyscallTable32().
SyscallReturn unimplementedFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc | ||
) |
Handler for unimplemented syscalls that we haven't thought about.
Definition at line 66 of file syscall_emul.cc.
References fatal, SyscallDesc::name(), and SyscallDesc::num().
SyscallReturn unlinkFunc | ( | SyscallDesc * | desc, |
ThreadContext * | tc, | ||
Addr | pathname | ||
) |
Target unlink() handler.
Definition at line 452 of file syscall_emul.cc.
References ThreadContext::getProcessPtr(), ThreadContext::getVirtProxy(), MipsISA::p, and PortProxy::tryReadString().
Referenced by SyscallTable32::SyscallTable32(), SyscallTable64::SyscallTable64(), and unlinkatFunc().
void warnUnsupportedOS | ( | std::string | syscall_name | ) |
Definition at line 60 of file syscall_emul.cc.
References warn.
Referenced by eventfdFunc(), fallocateFunc(), and statfsFunc().
const char* hostname = "m5.eecs.umich.edu" |
Definition at line 351 of file syscall_emul.cc.
Referenced by gethostnameFunc().