Syscalls: Make system calls access arguments like a stack, not an array.
authorGabe Black <gblack@eecs.umich.edu>
Fri, 30 Oct 2009 07:44:55 +0000 (00:44 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Fri, 30 Oct 2009 07:44:55 +0000 (00:44 -0700)
When accessing arguments for a syscall, the position of an argument depends on
the policies of the ISA, how much space preceding arguments took up, and the
"alignment" of the index for this particular argument into the number of
possible storate locations. This change adjusts getSyscallArg to take its
index parameter by reference instead of value and to adjust it to point to the
possible location of the next argument on the stack, basically just after the
current one. This way, the rules for the new argument can be applied locally
without knowing about other arguments since those have already been taken into
account implicitly.

All system calls have also been changed to reflect the new interface. In a
number of cases this made the implementation clearer since it encourages
arguments to be collected in one place in order and then used as necessary
later, as opposed to scattering them throughout the function or using them in
place in long expressions. It also discourages using getSyscallArg over and
over to retrieve the same value when a temporary would do the job.

27 files changed:
src/arch/alpha/linux/process.cc
src/arch/alpha/process.cc
src/arch/alpha/process.hh
src/arch/alpha/tru64/process.cc
src/arch/arm/linux/process.cc
src/arch/arm/linux/process.hh
src/arch/arm/process.cc
src/arch/arm/process.hh
src/arch/mips/linux/process.cc
src/arch/mips/process.cc
src/arch/mips/process.hh
src/arch/power/linux/process.cc
src/arch/power/linux/process.hh
src/arch/power/process.cc
src/arch/power/process.hh
src/arch/sparc/linux/syscalls.cc
src/arch/sparc/process.cc
src/arch/sparc/process.hh
src/arch/sparc/solaris/process.cc
src/arch/x86/linux/syscalls.cc
src/arch/x86/process.cc
src/arch/x86/process.hh
src/kern/tru64/tru64.hh
src/sim/process.cc
src/sim/process.hh
src/sim/syscall_emul.cc
src/sim/syscall_emul.hh

index 0f09e472b707f48858cc33209a65ae075a2859c5..a653d7845ffae9a0274211f5dfe471119a9d3ad4 100644 (file)
@@ -48,7 +48,8 @@ static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
 
     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "m5.eecs.umich.edu");
