d-iii-s / msim

Light-weight MIPS R4000 and RISC-V system simulator
https://d3s.mff.cuni.cz/software/msim/
GNU General Public License v2.0
5 stars 4 forks source link

RISC-V: Instruction Fetch with MPRV=1 #66

Open HanyzPAPU opened 4 months ago

HanyzPAPU commented 4 months ago

The RISC-V privileged specification states: "Instruction address-translation and protection are unaffected by the setting of MPRV." on page 23.

MPRV is a bit in mstatus CSR which enables memory translation of memory loads and stores for M mode. We currently translate all memory accesses when MPRV is set, which is incorrect behavior for instruction fetches, which should not be translated.