lowRISC / lowRISC/ibex

Does NMI need to be precise?

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

Nobody has claimed this yet.

Type:Question Type:Spec-Compliance
Dominant language
SystemVerilog
Stars
2.1k
Forks
810
Avg merge
5d 23h
Merged PRs (30d)
9

Description

Currently our NMI is much like other interrupts. In that you will get an architectural state that corresponds to what is was immediately before the instruction `mepc` points to executes. This means you can easily resume execution outside of the interrupt by jumping back to to `mepc` provided you restore the register state to what is was before you did anything in the interrupt handler. This is a precise interrupt (which I don't think is defined in the RISC-V spec but clearly you don't want normal interrupts to be imprecise).

Do we want NMI to be precise? The privileged spec states NMI will 'cause an immediate jump to an implementation-defined NMI vector running in M-mode'. Currently if we have an outstanding memory request we will wait for the response before executing any of the interrupt handler code (simply due to the pipeline structure). In particular if we want precise exceptions on bus errors we'd be waiting to see if there's an error response to handle the bus error exception before taking the NMI.

I think it would be reasonable to make NMI imprecise/unrecoverable, we could also then drop the specialised behaviour we have on NMI where we're in a special NMI mode that restores some CSR state from the mstack registers.

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 reviewing the current NMI pipeline behavior described in the issue, including outstanding memory requests, precise bus-error handling, the M-mode NMI vector, and mstack CSR restoration. Compare these behaviors with the privileged specification, then document or implement a decided precise-versus-imprecise NMI policy and verify that interrupt recovery semantics are consistent.

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
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.