Skip to content

Add mcounteren register#2403

Draft
SamuelRiedel wants to merge 7 commits into
lowRISC:masterfrom
SamuelRiedel:mcounteren
Draft

Add mcounteren register#2403
SamuelRiedel wants to merge 7 commits into
lowRISC:masterfrom
SamuelRiedel:mcounteren

Conversation

@SamuelRiedel
Copy link
Copy Markdown
Contributor

@SamuelRiedel SamuelRiedel commented May 11, 2026

This PR adds the mcounteren register, which has so far been tied to zero and implements the U-mode performance counter aliases. The mcounteren register can be locked with an external MUBI signal (mcounteren_writable_i).

DV:
This PR adds two directed tests:

  • mcounteren_test goes through multiple configurations of the mcounteren register and validates that u-mode can only access the ones enabled.
  • mcounteren_lock_test verifies that the mcounteren CSR cannot be modified without the mcounteren_writable_i signal being set.

To Dos:

  • For the directed tests and the cosim to pass, we have to update riscv-isa-sim to also support those performance counters: Enable ZIHPM unpriviledged performance counters riscv-isa-sim#29
  • Currently, u-mode counter reads will lead to illegal instruction exceptions. However, we are not gating the value at the CSR module's interface for simplicity. The signal will not leave the core, but we should double-check that this is no security issue.

@SamuelRiedel SamuelRiedel force-pushed the mcounteren branch 2 times, most recently from 58188e6 to 63fb24f Compare May 11, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant