riscvrocket-chip

RISC-V PMP instruction access fault when jumping to U mode


I am trying to use PMP on a 16-byte region to protect a specific memory region. However, I am getting an instruction access fault when jumping to U mode when the PMP configuration is enabled.

Details:

I am trying to figure out why it is giving instruction access fault when jumping to U mode. Could anyone please help me to understand what's happening?

I am running my code on Spike, I am seeing the same behavior on rocket-core simulation as well.


Solution

  • I found the answer to my own question, posting as thin might help someone else.

    It turns out I missed an important sentence in the spec about the PMP priority.

    If no PMP entry matches an M-mode access, the access succeeds. If no PMP entry matches an
    S-mode or U-mode access, but at least one PMP entry is implemented, the access fails.
    

    So I had to add a second PMP entry to match all addresses in U mode and that solved the issue.