Skip to content

PMP (Physical Memory Protection) on LicheePi4A #29

@fabian-thomas

Description

@fabian-thomas

[Not sure if this is the correct place to post something like this. Please redirect me if this is not the right place.]

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 LicheePi4a (also not on the BeagleV Ahead, related post: https://forum.beagleboard.org/t/pmp-physical-memory-protection-on-beaglev-ahead/37928/1).

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:

  • U-Boot (used https://github.com/chainsx/thead-u-boot); I even ripped out any occurence of pmpcfg and pmpaddr in the entire repo to be sure that it does not set up PMP
  • OpenSBI (also tried upstream which failed with init_coldboot: timer init failed (error -3))

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions