From 0e0183f1d9158236aea4434ecb3a96d8c946e74d Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 3 Feb 2021 00:25:48 -0800 Subject: [PATCH] arch,sim: Use VPtr<> instead of Addr in system call signatures. This tells the GuestABI mechanism that these are guest pointers and not uint64_ts, and that they should be treated as 32 bit or 64 bit values depending on the size of pointers in the target ABI. Change-Id: Ia9b5447848c52668a975d8b07b11ad457e756b13 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40498 Maintainer: Gabe Black Tested-by: kokoro Reviewed-by: Bobby R. Bruce --- src/arch/arm/freebsd/se_workload.cc | 4 +- src/arch/mips/linux/se_workload.cc | 4 +- src/arch/sparc/linux/syscalls.cc | 2 +- src/sim/syscall_emul.cc | 76 ++++++++------- src/sim/syscall_emul.hh | 146 ++++++++++++++-------------- 5 files changed, 120 insertions(+), 112 deletions(-) diff --git a/src/arch/arm/freebsd/se_workload.cc b/src/arch/arm/freebsd/se_workload.cc index ab6b03ec6..661a4a9d2 100644 --- a/src/arch/arm/freebsd/se_workload.cc +++ b/src/arch/arm/freebsd/se_workload.cc @@ -83,8 +83,8 @@ issetugidFunc(SyscallDesc *desc, ThreadContext *tc) #if !defined ( __GNU_LIBRARY__ ) static SyscallReturn -sysctlFunc(SyscallDesc *desc, ThreadContext *tc, Addr namep, size_t nameLen, - Addr oldp, Addr oldlenp, Addr newp, size_t newlen) +sysctlFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> namep, size_t nameLen, + VPtr<> oldp, VPtr<> oldlenp, VPtr<> newp, size_t newlen) { uint64_t ret; diff --git a/src/arch/mips/linux/se_workload.cc b/src/arch/mips/linux/se_workload.cc index 0abe2632e..ef12f4f1e 100644 --- a/src/arch/mips/linux/se_workload.cc +++ b/src/arch/mips/linux/se_workload.cc @@ -124,7 +124,7 @@ sys_getsysinfoFunc(SyscallDesc *desc, ThreadContext *tc, unsigned op, /// Target sys_setsysinfo() handler. static SyscallReturn sys_setsysinfoFunc(SyscallDesc *desc, ThreadContext *tc, unsigned op, - Addr bufPtr, unsigned nbytes) + VPtr<> bufPtr, unsigned nbytes) { switch (op) { @@ -147,7 +147,7 @@ sys_setsysinfoFunc(SyscallDesc *desc, ThreadContext *tc, unsigned op, } static SyscallReturn -setThreadAreaFunc(SyscallDesc *desc, ThreadContext *tc, Addr addr) +setThreadAreaFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> addr) { tc->setMiscRegNoEffect(MISCREG_TP_VALUE, addr); return 0; diff --git a/src/arch/sparc/linux/syscalls.cc b/src/arch/sparc/linux/syscalls.cc index a00f60e59..17cc705ea 100644 --- a/src/arch/sparc/linux/syscalls.cc +++ b/src/arch/sparc/linux/syscalls.cc @@ -54,7 +54,7 @@ unameFunc(SyscallDesc *desc, ThreadContext *tc, VPtr name) static SyscallReturn getresuidFunc(SyscallDesc *desc, ThreadContext *tc, - Addr ruid, Addr euid, Addr suid) + VPtr<> ruid, VPtr<> euid, VPtr<> suid) { const uint64_t id = htobe(100); // Handle the EFAULT case diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index 8f04cd538..4f6716b92 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -89,7 +89,7 @@ ignoreWarnOnceFunc(SyscallDesc *desc, ThreadContext *tc) } static void -exitFutexWake(ThreadContext *tc, Addr addr, uint64_t tgid) +exitFutexWake(ThreadContext *tc, VPtr<> addr, uint64_t tgid) { // Clear value at address pointed to by thread's childClearTID field. BufferArg ctidBuf(addr, sizeof(long)); @@ -243,7 +243,7 @@ getpagesizeFunc(SyscallDesc *desc, ThreadContext *tc) SyscallReturn -brkFunc(SyscallDesc *desc, ThreadContext *tc, Addr new_brk) +brkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> new_brk) { // change brk addr to first arg auto p = tc->getProcessPtr(); @@ -300,7 +300,7 @@ lseekFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn _llseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offset_high, uint32_t offset_low, - Addr result_ptr, int whence) + VPtr<> result_ptr, int whence) { auto p = tc->getProcessPtr(); @@ -325,7 +325,7 @@ _llseekFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn -munmapFunc(SyscallDesc *desc, ThreadContext *tc, Addr start, size_t length) +munmapFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> start, size_t length) { // Even if the system is currently not capable of recycling physical // pages, there is no reason we can't unmap them so that we trigger @@ -348,7 +348,7 @@ const char *hostname = "m5.eecs.umich.edu"; SyscallReturn gethostnameFunc(SyscallDesc *desc, ThreadContext *tc, - Addr buf_ptr, int name_len) + VPtr<> buf_ptr, int name_len) { BufferArg name(buf_ptr, name_len); strncpy((char *)name.bufferPtr(), hostname, name_len); @@ -358,7 +358,7 @@ gethostnameFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn getcwdFunc(SyscallDesc *desc, ThreadContext *tc, - Addr buf_ptr, unsigned long size) + VPtr<> buf_ptr, unsigned long size) { int result = 0; auto p = tc->getProcessPtr(); @@ -388,7 +388,7 @@ getcwdFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn readlinkFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, Addr buf_ptr, size_t bufsiz) + VPtr<> pathname, VPtr<> buf_ptr, size_t bufsiz) { std::string path; auto p = tc->getProcessPtr(); @@ -445,7 +445,7 @@ readlinkFunc(SyscallDesc *desc, ThreadContext *tc, } SyscallReturn -unlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname) +unlinkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname) { std::string path; auto p = tc->getProcessPtr(); @@ -461,7 +461,7 @@ unlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname) SyscallReturn linkFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, Addr new_pathname) + VPtr<> pathname, VPtr<> new_pathname) { std::string path; std::string new_path; @@ -482,7 +482,7 @@ linkFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn symlinkFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, Addr new_pathname) + VPtr<> pathname, VPtr<> new_pathname) { std::string path; std::string new_path; @@ -502,7 +502,7 @@ symlinkFunc(SyscallDesc *desc, ThreadContext *tc, } SyscallReturn -mkdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode) +mkdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode) { auto p = tc->getProcessPtr(); std::string path; @@ -516,7 +516,8 @@ mkdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode) } SyscallReturn -renameFunc(SyscallDesc *desc, ThreadContext *tc, Addr oldpath, Addr newpath) +renameFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> oldpath, + VPtr<> newpath) { auto p = tc->getProcessPtr(); @@ -537,7 +538,8 @@ renameFunc(SyscallDesc *desc, ThreadContext *tc, Addr oldpath, Addr newpath) } SyscallReturn -truncateFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, off_t length) +truncateFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, + off_t length) { std::string path; auto p = tc->getProcessPtr(); @@ -568,7 +570,7 @@ ftruncateFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, off_t length) SyscallReturn truncate64Func(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, int64_t length) + VPtr<> pathname, int64_t length) { auto process = tc->getProcessPtr(); std::string path; @@ -619,7 +621,7 @@ umaskFunc(SyscallDesc *desc, ThreadContext *tc) SyscallReturn chownFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, uint32_t owner, uint32_t group) + VPtr<> pathname, uint32_t owner, uint32_t group) { std::string path; auto p = tc->getProcessPtr(); @@ -789,13 +791,13 @@ pipePseudoFunc(SyscallDesc *desc, ThreadContext *tc) } SyscallReturn -pipeFunc(SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr) +pipeFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> tgt_addr) { return pipe2Func(desc, tc, tgt_addr, 0); } SyscallReturn -pipe2Func(SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr, int flags) +pipe2Func(SyscallDesc *desc, ThreadContext *tc, VPtr<> tgt_addr, int flags) { auto p = tc->getProcessPtr(); @@ -993,7 +995,7 @@ fallocateFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn accessFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, mode_t mode) + VPtr<> pathname, mode_t mode) { std::string path; auto p = tc->getProcessPtr(); @@ -1009,7 +1011,7 @@ accessFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn mknodFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, mode_t mode, dev_t dev) + VPtr<> pathname, mode_t mode, dev_t dev) { auto p = tc->getProcessPtr(); std::string path; @@ -1023,7 +1025,7 @@ mknodFunc(SyscallDesc *desc, ThreadContext *tc, } SyscallReturn -chdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname) +chdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname) { auto p = tc->getProcessPtr(); std::string path; @@ -1050,7 +1052,7 @@ chdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname) } SyscallReturn -rmdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname) +rmdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname) { auto p = tc->getProcessPtr(); std::string path; @@ -1067,7 +1069,7 @@ rmdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname) template static SyscallReturn getdentsImpl(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, unsigned count) + int tgt_fd, VPtr<> buf_ptr, unsigned count) { auto p = tc->getProcessPtr(); @@ -1109,7 +1111,7 @@ getdentsImpl(SyscallDesc *desc, ThreadContext *tc, #if defined(SYS_getdents) SyscallReturn getdentsFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, unsigned count) + int tgt_fd, VPtr<> buf_ptr, unsigned count) { typedef struct linux_dirent { unsigned long d_ino; @@ -1126,7 +1128,7 @@ getdentsFunc(SyscallDesc *desc, ThreadContext *tc, #if defined(SYS_getdents64) SyscallReturn getdents64Func(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, unsigned count) + int tgt_fd, VPtr<> buf_ptr, unsigned count) { typedef struct linux_dirent64 { ino64_t d_ino; @@ -1157,7 +1159,7 @@ shutdownFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int how) SyscallReturn bindFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, int addrlen) + int tgt_fd, VPtr<> buf_ptr, int addrlen) { auto p = tc->getProcessPtr(); @@ -1193,7 +1195,7 @@ listenFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int backlog) SyscallReturn connectFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, int addrlen) + int tgt_fd, VPtr<> buf_ptr, int addrlen) { auto p = tc->getProcessPtr(); @@ -1214,8 +1216,8 @@ connectFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn recvfromFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags, - Addr addrPtr, Addr addrlenPtr) + int tgt_fd, VPtr<> bufrPtr, size_t bufrLen, int flags, + VPtr<> addrPtr, VPtr<> addrlenPtr) { auto p = tc->getProcessPtr(); @@ -1274,8 +1276,8 @@ recvfromFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn sendtoFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags, - Addr addrPtr, socklen_t addrLen) + int tgt_fd, VPtr<> bufrPtr, size_t bufrLen, int flags, + VPtr<> addrPtr, socklen_t addrLen) { auto p = tc->getProcessPtr(); @@ -1306,7 +1308,7 @@ sendtoFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn recvmsgFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr msgPtr, int flags) + int tgt_fd, VPtr<> msgPtr, int flags) { auto p = tc->getProcessPtr(); @@ -1444,7 +1446,7 @@ recvmsgFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn sendmsgFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr msgPtr, int flags) + int tgt_fd, VPtr<> msgPtr, int flags) { auto p = tc->getProcessPtr(); @@ -1511,7 +1513,8 @@ sendmsgFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn getsockoptFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, int level, int optname, Addr valPtr, Addr lenPtr) + int tgt_fd, int level, int optname, VPtr<> valPtr, + VPtr<> lenPtr) { // union of all possible return value types from getsockopt union val { @@ -1549,7 +1552,7 @@ getsockoptFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn getsocknameFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr addrPtr, Addr lenPtr) + int tgt_fd, VPtr<> addrPtr, VPtr<> lenPtr) { auto p = tc->getProcessPtr(); @@ -1586,7 +1589,7 @@ getsocknameFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn getpeernameFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr sockAddrPtr, Addr addrlenPtr) + int tgt_fd, VPtr<> sockAddrPtr, VPtr<> addrlenPtr) { auto p = tc->getProcessPtr(); @@ -1613,7 +1616,8 @@ getpeernameFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn setsockoptFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, int level, int optname, Addr valPtr, socklen_t len) + int tgt_fd, int level, int optname, VPtr<> valPtr, + socklen_t len) { auto p = tc->getProcessPtr(); diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index d6afec886..0872b0f00 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -152,7 +152,7 @@ SyscallReturn setTidAddressFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn getpagesizeFunc(SyscallDesc *desc, ThreadContext *tc); /// Target brk() handler: set brk address. -SyscallReturn brkFunc(SyscallDesc *desc, ThreadContext *tc, Addr new_brk); +SyscallReturn brkFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> new_brk); /// Target close() handler. SyscallReturn closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd); @@ -164,10 +164,10 @@ SyscallReturn lseekFunc(SyscallDesc *desc, ThreadContext *tc, /// Target _llseek() handler. SyscallReturn _llseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offset_high, - uint32_t offset_low, Addr result_ptr, int whence); + uint32_t offset_low, VPtr<> result_ptr, int whence); /// Target munmap() handler. -SyscallReturn munmapFunc(SyscallDesc *desc, ThreadContext *tc, Addr start, +SyscallReturn munmapFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> start, size_t length); /// Target shutdown() handler. @@ -176,49 +176,50 @@ SyscallReturn shutdownFunc(SyscallDesc *desc, ThreadContext *tc, /// Target gethostname() handler. SyscallReturn gethostnameFunc(SyscallDesc *desc, ThreadContext *tc, - Addr buf_ptr, int name_len); + VPtr<> buf_ptr, int name_len); /// Target getcwd() handler. SyscallReturn getcwdFunc(SyscallDesc *desc, ThreadContext *tc, - Addr buf_ptr, unsigned long size); + VPtr<> buf_ptr, unsigned long size); /// Target readlink() handler. SyscallReturn readlinkFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, Addr buf, size_t bufsiz); + VPtr<> pathname, VPtr<> buf, size_t bufsiz); /// Target unlink() handler. -SyscallReturn unlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname); +SyscallReturn unlinkFunc(SyscallDesc *desc, ThreadContext *tc, + VPtr<> pathname); /// Target link() handler SyscallReturn linkFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, Addr new_pathname); + VPtr<> pathname, VPtr<> new_pathname); /// Target symlink() handler. SyscallReturn symlinkFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, Addr new_pathname); + VPtr<> pathname, VPtr<> new_pathname); /// Target mkdir() handler. SyscallReturn mkdirFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, mode_t mode); + VPtr<> pathname, mode_t mode); /// Target mknod() handler. SyscallReturn mknodFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, mode_t mode, dev_t dev); + VPtr<> pathname, mode_t mode, dev_t dev); /// Target chdir() handler. -SyscallReturn chdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname); +SyscallReturn chdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname); // Target rmdir() handler. -SyscallReturn rmdirFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname); +SyscallReturn rmdirFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname); /// Target rename() handler. SyscallReturn renameFunc(SyscallDesc *desc, ThreadContext *tc, - Addr oldpath, Addr newpath); + VPtr<> oldpath, VPtr<> newpath); /// Target truncate() handler. SyscallReturn truncateFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, off_t length); + VPtr<> pathname, off_t length); /// Target ftruncate() handler. @@ -228,7 +229,7 @@ SyscallReturn ftruncateFunc(SyscallDesc *desc, ThreadContext *tc, /// Target truncate64() handler. SyscallReturn truncate64Func(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, int64_t length); + VPtr<> pathname, int64_t length); /// Target ftruncate64() handler. SyscallReturn ftruncate64Func(SyscallDesc *desc, ThreadContext *tc, @@ -242,7 +243,7 @@ SyscallReturn gettidFunc(SyscallDesc *desc, ThreadContext *tc); /// Target chown() handler. SyscallReturn chownFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, uint32_t owner, uint32_t group); + VPtr<> pathname, uint32_t owner, uint32_t group); /// Target getpgrpFunc() handler. SyscallReturn getpgrpFunc(SyscallDesc *desc, ThreadContext *tc); @@ -272,22 +273,23 @@ SyscallReturn fcntl64Func(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd); /// Target pipe() handler. -SyscallReturn pipeFunc(SyscallDesc *desc, ThreadContext *tc, Addr tgt_addr); +SyscallReturn pipeFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> tgt_addr); /// Target pipe() handler. SyscallReturn pipe2Func(SyscallDesc *desc, ThreadContext *tc, - Addr tgt_addr, int flags); + VPtr<> tgt_addr, int flags); /// Target getpid() handler. SyscallReturn getpidFunc(SyscallDesc *desc, ThreadContext *tc); // Target getpeername() handler. SyscallReturn getpeernameFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr sockAddrPtr, Addr addrlenPtr); + int tgt_fd, VPtr<> sockAddrPtr, + VPtr<> addrlenPtr); // Target bind() handler. SyscallReturn bindFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, int addrlen); + int tgt_fd, VPtr<> buf_ptr, int addrlen); // Target listen() handler. SyscallReturn listenFunc(SyscallDesc *desc, ThreadContext *tc, @@ -295,37 +297,37 @@ SyscallReturn listenFunc(SyscallDesc *desc, ThreadContext *tc, // Target connect() handler. SyscallReturn connectFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, int addrlen); + int tgt_fd, VPtr<> buf_ptr, int addrlen); #if defined(SYS_getdents) // Target getdents() handler. SyscallReturn getdentsFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, unsigned count); + int tgt_fd, VPtr<> buf_ptr, unsigned count); #endif #if defined(SYS_getdents64) // Target getdents() handler. SyscallReturn getdents64Func(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, unsigned count); + int tgt_fd, VPtr<> buf_ptr, unsigned count); #endif // Target sendto() handler. SyscallReturn sendtoFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr bufrPtr, size_t bufrLen, int flags, - Addr addrPtr, socklen_t addrLen); + int tgt_fd, VPtr<> bufrPtr, size_t bufrLen, int flags, + VPtr<> addrPtr, socklen_t addrLen); // Target recvfrom() handler. SyscallReturn recvfromFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr bufrPtr, size_t bufrLen, - int flags, Addr addrPtr, Addr addrlenPtr); + int tgt_fd, VPtr<> bufrPtr, size_t bufrLen, + int flags, VPtr<> addrPtr, VPtr<> addrlenPtr); // Target recvmsg() handler. SyscallReturn recvmsgFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr msgPtr, int flags); + int tgt_fd, VPtr<> msgPtr, int flags); // Target sendmsg() handler. SyscallReturn sendmsgFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr msgPtr, int flags); + int tgt_fd, VPtr<> msgPtr, int flags); // Target getuid() handler. SyscallReturn getuidFunc(SyscallDesc *desc, ThreadContext *tc); @@ -344,17 +346,17 @@ SyscallReturn getegidFunc(SyscallDesc *desc, ThreadContext *tc); /// Target access() handler SyscallReturn accessFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, mode_t mode); + VPtr<> pathname, mode_t mode); // Target getsockopt() handler. SyscallReturn getsockoptFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, - Addr valPtr, Addr lenPtr); + VPtr<> valPtr, VPtr<> lenPtr); // Target setsockopt() handler. SyscallReturn setsockoptFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, - Addr valPtr, socklen_t len); + VPtr<> valPtr, socklen_t len); SyscallReturn getcpuFunc(SyscallDesc *desc, ThreadContext *tc, VPtr cpu, VPtr node, @@ -362,7 +364,7 @@ SyscallReturn getcpuFunc(SyscallDesc *desc, ThreadContext *tc, // Target getsockname() handler. SyscallReturn getsocknameFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr addrPtr, Addr lenPtr); + int tgt_fd, VPtr<> addrPtr, VPtr<> lenPtr); /// Futex system call /// Implemented by Daniel Sanchez @@ -370,7 +372,7 @@ SyscallReturn getsocknameFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn futexFunc(SyscallDesc *desc, ThreadContext *tc, - Addr uaddr, int op, int val, int timeout, Addr uaddr2, int val3) + VPtr<> uaddr, int op, int val, int timeout, VPtr<> uaddr2, int val3) { auto process = tc->getProcessPtr(); @@ -672,7 +674,7 @@ copyOutStatfsBuf(TgtStatPtr tgt, HostStatPtr host) template SyscallReturn ioctlFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, unsigned req, Addr addr) + int tgt_fd, unsigned req, VPtr<> addr) { auto p = tc->getProcessPtr(); @@ -747,7 +749,7 @@ ioctlFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn openatFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_dirfd, Addr pathname, int tgt_flags, int mode) + int tgt_dirfd, VPtr<> pathname, int tgt_flags, int mode) { auto p = tc->getProcessPtr(); @@ -896,7 +898,7 @@ openatFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn openFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, int tgt_flags, int mode) + VPtr<> pathname, int tgt_flags, int mode) { return openatFunc( desc, tc, OS::TGT_AT_FDCWD, pathname, tgt_flags, mode); @@ -905,7 +907,7 @@ openFunc(SyscallDesc *desc, ThreadContext *tc, /// Target unlinkat() handler. template SyscallReturn -unlinkatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, Addr pathname) +unlinkatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname) { if (dirfd != OS::TGT_AT_FDCWD) warn("unlinkat: first argument not AT_FDCWD; unlikely to work"); @@ -917,7 +919,7 @@ unlinkatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, Addr pathname) template SyscallReturn faccessatFunc(SyscallDesc *desc, ThreadContext *tc, - int dirfd, Addr pathname, int mode) + int dirfd, VPtr<> pathname, int mode) { if (dirfd != OS::TGT_AT_FDCWD) warn("faccessat: first argument not AT_FDCWD; unlikely to work"); @@ -928,7 +930,7 @@ faccessatFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn readlinkatFunc(SyscallDesc *desc, ThreadContext *tc, - int dirfd, Addr pathname, Addr buf, size_t bufsiz) + int dirfd, VPtr<> pathname, VPtr<> buf, size_t bufsiz) { if (dirfd != OS::TGT_AT_FDCWD) warn("openat: first argument not AT_FDCWD; unlikely to work"); @@ -939,7 +941,7 @@ readlinkatFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn renameatFunc(SyscallDesc *desc, ThreadContext *tc, - int olddirfd, Addr oldpath, int newdirfd, Addr newpath) + int olddirfd, VPtr<> oldpath, int newdirfd, VPtr<> newpath) { if (olddirfd != OS::TGT_AT_FDCWD) warn("renameat: first argument not AT_FDCWD; unlikely to work"); @@ -968,7 +970,7 @@ sysinfoFunc(SyscallDesc *desc, ThreadContext *tc, /// Target chmod() handler. template SyscallReturn -chmodFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode) +chmodFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode) { std::string path; auto process = tc->getProcessPtr(); @@ -995,7 +997,7 @@ chmodFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, mode_t mode) template SyscallReturn pollFunc(SyscallDesc *desc, ThreadContext *tc, - Addr fdsPtr, int nfds, int tmout) + VPtr<> fdsPtr, int nfds, int tmout) { auto p = tc->getProcessPtr(); @@ -1088,7 +1090,7 @@ fchmodFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t mode) template SyscallReturn mremapFunc(SyscallDesc *desc, ThreadContext *tc, - Addr start, uint64_t old_length, uint64_t new_length, uint64_t flags, + VPtr<> start, uint64_t old_length, uint64_t new_length, uint64_t flags, GuestABI::VarArgs varargs) { auto p = tc->getProcessPtr(); @@ -1117,7 +1119,7 @@ mremapFunc(SyscallDesc *desc, ThreadContext *tc, uint64_t diff = new_length - old_length; p->memState->mapRegion(mmap_end, diff, "remapped"); p->memState->setMmapEnd(mmap_end + diff); - return start; + return (Addr)start; } else { if (!use_provided_address && !(flags & OS::TGT_MREMAP_MAYMOVE)) { warn("can't remap here and MREMAP_MAYMOVE flag not set\n"); @@ -1163,7 +1165,7 @@ mremapFunc(SyscallDesc *desc, ThreadContext *tc, if (new_length != old_length) p->memState->unmapRegion(start + new_length, old_length - new_length); - return use_provided_address ? provided_address : start; + return use_provided_address ? provided_address : (Addr)start; } } @@ -1171,7 +1173,7 @@ mremapFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn statFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, VPtr tgt_stat) + VPtr<> pathname, VPtr tgt_stat) { std::string path; auto process = tc->getProcessPtr(); @@ -1198,7 +1200,7 @@ statFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn stat64Func(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, VPtr tgt_stat) + VPtr<> pathname, VPtr tgt_stat) { std::string path; auto process = tc->getProcessPtr(); @@ -1230,7 +1232,8 @@ stat64Func(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn fstatat64Func(SyscallDesc *desc, ThreadContext *tc, - int dirfd, Addr pathname, VPtr tgt_stat) + int dirfd, VPtr<> pathname, + VPtr tgt_stat) { auto process = tc->getProcessPtr(); if (dirfd != OS::TGT_AT_FDCWD) @@ -1294,7 +1297,7 @@ fstat64Func(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn lstatFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, VPtr tgt_stat) + VPtr<> pathname, VPtr tgt_stat) { std::string path; auto process = tc->getProcessPtr(); @@ -1320,7 +1323,7 @@ lstatFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn lstat64Func(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, VPtr tgt_stat) + VPtr<> pathname, VPtr tgt_stat) { std::string path; auto process = tc->getProcessPtr(); @@ -1377,7 +1380,7 @@ fstatFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn statfsFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, VPtr tgt_stat) + VPtr<> pathname, VPtr tgt_stat) { #if defined(__linux__) std::string path; @@ -1406,7 +1409,7 @@ statfsFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn cloneFunc(SyscallDesc *desc, ThreadContext *tc, RegVal flags, RegVal newStack, - Addr ptidPtr, Addr ctidPtr, Addr tlsPtr) + VPtr<> ptidPtr, VPtr<> ctidPtr, VPtr<> tlsPtr) { auto p = tc->getProcessPtr(); @@ -1517,7 +1520,8 @@ cloneFunc(SyscallDesc *desc, ThreadContext *tc, RegVal flags, RegVal newStack, template SyscallReturn cloneBackwardsFunc(SyscallDesc *desc, ThreadContext *tc, RegVal flags, - RegVal newStack, Addr ptidPtr, Addr tlsPtr, Addr ctidPtr) + RegVal newStack, VPtr<> ptidPtr, VPtr<> tlsPtr, + VPtr<> ctidPtr) { return cloneFunc(desc, tc, flags, newStack, ptidPtr, ctidPtr, tlsPtr); } @@ -1621,7 +1625,7 @@ writevFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn mmapFunc(SyscallDesc *desc, ThreadContext *tc, - Addr start, typename OS::size_t length, int prot, + VPtr<> start, typename OS::size_t length, int prot, int tgt_flags, int tgt_fd, typename OS::off_t offset) { auto p = tc->getProcessPtr(); @@ -1757,13 +1761,13 @@ mmapFunc(SyscallDesc *desc, ThreadContext *tc, */ p->memState->mapRegion(start, length, region_name, sim_fd, offset); - return start; + return (Addr)start; } template SyscallReturn pread64Func(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr bufPtr, int nbytes, int offset) + int tgt_fd, VPtr<> bufPtr, int nbytes, int offset) { auto p = tc->getProcessPtr(); @@ -1784,7 +1788,7 @@ pread64Func(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn pwrite64Func(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr bufPtr, int nbytes, int offset) + int tgt_fd, VPtr<> bufPtr, int nbytes, int offset) { auto p = tc->getProcessPtr(); @@ -1805,7 +1809,7 @@ pwrite64Func(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn mmap2Func(SyscallDesc *desc, ThreadContext *tc, - Addr start, typename OS::size_t length, int prot, + VPtr<> start, typename OS::size_t length, int prot, int tgt_flags, int tgt_fd, typename OS::off_t offset) { auto page_size = tc->getProcessPtr()->pTable->pageSize(); @@ -1853,7 +1857,7 @@ getrlimitFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn prlimitFunc(SyscallDesc *desc, ThreadContext *tc, - int pid, int resource, Addr n, VPtr rlp) + int pid, int resource, VPtr<> n, VPtr rlp) { if (pid != 0) { warn("prlimit: ignoring rlimits for nonzero pid"); @@ -1916,7 +1920,7 @@ clock_getresFunc(SyscallDesc *desc, ThreadContext *tc, int clk_id, template SyscallReturn gettimeofdayFunc(SyscallDesc *desc, ThreadContext *tc, - VPtr tp, Addr tz_ptr) + VPtr tp, VPtr<> tz_ptr) { getElapsedTimeMicro(tp->tv_sec, tp->tv_usec); tp->tv_sec += seconds_since_epoch; @@ -1930,7 +1934,7 @@ gettimeofdayFunc(SyscallDesc *desc, ThreadContext *tc, /// Target utimes() handler. template SyscallReturn -utimesFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, +utimesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr tp) { std::string path; @@ -1959,7 +1963,7 @@ utimesFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, template SyscallReturn execveFunc(SyscallDesc *desc, ThreadContext *tc, - Addr pathname, Addr argv_mem_loc, Addr envp_mem_loc) + VPtr<> pathname, VPtr<> argv_mem_loc, VPtr<> envp_mem_loc) { auto p = tc->getProcessPtr(); @@ -1972,7 +1976,7 @@ execveFunc(SyscallDesc *desc, ThreadContext *tc, return -EACCES; auto read_in = [](std::vector &vect, - PortProxy &mem_proxy, Addr mem_loc) + PortProxy &mem_proxy, VPtr<> mem_loc) { for (int inc = 0; ; inc++) { BufferArg b((mem_loc + sizeof(Addr) * inc), sizeof(Addr)); @@ -2113,7 +2117,7 @@ timesFunc(SyscallDesc *desc, ThreadContext *tc, VPtr bufp) /// Target time() function. template SyscallReturn -timeFunc(SyscallDesc *desc, ThreadContext *tc, Addr taddr) +timeFunc(SyscallDesc *desc, ThreadContext *tc, VPtr<> taddr) { typename OS::time_t sec, usec; getElapsedTimeMicro(sec, usec); @@ -2192,7 +2196,7 @@ socketFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn socketpairFunc(SyscallDesc *desc, ThreadContext *tc, - int domain, int type, int prot, Addr svPtr) + int domain, int type, int prot, VPtr<> svPtr) { auto p = tc->getProcessPtr(); @@ -2382,7 +2386,7 @@ selectFunc(SyscallDesc *desc, ThreadContext *tc, int nfds, template SyscallReturn readFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, int nbytes) + int tgt_fd, VPtr<> buf_ptr, int nbytes) { auto p = tc->getProcessPtr(); @@ -2410,7 +2414,7 @@ readFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn writeFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr buf_ptr, int nbytes) + int tgt_fd, VPtr<> buf_ptr, int nbytes) { auto p = tc->getProcessPtr(); @@ -2449,7 +2453,7 @@ writeFunc(SyscallDesc *desc, ThreadContext *tc, template SyscallReturn wait4Func(SyscallDesc *desc, ThreadContext *tc, - pid_t pid, Addr statPtr, int options, Addr rusagePtr) + pid_t pid, VPtr<> statPtr, int options, VPtr<> rusagePtr) { auto p = tc->getProcessPtr(); @@ -2507,7 +2511,7 @@ success: template SyscallReturn acceptFunc(SyscallDesc *desc, ThreadContext *tc, - int tgt_fd, Addr addrPtr, Addr lenPtr) + int tgt_fd, VPtr<> addrPtr, VPtr<> lenPtr) { struct sockaddr sa; socklen_t addrLen; -- 2.30.2