arch,sim: Drop the syscall number from the syscall func signature.
This value is almost never used, and is now part of the SyscallDesc. Change-Id: Ia4ffc19774bb2eac8f29134e3765c06a264407b6 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24118 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -87,16 +87,15 @@ ArmFreebsdObjectFileLoader loader;
|
||||
} // anonymous namespace
|
||||
|
||||
static SyscallReturn
|
||||
issetugidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
issetugidFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined ( __GNU_LIBRARY__ )
|
||||
static SyscallReturn
|
||||
sysctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr namep, size_t nameLen, Addr oldp, Addr oldlenp,
|
||||
Addr newp, size_t newlen)
|
||||
sysctlFunc(SyscallDesc *desc, ThreadContext *tc, Addr namep, size_t nameLen,
|
||||
Addr oldp, Addr oldlenp, Addr newp, size_t newlen)
|
||||
{
|
||||
uint64_t ret;
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ ArmLinuxObjectFileLoader loader;
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc32(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Linux::utsname> name(utsname);
|
||||
@@ -117,7 +117,7 @@ unameFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc64(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Linux::utsname> name(utsname);
|
||||
@@ -134,8 +134,7 @@ unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
|
||||
/// Target set_tls() handler.
|
||||
static SyscallReturn
|
||||
setTLSFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
uint32_t tlsPtr)
|
||||
setTLSFunc32(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
|
||||
{
|
||||
tc->getVirtProxy().writeBlob(ArmLinuxProcess32::commPage + 0x0ff0,
|
||||
&tlsPtr, sizeof(tlsPtr));
|
||||
@@ -144,8 +143,7 @@ setTLSFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
}
|
||||
|
||||
static SyscallReturn
|
||||
setTLSFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
uint32_t tlsPtr)
|
||||
setTLSFunc64(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
|
||||
{
|
||||
tc->setMiscReg(MISCREG_TPIDRRO_EL0, tlsPtr);
|
||||
return 0;
|
||||
|
||||
@@ -77,7 +77,7 @@ MipsLinuxObjectFileLoader loader;
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Linux::utsname> name(utsname);
|
||||
@@ -96,8 +96,8 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
/// borrowed from Tru64, the subcases that get used appear to be
|
||||
/// different in practice from those used by Tru64 processes.
|
||||
static SyscallReturn
|
||||
sys_getsysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
unsigned op, unsigned bufPtr, unsigned nbytes)
|
||||
sys_getsysinfoFunc(SyscallDesc *desc, ThreadContext *tc, unsigned op,
|
||||
unsigned bufPtr, unsigned nbytes)
|
||||
{
|
||||
switch (op) {
|
||||
case 45:
|
||||
@@ -120,8 +120,8 @@ sys_getsysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
/// Target sys_setsysinfo() handler.
|
||||
static SyscallReturn
|
||||
sys_setsysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
unsigned op, Addr bufPtr, unsigned nbytes)
|
||||
sys_setsysinfoFunc(SyscallDesc *desc, ThreadContext *tc, unsigned op,
|
||||
Addr bufPtr, unsigned nbytes)
|
||||
{
|
||||
switch (op) {
|
||||
|
||||
@@ -145,7 +145,7 @@ sys_setsysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
}
|
||||
|
||||
static SyscallReturn
|
||||
setThreadAreaFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr addr)
|
||||
setThreadAreaFunc(SyscallDesc *desc, ThreadContext *tc, Addr addr)
|
||||
{
|
||||
tc->setMiscRegNoEffect(MISCREG_TP_VALUE, addr);
|
||||
return 0;
|
||||
|
||||
@@ -76,7 +76,7 @@ PowerLinuxObjectFileLoader loader;
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Linux::utsname> name(utsname);
|
||||
|
||||
@@ -84,7 +84,7 @@ RiscvLinuxObjectFileLoader loader;
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc64(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Linux::utsname> name(utsname);
|
||||
@@ -101,7 +101,7 @@ unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc32(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Linux::utsname> name(utsname);
|
||||
|
||||
@@ -91,7 +91,7 @@ class Sparc64LinuxProcess : public SparcLinuxProcess, public Sparc64Process
|
||||
void handleTrap(int trapNum, ThreadContext *tc, Fault *fault) override;
|
||||
};
|
||||
|
||||
SyscallReturn getresuidFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn getresuidFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr ruid, Addr euid, Addr suid);
|
||||
|
||||
} // namespace SparcISA
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace SparcISA {
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Linux::utsname> name(utsname);
|
||||
@@ -55,7 +55,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
|
||||
|
||||
SyscallReturn
|
||||
getresuidFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
getresuidFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr ruid, Addr euid, Addr suid)
|
||||
{
|
||||
const uint64_t id = htobe(100);
|
||||
|
||||
@@ -70,7 +70,7 @@ SparcSolarisObjectFileLoader loader;
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Solaris::utsname> name(utsname);
|
||||
|
||||
@@ -89,7 +89,7 @@ X86LinuxObjectFileLoader loader;
|
||||
|
||||
/// Target uname() handler.
|
||||
static SyscallReturn
|
||||
unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
unameFunc(SyscallDesc *desc, ThreadContext *tc, Addr utsname)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
TypedBufferArg<Linux::utsname> name(utsname);
|
||||
@@ -106,8 +106,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr utsname)
|
||||
}
|
||||
|
||||
static SyscallReturn
|
||||
archPrctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
int code, uint64_t addr)
|
||||
archPrctlFunc(SyscallDesc *desc, ThreadContext *tc, int code, uint64_t addr)
|
||||
{
|
||||
enum ArchPrctlCodes
|
||||
{
|
||||
@@ -168,8 +167,7 @@ struct UserDesc64 {
|
||||
};
|
||||
|
||||
static SyscallReturn
|
||||
setThreadArea32Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr userDescPtr)
|
||||
setThreadArea32Func(SyscallDesc *desc, ThreadContext *tc, Addr userDescPtr)
|
||||
{
|
||||
const int minTLSEntry = 6;
|
||||
const int numTLSEntries = 3;
|
||||
|
||||
@@ -428,7 +428,7 @@ Process::doSyscall(int64_t callnum, ThreadContext *tc, Fault *fault)
|
||||
if (desc == nullptr)
|
||||
fatal("Syscall %d out of range", callnum);
|
||||
|
||||
desc->doSyscall(callnum, tc, fault);
|
||||
desc->doSyscall(tc, fault);
|
||||
}
|
||||
|
||||
EmulatedDriver *
|
||||
|
||||
@@ -35,11 +35,11 @@
|
||||
class ThreadContext;
|
||||
|
||||
void
|
||||
SyscallDesc::doSyscall(int callnum, ThreadContext *tc, Fault *fault)
|
||||
SyscallDesc::doSyscall(ThreadContext *tc, Fault *fault)
|
||||
{
|
||||
DPRINTF_SYSCALL(Base, "Calling %s...\n", dumper(name(), tc));
|
||||
|
||||
SyscallReturn retval = executor(this, callnum, tc);
|
||||
SyscallReturn retval = executor(this, tc);
|
||||
|
||||
if (retval.needsRetry())
|
||||
DPRINTF_SYSCALL(Base, "Needs retry.\n", name());
|
||||
|
||||
@@ -55,8 +55,7 @@
|
||||
|
||||
class SyscallDesc;
|
||||
|
||||
SyscallReturn unimplementedFunc(SyscallDesc *desc, int num,
|
||||
ThreadContext *tc);
|
||||
SyscallReturn unimplementedFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/**
|
||||
* This class provides the wrapper interface for the system call
|
||||
@@ -70,11 +69,9 @@ class SyscallDesc {
|
||||
* Interface for invoking the system call funcion pointer. Note that
|
||||
* this acts as a gateway for all system calls and serves a good point
|
||||
* to add filters for behaviors or apply checks for all system calls.
|
||||
* @param callnum Number associated with call (by operating system)
|
||||
* @param proc Handle for the owning Process to pass information
|
||||
* @param tc Handle for owning ThreadContext to pass information
|
||||
*/
|
||||
void doSyscall(int callnum, ThreadContext *tc, Fault *fault);
|
||||
void doSyscall(ThreadContext *tc, Fault *fault);
|
||||
|
||||
std::string name() const { return _name; }
|
||||
int num() const { return _num; }
|
||||
@@ -87,7 +84,7 @@ class SyscallDesc {
|
||||
|
||||
protected:
|
||||
using Executor =
|
||||
std::function<SyscallReturn(SyscallDesc *, int num, ThreadContext *)>;
|
||||
std::function<SyscallReturn(SyscallDesc *, ThreadContext *)>;
|
||||
using Dumper = std::function<std::string(std::string, ThreadContext *)>;
|
||||
|
||||
SyscallDesc(int num, const char *name, Executor exec, Dumper dump) :
|
||||
@@ -116,12 +113,11 @@ class SyscallDescABI : public SyscallDesc
|
||||
// Aliases to make the code below a little more concise.
|
||||
template <typename ...Args>
|
||||
using ABIExecutor =
|
||||
std::function<SyscallReturn(SyscallDesc *, int,
|
||||
ThreadContext *, Args...)>;
|
||||
std::function<SyscallReturn(SyscallDesc *, ThreadContext *, Args...)>;
|
||||
|
||||
template <typename ...Args>
|
||||
using ABIExecutorPtr =
|
||||
SyscallReturn (*)(SyscallDesc *, int, ThreadContext *, Args...);
|
||||
SyscallReturn (*)(SyscallDesc *, ThreadContext *, Args...);
|
||||
|
||||
|
||||
// Wrap an executor with guest arguments with a normal executor that gets
|
||||
@@ -130,13 +126,13 @@ class SyscallDescABI : public SyscallDesc
|
||||
static inline Executor
|
||||
buildExecutor(ABIExecutor<Args...> target)
|
||||
{
|
||||
return [target](SyscallDesc *desc, int num,
|
||||
return [target](SyscallDesc *desc,
|
||||
ThreadContext *tc) -> SyscallReturn {
|
||||
// Create a partial function which will stick desc and num to the
|
||||
// front of the parameter list.
|
||||
auto partial = [target,desc,num](
|
||||
// Create a partial function which will stick desc to the front of
|
||||
// the parameter list.
|
||||
auto partial = [target,desc](
|
||||
ThreadContext *tc, Args... args) -> SyscallReturn {
|
||||
return target(desc, num, tc, args...);
|
||||
return target(desc, tc, args...);
|
||||
};
|
||||
|
||||
// Use invokeSimcall to gather the other arguments based on the
|
||||
|
||||
@@ -62,23 +62,21 @@ warnUnsupportedOS(std::string syscall_name)
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
unimplementedFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
unimplementedFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
fatal("syscall %s (#%d) unimplemented.", desc->name(), callnum);
|
||||
|
||||
return 1;
|
||||
fatal("syscall %s (#%d) unimplemented.", desc->name(), desc->num());
|
||||
}
|
||||
|
||||
|
||||
SyscallReturn
|
||||
ignoreFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
ignoreFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
warn("ignoring syscall %s(...)", desc->name());
|
||||
return 0;
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
ignoreWarnOnceFunc(SyscallDesc *desc, int num, ThreadContext *tc)
|
||||
ignoreWarnOnceFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
static std::unordered_map<SyscallDesc *, bool> bool_map;
|
||||
|
||||
@@ -107,8 +105,7 @@ exitFutexWake(ThreadContext *tc, Addr addr, uint64_t tgid)
|
||||
}
|
||||
|
||||
static SyscallReturn
|
||||
exitImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool group,
|
||||
int status)
|
||||
exitImpl(SyscallDesc *desc, ThreadContext *tc, bool group, int status)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -228,27 +225,26 @@ exitImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool group,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
exitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int status)
|
||||
exitFunc(SyscallDesc *desc, ThreadContext *tc, int status)
|
||||
{
|
||||
return exitImpl(desc, callnum, tc, false, status);
|
||||
return exitImpl(desc, tc, false, status);
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
exitGroupFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int status)
|
||||
exitGroupFunc(SyscallDesc *desc, ThreadContext *tc, int status)
|
||||
{
|
||||
return exitImpl(desc, callnum, tc, true, status);
|
||||
return exitImpl(desc, tc, true, status);
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getpagesizeFunc(SyscallDesc *desc, int num, ThreadContext *tc)
|
||||
getpagesizeFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
return (int)PageBytes;
|
||||
}
|
||||
|
||||
|
||||
SyscallReturn
|
||||
brkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr new_brk)
|
||||
brkFunc(SyscallDesc *desc, ThreadContext *tc, Addr new_brk)
|
||||
{
|
||||
// change brk addr to first arg
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -295,8 +291,7 @@ brkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
setTidAddressFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
uint64_t tidPtr)
|
||||
setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc, uint64_t tidPtr)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
|
||||
@@ -305,14 +300,14 @@ setTidAddressFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
closeFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd)
|
||||
closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
return p->fds->closeFDEntry(tgt_fd);
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
lseekFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
lseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t offs, int whence)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -329,7 +324,7 @@ lseekFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
|
||||
SyscallReturn
|
||||
_llseekFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
_llseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t offset_high, uint32_t offset_low,
|
||||
Addr result_ptr, int whence)
|
||||
{
|
||||
@@ -356,7 +351,7 @@ _llseekFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
|
||||
SyscallReturn
|
||||
munmapFunc(SyscallDesc *desc, int num, ThreadContext *tc)
|
||||
munmapFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
// With mmap more fully implemented, it might be worthwhile to bite
|
||||
// the bullet and implement munmap. Should allow us to reuse simulated
|
||||
@@ -368,7 +363,7 @@ munmapFunc(SyscallDesc *desc, int num, ThreadContext *tc)
|
||||
const char *hostname = "m5.eecs.umich.edu";
|
||||
|
||||
SyscallReturn
|
||||
gethostnameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
gethostnameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr buf_ptr, int name_len)
|
||||
{
|
||||
BufferArg name(buf_ptr, name_len);
|
||||
@@ -378,7 +373,7 @@ gethostnameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getcwdFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
getcwdFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr buf_ptr, unsigned long size)
|
||||
{
|
||||
int result = 0;
|
||||
@@ -408,7 +403,7 @@ getcwdFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
readlinkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, Addr buf_ptr, size_t bufsiz)
|
||||
{
|
||||
string path;
|
||||
@@ -466,7 +461,7 @@ readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
unlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname)
|
||||
unlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname)
|
||||
{
|
||||
string path;
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -481,7 +476,7 @@ unlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname)
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
linkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
linkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, Addr new_pathname)
|
||||
{
|
||||
string path;
|
||||
@@ -502,7 +497,7 @@ linkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
symlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
symlinkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, Addr new_pathname)
|
||||
{
|
||||
string path;
|
||||
@@ -523,8 +518,7 @@ symlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
mkdirFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr pathname, mode_t mode)
|
||||
mkdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
std::string path;
|
||||
@@ -538,8 +532,7 @@ mkdirFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
renameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr oldpath, Addr newpath)
|
||||
renameFunc(SyscallDesc *desc, ThreadContext *tc, Addr oldpath, Addr newpath)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -560,8 +553,7 @@ renameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
truncateFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr pathname, off_t length)
|
||||
truncateFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, off_t length)
|
||||
{
|
||||
string path;
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -577,8 +569,7 @@ truncateFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
ftruncateFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int tgt_fd, off_t length)
|
||||
ftruncateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, off_t length)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -592,7 +583,7 @@ ftruncateFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
truncate64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
truncate64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, int64_t length)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
@@ -613,7 +604,7 @@ truncate64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
ftruncate64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int64_t length)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -632,7 +623,7 @@ ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
umaskFunc(SyscallDesc *desc, int num, ThreadContext *tc)
|
||||
umaskFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
// Letting the simulated program change the simulator's umask seems like
|
||||
// a bad idea. Compromise by just returning the current umask but not
|
||||
@@ -643,7 +634,7 @@ umaskFunc(SyscallDesc *desc, int num, ThreadContext *tc)
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
chownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
chownFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, uint32_t owner, uint32_t group)
|
||||
{
|
||||
string path;
|
||||
@@ -664,7 +655,7 @@ chownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
fchownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
fchownFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint32_t owner, uint32_t group)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -689,7 +680,7 @@ fchownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
* for the fd entries that we maintain for checkpoint restoration.
|
||||
*/
|
||||
SyscallReturn
|
||||
dupFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd)
|
||||
dupFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -709,8 +700,7 @@ dupFunc(SyscallDesc *desc, int num, ThreadContext *tc, int tgt_fd)
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
dup2Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int old_tgt_fd, int new_tgt_fd)
|
||||
dup2Func(SyscallDesc *desc, ThreadContext *tc, int old_tgt_fd, int new_tgt_fd)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
auto old_hbp = std::dynamic_pointer_cast<HBFDEntry>((*p->fds)[old_tgt_fd]);
|
||||
@@ -738,7 +728,7 @@ dup2Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
fcntlFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int cmd, GuestABI::VarArgs<int> varargs)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -780,8 +770,7 @@ fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int tgt_fd, int cmd)
|
||||
fcntl64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -810,20 +799,19 @@ fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
pipePseudoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
pipePseudoFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
return pipe2Func(desc, callnum, tc, 0, 0);
|
||||
return pipe2Func(desc, tc, 0, 0);
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
pipeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr tgt_addr)
|
||||
pipeFunc(SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr)
|
||||
{
|
||||
return pipe2Func(desc, callnum, tc, tgt_addr, 0);
|
||||
return pipe2Func(desc, tc, tgt_addr, 0);
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
pipe2Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr tgt_addr, int flags)
|
||||
pipe2Func(SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr, int flags)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -908,15 +896,14 @@ pipe2Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getpgrpFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
getpgrpFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
return process->pgid();
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
setpgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
int pid, int pgid)
|
||||
setpgidFunc(SyscallDesc *desc, ThreadContext *tc, int pid, int pgid)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
|
||||
@@ -950,56 +937,56 @@ setpgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
|
||||
SyscallReturn
|
||||
getpidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
getpidFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
return process->tgid();
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
gettidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
gettidFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
return process->pid();
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getppidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
getppidFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
return process->ppid();
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
getuidFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
return process->uid(); // UID
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
geteuidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
geteuidFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
return process->euid(); // UID
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getgidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
getgidFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
return process->gid();
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getegidFunc(SyscallDesc *desc, int callnum, ThreadContext *tc)
|
||||
getegidFunc(SyscallDesc *desc, ThreadContext *tc)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
return process->egid();
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
fallocateFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
fallocateFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int mode, off_t offset, off_t len)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
@@ -1021,7 +1008,7 @@ fallocateFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
accessFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
accessFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, mode_t mode)
|
||||
{
|
||||
string path;
|
||||
@@ -1037,7 +1024,7 @@ accessFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
mknodFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
mknodFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, mode_t mode, dev_t dev)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1052,7 +1039,7 @@ mknodFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
chdirFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname)
|
||||
chdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
std::string path;
|
||||
@@ -1079,7 +1066,7 @@ chdirFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname)
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
rmdirFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname)
|
||||
rmdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
std::string path;
|
||||
@@ -1095,7 +1082,7 @@ rmdirFunc(SyscallDesc *desc, int num, ThreadContext *tc, Addr pathname)
|
||||
#if defined(SYS_getdents) || defined(SYS_getdents64)
|
||||
template<typename DE, int SYS_NUM>
|
||||
static SyscallReturn
|
||||
getdentsImpl(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
getdentsImpl(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, unsigned count)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1137,7 +1124,7 @@ getdentsImpl(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
#if defined(SYS_getdents)
|
||||
SyscallReturn
|
||||
getdentsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
getdentsFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, unsigned count)
|
||||
{
|
||||
typedef struct linux_dirent {
|
||||
@@ -1147,14 +1134,14 @@ getdentsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
char dname[];
|
||||
} LinDent;
|
||||
|
||||
return getdentsImpl<LinDent, SYS_getdents>(desc, callnum, tc,
|
||||
return getdentsImpl<LinDent, SYS_getdents>(desc, tc,
|
||||
tgt_fd, buf_ptr, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SYS_getdents64)
|
||||
SyscallReturn
|
||||
getdents64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
getdents64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, unsigned count)
|
||||
{
|
||||
typedef struct linux_dirent64 {
|
||||
@@ -1164,14 +1151,13 @@ getdents64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
char dname[];
|
||||
} LinDent64;
|
||||
|
||||
return getdentsImpl<LinDent64, SYS_getdents64>(desc, callnum, tc,
|
||||
return getdentsImpl<LinDent64, SYS_getdents64>(desc, tc,
|
||||
tgt_fd, buf_ptr, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
SyscallReturn
|
||||
shutdownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int tgt_fd, int how)
|
||||
shutdownFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int how)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -1186,7 +1172,7 @@ shutdownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
bindFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
bindFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, int addrlen)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1207,8 +1193,7 @@ bindFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
listenFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int tgt_fd, int backlog)
|
||||
listenFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int backlog)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -1223,7 +1208,7 @@ listenFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
connectFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
connectFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, int addrlen)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1244,7 +1229,7 @@ connectFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
recvfromFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
recvfromFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags,
|
||||
Addr addrPtr, Addr addrlenPtr)
|
||||
{
|
||||
@@ -1304,7 +1289,7 @@ recvfromFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
sendtoFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
sendtoFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags,
|
||||
Addr addrPtr, socklen_t addrLen)
|
||||
{
|
||||
@@ -1336,7 +1321,7 @@ sendtoFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
recvmsgFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr msgPtr, int flags)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1474,7 +1459,7 @@ recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
sendmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
sendmsgFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr msgPtr, int flags)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1541,7 +1526,7 @@ sendmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
getsockoptFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int level, int optname, Addr valPtr, Addr lenPtr)
|
||||
{
|
||||
// union of all possible return value types from getsockopt
|
||||
@@ -1579,7 +1564,7 @@ getsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getsocknameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
getsocknameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr addrPtr, Addr lenPtr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1616,7 +1601,7 @@ getsocknameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
getpeernameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
getpeernameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr sockAddrPtr, Addr addrlenPtr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1643,7 +1628,7 @@ getpeernameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
}
|
||||
|
||||
SyscallReturn
|
||||
setsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
setsockoptFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int level, int optname, Addr valPtr, socklen_t len)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -121,248 +121,240 @@
|
||||
void warnUnsupportedOS(std::string syscall_name);
|
||||
|
||||
/// Handler for unimplemented syscalls that we haven't thought about.
|
||||
SyscallReturn unimplementedFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn unimplementedFunc(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.
|
||||
SyscallReturn ignoreFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn ignoreFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
/// Like above, but only prints a warning once per syscall desc it's used with.
|
||||
SyscallReturn
|
||||
ignoreWarnOnceFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
ignoreWarnOnceFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
// Target fallocateFunc() handler.
|
||||
SyscallReturn fallocateFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn fallocateFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int mode, off_t offset, off_t len);
|
||||
|
||||
/// Target exit() handler: terminate current context.
|
||||
SyscallReturn exitFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int status);
|
||||
SyscallReturn exitFunc(SyscallDesc *desc, ThreadContext *tc, int status);
|
||||
|
||||
/// Target exit_group() handler: terminate simulation. (exit all threads)
|
||||
SyscallReturn exitGroupFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int status);
|
||||
SyscallReturn exitGroupFunc(SyscallDesc *desc, ThreadContext *tc, int status);
|
||||
|
||||
/// Target set_tid_address() handler.
|
||||
SyscallReturn setTidAddressFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
uint64_t tidPtr);
|
||||
|
||||
/// Target getpagesize() handler.
|
||||
SyscallReturn getpagesizeFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn getpagesizeFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target brk() handler: set brk address.
|
||||
SyscallReturn brkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr new_brk);
|
||||
SyscallReturn brkFunc(SyscallDesc *desc, ThreadContext *tc, Addr new_brk);
|
||||
|
||||
/// Target close() handler.
|
||||
SyscallReturn closeFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int tgt_fd);
|
||||
SyscallReturn closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd);
|
||||
|
||||
/// Target lseek() handler.
|
||||
SyscallReturn lseekFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn lseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t offs, int whence);
|
||||
|
||||
/// Target _llseek() handler.
|
||||
SyscallReturn _llseekFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn _llseekFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t offset_high,
|
||||
uint32_t offset_low, Addr result_ptr, int whence);
|
||||
|
||||
/// Target munmap() handler.
|
||||
SyscallReturn munmapFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn munmapFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target shutdown() handler.
|
||||
SyscallReturn shutdownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn shutdownFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int how);
|
||||
|
||||
/// Target gethostname() handler.
|
||||
SyscallReturn gethostnameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn gethostnameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr buf_ptr, int name_len);
|
||||
|
||||
/// Target getcwd() handler.
|
||||
SyscallReturn getcwdFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn getcwdFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr buf_ptr, unsigned long size);
|
||||
|
||||
/// Target readlink() handler.
|
||||
SyscallReturn readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn readlinkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, Addr buf, size_t bufsiz);
|
||||
|
||||
/// Target unlink() handler.
|
||||
SyscallReturn unlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr pathname);
|
||||
SyscallReturn unlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname);
|
||||
|
||||
/// Target link() handler
|
||||
SyscallReturn linkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn linkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, Addr new_pathname);
|
||||
|
||||
/// Target symlink() handler.
|
||||
SyscallReturn symlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn symlinkFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, Addr new_pathname);
|
||||
|
||||
/// Target mkdir() handler.
|
||||
SyscallReturn mkdirFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn mkdirFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, mode_t mode);
|
||||
|
||||
/// Target mknod() handler.
|
||||
SyscallReturn mknodFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn mknodFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, mode_t mode, dev_t dev);
|
||||
|
||||
/// Target chdir() handler.
|
||||
SyscallReturn chdirFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr pathname);
|
||||
SyscallReturn chdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname);
|
||||
|
||||
// Target rmdir() handler.
|
||||
SyscallReturn rmdirFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr pathname);
|
||||
SyscallReturn rmdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname);
|
||||
|
||||
/// Target rename() handler.
|
||||
SyscallReturn renameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn renameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr oldpath, Addr newpath);
|
||||
|
||||
|
||||
/// Target truncate() handler.
|
||||
SyscallReturn truncateFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn truncateFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, off_t length);
|
||||
|
||||
|
||||
/// Target ftruncate() handler.
|
||||
SyscallReturn ftruncateFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn ftruncateFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, off_t length);
|
||||
|
||||
|
||||
/// Target truncate64() handler.
|
||||
SyscallReturn truncate64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn truncate64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, int64_t length);
|
||||
|
||||
/// Target ftruncate64() handler.
|
||||
SyscallReturn ftruncate64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn ftruncate64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int64_t length);
|
||||
|
||||
/// Target umask() handler.
|
||||
SyscallReturn umaskFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn umaskFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target gettid() handler.
|
||||
SyscallReturn gettidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn gettidFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target chown() handler.
|
||||
SyscallReturn chownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn chownFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, uint32_t owner, uint32_t group);
|
||||
|
||||
/// Target getpgrpFunc() handler.
|
||||
SyscallReturn getpgrpFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn getpgrpFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target setpgid() handler.
|
||||
SyscallReturn setpgidFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn setpgidFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int pid, int pgid);
|
||||
|
||||
/// Target fchown() handler.
|
||||
SyscallReturn fchownFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn fchownFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint32_t owner, uint32_t group);
|
||||
|
||||
/// Target dup() handler.
|
||||
SyscallReturn dupFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn dupFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd);
|
||||
|
||||
/// Target dup2() handler.
|
||||
SyscallReturn dup2Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn dup2Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int old_tgt_fd, int new_tgt_fd);
|
||||
|
||||
/// Target fcntl() handler.
|
||||
SyscallReturn fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn fcntlFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int cmd, GuestABI::VarArgs<int> varargs);
|
||||
|
||||
/// Target fcntl64() handler.
|
||||
SyscallReturn fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn fcntl64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int cmd);
|
||||
|
||||
/// Target pipe() handler.
|
||||
SyscallReturn pipeFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
Addr tgt_addr);
|
||||
SyscallReturn pipeFunc(SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr);
|
||||
|
||||
/// Target pipe() handler.
|
||||
SyscallReturn pipe2Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn pipe2Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr tgt_addr, int flags);
|
||||
|
||||
/// Target getpid() handler.
|
||||
SyscallReturn getpidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn getpidFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
// Target getpeername() handler.
|
||||
SyscallReturn getpeernameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn getpeernameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr sockAddrPtr, Addr addrlenPtr);
|
||||
|
||||
// Target bind() handler.
|
||||
SyscallReturn bindFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn bindFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, int addrlen);
|
||||
|
||||
// Target listen() handler.
|
||||
SyscallReturn listenFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn listenFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int backlog);
|
||||
|
||||
// Target connect() handler.
|
||||
SyscallReturn connectFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn connectFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, int addrlen);
|
||||
|
||||
#if defined(SYS_getdents)
|
||||
// Target getdents() handler.
|
||||
SyscallReturn getdentsFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn getdentsFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, unsigned count);
|
||||
#endif
|
||||
|
||||
#if defined(SYS_getdents64)
|
||||
// Target getdents() handler.
|
||||
SyscallReturn getdents64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn getdents64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, unsigned count);
|
||||
#endif
|
||||
|
||||
// Target sendto() handler.
|
||||
SyscallReturn sendtoFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn sendtoFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags,
|
||||
Addr addrPtr, socklen_t addrLen);
|
||||
|
||||
// Target recvfrom() handler.
|
||||
SyscallReturn recvfromFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn recvfromFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufrPtr, size_t bufrLen,
|
||||
int flags, Addr addrPtr, Addr addrlenPtr);
|
||||
|
||||
// Target recvmsg() handler.
|
||||
SyscallReturn recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn recvmsgFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr msgPtr, int flags);
|
||||
|
||||
// Target sendmsg() handler.
|
||||
SyscallReturn sendmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn sendmsgFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr msgPtr, int flags);
|
||||
|
||||
// Target getuid() handler.
|
||||
SyscallReturn getuidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn getuidFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target getgid() handler.
|
||||
SyscallReturn getgidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn getgidFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target getppid() handler.
|
||||
SyscallReturn getppidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn getppidFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target geteuid() handler.
|
||||
SyscallReturn geteuidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn geteuidFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target getegid() handler.
|
||||
SyscallReturn getegidFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn getegidFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
/// Target access() handler
|
||||
SyscallReturn accessFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn accessFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, mode_t mode);
|
||||
|
||||
// Target getsockopt() handler.
|
||||
SyscallReturn getsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn getsockoptFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int level, int optname,
|
||||
Addr valPtr, Addr lenPtr);
|
||||
|
||||
// Target setsockopt() handler.
|
||||
SyscallReturn setsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn setsockoptFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, int level, int optname,
|
||||
Addr valPtr, socklen_t len);
|
||||
|
||||
// Target getsockname() handler.
|
||||
SyscallReturn getsocknameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
SyscallReturn getsocknameFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr addrPtr, Addr lenPtr);
|
||||
|
||||
/// Futex system call
|
||||
@@ -370,7 +362,7 @@ SyscallReturn getsocknameFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
/// Used by printf's in multi-threaded apps
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
futexFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
futexFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr uaddr, int op, int val, int timeout, Addr uaddr2, int val3)
|
||||
{
|
||||
using namespace std;
|
||||
@@ -503,7 +495,7 @@ futexFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
/// Pseudo Funcs - These functions use a different return convension,
|
||||
/// returning a second value in a register other than the normal return register
|
||||
SyscallReturn pipePseudoFunc(SyscallDesc *desc, int num, ThreadContext *tc);
|
||||
SyscallReturn pipePseudoFunc(SyscallDesc *desc, ThreadContext *tc);
|
||||
|
||||
|
||||
/// Approximate seconds since the epoch (1/1/1970). About a billion,
|
||||
@@ -699,8 +691,8 @@ copyOutStatfsBuf(PortProxy &mem, Addr addr,
|
||||
/// not TTYs to provide repeatable results.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
int tgt_fd, unsigned req, Addr addr)
|
||||
ioctlFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, unsigned req, Addr addr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -774,7 +766,7 @@ ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target open() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
openatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
openatFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_dirfd, Addr pathname, int tgt_flags, int mode)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -921,51 +913,50 @@ openatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target open() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
openFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
openFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, int tgt_flags, int mode)
|
||||
{
|
||||
return openatFunc<OS>(desc, callnum, tc, OS::TGT_AT_FDCWD,
|
||||
pathname, tgt_flags, mode);
|
||||
return openatFunc<OS>(
|
||||
desc, tc, OS::TGT_AT_FDCWD, pathname, tgt_flags, mode);
|
||||
}
|
||||
|
||||
/// Target unlinkat() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
unlinkatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
int dirfd, Addr pathname)
|
||||
unlinkatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, Addr pathname)
|
||||
{
|
||||
if (dirfd != OS::TGT_AT_FDCWD)
|
||||
warn("unlinkat: first argument not AT_FDCWD; unlikely to work");
|
||||
|
||||
return unlinkFunc(desc, callnum, tc, pathname);
|
||||
return unlinkFunc(desc, tc, pathname);
|
||||
}
|
||||
|
||||
/// Target facessat() handler
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
faccessatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
faccessatFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int dirfd, Addr pathname, int mode)
|
||||
{
|
||||
if (dirfd != OS::TGT_AT_FDCWD)
|
||||
warn("faccessat: first argument not AT_FDCWD; unlikely to work");
|
||||
return accessFunc(desc, callnum, tc, pathname, mode);
|
||||
return accessFunc(desc, tc, pathname, mode);
|
||||
}
|
||||
|
||||
/// Target readlinkat() handler
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
readlinkatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
readlinkatFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int dirfd, Addr pathname, Addr buf, size_t bufsiz)
|
||||
{
|
||||
if (dirfd != OS::TGT_AT_FDCWD)
|
||||
warn("openat: first argument not AT_FDCWD; unlikely to work");
|
||||
return readlinkFunc(desc, callnum, tc, pathname, buf, bufsiz);
|
||||
return readlinkFunc(desc, tc, pathname, buf, bufsiz);
|
||||
}
|
||||
|
||||
/// Target renameat() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
renameatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
renameatFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int olddirfd, Addr oldpath, int newdirfd, Addr newpath)
|
||||
{
|
||||
if (olddirfd != OS::TGT_AT_FDCWD)
|
||||
@@ -974,13 +965,13 @@ renameatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
if (newdirfd != OS::TGT_AT_FDCWD)
|
||||
warn("renameat: third argument not AT_FDCWD; unlikely to work");
|
||||
|
||||
return renameFunc(desc, callnum, tc, oldpath, newpath);
|
||||
return renameFunc(desc, tc, oldpath, newpath);
|
||||
}
|
||||
|
||||
/// Target sysinfo() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
sysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr info)
|
||||
sysinfoFunc(SyscallDesc *desc, ThreadContext *tc, Addr info)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
|
||||
@@ -998,8 +989,7 @@ sysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr info)
|
||||
/// Target chmod() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
chmodFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr pathname, mode_t mode)
|
||||
chmodFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode)
|
||||
{
|
||||
std::string path;
|
||||
auto process = tc->getProcessPtr();
|
||||
@@ -1025,7 +1015,7 @@ chmodFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
pollFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
pollFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr fdsPtr, int nfds, int tmout)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1099,8 +1089,7 @@ pollFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
/// Target fchmod() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
fchmodFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
int tgt_fd, uint32_t mode)
|
||||
fchmodFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t mode)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -1119,7 +1108,7 @@ fchmodFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target mremap() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
mremapFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
mremapFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr start, uint64_t old_length, uint64_t new_length, uint64_t flags,
|
||||
GuestABI::VarArgs<uint64_t> varargs)
|
||||
{
|
||||
@@ -1196,8 +1185,7 @@ mremapFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target stat() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
statFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr pathname, Addr bufPtr)
|
||||
statFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr bufPtr)
|
||||
{
|
||||
std::string path;
|
||||
auto process = tc->getProcessPtr();
|
||||
@@ -1223,8 +1211,7 @@ statFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target stat64() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
stat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr pathname, Addr bufPtr)
|
||||
stat64Func(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr bufPtr)
|
||||
{
|
||||
std::string path;
|
||||
auto process = tc->getProcessPtr();
|
||||
@@ -1255,7 +1242,7 @@ stat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target fstatat64() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
fstatat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
fstatat64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int dirfd, Addr pathname, Addr bufPtr)
|
||||
{
|
||||
auto process = tc->getProcessPtr();
|
||||
@@ -1289,8 +1276,7 @@ fstatat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target fstat64() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
fstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufPtr)
|
||||
fstat64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr bufPtr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -1319,8 +1305,7 @@ fstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target lstat() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
lstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr pathname, Addr bufPtr)
|
||||
lstatFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr bufPtr)
|
||||
{
|
||||
std::string path;
|
||||
auto process = tc->getProcessPtr();
|
||||
@@ -1345,8 +1330,7 @@ lstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target lstat64() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
lstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr pathname, Addr bufPtr)
|
||||
lstat64Func(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr bufPtr)
|
||||
{
|
||||
std::string path;
|
||||
auto process = tc->getProcessPtr();
|
||||
@@ -1376,8 +1360,7 @@ lstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target fstat() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
fstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufPtr)
|
||||
fstatFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr bufPtr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -1402,8 +1385,7 @@ fstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target statfs() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
statfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr pathname, Addr bufPtr)
|
||||
statfsFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr bufPtr)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
std::string path;
|
||||
@@ -1431,9 +1413,8 @@ statfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
cloneFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
RegVal flags, RegVal newStack, Addr ptidPtr,
|
||||
Addr ctidPtr, Addr tlsPtr)
|
||||
cloneFunc(SyscallDesc *desc, ThreadContext *tc, RegVal flags, RegVal newStack,
|
||||
Addr ptidPtr, Addr ctidPtr, Addr tlsPtr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -1547,19 +1528,16 @@ cloneFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
cloneBackwardsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
RegVal flags, RegVal newStack, Addr ptidPtr,
|
||||
Addr tlsPtr, Addr ctidPtr)
|
||||
cloneBackwardsFunc(SyscallDesc *desc, ThreadContext *tc, RegVal flags,
|
||||
RegVal newStack, Addr ptidPtr, Addr tlsPtr, Addr ctidPtr)
|
||||
{
|
||||
return cloneFunc<OS>(desc, callnum, tc, flags, newStack, ptidPtr,
|
||||
ctidPtr, tlsPtr);
|
||||
return cloneFunc<OS>(desc, tc, flags, newStack, ptidPtr, ctidPtr, tlsPtr);
|
||||
}
|
||||
|
||||
/// Target fstatfs() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
fstatfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufPtr)
|
||||
fstatfsFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, Addr bufPtr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
|
||||
@@ -1582,7 +1560,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target readv() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
readvFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
readvFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t tiov_base, size_t count)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1619,7 +1597,7 @@ readvFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target writev() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
writevFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
writevFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, uint64_t tiov_base, size_t count)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1653,7 +1631,7 @@ writevFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target mmap() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
mmapFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
mmapFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr start, uint64_t length, int prot, int tgt_flags,
|
||||
int tgt_fd, int offset)
|
||||
{
|
||||
@@ -1818,7 +1796,7 @@ mmapFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
pread64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
pread64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufPtr, int nbytes, int offset)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1839,7 +1817,7 @@ pread64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
pwrite64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
pwrite64Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr bufPtr, int nbytes, int offset)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -1860,18 +1838,18 @@ pwrite64Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
/// Target mmap2() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
mmap2Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
mmap2Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr start, uint64_t length, int prot, int tgt_flags,
|
||||
int tgt_fd, int offset)
|
||||
{
|
||||
return mmapFunc<OS>(desc, num, tc, start, length, prot, tgt_flags,
|
||||
return mmapFunc<OS>(desc, tc, start, length, prot, tgt_flags,
|
||||
tgt_fd, offset * tc->getSystemPtr()->getPageBytes());
|
||||
}
|
||||
|
||||
/// Target getrlimit() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
getrlimitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
getrlimitFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
unsigned resource, Addr rlim)
|
||||
{
|
||||
TypedBufferArg<typename OS::rlimit> rlp(rlim);
|
||||
@@ -1910,7 +1888,7 @@ getrlimitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
prlimitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
prlimitFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int pid, int resource, Addr n, Addr o)
|
||||
{
|
||||
if (pid != 0) {
|
||||
@@ -1948,7 +1926,7 @@ prlimitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target clock_gettime() function.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
clock_gettimeFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
clock_gettimeFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int clk_id, Addr tp_ptr)
|
||||
{
|
||||
TypedBufferArg<typename OS::timespec> tp(tp_ptr);
|
||||
@@ -1966,8 +1944,7 @@ clock_gettimeFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
/// Target clock_getres() function.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
clock_getresFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int clk_id, Addr tp_ptr)
|
||||
clock_getresFunc(SyscallDesc *desc, ThreadContext *tc, int clk_id, Addr tp_ptr)
|
||||
{
|
||||
TypedBufferArg<typename OS::timespec> tp(tp_ptr);
|
||||
|
||||
@@ -1983,7 +1960,7 @@ clock_getresFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
/// Target gettimeofday() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
gettimeofdayFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
gettimeofdayFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr tv_ptr, Addr tz_ptr)
|
||||
{
|
||||
TypedBufferArg<typename OS::timeval> tp(tv_ptr);
|
||||
@@ -2002,8 +1979,7 @@ gettimeofdayFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target utimes() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
utimesFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
Addr pathname, Addr times)
|
||||
utimesFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr times)
|
||||
{
|
||||
std::string path;
|
||||
auto process = tc->getProcessPtr();
|
||||
@@ -2033,7 +2009,7 @@ utimesFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
execveFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
execveFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
Addr pathname, Addr argv_mem_loc, Addr envp_mem_loc)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -2122,7 +2098,7 @@ execveFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target getrusage() function.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
getrusageFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
getrusageFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int who /* THREAD, SELF, or CHILDREN */, Addr usage)
|
||||
{
|
||||
TypedBufferArg<typename OS::rusage> rup(usage);
|
||||
@@ -2172,7 +2148,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
/// Target times() function.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
timesFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr bufPtr)
|
||||
timesFunc(SyscallDesc *desc, ThreadContext *tc, Addr bufPtr)
|
||||
{
|
||||
TypedBufferArg<typename OS::tms> bufp(bufPtr);
|
||||
|
||||
@@ -2196,7 +2172,7 @@ timesFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr bufPtr)
|
||||
/// Target time() function.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
timeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr taddr)
|
||||
timeFunc(SyscallDesc *desc, ThreadContext *tc, Addr taddr)
|
||||
{
|
||||
typename OS::time_t sec, usec;
|
||||
getElapsedTimeMicro(sec, usec);
|
||||
@@ -2213,8 +2189,7 @@ timeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr taddr)
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
tgkillFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
int tgid, int tid, int sig)
|
||||
tgkillFunc(SyscallDesc *desc, ThreadContext *tc, int tgid, int tid, int sig)
|
||||
{
|
||||
/**
|
||||
* This system call is intended to allow killing a specific thread
|
||||
@@ -2251,14 +2226,14 @@ tgkillFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
return -ESRCH;
|
||||
|
||||
if (sig == OS::TGT_SIGABRT)
|
||||
exitGroupFunc(desc, num, tc, 0);
|
||||
exitGroupFunc(desc, tc, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
socketFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
socketFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int domain, int type, int prot)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -2275,7 +2250,7 @@ socketFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
socketpairFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
socketpairFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int domain, int type, int prot, Addr svPtr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -2298,7 +2273,7 @@ socketpairFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
selectFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
selectFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int nfds_t, Addr fds_read_ptr, Addr fds_writ_ptr,
|
||||
Addr fds_excp_ptr, Addr time_val_ptr)
|
||||
{
|
||||
@@ -2490,7 +2465,7 @@ selectFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
readFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
readFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, int nbytes)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -2518,7 +2493,7 @@ readFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
writeFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
writeFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr buf_ptr, int nbytes)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -2557,7 +2532,7 @@ writeFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
wait4Func(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
wait4Func(SyscallDesc *desc, ThreadContext *tc,
|
||||
pid_t pid, Addr statPtr, int options, Addr rusagePtr)
|
||||
{
|
||||
auto p = tc->getProcessPtr();
|
||||
@@ -2615,7 +2590,7 @@ success:
|
||||
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
acceptFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
acceptFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
int tgt_fd, Addr addrPtr, Addr lenPtr)
|
||||
{
|
||||
struct sockaddr sa;
|
||||
@@ -2682,7 +2657,7 @@ acceptFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
/// Target eventfd() function.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
eventfdFunc(SyscallDesc *desc, int num, ThreadContext *tc,
|
||||
eventfdFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
unsigned initval, int in_flags)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
|
||||
Reference in New Issue
Block a user