Skip to content

fix(riscv): take pending interrupt trap in wfi - #295

Closed
carlosqwqqwq wants to merge 1 commit into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-wfi-pending-trap
Closed

fix(riscv): take pending interrupt trap in wfi#295
carlosqwqqwq wants to merge 1 commit into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-wfi-pending-trap

Conversation

@carlosqwqqwq

Copy link
Copy Markdown
Contributor

Make wfi take the interrupt trap immediately when an enabled interrupt is
pending, per priv 1.12 norm:wfi_mepc_val. Currently Op::Wfi always returns
Ok(RiscVExit::Wfi) (stall hint) even when mip & mie is non-zero.

Validation

  • Probe R-014 (asserting the defective stall behavior) now fails, i.e. the
    defect is fixed.
  • New regression tests v058/v058b verify: no pending interrupt -> still
    returns Wfi; pending enabled interrupt -> traps.
  • Full probe suite: 53 passed; the 8 failures are all expected
    (R-010..R-014 for the sret/wfi fixes, R-023 for the segment-ff decode fix,
    R-017 obsolete, V-012 already adopted upstream).
  • cargo test --lib passes.

Closes #290

@carlosqwqqwq carlosqwqqwq changed the title ## Summary fix(riscv): take pending interrupt trap in wfi Aug 13, 2026

19h commented Aug 13, 2026

Copy link
Copy Markdown
Member

Thanks for the report and patch. I independently checked WFI against the privileged architecture and implemented the valid part in #296: a locally enabled pending interrupt wakes WFI irrespective of the global enable. The rollup does not force a trap when global/delegation conditions make that interrupt non-actionable, because wake eligibility and trap eligibility are distinct. It includes your co-author credit and asks for your review. I’m closing this PR as superseded by #296.

@19h 19h closed this Aug 13, 2026
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.

wfi does not take the trap when an enabled interrupt is pending

2 participants