changeset ada5603bdb1c in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=ada5603bdb1c
description:
riscv: Fix crash when syscall argument reg index is too high
By default, doSyscall gets the values of six registers to be used for
system call arguments. RISC-V, by convention, only has four. Because
RISC-V's implementation of these indices is as arrays of integers rather
than as base indices plus offsets, trying to get the fifth argument
register's value will cause a crash. This patch fixes that by
returning 0
for any index higher than 3.
Signed-off-by: Jason Lowe-Power <[email protected]>
diffstat:
src/arch/riscv/process.cc | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diffs (18 lines):
diff -r 8702d8dc2def -r ada5603bdb1c src/arch/riscv/process.cc
--- a/src/arch/riscv/process.cc Fri Jan 27 15:03:17 2017 -0600
+++ b/src/arch/riscv/process.cc Fri Jan 27 15:05:01 2017 -0600
@@ -217,7 +217,13 @@
RiscvISA::IntReg
RiscvLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
{
- return tc->readIntReg(SyscallArgumentRegs[i++]);
+ // RISC-V only has four system call argument registers by convention, so
+ // if a larger index is requested return 0
+ RiscvISA::IntReg retval = 0;
+ if (i < 4)
+ retval = tc->readIntReg(SyscallArgumentRegs[i]);
+ i++;
+ return retval;
}
void
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev