lowRISC / lowRISC/ibex

[rtl] Behaviour of debug single stepping with dummy instruction insertion may be surprising

Open
#2,186 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component:RTL Type:Bug
Dominant language
SystemVerilog
Stars
2.1k
Forks
810
Avg merge
5d 23h
Merged PRs (30d)
9

Description

I have observed a scenario where Ibex is single stepping whilst dummy instruction insertion is enabled. When a dummy instruction is inserted just as Ibex returns from debug mode to single step the next instruction, it single steps the dummy instruction instead. The depc is set correctly (i.e. it will rerun the instruction that should have been single stepped after a dret) but it could cause confusion for a debugger user and might break the debugger itself (that may reasonably assume a single step will always occur) but the instruction won't be incorrectly skipped.

This results in a mismatch with the cosim as it doesn't observe the dummy instruction on the RVFI interface so it sees the debug vector being re-entered without the single stepped instruction being executed.

To reproduce run:

make TEST=riscv_debug_single_step_test SEED=6250 ITERATIONS=1 WAVES=1 against commit 3384bf4c421781a2f5129307b912ac586c784977

There's three options I see here:

  1. Declare this behaviour is reasonable
  2. Force dummy instruction insertion to be disabled when running in single step
  3. Alter the controller behaviour so we'll execute the dummy instruction and then single step

Option 3 is the most complex, option 2 should be pretty simple though does require an RTL change. Option 1 seems reasonable for OpenTitan (so no RTL fix needed for Earlgrey).

For any of these options we should look at DV in this area to ensure this scenario is properly covered.

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 by reproducing the scenario with make TEST=riscv_debug_single_step_test SEED=6250 ITERATIONS=1 WAVES=1 at commit 3384bf4c421781a2f5129307b912ac586c784977. Then inspect the debug single-step and dummy-instruction controller behavior and the related DV coverage. Done means the project has a decided policy for this case and the cosim/RVFI behavior and tests reflect it.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.