@@ -67,13 +68,15 @@ static SyscallReturn
 osf_getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                    ThreadContext *tc)
 {
-    unsigned op = process->getSyscallArg(tc, 0);
+    int index = 0;
+    unsigned op = process->getSyscallArg(tc, index);
+    Addr bufPtr = process->getSyscallArg(tc, index);
     // unsigned nbytes = process->getSyscallArg(tc, 2);
 
     switch (op) {
 
       case 45: { // GSI_IEEE_FP_CONTROL
-          TypedBufferArg<uint64_t> fpcr(process->getSyscallArg(tc, 1));
+          TypedBufferArg<uint64_t> fpcr(bufPtr);
           // I don't think this exactly matches the HW FPCR
           *fpcr = 0;
           fpcr.copyOut(tc->getMemPort());
@@ -94,13 +97,15 @@ static SyscallReturn
 osf_setsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                    ThreadContext *tc)
 {
-    unsigned op = process->getSyscallArg(tc, 0);
+    int index = 0;
+    unsigned op = process->getSyscallArg(tc, index);
+    Addr bufPtr = process->getSyscallArg(tc, index);
     // unsigned nbytes = process->getSyscallArg(tc, 2);
 
     switch (op) {
 
       case 14: { // SSI_IEEE_FP_CONTROL
-          TypedBufferArg<uint64_t> fpcr(process->getSyscallArg(tc, 1));
+          TypedBufferArg<uint64_t> fpcr(bufPtr);
           // I don't think this exactly matches the HW FPCR
           fpcr.copyIn(tc->getMemPort());
           DPRINTFR(SyscallVerbose, "osf_setsysinfo(SSI_IEEE_FP_CONTROL): "
index 6aad45da89a616a997410c591085b13c381031e1..9d75d5fa144d24ed3ef8f5f7964f75004476ca18 100644 (file)
@@ -193,10 +193,10 @@ AlphaLiveProcess::startup()
 }
 
 AlphaISA::IntReg
-AlphaLiveProcess::getSyscallArg(ThreadContext *tc, int i)
+AlphaLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     assert(i < 6);
-    return tc->readIntReg(FirstArgumentReg + i);
+    return tc->readIntReg(FirstArgumentReg + i++);
 }
 
 void
index 6d083c5ac29831f2bbb0f63969910786afce1efe..36b25a48efd88f300ec251aae3524a80296706e3 100644 (file)
@@ -44,7 +44,7 @@ class AlphaLiveProcess : public LiveProcess
     void argsInit(int intSize, int pageSize);
 
   public:
-    AlphaISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+    AlphaISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
     void setSyscallArg(ThreadContext *tc, int i, AlphaISA::IntReg val);
     void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
 };
index 8fa3cdedacff789761f343f2d9d22acccdc490a2..b039fbe1954a3d69c02291ff694669c0065f7923 100644 (file)
@@ -45,7 +45,8 @@ static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    TypedBufferArg<AlphaTru64::utsname> name(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<AlphaTru64::utsname> name(process->getSyscallArg(tc, index));
 
     strcpy(name->sysname, "OSF1");
     strcpy(name->nodename, "m5.eecs.umich.edu");
@@ -62,35 +63,36 @@ static SyscallReturn
 getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                ThreadContext *tc)
 {
-    unsigned op = process->getSyscallArg(tc, 0);
-    unsigned nbytes = process->getSyscallArg(tc, 2);
+    int index = 0;
+    unsigned op = process->getSyscallArg(tc, index);
+    Addr bufPtr = process->getSyscallArg(tc, index);
+    unsigned nbytes = process->getSyscallArg(tc, index);
 
     switch (op) {
 
       case AlphaTru64::GSI_MAX_CPU: {
-          TypedBufferArg<uint32_t> max_cpu(process->getSyscallArg(tc, 1));
+          TypedBufferArg<uint32_t> max_cpu(bufPtr);
           *max_cpu = htog((uint32_t)process->numCpus());
           max_cpu.copyOut(tc->getMemPort());
           return 1;
       }
 
       case AlphaTru64::GSI_CPUS_IN_BOX: {
-          TypedBufferArg<uint32_t> cpus_in_box(process->getSyscallArg(tc, 1));
+          TypedBufferArg<uint32_t> cpus_in_box(bufPtr);
           *cpus_in_box = htog((uint32_t)process->numCpus());
           cpus_in_box.copyOut(tc->getMemPort());
           return 1;
       }
 
       case AlphaTru64::GSI_PHYSMEM: {
-          TypedBufferArg<uint64_t> physmem(process->getSyscallArg(tc, 1));
+          TypedBufferArg<uint64_t> physmem(bufPtr);
           *physmem = htog((uint64_t)1024 * 1024);  // physical memory in KB
           physmem.copyOut(tc->getMemPort());
           return 1;
       }
 
       case AlphaTru64::GSI_CPU_INFO: {
-          TypedBufferArg<AlphaTru64::cpu_info>
-              infop(process->getSyscallArg(tc, 1));
+          TypedBufferArg<AlphaTru64::cpu_info> infop(bufPtr);
 
           infop->current_cpu = htog(0);
           infop->cpus_in_box = htog(process->numCpus());
@@ -107,14 +109,14 @@ getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
       }
 
       case AlphaTru64::GSI_PROC_TYPE: {
-          TypedBufferArg<uint64_t> proc_type(process->getSyscallArg(tc, 1));
+          TypedBufferArg<uint64_t> proc_type(bufPtr);
           *proc_type = htog((uint64_t)11);
           proc_type.copyOut(tc->getMemPort());
           return 1;
       }
 
       case AlphaTru64::GSI_PLATFORM_NAME: {
-          BufferArg bufArg(process->getSyscallArg(tc, 1), nbytes);
+          BufferArg bufArg(bufPtr, nbytes);
           strncpy((char *)bufArg.bufferPtr(),
                   "COMPAQ Professional Workstation XP1000",
                   nbytes);
@@ -123,7 +125,7 @@ getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
       }
 
       case AlphaTru64::GSI_CLK_TCK: {
-          TypedBufferArg<uint64_t> clk_hz(process->getSyscallArg(tc, 1));
+          TypedBufferArg<uint64_t> clk_hz(bufPtr);
           *clk_hz = htog((uint64_t)1024);
           clk_hz.copyOut(tc->getMemPort());
           return 1;
@@ -142,12 +144,13 @@ static SyscallReturn
 setsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                ThreadContext *tc)
 {
-    unsigned op = process->getSyscallArg(tc, 0);
+    int index = 0;
+    unsigned op = process->getSyscallArg(tc, index);
 
     switch (op) {
       case AlphaTru64::SSI_IEEE_FP_CONTROL:
         warn("setsysinfo: ignoring ieee_set_fp_control() arg 0x%x\n",
-             process->getSyscallArg(tc, 1));
+             process->getSyscallArg(tc, index));
         break;
 
       default:
@@ -165,17 +168,19 @@ tableFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     using namespace std;
 
-    int id = process->getSyscallArg(tc, 0);      // table ID
-    int index = process->getSyscallArg(tc, 1);   // index into table
+    int argIndex = 0;
+    int id = process->getSyscallArg(tc, argIndex);    // table ID
+    int index = process->getSyscallArg(tc, argIndex); // index into table
+    Addr bufPtr = process->getSyscallArg(tc, argIndex);
     // arg 2 is buffer pointer; type depends on table ID
-    int nel = process->getSyscallArg(tc, 3);     // number of elements
-    int lel = process->getSyscallArg(tc, 4);     // expected element size
+    int nel = process->getSyscallArg(tc, argIndex);   // number of elements
+    int lel = process->getSyscallArg(tc, argIndex);   // expected element size
 
     switch (id) {
       case AlphaTru64::TBL_SYSINFO: {
           if (index != 0 || nel != 1 || lel != sizeof(Tru64::tbl_sysinfo))
               return -EINVAL;
-          TypedBufferArg<Tru64::tbl_sysinfo> elp(process->getSyscallArg(tc, 2));
+          TypedBufferArg<Tru64::tbl_sysinfo> elp(bufPtr);
 
           const int clk_hz = one_million;
           elp->si_user = htog(curTick / (Clock::Frequency / clk_hz));
index a7f36e18d45c5dc432b59871b00c5660b8951428..f909d871ae72da6cf86835a808dc0a0183fb3ebd 100644 (file)
@@ -50,7 +50,8 @@ static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
 
     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "m5.eecs.umich.edu");
@@ -417,7 +418,8 @@ static SyscallReturn
 setTLSFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    uint32_t tlsPtr = process->getSyscallArg(tc, 0);
+    int index = 0;
+    uint32_t tlsPtr = process->getSyscallArg(tc, index);
 
     tc->getMemPort()->writeBlob(ArmLinuxProcess::commPage + 0x0ff0,
                                 (uint8_t *)&tlsPtr, sizeof(tlsPtr));
@@ -511,12 +513,12 @@ ArmLinuxProcess::startup()
 }
 
 ArmISA::IntReg
-ArmLinuxProcess::getSyscallArg(ThreadContext *tc, int i)
+ArmLinuxProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     // Linux apparently allows more parameter than the ABI says it should.
     // This limit may need to be increased even further.
     assert(i < 6);
-    return tc->readIntReg(ArgumentReg0 + i);
+    return tc->readIntReg(ArgumentReg0 + i++);
 }
 
 void
index 53b3781d23c88d88e37e14cd743720bfe51ee311..ab836fab2273c61e447a90faa1be76a7a341d17e 100644 (file)
@@ -44,7 +44,7 @@ class ArmLinuxProcess : public ArmLiveProcess
 
     void startup();
 
-    ArmISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+    ArmISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
     void setSyscallArg(ThreadContext *tc, int i, ArmISA::IntReg val);
 
     /// The target system's hostname.
index cd7cc9736e878aad015d9cacf3569f4f75b6fa60..702922a4330b5be55c4e1470f516edf9465aa40a 100644 (file)
@@ -324,10 +324,10 @@ ArmLiveProcess::argsInit(int intSize, int pageSize)
 }
 
 ArmISA::IntReg
-ArmLiveProcess::getSyscallArg(ThreadContext *tc, int i)
+ArmLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     assert(i < 4);
-    return tc->readIntReg(ArgumentReg0 + i);
+    return tc->readIntReg(ArgumentReg0 + i++);
 }
 
 void
index 8954d371947cfea78300611c42a3983b4c95cef3..f793892d09bf488e7ea7d6d577730d21ebdc8285 100644 (file)
@@ -53,7 +53,7 @@ class ArmLiveProcess : public LiveProcess
   public:
     void argsInit(int intSize, int pageSize);
 
-    ArmISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+    ArmISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
     void setSyscallArg(ThreadContext *tc, int i, ArmISA::IntReg val);
     void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
 };
index dde3a4efded2284236fb18853a9bc4cd1b5af596..c2a05b73b7a83af6acb6c4728c57ce61829bd7ca 100644 (file)
@@ -51,7 +51,8 @@ static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
 
     strcpy(name->sysname, "Linux");
     strcpy(name->nodename,"m5.eecs.umich.edu");
@@ -70,14 +71,16 @@ static SyscallReturn
 sys_getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                    ThreadContext *tc)
 {
-    unsigned op = process->getSyscallArg(tc, 0);
-    // unsigned nbytes = process->getSyscallArg(tc, 2);
+    int index = 0;
+    unsigned op = process->getSyscallArg(tc, index);
+    unsigned bufPtr = process->getSyscallArg(tc, index);
+    // unsigned nbytes = process->getSyscallArg(tc, index);
 
     switch (op) {
       case 45:
         { 
             // GSI_IEEE_FP_CONTROL
-            TypedBufferArg<uint64_t> fpcr(process->getSyscallArg(tc, 1));
+            TypedBufferArg<uint64_t> fpcr(bufPtr);
             // I don't think this exactly matches the HW FPCR
             *fpcr = 0;
             fpcr.copyOut(tc->getMemPort());
@@ -97,15 +100,17 @@ static SyscallReturn
 sys_setsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                    ThreadContext *tc)
 {
-    unsigned op = process->getSyscallArg(tc, 0);
-    // unsigned nbytes = process->getSyscallArg(tc, 2);
+    int index = 0;
+    unsigned op = process->getSyscallArg(tc, index);
+    Addr bufPtr = process->getSyscallArg(tc, index);
+    // unsigned nbytes = process->getSyscallArg(tc, index);
 
     switch (op) {
 
       case 14:
         {
             // SSI_IEEE_FP_CONTROL
-            TypedBufferArg<uint64_t> fpcr(process->getSyscallArg(tc, 1));
+            TypedBufferArg<uint64_t> fpcr(bufPtr);
             // I don't think this exactly matches the HW FPCR
             fpcr.copyIn(tc->getMemPort());
             DPRINTFR(SyscallVerbose, "sys_setsysinfo(SSI_IEEE_FP_CONTROL): "
index b9f608922ed96d17586c366f37201d49826ffdb5..d96b0c81c698ee751dd7e54cb2cc792465791beb 100644 (file)
@@ -147,10 +147,10 @@ MipsLiveProcess::argsInit(int intSize, int pageSize)
 
 
 MipsISA::IntReg
-MipsLiveProcess::getSyscallArg(ThreadContext *tc, int i)
+MipsLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     assert(i < 6);
-    return tc->readIntReg(FirstArgumentReg + i);
+    return tc->readIntReg(FirstArgumentReg + i++);
 }
 
 void
index b8f4de20abb86167469a8b2fe923a30f0d40906f..f35ec8554255635c358ecbd23d5c1df7a00db054 100644 (file)
@@ -50,7 +50,7 @@ class MipsLiveProcess : public LiveProcess
     void argsInit(int intSize, int pageSize);
 
   public:
-    MipsISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+    MipsISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
     void setSyscallArg(ThreadContext *tc, int i, MipsISA::IntReg val);
     void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
 };
index b03ccfc8c11342eef4a669bc4411d87f6bc70b34..504d0e33421f3097b2ce9c78d62beb60df2dc5f4 100644 (file)
@@ -52,7 +52,8 @@ static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
 
     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "m5.eecs.umich.edu");
@@ -437,12 +438,12 @@ PowerLinuxProcess::startup()
 }
 
 PowerISA::IntReg
-PowerLinuxProcess::getSyscallArg(ThreadContext *tc, int i)
+PowerLinuxProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     // Linux apparently allows more parameter than the ABI says it should.
     // This limit may need to be increased even further.
     assert(i < 6);
-    return tc->readIntReg(ArgumentReg0 + i);
+    return tc->readIntReg(ArgumentReg0 + i++);
 }
 
 void
index 78b0eef7fedbfe46ca04524706941a1fe0266882..db6759a7737d083b0b860680782a3c44e26e57bb 100644 (file)
@@ -46,7 +46,7 @@ class PowerLinuxProcess : public PowerLiveProcess
 
     void startup();
 
-    PowerISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+    PowerISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
     void setSyscallArg(ThreadContext *tc, int i, PowerISA::IntReg val);
 
     /// Array of syscall descriptors, indexed by call number.
index 8828a1a9343a9515ffef8b34f6d5341e15587972..92f993e4c756d523b1f16f6bfb3c22a9c8c9f4ea 100644 (file)
@@ -266,10 +266,10 @@ PowerLiveProcess::argsInit(int intSize, int pageSize)
 }
 
 PowerISA::IntReg
-PowerLiveProcess::getSyscallArg(ThreadContext *tc, int i)
+PowerLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     assert(i < 5);
-    return tc->readIntReg(ArgumentReg0 + i);
+    return tc->readIntReg(ArgumentReg0 + i++);
 }
 
 void
