Sv39 virtual memory translation on Milk V Duo

Hey there,

I’m trying to get Sv39 running on the Milk V Duo and I just can’t get it working.

Quick info about the setup: I used fiptool to emplace my binary into the OpenSBI slot, which means it is running completely bare metal, starts in M-mode and then I push it down to S-mode, where my minikernel runs.

I use identity mapping for the kernel (with megapages) and the user mapping uses traditional 4KiB pages (meaning the full three levels).

I know for sure the page table setup works correctly – I tested in in an emulator (MSIM) and it works there. Yes, MSIM currently only supports 32bit RV32, however, I contributed with an RV64 implementation with Sv39 support.

The problem is, when I update satp with the ASID (starts at 0) and the root of the table, the instruction after the CSR write causes fault 12, which is Instruction page fault. I don’t know what is happening since the PTEs should be correct and the kernel is identity mapped, so it should continue execution without a problem.

Has anyone tried to get Sv39 running on the CV1800B?

Cheers!

1 Like

I have to, once again, respond to myself but in case anyone has the same problem with it:

The problem wasn’t the Sv39 memory translation itself, it was that on the chip, you CANNOT DELEGATE M-MODE EXCEPTIONS TO S-MODE. It took me forever to fix this, even though it is written in the chip manual.

Also, when trying to get Sv39 working, do not forget to set the proper bits (bit 21) in mxstatus.

1 Like