arch-riscv: Remove "magic" syscall number constant
authorAlec Roelke <ar4jc@virginia.edu>
Thu, 4 Jan 2018 19:17:13 +0000 (14:17 -0500)
committerAlec Roelke <ar4jc@virginia.edu>
Thu, 4 Jan 2018 19:49:41 +0000 (19:49 +0000)
getSyscallArg() in RISC-V has an explicit check to make sure that the
register index is within the bounds of the system call register indices
vector. This patch fixes it so that it uses SyscallArgumentRegs.size()
rather than a "magic" constant that has to be updated every time
SyscallArgumentRegs is changed.

Change-Id: I2935d811177dc8028cb3df64b250ba997bc970d8
Reviewed-on: https://gem5-review.googlesource.com/7061
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Alec Roelke <ar4jc@virginia.edu>

src/arch/riscv/process.cc

index 6fe935c1381bea0e1f2aa35f2b5a15c68b9520a5..b4fe1eefca2083f2d8b415c5e09dd814644ddca5 100644 (file)
@@ -215,10 +215,10 @@ RiscvProcess::argsInit(int pageSize)
 RiscvISA::IntReg
 RiscvProcess::getSyscallArg(ThreadContext *tc, int &i)
 {
-    // RISC-V only has four system call argument registers by convention, so
-    // if a larger index is requested return 0
+    // If a larger index is requested than there are syscall argument
+    // registers, return 0
     RiscvISA::IntReg retval = 0;
-    if (i < 4)
+    if (i < SyscallArgumentRegs.size())
         retval = tc->readIntReg(SyscallArgumentRegs[i]);
     i++;
     return retval;