From 160c1a5cee45d3842824af565e52458e2f8b3c48 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 27 Nov 2017 14:18:06 -0800 Subject: [PATCH] Set tval to 0 on traps with no specified tval Simply not writing the register was not a conformant implementation. --- riscv/processor.cc | 6 ++---- riscv/trap.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/riscv/processor.cc b/riscv/processor.cc index 722ca45..564b34f 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -272,8 +272,7 @@ void processor_t::take_trap(trap_t& t, reg_t epc) state.pc = state.stvec; state.scause = t.cause(); state.sepc = epc; - if (t.has_badaddr()) - state.sbadaddr = t.get_badaddr(); + state.sbadaddr = t.get_badaddr(); reg_t s = state.mstatus; s = set_field(s, MSTATUS_SPIE, get_field(s, MSTATUS_SIE)); @@ -286,8 +285,7 @@ void processor_t::take_trap(trap_t& t, reg_t epc) state.pc = (state.mtvec & ~(reg_t)1) + vector; state.mepc = epc; state.mcause = t.cause(); - if (t.has_badaddr()) - state.mbadaddr = t.get_badaddr(); + state.mbadaddr = t.get_badaddr(); reg_t s = state.mstatus; s = set_field(s, MSTATUS_MPIE, get_field(s, MSTATUS_MIE)); diff --git a/riscv/trap.h b/riscv/trap.h index 91e5223..1fe44eb 100644 --- a/riscv/trap.h +++ b/riscv/trap.h @@ -14,7 +14,7 @@ class trap_t trap_t(reg_t which) : which(which) {} virtual const char* name(); virtual bool has_badaddr() { return false; } - virtual reg_t get_badaddr() { abort(); } + virtual reg_t get_badaddr() { return 0; } reg_t cause() { return which; } private: char _name[16]; -- 2.30.2