lowRISC / lowRISC/ibex

[cosim] Sort out error/pmp failure behaviour on unaligned accesses

Open
#1,948 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component:DV Priority:P3
Dominant language
SystemVerilog
Stars
2.1k
Forks
810
Avg merge
5d 23h
Merged PRs (30d)
9

Description

When spike encounters an unaligned access it splits it into single byte accesses. If one of these sees a bus error or a PMP failure it immediately causes an exception. In Ibex unaligned accesses are split in two and both accesses are tried regardless of bus errors and PMP failures of the other access.

This leads to co-sim mismatches in cases where unaligned accesses cross PMP boundaries (the co-sim framework can currently handle the difference in behaviour for bus errors). What Ibex does is architectural permissible so we should modify spike to match. I have a PR for this: https://github.com/lowRISC/riscv-isa-sim/pull/23 though it also needs some changes on the co-sim side, as it currently removes outstanding unaligned accesses from the pending memory access queue on an error to help deal with the mismatch.

We can remove the co-sim behaviour that removes accesses for the pending memory access queue, that you can see at https://github.com/lowRISC/ibex/blob/726eb97a88964107bb67796613ebed2b3e05f129/dv/cosim/spike_cosim.cc#L882-L892

However this causes other errors.

This needs to be resolve, though can be done post V2. I've observed PMP tests correctly dealing with cross PMP region accesses so we have confidence this issue is not hiding a real RTL bug behind it.

estimate 4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in dv/cosim/spike_cosim.cc around lines 882-892, where pending unaligned accesses are removed after an error. Reproduce the cross-PMP unaligned-access co-simulation failures and compare the behavior with Ibex and the referenced Spike PR. Done means the pending access handling matches the intended Ibex behavior without introducing other co-simulation errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.