index dae776c4c4414376009a0ef36c5d1585b6851034..ede75f05f10ec07fe21fa79e6db5c4754e32f643 100644 (file)
@@ -50,7 +50,7 @@ class PowerLiveProcess : public LiveProcess
 
   public:
     void argsInit(int intSize, int pageSize);
-    PowerISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+    PowerISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
     void setSyscallArg(ThreadContext *tc, int i, PowerISA::IntReg val);
     void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
 };
index c508039762685da08c7a0e2a4e8b8f2430d49cee..874ddc005360b9e46fc921267f7be96f81ac4223 100644 (file)
@@ -41,7 +41,8 @@ static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
         ThreadContext *tc)
 {
-    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
 
     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "m5.eecs.umich.edu");
@@ -59,9 +60,10 @@ SyscallReturn getresuidFunc(SyscallDesc *desc, int num,
         LiveProcess *p, ThreadContext *tc)
 {
     const IntReg id = htog(100);
-    Addr ruid = p->getSyscallArg(tc, 0);
-    Addr euid = p->getSyscallArg(tc, 1);
-    Addr suid = p->getSyscallArg(tc, 2);
+    int index = 0;
+    Addr ruid = p->getSyscallArg(tc, index);
+    Addr euid = p->getSyscallArg(tc, index);
+    Addr suid = p->getSyscallArg(tc, index);
     //Handle the EFAULT case
     //Set the ruid
     if(ruid)
index 89e8535737761d62a09fb62ba2074c7190323ad6..7e01f6b07a029b053afac1aecc8ae1c6b047222a 100644 (file)
@@ -514,10 +514,10 @@ void Sparc64LiveProcess::flushWindows(ThreadContext *tc)
 }
 
 IntReg
-Sparc32LiveProcess::getSyscallArg(ThreadContext *tc, int i)
+Sparc32LiveProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     assert(i < 6);
-    return bits(tc->readIntReg(FirstArgumentReg + i), 31, 0);
+    return bits(tc->readIntReg(FirstArgumentReg + i++), 31, 0);
 }
 
 void
@@ -528,10 +528,10 @@ Sparc32LiveProcess::setSyscallArg(ThreadContext *tc, int i, IntReg val)
 }
 
 IntReg
-Sparc64LiveProcess::getSyscallArg(ThreadContext *tc, int i)
+Sparc64LiveProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     assert(i < 6);
-    return tc->readIntReg(FirstArgumentReg + i);
+    return tc->readIntReg(FirstArgumentReg + i++);
 }
 
 void
index fdb9734bac61ee900cd195246205e203defc21b9..cca312e0ab9d54cde4dd9dafb9cf125dc988d086 100644 (file)
@@ -95,7 +95,7 @@ class Sparc32LiveProcess : public SparcLiveProcess
 
     void flushWindows(ThreadContext *tc);
 
-    SparcISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+    SparcISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
     void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
 };
 
@@ -123,7 +123,7 @@ class Sparc64LiveProcess : public SparcLiveProcess
 
     void flushWindows(ThreadContext *tc);
 
-    SparcISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+    SparcISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
     void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
 };
 
index eafb488df776f6ff76fdfc55d8eda14c6080c45e..24abd86879685678a94013ffd8202573c73bcc1a 100644 (file)
@@ -48,7 +48,8 @@ static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    TypedBufferArg<Solaris::utsname> name(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<Solaris::utsname> name(process->getSyscallArg(tc, index));
 
     strcpy(name->sysname, "SunOS");
     strcpy(name->nodename, "m5.eecs.umich.edu");
index 14b3fa69b85649c48c81d6a7bfa7867b55ead2cd..4c29559fb1c3806a0d5b49025b447d02edc15730 100644 (file)
@@ -68,7 +68,8 @@ static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
 
     strcpy(name->sysname, "Linux");
     strcpy(name->nodename, "m5.eecs.umich.edu");
@@ -94,8 +95,9 @@ archPrctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     };
 
     //First argument is the code, second is the address
-    int code = process->getSyscallArg(tc, 0);
-    uint64_t addr = process->getSyscallArg(tc, 1);
+    int index = 0;
+    int code = process->getSyscallArg(tc, index);
+    uint64_t addr = process->getSyscallArg(tc, index);
     uint64_t fsBase, gsBase;
     TranslatingPort *p = tc->getMemPort();
     switch(code)
@@ -159,7 +161,8 @@ setThreadArea32Func(SyscallDesc *desc, int callnum,
 
     assert((maxTLSEntry + 1) * sizeof(uint64_t) <= x86lp->gdtSize());
 
-    TypedBufferArg<UserDesc32> userDesc(process->getSyscallArg(tc, 0));
+    int argIndex = 0;
+    TypedBufferArg<UserDesc32> userDesc(process->getSyscallArg(tc, argIndex));
     TypedBufferArg<uint64_t>
         gdt(x86lp->gdtStart() + minTLSEntry * sizeof(uint64_t),
                 numTLSEntries * sizeof(uint64_t));
index f7678443d181035b08e305848ad1562934d02f6e..f7b3ce24ae16c5d06d59db5e97d37de62790fe0e 100644 (file)
@@ -698,10 +698,10 @@ X86LiveProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn return_value)
 }
 
 X86ISA::IntReg
-X86_64LiveProcess::getSyscallArg(ThreadContext *tc, int i)
+X86_64LiveProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     assert(i < NumArgumentRegs);
-    return tc->readIntReg(ArgumentReg[i]);
+    return tc->readIntReg(ArgumentReg[i++]);
 }
 
 void
@@ -712,10 +712,21 @@ X86_64LiveProcess::setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val)
 }
 
 X86ISA::IntReg
-I386LiveProcess::getSyscallArg(ThreadContext *tc, int i)
+I386LiveProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
     assert(i < NumArgumentRegs32);
