Skip to content

Make PMP granularity configurable

Jay Chang qemu-devel qemu-riscv 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2target/riscv: Make PMP granularity configurabletarget/riscv/cpu.c target/riscv/cpu.h target/riscv/cpu_cfg_fields.h.inc+41 -00 replies
2/2target/riscv: Make PMP CSRs conform to WARL constraintstarget/riscv/pmp.c+46 -00 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchFrank ChangJim Shu
SeriesR-b R-b R-b R-b
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH v1 0/2] Make PMP granularity configurable

This patch series enhances QEMU's RISC-V PMP support to conform with the RISC-V Privileged Specification regarding PMP granularity and WARL constraints.

Previously, QEMU always used a fixed minimum PMP granularity of 4 bytes. This series introduces a configurable "pmp-granularity" parameter, allowing platforms to specify larger granularity values. In addition, the handling of pmpcfg and pmpaddr CSRs has been updated to follow WARL constraints. For example, when NA4 is not valid due to a larger granularity, it is silently ignored. TOR and NAPOT address ranges are also properly aligned according to the configured granularity.

A new CPU parameter pmp-granularity is now available on the QEMU command line. For example:

    -cpu rv64,g=true,c=true,pmp=true,pmp-granularity=1024

If not provided, the default remains 4 bytes.

---

Patch summary:

1. target/riscv: Make PMP granularity configurable
- Introduce CPU property pmp-granularity for platforms to configure PMP granularity.
- Default remains 4 bytes if unspecified.

2. target/riscv: Make PMP CSRs conform to WARL constraints
- Update pmpcfg and pmpaddr handling to follow WARL semantics.
- Align start and end addresses of TOR regions to PMP granularity.
- Ensure software can read back correct values per the spec.

PATCH v1 update
Add the UL type to prevent bit-width errors.

Jay Chang (2):
target/riscv: Make PMP granularity configurable target/riscv: Make PMP CSRs conform to WARL constraints

 target/riscv/cpu.c                | 39 ++++++++++++++++++++++++++
 target/riscv/cpu.h                |  1 +
 target/riscv/cpu_cfg_fields.h.inc |  1 +
 target/riscv/pmp.c                | 46 +++++++++++++++++++++++++++++++
 4 files changed, 87 insertions(+)
Signature · 1 line
2.48.1