Skip to content

Fix the riscv_dret_test - #2338

Merged
SamuelRiedel merged 1 commit into
lowRISC:masterfrom
SamuelRiedel:dret-test
Dec 3, 2025
Merged

SamuelRiedel merged 1 commit into
lowRISC:masterfrom
SamuelRiedel:dret-test

Conversation

@SamuelRiedel

@SamuelRiedel SamuelRiedel commented Dec 1, 2025 •

Copy link
Copy Markdown
Contributor

The test checked for the exception handler to launch and then waited for the core to flush its pipeline. However, the flush happened immediately after the exception, which led the test to miss the first exception handler and the check_priv_mode to fail, since the check only executed after the flush leaving the exception handlers. This also means that on later executions, we were not checking the exception handlers as we go, but instead, the exception handler from the exception before. Accordingly, this test only failed if Ibex initially started in USER mode. Otherwise, it was anyway always in MACHINE mode.

The failure in the nightly regression are all due to:

Check failed dut_vif.dut_cb.priv_mode == mode (0 [0x0] vs 3 [0x3]) Incorrect privilege mode

Alternatively, I tried using a fork/join to check for entering the exception handler and the flush independently. This also works, but is an overkill IMO, because the flush will always be instant and communicating that the exception handler starts will always take a few cycles after the flush completed.

@rswarbrick rswarbrick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful explanation (I'd have struggled to understand what was going on without it!). This looks good to me (modulo a nitty comment about long lines)

Comment thread dv/uvm/core_ibex/tests/core_ibex_test_lib.sv Outdated
The test checked for the exception handler to launch and then waited for
the core to flush its pipeline. However, the flush happened immediately
after the exception, which led the test to miss the first exception
handler and the `check_priv_mode` to fail, since the check only executed
after the flush leaving the exception handlers. This also means that on
later executions, we were not checking the exception handlers as we go,
but instead, the exception handler from the exception before.
Accordingly, this test only failed if Ibex initially started in USER
mode. Otherwise, it was anyways always in MACHINE mode

@rswarbrick rswarbrick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great (and thanks for the explanation!)

@SamuelRiedel
SamuelRiedel added this pull request to the merge queue Dec 3, 2025
Merged via the queue into lowRISC:master with commit e84ec08 Dec 3, 2025
12 checks passed
@SamuelRiedel SamuelRiedel mentioned this pull request Dec 18, 2025
12 of 13 tasks
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.

2 participants