-    return tc->readIntReg(ArgumentReg32[i]);
+    return tc->readIntReg(ArgumentReg32[i++]);
+}
+
+X86ISA::IntReg
+I386LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
+{
+    assert(width == 32 || width == 64);
+    assert(i < NumArgumentRegs);
+    uint64_t retVal = tc->readIntReg(ArgumentReg32[i++]) & mask(32);
+    if (width == 64)
+        retVal |= ((uint64_t)tc->readIntReg(ArgumentReg[i++]) << 32);
+    return retVal;
 }
 
 void
index cd6d99e667c8a6f5650b213375b0234664d0996c..4d031bd5a37986200f03011fab2d2e884d8ecfff 100644 (file)
@@ -105,7 +105,7 @@ namespace X86ISA
         void argsInit(int intSize, int pageSize);
         void startup();
 
-        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
         void setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val);
     };
 
@@ -130,7 +130,8 @@ namespace X86ISA
         void startup();
 
         void syscall(int64_t callnum, ThreadContext *tc);
-        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
+        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width);
         void setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val);
     };
 }
index c2bdd27764af549289051fe754b7a08ea5545815..033f30946139522eddd845ec483d6df4c4f92e48 100644 (file)
@@ -440,10 +440,11 @@ class Tru64 : public OperatingSystem
 #ifdef __CYGWIN__
         panic("getdirent not implemented on cygwin!");
 #else
-        int fd = process->sim_fd(process->getSyscallArg(tc, 0));
-        Addr tgt_buf = process->getSyscallArg(tc, 1);
-        int tgt_nbytes = process->getSyscallArg(tc, 2);
-        Addr tgt_basep = process->getSyscallArg(tc, 3);
+        int index = 0;
+        int fd = process->sim_fd(process->getSyscallArg(tc, index));
+        Addr tgt_buf = process->getSyscallArg(tc, index);
+        int tgt_nbytes = process->getSyscallArg(tc, index);
+        Addr tgt_basep = process->getSyscallArg(tc, index);
 
         char * const host_buf = new char[tgt_nbytes];
 
@@ -498,7 +499,8 @@ class Tru64 : public OperatingSystem
     {
         using namespace TheISA;
 
-        TypedBufferArg<Tru64::sigcontext> sc(process->getSyscallArg(tc, 0));
+        int index = 0;
+        TypedBufferArg<Tru64::sigcontext> sc(process->getSyscallArg(tc, index));
 
         sc.copyIn(tc->getMemPort());
 
@@ -530,7 +532,8 @@ class Tru64 : public OperatingSystem
     {
         using namespace TheISA;
 
-        TypedBufferArg<Tru64::vm_stack> argp(process->getSyscallArg(tc, 0));
+        int index = 0;
+        TypedBufferArg<Tru64::vm_stack> argp(process->getSyscallArg(tc, index));
 
         argp.copyIn(tc->getMemPort());
 
@@ -578,9 +581,10 @@ class Tru64 : public OperatingSystem
         using namespace std;
         using namespace TheISA;
 
+        int index = 0;
         TypedBufferArg<Tru64::nxm_task_attr>
-            attrp(process->getSyscallArg(tc, 0));
-        TypedBufferArg<Addr> configptr_ptr(process->getSyscallArg(tc, 1));
+            attrp(process->getSyscallArg(tc, index));
+        TypedBufferArg<Addr> configptr_ptr(process->getSyscallArg(tc, index));
 
         attrp.copyIn(tc->getMemPort());
 
@@ -712,10 +716,11 @@ class Tru64 : public OperatingSystem
         using namespace std;
         using namespace TheISA;
 
+        int index = 0;
         TypedBufferArg<Tru64::nxm_thread_attr>
-            attrp(process->getSyscallArg(tc, 0));
-        TypedBufferArg<uint64_t> kidp(process->getSyscallArg(tc, 1));
-        int thread_index = process->getSyscallArg(tc, 2);
+            attrp(process->getSyscallArg(tc, index));
+        TypedBufferArg<uint64_t> kidp(process->getSyscallArg(tc, index));
+        int thread_index = process->getSyscallArg(tc, index);
 
         // get attribute args
         attrp.copyIn(tc->getMemPort());
@@ -834,11 +839,12 @@ class Tru64 : public OperatingSystem
     {
         using namespace std;
 
-        uint64_t tid = process->getSyscallArg(tc, 0);
-        uint64_t secs = process->getSyscallArg(tc, 1);
-        uint64_t flags = process->getSyscallArg(tc, 2);
-        uint64_t action = process->getSyscallArg(tc, 3);
-        uint64_t usecs = process->getSyscallArg(tc, 4);
+        int index = 0;
+        uint64_t tid = process->getSyscallArg(tc, index);
+        uint64_t secs = process->getSyscallArg(tc, index);
+        uint64_t flags = process->getSyscallArg(tc, index);
+        uint64_t action = process->getSyscallArg(tc, index);
+        uint64_t usecs = process->getSyscallArg(tc, index);
 
         cout << tc->getCpuPtr()->name() << ": nxm_thread_block " << tid << " "
              << secs << " " << flags << " " << action << " " << usecs << endl;
@@ -853,11 +859,12 @@ class Tru64 : public OperatingSystem
     {
         using namespace std;
 
-        Addr uaddr = process->getSyscallArg(tc, 0);
-        uint64_t val = process->getSyscallArg(tc, 1);
-        uint64_t secs = process->getSyscallArg(tc, 2);
-        uint64_t usecs = process->getSyscallArg(tc, 3);
-        uint64_t flags = process->getSyscallArg(tc, 4);
+        int index = 0;
+        Addr uaddr = process->getSyscallArg(tc, index);
+        uint64_t val = process->getSyscallArg(tc, index);
+        uint64_t secs = process->getSyscallArg(tc, index);
+        uint64_t usecs = process->getSyscallArg(tc, index);
+        uint64_t flags = process->getSyscallArg(tc, index);
 
         BaseCPU *cpu = tc->getCpuPtr();
 
@@ -876,7 +883,8 @@ class Tru64 : public OperatingSystem
     {
         using namespace std;
 
-        Addr uaddr = process->getSyscallArg(tc, 0);
+        int index = 0;
+        Addr uaddr = process->getSyscallArg(tc, index);
 
         cout << tc->getCpuPtr()->name() << ": nxm_unblock "
              << hex << uaddr << dec << endl;
@@ -977,7 +985,8 @@ class Tru64 : public OperatingSystem
     m5_mutex_lockFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                       ThreadContext *tc)
     {
-        Addr uaddr = process->getSyscallArg(tc, 0);
+        int index = 0;
+        Addr uaddr = process->getSyscallArg(tc, index);
 
         m5_lock_mutex(uaddr, process, tc);
 
@@ -994,7 +1003,8 @@ class Tru64 : public OperatingSystem
     {
         using namespace TheISA;
 
-        Addr uaddr = process->getSyscallArg(tc, 0);
+        int index = 0;
+        Addr uaddr = process->getSyscallArg(tc, index);
         TypedBufferArg<uint64_t> lockp(uaddr);
 
         lockp.copyIn(tc->getMemPort());
@@ -1014,7 +1024,8 @@ class Tru64 : public OperatingSystem
     m5_mutex_unlockFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                         ThreadContext *tc)
     {
-        Addr uaddr = process->getSyscallArg(tc, 0);
+        int index = 0;
+        Addr uaddr = process->getSyscallArg(tc, index);
 
         m5_unlock_mutex(uaddr, process, tc);
 
@@ -1026,7 +1037,8 @@ class Tru64 : public OperatingSystem
     m5_cond_signalFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                        ThreadContext *tc)
     {
-        Addr cond_addr = process->getSyscallArg(tc, 0);
+        int index = 0;
+        Addr cond_addr = process->getSyscallArg(tc, index);
 
         // Wake up one process waiting on the condition variable.
         activate_waiting_context(cond_addr, process);
@@ -1039,7 +1051,8 @@ class Tru64 : public OperatingSystem
     m5_cond_broadcastFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                           ThreadContext *tc)
     {
-        Addr cond_addr = process->getSyscallArg(tc, 0);
+        int index = 0;
+        Addr cond_addr = process->getSyscallArg(tc, index);
 
         activate_waiting_context(cond_addr, process, true);
 
@@ -1053,8 +1066,9 @@ class Tru64 : public OperatingSystem
     {
         using namespace TheISA;
 
-        Addr cond_addr = process->getSyscallArg(tc, 0);
-        Addr lock_addr = process->getSyscallArg(tc, 1);
+        int index = 0;
+        Addr cond_addr = process->getSyscallArg(tc, index);
+        Addr lock_addr = process->getSyscallArg(tc, index);
         TypedBufferArg<uint64_t> condp(cond_addr);
         TypedBufferArg<uint64_t> lockp(lock_addr);
 
@@ -1086,10 +1100,11 @@ class Tru64 : public OperatingSystem
     indirectSyscallFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
                         ThreadContext *tc)
     {
-        int new_callnum = process->getSyscallArg(tc, 0);
+        int index = 0;
+        int new_callnum = process->getSyscallArg(tc, index);
 
         for (int i = 0; i < 5; ++i)
-            process->setSyscallArg(tc, i, process->getSyscallArg(tc, i+1));
+            process->setSyscallArg(tc, i, process->getSyscallArg(tc, index));
 
 
         SyscallDesc *new_desc = process->getDesc(new_callnum);
index cf0f2b84d2b2eef35cffc0dfaec3defde12ae59e..e71d6441f968a7c8154c790e2fb5b76148f281c6 100644 (file)
@@ -647,6 +647,12 @@ LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
     desc->doSyscall(callnum, this, tc);
 }
 
+IntReg
+LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
+{
+    return getSyscallArg(tc, i);
+}
+
 LiveProcess *
 LiveProcess::create(LiveProcessParams * params)
 {
index 7922ce0732a50bc88ae105de3ee9be7af61896bc..ab9d64cf337083f3df967e66222c4aa620b5806c 100644 (file)
@@ -325,7 +325,9 @@ class LiveProcess : public Process
     std::string getcwd() const { return cwd; }
 
     virtual void syscall(int64_t callnum, ThreadContext *tc);
-    virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int i) = 0;
+
+    virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i) = 0;
+    virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width);
     virtual void setSyscallArg(ThreadContext *tc,
             int i, TheISA::IntReg val) = 0;
     virtual void setSyscallReturn(ThreadContext *tc,
index 13ad043111c53ea5cd8533de331d757b0c1e4db9..d25f7b9fa10444119be1b367cf3b0dd2c9abd79c 100644 (file)
@@ -52,11 +52,14 @@ using namespace TheISA;
 void
 SyscallDesc::doSyscall(int callnum, LiveProcess *process, ThreadContext *tc)
 {
+    int index = 0;
     DPRINTFR(SyscallVerbose,
              "%d: %s: syscall %s called w/arguments %d,%d,%d,%d\n",
              curTick, tc->getCpuPtr()->name(), name,
-             process->getSyscallArg(tc, 0), process->getSyscallArg(tc, 1),
-             process->getSyscallArg(tc, 2), process->getSyscallArg(tc, 3));
+             process->getSyscallArg(tc, index),
+             process->getSyscallArg(tc, index),
+             process->getSyscallArg(tc, index),
+             process->getSyscallArg(tc, index));
 
     SyscallReturn retval = (*funcPtr)(this, callnum, process, tc);
 
@@ -82,8 +85,9 @@ SyscallReturn
 ignoreFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
            ThreadContext *tc)
 {
+    int index = 0;
     warn("ignoring syscall %s(%d, %d, ...)", desc->name,
-         process->getSyscallArg(tc, 0), process->getSyscallArg(tc, 1));
+         process->getSyscallArg(tc, index), process->getSyscallArg(tc, index));
 
     return 0;
 }
@@ -95,8 +99,9 @@ exitFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     if (process->system->numRunningContexts() == 1) {
         // Last running context... exit simulator
+        int index = 0;
         exitSimLoop("target called exit()",
-                    process->getSyscallArg(tc, 0) & 0xff);
+                    process->getSyscallArg(tc, index) & 0xff);
     } else {
         // other running threads... just halt this one
         tc->halt();
@@ -112,8 +117,9 @@ exitGroupFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     // really should just halt all thread contexts belonging to this
     // process in case there's another process running...
+    int index = 0;
     exitSimLoop("target called exit()",
-                process->getSyscallArg(tc, 0) & 0xff);
+                process->getSyscallArg(tc, index) & 0xff);
 
     return 1;
 }
@@ -130,7 +136,8 @@ SyscallReturn
 brkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     // change brk addr to first arg
-    Addr new_brk = p->getSyscallArg(tc, 0);
+    int index = 0;
+    Addr new_brk = p->getSyscallArg(tc, index);
 
     // in Linux at least, brk(0) returns the current break value
     // (note that the syscall and the glibc function have different behavior)
@@ -174,7 +181,8 @@ brkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 SyscallReturn
 closeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
-    int target_fd = p->getSyscallArg(tc, 0);
+    int index = 0;
+    int target_fd = p->getSyscallArg(tc, index);
     int status = close(p->sim_fd(target_fd));
     if (status >= 0)
         p->free_fd(target_fd);
@@ -185,9 +193,11 @@ closeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 SyscallReturn
 readFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
-    int fd = p->sim_fd(p->getSyscallArg(tc, 0));
-    int nbytes = p->getSyscallArg(tc, 2);
-    BufferArg bufArg(p->getSyscallArg(tc, 1), nbytes);
+    int index = 0;
+    int fd = p->sim_fd(p->getSyscallArg(tc, index));
+    Addr bufPtr = p->getSyscallArg(tc, index);
+    int nbytes = p->getSyscallArg(tc, index);
+    BufferArg bufArg(bufPtr, nbytes);
 
     int bytes_read = read(fd, bufArg.bufferPtr(), nbytes);
 
@@ -200,9 +210,11 @@ readFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 SyscallReturn
 writeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
-    int fd = p->sim_fd(p->getSyscallArg(tc, 0));
-    int nbytes = p->getSyscallArg(tc, 2);
-    BufferArg bufArg(p->getSyscallArg(tc, 1), nbytes);
+    int index = 0;
+    int fd = p->sim_fd(p->getSyscallArg(tc, index));
+    Addr bufPtr = p->getSyscallArg(tc, index);
+    int nbytes = p->getSyscallArg(tc, index);
+    BufferArg bufArg(bufPtr, nbytes);
 
     bufArg.copyIn(tc->getMemPort());
 
@@ -217,9 +229,10 @@ writeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 SyscallReturn
 lseekFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
-    int fd = p->sim_fd(p->getSyscallArg(tc, 0));
-    uint64_t offs = p->getSyscallArg(tc, 1);
-    int whence = p->getSyscallArg(tc, 2);
+    int index = 0;
+    int fd = p->sim_fd(p->getSyscallArg(tc, index));
+    uint64_t offs = p->getSyscallArg(tc, index);
+    int whence = p->getSyscallArg(tc, index);
 
     off_t result = lseek(fd, offs, whence);
 
@@ -230,11 +243,12 @@ lseekFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 SyscallReturn
 _llseekFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
-    int fd = p->sim_fd(p->getSyscallArg(tc, 0));
-    uint64_t offset_high = p->getSyscallArg(tc, 1);
-    uint32_t offset_low = p->getSyscallArg(tc, 2);
-    Addr result_ptr = p->getSyscallArg(tc, 3);
-    int whence = p->getSyscallArg(tc, 4);
+    int index = 0;
+    int fd = p->sim_fd(p->getSyscallArg(tc, index));
+    uint64_t offset_high = p->getSyscallArg(tc, index);
+    uint32_t offset_low = p->getSyscallArg(tc, index);
+    Addr result_ptr = p->getSyscallArg(tc, index);
+    int whence = p->getSyscallArg(tc, index);
 
     uint64_t offset = (offset_high << 32) | offset_low;
 
@@ -273,8 +287,10 @@ const char *hostname = "m5.eecs.umich.edu";
 SyscallReturn
 gethostnameFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
-    int name_len = p->getSyscallArg(tc, 1);
-    BufferArg name(p->getSyscallArg(tc, 0), name_len);
+    int index = 0;
+    Addr bufPtr = p->getSyscallArg(tc, index);
+    int name_len = p->getSyscallArg(tc, index);
+    BufferArg name(bufPtr, name_len);
 
     strncpy((char *)name.bufferPtr(), hostname, name_len);
 
@@ -287,8 +303,10 @@ SyscallReturn
 getcwdFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     int result = 0;
-    unsigned long size = p->getSyscallArg(tc, 1);
-    BufferArg buf(p->getSyscallArg(tc, 0), size);
+    int index;
+    Addr bufPtr = p->getSyscallArg(tc, index);
+    unsigned long size = p->getSyscallArg(tc, index);
+    BufferArg buf(bufPtr, size);
 
     // Is current working directory defined?
     string cwd = p->getcwd();
@@ -320,14 +338,17 @@ readlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     string path;
 
-    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, index)))
         return (TheISA::IntReg)-EFAULT;
 
     // Adjust path for current working directory
     path = p->fullPath(path);
 
