From: Gabe Black Date: Thu, 28 Nov 2019 06:53:47 +0000 (-0800) Subject: sim: Use variadic GuestABI arguments in a few additional syscalls. X-Git-Tag: v20.0.0.0~396 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=382dda67dc88bb5ed4a09ebd4b63ff28954ed679;p=gem5.git sim: Use variadic GuestABI arguments in a few additional syscalls. Jira Issue: https://gem5.atlassian.net/browse/GEM5-187 Change-Id: Ib2f193e7409859469c853e11f121eba82b3c0ddc Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23196 Reviewed-by: Bobby R. Bruce Maintainer: Bobby R. Bruce Tested-by: kokoro --- diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index 4e69d76c8..4084009ba 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -740,13 +740,10 @@ dup2Func(SyscallDesc *desc, int num, ThreadContext *tc, } SyscallReturn -fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc) +fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc, + int tgt_fd, int cmd, GuestABI::VarArgs varargs) { - int arg; - int index = 0; auto p = tc->getProcessPtr(); - int tgt_fd = p->getSyscallArg(tc, index); - int cmd = p->getSyscallArg(tc, index); auto hbfdp = std::dynamic_pointer_cast((*p->fds)[tgt_fd]); if (!hbfdp) @@ -760,7 +757,7 @@ fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc) return coe & FD_CLOEXEC; case F_SETFD: { - arg = p->getSyscallArg(tc, index); + int arg = varargs.get(); arg ? hbfdp->setCOE(true) : hbfdp->setCOE(false); return 0; } @@ -773,7 +770,7 @@ fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc) // subsequent fcntls. case F_GETFL: case F_SETFL: { - arg = p->getSyscallArg(tc, index); + int arg = varargs.get(); int rv = fcntl(sim_fd, cmd, arg); return (rv == -1) ? -errno : rv; } @@ -785,18 +782,16 @@ fcntlFunc(SyscallDesc *desc, int num, ThreadContext *tc) } SyscallReturn -fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc) +fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc, + int tgt_fd, int cmd) { - int index = 0; auto p = tc->getProcessPtr(); - int tgt_fd = p->getSyscallArg(tc, index); auto hbfdp = std::dynamic_pointer_cast((*p->fds)[tgt_fd]); if (!hbfdp) return -EBADF; int sim_fd = hbfdp->getSimFD(); - int cmd = p->getSyscallArg(tc, index); switch (cmd) { case 33: //F_GETLK64 warn("fcntl64(%d, F_GETLK64) not supported, error returned\n", tgt_fd); diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index a6f04097f..5a4811fb2 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -99,6 +99,7 @@ #include "params/Process.hh" #include "sim/emul_driver.hh" #include "sim/futex_map.hh" +#include "sim/guest_abi.hh" #include "sim/process.hh" #include "sim/syscall_debug_macros.hh" #include "sim/syscall_desc.hh" @@ -267,10 +268,12 @@ SyscallReturn dup2Func(SyscallDesc *desc, int num, 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, int num, ThreadContext *tc, + int tgt_fd, int cmd, GuestABI::VarArgs varargs); /// Target fcntl64() handler. -SyscallReturn fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc); +SyscallReturn fcntl64Func(SyscallDesc *desc, int num, ThreadContext *tc, + int tgt_fd, int cmd); /// Target pipe() handler. SyscallReturn pipeFunc(SyscallDesc *desc, int num, ThreadContext *tc); @@ -709,14 +712,11 @@ copyOutStatfsBuf(PortProxy &mem, Addr addr, /// not TTYs to provide repeatable results. template SyscallReturn -ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) +ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, + int tgt_fd, unsigned req, GuestABI::VarArgs varargs) { - int index = 0; auto p = tc->getProcessPtr(); - int tgt_fd = p->getSyscallArg(tc, index); - unsigned req = p->getSyscallArg(tc, index); - DPRINTF_SYSCALL(Verbose, "ioctl(%d, 0x%x, ...)\n", tgt_fd, req); if (OS::isTtyReq(req)) @@ -735,7 +735,7 @@ ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) switch (req) { case SIOCGIFCONF: { - Addr conf_addr = p->getSyscallArg(tc, index); + Addr conf_addr = varargs.get(); BufferArg conf_arg(conf_addr, sizeof(ifconf)); conf_arg.copyIn(tc->getVirtProxy()); @@ -765,7 +765,7 @@ ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) case SIOCGIFHWADDR: #endif case SIOCGIFMTU: { - Addr req_addr = p->getSyscallArg(tc, index); + Addr req_addr = varargs.get(); BufferArg req_arg(req_addr, sizeof(ifreq)); req_arg.copyIn(tc->getVirtProxy()); @@ -1134,19 +1134,16 @@ fchmodFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, /// Target mremap() handler. template SyscallReturn -mremapFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) +mremapFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, + Addr start, uint64_t old_length, uint64_t new_length, uint64_t flags, + GuestABI::VarArgs varargs) { - int index = 0; auto process = tc->getProcessPtr(); - Addr start = process->getSyscallArg(tc, index); - uint64_t old_length = process->getSyscallArg(tc, index); - uint64_t new_length = process->getSyscallArg(tc, index); - uint64_t flags = process->getSyscallArg(tc, index); uint64_t provided_address = 0; bool use_provided_address = flags & OS::TGT_MREMAP_FIXED; if (use_provided_address) - provided_address = process->getSyscallArg(tc, index); + provided_address = varargs.get(); if ((start % TheISA::PageBytes != 0) || (provided_address % TheISA::PageBytes != 0)) {