gem5  v20.1.0.0
Functions | Variables
syscall_emul.cc File Reference
#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"
 

Function Documentation

◆ _llseekFunc()

SyscallReturn _llseekFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
uint64_t  offset_high,
uint32_t  offset_low,
Addr  result_ptr,
int  whence 
)

◆ accessFunc()

SyscallReturn accessFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname,
mode_t  mode 
)

◆ bindFunc()

SyscallReturn bindFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
Addr  buf_ptr,
int  addrlen 
)

◆ brkFunc()

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().

◆ chdirFunc()

SyscallReturn chdirFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname 
)

◆ chownFunc()

SyscallReturn chownFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname,
uint32_t  owner,
uint32_t  group 
)

◆ closeFunc()

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().

◆ connectFunc()

SyscallReturn connectFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
Addr  buf_ptr,
int  addrlen 
)

◆ dup2Func()

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.

◆ dupFunc()

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().

◆ exitFunc()

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().

◆ exitFutexWake()

static void exitFutexWake ( ThreadContext tc,
Addr  addr,
uint64_t  tgid 
)
static

◆ exitGroupFunc()

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().

◆ exitImpl()

static SyscallReturn exitImpl ( SyscallDesc desc,
ThreadContext tc,
bool  group,
int  status 
)
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().

◆ fallocateFunc()

SyscallReturn fallocateFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
int  mode,
off_t  offset,
off_t  len 
)

◆ fchownFunc()

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.

◆ fcntl64Func()

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().

◆ fcntlFunc()

SyscallReturn fcntlFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
int  cmd,
GuestABI::VarArgs< int >  varargs 
)

◆ ftruncate64Func()

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().

◆ ftruncateFunc()

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().

◆ getcpuFunc()

SyscallReturn getcpuFunc ( SyscallDesc desc,
ThreadContext tc,
VPtr< uint32_t >  cpu,
VPtr< uint32_t >  node,
VPtr< uint32_t >  tcache 
)

◆ getcwdFunc()

SyscallReturn getcwdFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  buf_ptr,
unsigned long  size 
)

◆ getegidFunc()

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().

◆ geteuidFunc()

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().

◆ getgidFunc()

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().

◆ gethostnameFunc()

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().

◆ getpagesizeFunc()

SyscallReturn getpagesizeFunc ( SyscallDesc desc,
ThreadContext tc 
)

Target getpagesize() handler.

Definition at line 242 of file syscall_emul.cc.

References System::getPageBytes(), and ThreadContext::getSystemPtr().

◆ getpeernameFunc()

SyscallReturn getpeernameFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
Addr  sockAddrPtr,
Addr  addrlenPtr 
)

◆ getpgrpFunc()

SyscallReturn getpgrpFunc ( SyscallDesc desc,
ThreadContext tc 
)

Target getpgrpFunc() handler.

Definition at line 887 of file syscall_emul.cc.

References ThreadContext::getProcessPtr(), and Process::pgid().

◆ getpidFunc()

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().

◆ getppidFunc()

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().

◆ getsocknameFunc()

SyscallReturn getsocknameFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
Addr  addrPtr,
Addr  lenPtr 
)

◆ getsockoptFunc()

SyscallReturn getsockoptFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
int  level,
int  optname,
Addr  valPtr,
Addr  lenPtr 
)

◆ gettidFunc()

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().

◆ getuidFunc()

SyscallReturn getuidFunc ( SyscallDesc desc,
ThreadContext tc 
)

◆ ignoreFunc()

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().

◆ ignoreWarnOnceFunc()

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().

◆ linkFunc()

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.

◆ listenFunc()

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.

◆ lseekFunc()

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().

◆ mkdirFunc()

SyscallReturn mkdirFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname,
mode_t  mode 
)

◆ mknodFunc()

SyscallReturn mknodFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname,
mode_t  mode,
dev_t  dev 
)

◆ munmapFunc()

SyscallReturn munmapFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  start,
size_t  length 
)

◆ pipe2Func()

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().

◆ pipeFunc()

SyscallReturn pipeFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  tgt_addr 
)

Target pipe() handler.

Definition at line 796 of file syscall_emul.cc.

References pipe2Func().

◆ pipePseudoFunc()

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().

◆ readlinkFunc()

SyscallReturn readlinkFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname,
Addr  buf_ptr,
size_t  bufsiz 
)

◆ recvfromFunc()

SyscallReturn recvfromFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
Addr  bufrPtr,
size_t  bufrLen,
int  flags,
Addr  addrPtr,
Addr  addrlenPtr 
)

◆ recvmsgFunc()

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.

◆ renameFunc()

SyscallReturn renameFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  oldpath,
Addr  newpath 
)

◆ rmdirFunc()

SyscallReturn rmdirFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname 
)

◆ sendmsgFunc()

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.

◆ sendtoFunc()

SyscallReturn sendtoFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
Addr  bufrPtr,
size_t  bufrLen,
int  flags,
Addr  addrPtr,
socklen_t  addrLen 
)

◆ setpgidFunc()

SyscallReturn setpgidFunc ( SyscallDesc desc,
ThreadContext tc,
int  pid,
int  pgid 
)

◆ setsockoptFunc()

SyscallReturn setsockoptFunc ( SyscallDesc desc,
ThreadContext tc,
int  tgt_fd,
int  level,
int  optname,
Addr  valPtr,
socklen_t  len 
)

◆ setTidAddressFunc()

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().

◆ shutdownFunc()

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.

◆ symlinkFunc()

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.

◆ truncate64Func()

SyscallReturn truncate64Func ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname,
int64_t  length 
)

◆ truncateFunc()

SyscallReturn truncateFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname,
off_t  length 
)

◆ umaskFunc()

SyscallReturn umaskFunc ( SyscallDesc desc,
ThreadContext tc 
)

Target umask() handler.

Definition at line 614 of file syscall_emul.cc.

Referenced by SyscallTable32::SyscallTable32().

◆ unimplementedFunc()

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().

◆ unlinkFunc()

SyscallReturn unlinkFunc ( SyscallDesc desc,
ThreadContext tc,
Addr  pathname 
)

◆ warnUnsupportedOS()

void warnUnsupportedOS ( std::string  syscall_name)

Definition at line 60 of file syscall_emul.cc.

References warn.

Referenced by eventfdFunc(), fallocateFunc(), and statfsFunc().

Variable Documentation

◆ hostname

const char* hostname = "m5.eecs.umich.edu"

Definition at line 351 of file syscall_emul.cc.

Referenced by gethostnameFunc().


Generated on Wed Sep 30 2020 14:02:19 for gem5 by doxygen 1.8.17