-    size_t bufsiz = p->getSyscallArg(tc, 2);
-    BufferArg buf(p->getSyscallArg(tc, 1), bufsiz);
+    Addr bufPtr = p->getSyscallArg(tc, index);
+    size_t bufsiz = p->getSyscallArg(tc, index);
+
+    BufferArg buf(bufPtr, bufsiz);
 
     int result = readlink(path.c_str(), (char *)buf.bufferPtr(), bufsiz);
 
@@ -341,7 +362,8 @@ unlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     string path;
 
-    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, index)))
         return (TheISA::IntReg)-EFAULT;
 
     // Adjust path for current working directory
@@ -357,13 +379,14 @@ mkdirFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     string path;
 
-    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, index)))
         return (TheISA::IntReg)-EFAULT;
 
     // Adjust path for current working directory
     path = p->fullPath(path);
 
-    mode_t mode = p->getSyscallArg(tc, 1);
+    mode_t mode = p->getSyscallArg(tc, index);
 
     int result = mkdir(path.c_str(), mode);
     return (result == -1) ? -errno : result;
@@ -374,12 +397,13 @@ renameFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     string old_name;
 
-    if (!tc->getMemPort()->tryReadString(old_name, p->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(old_name, p->getSyscallArg(tc, index)))
         return -EFAULT;
 
     string new_name;
 
-    if (!tc->getMemPort()->tryReadString(new_name, p->getSyscallArg(tc, 1)))
+    if (!tc->getMemPort()->tryReadString(new_name, p->getSyscallArg(tc, index)))
         return -EFAULT;
 
     // Adjust path for current working directory
@@ -395,10 +419,11 @@ truncateFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     string path;
 
-    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, index)))
         return -EFAULT;
 
-    off_t length = p->getSyscallArg(tc, 1);
+    off_t length = p->getSyscallArg(tc, index);
 
     // Adjust path for current working directory
     path = p->fullPath(path);
@@ -411,12 +436,13 @@ SyscallReturn
 ftruncateFunc(SyscallDesc *desc, int num,
               LiveProcess *process, ThreadContext *tc)
 {
-    int fd = process->sim_fd(process->getSyscallArg(tc, 0));
+    int index = 0;
+    int fd = process->sim_fd(process->getSyscallArg(tc, index));
 
     if (fd < 0)
         return -EBADF;
 
-    off_t length = process->getSyscallArg(tc, 1);
+    off_t length = process->getSyscallArg(tc, index);
 
     int result = ftruncate(fd, length);
     return (result == -1) ? -errno : result;
@@ -426,13 +452,13 @@ SyscallReturn
 ftruncate64Func(SyscallDesc *desc, int num,
                 LiveProcess *process, ThreadContext *tc)
 {
-    int fd = process->sim_fd(process->getSyscallArg(tc, 0));
+    int index = 0;
+    int fd = process->sim_fd(process->getSyscallArg(tc, index));
 
     if (fd < 0)
         return -EBADF;
 
-    // I'm not sure why, but the length argument is in arg reg 3
-    loff_t length = process->getSyscallArg(tc, 3);
+    loff_t length = process->getSyscallArg(tc, index, 64);
 
     int result = ftruncate64(fd, length);
     return (result == -1) ? -errno : result;
@@ -454,13 +480,14 @@ chownFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     string path;
 
-    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path, p->getSyscallArg(tc, index)))
         return -EFAULT;
 
     /* XXX endianess */
-    uint32_t owner = p->getSyscallArg(tc, 1);
+    uint32_t owner = p->getSyscallArg(tc, index);
     uid_t hostOwner = owner;
-    uint32_t group = p->getSyscallArg(tc, 2);
+    uint32_t group = p->getSyscallArg(tc, index);
     gid_t hostGroup = group;
 
     // Adjust path for current working directory
@@ -473,15 +500,16 @@ chownFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 SyscallReturn
 fchownFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
 {
-    int fd = process->sim_fd(process->getSyscallArg(tc, 0));
+    int index = 0;
+    int fd = process->sim_fd(process->getSyscallArg(tc, index));
 
     if (fd < 0)
         return -EBADF;
 
     /* XXX endianess */
-    uint32_t owner = process->getSyscallArg(tc, 1);
+    uint32_t owner = process->getSyscallArg(tc, index);
     uid_t hostOwner = owner;
-    uint32_t group = process->getSyscallArg(tc, 2);
+    uint32_t group = process->getSyscallArg(tc, index);
     gid_t hostGroup = group;
 
     int result = fchown(fd, hostOwner, hostGroup);
@@ -492,11 +520,12 @@ fchownFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
 SyscallReturn
 dupFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
 {
-    int fd = process->sim_fd(process->getSyscallArg(tc, 0));
+    int index = 0;
+    int fd = process->sim_fd(process->getSyscallArg(tc, index));
     if (fd < 0)
         return -EBADF;
 
-    Process::FdMap *fdo = process->sim_fd_obj(process->getSyscallArg(tc, 0));
+    Process::FdMap *fdo = process->sim_fd_obj(fd);
 
     int result = dup(fd);
     return (result == -1) ? -errno :
@@ -508,12 +537,13 @@ SyscallReturn
 fcntlFunc(SyscallDesc *desc, int num, LiveProcess *process,
           ThreadContext *tc)
 {
-    int fd = process->getSyscallArg(tc, 0);
+    int index = 0;
+    int fd = process->getSyscallArg(tc, index);
 
     if (fd < 0 || process->sim_fd(fd) < 0)
         return -EBADF;
 
-    int cmd = process->getSyscallArg(tc, 1);
+    int cmd = process->getSyscallArg(tc, index);
     switch (cmd) {
       case 0: // F_DUPFD
         // if we really wanted to support this, we'd need to do it
@@ -550,12 +580,13 @@ SyscallReturn
 fcntl64Func(SyscallDesc *desc, int num, LiveProcess *process,
             ThreadContext *tc)
 {
-    int fd = process->getSyscallArg(tc, 0);
+    int index = 0;
+    int fd = process->getSyscallArg(tc, index);
 
     if (fd < 0 || process->sim_fd(fd) < 0)
         return -EBADF;
 
-    int cmd = process->getSyscallArg(tc, 1);
+    int cmd = process->getSyscallArg(tc, index);
     switch (cmd) {
       case 33: //F_GETLK64
         warn("fcntl64(%d, F_GETLK64) not supported, error returned\n", fd);
@@ -639,7 +670,8 @@ setuidFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
            ThreadContext *tc)
 {
     // can't fathom why a benchmark would call this.
-    warn("Ignoring call to setuid(%d)\n", process->getSyscallArg(tc, 0));
+    int index = 0;
+    warn("Ignoring call to setuid(%d)\n", process->getSyscallArg(tc, index));
     return 0;
 }
 
@@ -695,17 +727,20 @@ SyscallReturn
 cloneFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
            ThreadContext *tc)
 {
+    int index = 0;
+    IntReg flags = process->getSyscallArg(tc, index);
+    IntReg newStack = process->getSyscallArg(tc, index);
+
     DPRINTF(SyscallVerbose, "In sys_clone:\n");
-    DPRINTF(SyscallVerbose, " Flags=%llx\n", process->getSyscallArg(tc, 0));
-    DPRINTF(SyscallVerbose, " Child stack=%llx\n",
-            process->getSyscallArg(tc, 1));
+    DPRINTF(SyscallVerbose, " Flags=%llx\n", flags);
+    DPRINTF(SyscallVerbose, " Child stack=%llx\n", newStack);
 
 
-    if (process->getSyscallArg(tc, 0) != 0x10f00) {
+    if (flags != 0x10f00) {
         warn("This sys_clone implementation assumes flags "
              "CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD "
              "(0x10f00), and may not work correctly with given flags "
-             "0x%llx\n", process->getSyscallArg(tc, 0));
+             "0x%llx\n", flags);
     }
 
     ThreadContext* ctc; // child thread context
@@ -738,7 +773,7 @@ cloneFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
         #endif
 
         // Set up stack register
-        ctc->setIntReg(TheISA::StackPointerReg, process->getSyscallArg(tc, 1));
+        ctc->setIntReg(TheISA::StackPointerReg, newStack);
 
         // Set up syscall return values in parent and child
         ctc->setIntReg(ReturnValueReg, 0); // return value, child
index 0c51c7dec96d10f19c18494c4408e72b73a3935c..8fe53e266698d92d85aeb36f940557749bb70184 100644 (file)
@@ -481,8 +481,9 @@ SyscallReturn
 ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    int fd = process->getSyscallArg(tc, 0);
-    unsigned req = process->getSyscallArg(tc, 1);
+    int index = 0;
+    int fd = process->getSyscallArg(tc, index);
+    unsigned req = process->getSyscallArg(tc, index);
 
     DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", fd, req);
 
@@ -517,7 +518,9 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     std::string path;
 
-    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path,
+                process->getSyscallArg(tc, index)))
         return -EFAULT;
 
     if (path == "/dev/sysdev0") {
@@ -527,8 +530,8 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
         return -ENOENT;
     }
 
-    int tgtFlags = process->getSyscallArg(tc, 1);
-    int mode = process->getSyscallArg(tc, 2);
+    int tgtFlags = process->getSyscallArg(tc, index);
+    int mode = process->getSyscallArg(tc, index);
     int hostFlags = 0;
 
     // translate open flags
@@ -573,14 +576,16 @@ sysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
          ThreadContext *tc)
 {
 
-   TypedBufferArg<typename OS::tgt_sysinfo> sysinfo(process->getSyscallArg(tc, 0));   
+    int index = 0;
+    TypedBufferArg<typename OS::tgt_sysinfo>
+        sysinfo(process->getSyscallArg(tc, index));   
 
-   sysinfo->uptime=seconds_since_epoch;
-   sysinfo->totalram=process->system->memSize();
+    sysinfo->uptime=seconds_since_epoch;
+    sysinfo->totalram=process->system->memSize();
 
-   sysinfo.copyOut(tc->getMemPort());
+    sysinfo.copyOut(tc->getMemPort());
 
-   return 0;
+    return 0;
 }
 
 /// Target chmod() handler.
@@ -591,10 +596,13 @@ chmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     std::string path;
 
-    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path,
+                process->getSyscallArg(tc, index))) {
         return -EFAULT;
+    }
 
-    uint32_t mode = process->getSyscallArg(tc, 1);
+    uint32_t mode = process->getSyscallArg(tc, index);
     mode_t hostMode = 0;
 
     // XXX translate mode flags via OS::something???
@@ -618,13 +626,14 @@ SyscallReturn
 fchmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
            ThreadContext *tc)
 {
-    int fd = process->getSyscallArg(tc, 0);
+    int index = 0;
+    int fd = process->getSyscallArg(tc, index);
     if (fd < 0 || process->sim_fd(fd) < 0) {
         // doesn't map to any simulator fd: not a valid target fd
         return -EBADF;
     }
 
-    uint32_t mode = process->getSyscallArg(tc, 1);
+    uint32_t mode = process->getSyscallArg(tc, index);
     mode_t hostMode = 0;
 
     // XXX translate mode flags via OS::someting???
@@ -643,10 +652,11 @@ template <class OS>
 SyscallReturn
 mremapFunc(SyscallDesc *desc, int callnum, LiveProcess *process, ThreadContext *tc)
 {
-    Addr start = process->getSyscallArg(tc, 0);
-    uint64_t old_length = process->getSyscallArg(tc, 1);
-    uint64_t new_length = process->getSyscallArg(tc, 2);
-    uint64_t flags = process->getSyscallArg(tc, 3);
+    int index = 0;
+    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);
 
     if ((start % TheISA::VMPageSize != 0) ||
             (new_length % TheISA::VMPageSize != 0)) {
@@ -692,8 +702,12 @@ statFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     std::string path;
 
-    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 0)))
-    return -EFAULT;
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path,
+                process->getSyscallArg(tc, index))) {
+        return -EFAULT;
+    }
+    Addr bufPtr = process->getSyscallArg(tc, index);
 
     // Adjust path for current working directory
     path = process->fullPath(path);
@@ -704,8 +718,7 @@ statFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (result < 0)
         return -errno;
 
-    copyOutStatBuf<OS>(tc->getMemPort(), process->getSyscallArg(tc, 1),
-            &hostBuf);
+    copyOutStatBuf<OS>(tc->getMemPort(), bufPtr, &hostBuf);
 
     return 0;
 }
@@ -719,8 +732,11 @@ stat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     std::string path;
 
-    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 0)))
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path,
+                process->getSyscallArg(tc, index)))
         return -EFAULT;
+    Addr bufPtr = process->getSyscallArg(tc, index);
 
     // Adjust path for current working directory
     path = process->fullPath(path);
@@ -736,8 +752,7 @@ stat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (result < 0)
         return -errno;
 
-    copyOutStat64Buf<OS>(tc->getMemPort(), process->getSyscallArg(tc, 1),
-            &hostBuf);
+    copyOutStat64Buf<OS>(tc->getMemPort(), bufPtr, &hostBuf);
 
     return 0;
 }
@@ -749,7 +764,9 @@ SyscallReturn
 fstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
             ThreadContext *tc)
 {
-    int fd = process->getSyscallArg(tc, 0);
+    int index = 0;
+    int fd = process->getSyscallArg(tc, index);
+    Addr bufPtr = process->getSyscallArg(tc, index);
     if (fd < 0 || process->sim_fd(fd) < 0) {
         // doesn't map to any simulator fd: not a valid target fd
         return -EBADF;
@@ -766,8 +783,7 @@ fstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (result < 0)
         return -errno;
 
-    copyOutStat64Buf<OS>(tc->getMemPort(), process->getSyscallArg(tc, 1),
-        &hostBuf, (fd == 1));
+    copyOutStat64Buf<OS>(tc->getMemPort(), bufPtr, &hostBuf, (fd == 1));
 
     return 0;
 }
@@ -781,8 +797,12 @@ lstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     std::string path;
 
-    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 0)))
-      return -EFAULT;
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path,
+                process->getSyscallArg(tc, index))) {
+        return -EFAULT;
+    }
+    Addr bufPtr = process->getSyscallArg(tc, index);
 
     // Adjust path for current working directory
     path = process->fullPath(path);
@@ -793,8 +813,7 @@ lstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (result < 0)
         return -errno;
 
-    copyOutStatBuf<OS>(tc->getMemPort(), process->getSyscallArg(tc, 1),
-            &hostBuf);
+    copyOutStatBuf<OS>(tc->getMemPort(), bufPtr, &hostBuf);
 
     return 0;
 }
@@ -807,8 +826,12 @@ lstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     std::string path;
 
-    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 0)))
-      return -EFAULT;
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path,
+                process->getSyscallArg(tc, index))) {
+        return -EFAULT;
+    }
+    Addr bufPtr = process->getSyscallArg(tc, index);
 
     // Adjust path for current working directory
     path = process->fullPath(path);
@@ -824,8 +847,7 @@ lstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (result < 0)
         return -errno;
 
-    copyOutStat64Buf<OS>(tc->getMemPort(), process->getSyscallArg(tc, 1),
-            &hostBuf);
+    copyOutStat64Buf<OS>(tc->getMemPort(), bufPtr, &hostBuf);
 
     return 0;
 }
@@ -836,7 +858,9 @@ SyscallReturn
 fstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
           ThreadContext *tc)
 {
-    int fd = process->sim_fd(process->getSyscallArg(tc, 0));
+    int index = 0;
+    int fd = process->sim_fd(process->getSyscallArg(tc, index));
+    Addr bufPtr = process->getSyscallArg(tc, index);
 
     DPRINTF(SyscallVerbose, "fstat(%d, ...)\n", fd);
 
@@ -849,8 +873,7 @@ fstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (result < 0)
         return -errno;
 
-    copyOutStatBuf<OS>(tc->getMemPort(), process->getSyscallArg(tc, 1),
-        &hostBuf, (fd == 1));
+    copyOutStatBuf<OS>(tc->getMemPort(), bufPtr, &hostBuf, (fd == 1));
 
     return 0;
 }
@@ -864,8 +887,12 @@ statfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     std::string path;
 
-    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 0)))
-      return -EFAULT;
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path,
+                process->getSyscallArg(tc, index))) {
+        return -EFAULT;
+    }
+    Addr bufPtr = process->getSyscallArg(tc, index);
 
     // Adjust path for current working directory
     path = process->fullPath(path);
@@ -876,8 +903,7 @@ statfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (result < 0)
         return -errno;
 
-    OS::copyOutStatfsBuf(tc->getMemPort(),
-            (Addr)(process->getSyscallArg(tc, 1)), &hostBuf);
+    OS::copyOutStatfsBuf(tc->getMemPort(), bufPtr, &hostBuf);
 
     return 0;
 }
@@ -889,7 +915,9 @@ SyscallReturn
 fstatfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
             ThreadContext *tc)
 {
-    int fd = process->sim_fd(process->getSyscallArg(tc, 0));
+    int index = 0;
+    int fd = process->sim_fd(process->getSyscallArg(tc, index));
+    Addr bufPtr = process->getSyscallArg(tc, index);
 
     if (fd < 0)
         return -EBADF;
@@ -900,8 +928,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (result < 0)
         return -errno;
 
-    OS::copyOutStatfsBuf(tc->getMemPort(), process->getSyscallArg(tc, 1),
-        &hostBuf);
+    OS::copyOutStatfsBuf(tc->getMemPort(), bufPtr, &hostBuf);
 
     return 0;
 }
@@ -913,15 +940,16 @@ SyscallReturn
 writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
            ThreadContext *tc)
 {
-    int fd = process->getSyscallArg(tc, 0);
+    int index = 0;
+    int fd = process->getSyscallArg(tc, index);
     if (fd < 0 || process->sim_fd(fd) < 0) {
         // doesn't map to any simulator fd: not a valid target fd
         return -EBADF;
     }
 
     TranslatingPort *p = tc->getMemPort();
-    uint64_t tiov_base = process->getSyscallArg(tc, 1);
-    size_t count = process->getSyscallArg(tc, 2);
+    uint64_t tiov_base = process->getSyscallArg(tc, index);
+    size_t count = process->getSyscallArg(tc, index);
     struct iovec hiov[count];
     for (size_t i = 0; i < count; ++i) {
         typename OS::tgt_iovec tiov;
@@ -962,12 +990,13 @@ template <class OS>
 SyscallReturn
 mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
-    Addr start = p->getSyscallArg(tc, 0);
-    uint64_t length = p->getSyscallArg(tc, 1);
-    // int prot = p->getSyscallArg(tc, 2);
-    int flags = p->getSyscallArg(tc, 3);
-    // int fd = p->sim_fd(p->getSyscallArg(tc, 4));
-    // int offset = p->getSyscallArg(tc, 5);
+    int index = 0;
+    Addr start = p->getSyscallArg(tc, index);
+    uint64_t length = p->getSyscallArg(tc, index);
+    index++; // int prot = p->getSyscallArg(tc, index);
+    int flags = p->getSyscallArg(tc, index);
+    int fd = p->sim_fd(p->getSyscallArg(tc, index));
+    // int offset = p->getSyscallArg(tc, index);
 
 
     if ((start  % TheISA::VMPageSize) != 0 ||
@@ -995,7 +1024,7 @@ mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 
     if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
         warn("allowing mmap of file @ fd %d. "
-             "This will break if not /dev/zero.", p->getSyscallArg(tc, 4));
+             "This will break if not /dev/zero.", fd);
     }
 
     return start;
@@ -1007,8 +1036,9 @@ SyscallReturn
 getrlimitFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
         ThreadContext *tc)
 {
-    unsigned resource = process->getSyscallArg(tc, 0);
-    TypedBufferArg<typename OS::rlimit> rlp(process->getSyscallArg(tc, 1));
+    int index = 0;
+    unsigned resource = process->getSyscallArg(tc, index);
+    TypedBufferArg<typename OS::rlimit> rlp(process->getSyscallArg(tc, index));
 
     switch (resource) {
         case OS::TGT_RLIMIT_STACK:
@@ -1042,7 +1072,8 @@ SyscallReturn
 gettimeofdayFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
         ThreadContext *tc)
 {
-    TypedBufferArg<typename OS::timeval> tp(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<typename OS::timeval> tp(process->getSyscallArg(tc, index));
 
     getElapsedTime(tp->tv_sec, tp->tv_usec);
     tp->tv_sec += seconds_since_epoch;
@@ -1063,10 +1094,14 @@ utimesFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
 {
     std::string path;
 
-    if (!tc->getMemPort()->tryReadString(path, process->getSyscallArg(tc, 0)))
-      return -EFAULT;
+    int index = 0;
+    if (!tc->getMemPort()->tryReadString(path,
+                process->getSyscallArg(tc, index))) {
+        return -EFAULT;
+    }
 
-    TypedBufferArg<typename OS::timeval [2]> tp(process->getSyscallArg(tc, 1));
+    TypedBufferArg<typename OS::timeval [2]>
+        tp(process->getSyscallArg(tc, index));
     tp.copyIn(tc->getMemPort());
 
     struct timeval hostTimeval[2];
@@ -1092,8 +1127,9 @@ SyscallReturn
 getrusageFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
               ThreadContext *tc)
 {
-    int who = process->getSyscallArg(tc, 0);     // THREAD, SELF, or CHILDREN
-    TypedBufferArg<typename OS::rusage> rup(process->getSyscallArg(tc, 1));
+    int index = 0;
+    int who = process->getSyscallArg(tc, index); // THREAD, SELF, or CHILDREN
+    TypedBufferArg<typename OS::rusage> rup(process->getSyscallArg(tc, index));
 
     rup->ru_utime.tv_sec = 0;
     rup->ru_utime.tv_usec = 0;
@@ -1143,7 +1179,8 @@ SyscallReturn
 timesFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
            ThreadContext *tc)
 {
-    TypedBufferArg<typename OS::tms> bufp(process->getSyscallArg(tc, 0));
+    int index = 0;
+    TypedBufferArg<typename OS::tms> bufp(process->getSyscallArg(tc, index));
 
     // Fill in the time structure (in clocks)
     int64_t clocks = curTick * OS::_SC_CLK_TCK / Clock::Int::s;
@@ -1172,7 +1209,8 @@ timeFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     getElapsedTime(sec, usec);
     sec += seconds_since_epoch;
 
-    Addr taddr = (Addr)process->getSyscallArg(tc, 0);
+    int index = 0;
+    Addr taddr = (Addr)process->getSyscallArg(tc, index);
     if(taddr != 0) {
         typename OS::time_t t = sec;
         t = htog(t);