From b21a28bce174f2d1ac3e8a424bc9b9b1f01251a6 Mon Sep 17 00:00:00 2001 From: Scott Johnson Date: Wed, 13 Jul 2022 10:21:43 -0700 Subject: Add assertion to ensure proper logging of mstatus changes on RV32 --- riscv/csrs.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'riscv') diff --git a/riscv/csrs.cc b/riscv/csrs.cc index dac3eef..7a52353 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -455,6 +455,10 @@ sstatus_proxy_csr_t::sstatus_proxy_csr_t(processor_t* const proc, const reg_t ad bool sstatus_proxy_csr_t::unlogged_write(const reg_t val) noexcept { const reg_t new_mstatus = (mstatus->read() & ~sstatus_write_mask) | (val & sstatus_write_mask); + // On RV32 this will only log the low 32 bits, so make sure we're + // not modifying anything in the upper 32 bits. + assert((sstatus_write_mask & 0xffffffffU) == sstatus_write_mask); + mstatus->write(new_mstatus); return false; // avoid double logging: already logged by mstatus->write() } -- cgit v1.1