Skip to content

[dv] Run a first directed test in CHERIoT mode - #2596

Open
henrikpedersen-oss wants to merge 3 commits into
lowRISC:masterfrom
henrikpedersen-oss:upstream-cheriot-basic
Open

henrikpedersen-oss wants to merge 3 commits into
lowRISC:masterfrom
henrikpedersen-oss:upstream-cheriot-basic

Conversation

@henrikpedersen-oss

Copy link
Copy Markdown
Contributor

The UVM testbench ties cheriot_enable_i off, so no test runs in CHERIoT mode, although the default opentitan configuration is built with BaseIsaRV32IorCHERIoT. This PR adds a way to turn it on and one small test that uses it.

  • +cheriot_enable=1 holds cheriot_enable_i On from reset, as the one-way switch requires. Without the plusarg nothing changes. With it, a build that isn't CHERIoT stops with an error.
  • cheriot_cap_basic reads the root memory capability from mtdc, which holds it after reset (doc/03_reference/cheriot.rst). It moves the address to a buffer, sets 16-byte bounds, checks address, base, length and tag, stores and loads through the capability and an offset copy of it, and checks that CClearTag clears only the tag. In CHERIoT mode every load and store needs a capability, so the test has its own short start-up and writes pass or fail through a capability derived from mtdc. The CHERIoT instructions are written with .insn, as the toolchain does not know them.
  • The test checks itself and runs with +disable_cosim=1, as the Zcmp tests do, because the cosim does not model CHERIoT yet (a CHERIoT-Sail cosim is planned as a separate PR; the test can then also run with cosim). rtl_params restricts it to CHERIoT builds. +disable_spurious_dside_responses=1 keeps injected bus errors away from its loads and stores.

Tested with Xcelium on top of be1d803, IBEX_CONFIG=opentitan: cheriot_cap_basic passed on 5 seeds, and the trace shows the CHERIoT instructions executing. It also fails when it should: with the expected length changed to 17 it reports TEST_FAIL, and without +cheriot_enable=1 its first CHERIoT instruction traps as illegal.

The testbench tied cheriot_enable_i off, so no test ran in CHERIoT mode.
+cheriot_enable=1 now holds it On from reset, in CHERIoT builds only.

cheriot_cap_basic derives a 16-byte capability from mtdc, checks its
address, bounds and tag, and stores and loads through it. It checks
itself, as the cosim does not model CHERIoT yet.

Signed-off-by: Henrik M Pedersen <henrik.pedersen@lowrisc.org>
The merge with master kept master's tie-off of cheriot_enable_i next to
the new connection, so the testbench no longer elaborated (xmelab
CUVPOM). Drive cheriot_enable_i, cheriot_enable_shadow_i and
cheriot_enable_cmp_i from the same plusarg, so the lockstep pair agrees.

Signed-off-by: Henrik M Pedersen <henrik.pedersen@lowrisc.org>

AI-assisted (Claude Code) — reviewed and approved by author

Co-Authored-By: Claude <claude@anthropic.com>
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