From aa4fe362a582ca52cff0ccf83b764cc109bbc5c4 Mon Sep 17 00:00:00 2001 From: Yu-Cheng Chang Date: Mon, 19 Aug 2024 23:21:42 +0800 Subject: [PATCH] arch-riscv: Sign-extend the address in newPCState (#1471) From #1316, creating the new PCState should sign-extend the address to avoid wrong address issue. Change-Id: I884b4e3708f5f1cc49cfd44d51bec5a2b63cc47a --- src/arch/riscv/isa.hh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/arch/riscv/isa.hh b/src/arch/riscv/isa.hh index 04bbcfbe9e..a27982bc7d 100644 --- a/src/arch/riscv/isa.hh +++ b/src/arch/riscv/isa.hh @@ -117,6 +117,9 @@ class ISA : public BaseISA newPCState(Addr new_inst_addr=0) const override { unsigned vlenb = vlen >> 3; + if (_rvType == RV32) { + new_inst_addr = sext<32>(new_inst_addr); + } return new PCState(new_inst_addr, _rvType, vlenb); }