generated from riscv/docs-spec-template
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial notes on trap handlers #84
Draft
orangecms
wants to merge
1
commit into
riscv-non-isa:main
Choose a base branch
from
orangecms:trap-handlers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
[[trap-handlers]] | ||
== Machine-Level Interrupts and Exceptions | ||
|
||
=== Delegation | ||
|
||
A RISC-V Machine mode execution environment may delegate handling interrupts and exceptions to the Supervisor or Hypervisor mode execution environment. | ||
|
||
For reference, see https://github.com/riscv/riscv-isa-manual/blob/main/src/machine.adoc#machine-cause-register-mcause[the definitions in the RISC-V ISA spec]. | ||
|
||
==== Interrupts | ||
[%autowidth,float="center",align="center",cols=">,>,<",options="header",] | ||
|=== | ||
| Code / Description |OpenSBI |oreboot SBI | ||
|0 _Reserved_ + | ||
1 Supervisor software interrupt + | ||
2 _Reserved_ + | ||
3 Machine software interrupt + | ||
4 _Reserved_ + | ||
5 Supervisor timer interrupt + | ||
6 _Reserved_ + | ||
7 Machine timer interrupt + | ||
8 _Reserved_ + | ||
9 Supervisor external interrupt + | ||
10 _Reserved_ + | ||
11 Machine external interrupt | ||
12-15 _Reserved_ + | ||
≥16 _Designated for platform use_ | ||
| O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O | ||
| O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O | ||
|=== | ||
|
||
X = explicitly set | ||
O = explicitly unset | ||
I = initial value unchanged | ||
|
||
==== Exceptions | ||
[%autowidth,float="center",align="center",cols=">,>,<",options="header",] | ||
|=== | ||
| Code / Description |OpenSBI |oreboot SBI | ||
|0 Instruction address misaligned + | ||
1 Instruction access fault + | ||
2 Illegal instruction + | ||
3 Breakpoint + | ||
4 Load address misaligned + | ||
5 Load access fault + | ||
6 Store/AMO address misaligned + | ||
7 Store/AMO access fault + | ||
8 Environment call from U-mode + | ||
9 Environment call from S-mode + | ||
10 _Reserved_ + | ||
11 Environment call from M-mode + | ||
12 Instruction page fault + | ||
13 Load page fault + | ||
14 _Reserved_ + | ||
15 Store/AMO page fault + | ||
16-23 _Reserved_ + | ||
24-31 _Designated for custom use_ + | ||
32-47 _Reserved_ + | ||
48-63 _Designated for custom use_ + | ||
≥64 _Reserved_ | ||
|O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O | ||
|O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O + | ||
O | ||
|=== |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why reference m-mode implementations? Why not call out what the expected behavior should be? And we should probably include the reasoning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for reference now, based on this suggestion #83 (comment)
my pledge is to always delegate everything that S-mode could handle, which only excludes operations involving CSRs and possibly MMIO spaces that are M-mode accessible only, AIUI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I had implied we should go into describing M mode implementations, that was not the intention. The BRS spec describes S mode behavior as it relates to booting at OS. Some implementations may not even have an M mode (think VMs).
We should come up with expected behavior (or a mechanism of conveying the necessary info). But I kinda wanna second Ved's feedback or why we ought to care - I think the assumption is that the OS will take the exception eventually for reasons that it would care about (even if the original exception went to M, as it very well might, for example due to firwmare-first error handling)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also went I mentioned "can we enumerate" I meant in the context of understanding the problem space, the github ticket, not actually enumerating in the spec. I definitely don't think this belongs in the spec itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"my pledge is to always delegate everything that S-mode could handle" we're definitely into impl-specific choices, and I don't think the BRS spec is the place to push for those choices. Like with other architectures, work-arounds and additional complexity may end up getting put into M, but in a manner generally transparent to S mode software. What matters is not what's done, but what's the measurable impact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. I had understood from this comment that BRS would supersede the platform spec:
riscvarchive/riscv-platform-specs#91 (comment)
So my intention was to get to a definition of behavior an S-mode OS would expect to avoid confusion where exceptions and/or interrupts are or are not arriving. That is what surprised me when Linux was not handling unaligned access traps, which is now being implemented in a pending patch series. Other OSes that are not part of that development history would benefit. Should this rather go into PRS, then? I would be happy to see it well-defined somewhere, not being picky where. BRS appeared to be closest to that from my current understanding. Where do you rather see it? It could also live in the wiki or in a blog post, I think.
For clarification: In which sense do you mean "transparent"?
There are two interpretations around:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, so basically you want a base set of exceptions that an S-Mode OS can expect to be delivered? (like unaligned access).
Will bring this up in the BRS call today and come back with some guidance.