PMP (Physical Memory Protection) on BeagleV Ahead

Hey,

I’m currently working on a research project on RISC-V where I try to protect memory regions from either OpenSBI or the kernel. Unfortunately I can’t get PMP to work on the BeagleV Ahead.

Every time I boot up the system, the OpenSBI PMP detection prints:

Boot HART PMP Count       : 0
Boot HART PMP Granularity : 0
Boot HART PMP Address Bits: 0

This detection simply checks if the PMP CSRs are writable, so I’m pretty confident that it should print 8 or 16 if the chip behaves correctly (The official C910 documentation states that there are options with either 8 or 16 PMP registers, so I assume my machine has at least 8).

My current guess is that either PMP is broken on the C910 (TH1520) or that some software I currently have no control of already sets the PMP registers and sets them locked so that I can’t change them later. What stands against this guess is that reading from the pmp registers returns 0, which I would not assume even in the locked case.

I already tried to patch the two projects I’m currently aware of that could setup PMP related functionality:

Here are my main questions:

  1. Has someone found PMP working on the C910 (TH1520)?
  2. I found that the Linux kernel sets up PMP in early boot when it is compiled with M_MODE. Is PMP required to be setup to do memory writes? I assumed when PMP is not setup it just performs no checks.
  3. Is there some other software involved in setting up PMP before U-Boot or in between the jump from U-Boot to OpenSBI?

(Can’t edit for some reason) Related post for LicheePi4A: PMP (Physical Memory Protection) on LicheePi4A · Issue #29 · sipeed/LicheePi4A · GitHub

I have the same problem with BeagleV Ahead, but unfortunately no answers. I tried to get Keystone Enclave framework (https://keystone-enclave.org/) to be ported to BeagleV Ahead. I used OpenSBI v1.4 as it seems to include support for the board as part of its generic platform. Keystone is using PMP to manage enclaves. I was hoping that it will work with small modifications despite those odd Boot HART PMP log entries but no luck so far.

Cross posting from the github issue again. The current state there is that I got opensbi v1.4 to work, but it didn’t help. At this point I’m pretty sure that SBI can’t be the problem.

With a few hints I found that the pmp registers seem to be mapped to memory in sbi, where sbi then clears the current configuration. But when I try writing meaningful configurations into that memory region, the writes to the interesting bits are silently dropped.