diff options
author | Andrew Waterman <andrew@sifive.com> | 2024-01-29 16:38:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 16:38:59 -0800 |
commit | 4f66e8be0ffe9ab52fcc36fe864171ecd61b3239 (patch) | |
tree | 0d15cb7dc37adf3c61008a63b4a45a39b46f047d | |
parent | 86ff22d64be34bf880290f74b57190a7d3bca0f1 (diff) | |
parent | 6159883fea63b01c6ae23f2f2c9efb5d7234669a (diff) | |
download | riscv-isa-manual-4f66e8be0ffe9ab52fcc36fe864171ecd61b3239.zip riscv-isa-manual-4f66e8be0ffe9ab52fcc36fe864171ecd61b3239.tar.gz riscv-isa-manual-4f66e8be0ffe9ab52fcc36fe864171ecd61b3239.tar.bz2 |
Merge pull request #1208 from ved-rivos/trap_handler_guidelines
Add note to guide trap handler design
-rw-r--r-- | src/machine.adoc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/machine.adoc b/src/machine.adoc index 2e85dee..269607c 100644 --- a/src/machine.adoc +++ b/src/machine.adoc @@ -437,6 +437,19 @@ __y__≠M, __x__RET also sets MPRV=0. Setting __x__PP to the least-privileged supported mode on an __x__RET helps identify software bugs in the management of the two-level privilege-mode stack. ==== +[NOTE] +==== +Trap handlers must be designed to neither enable interrupts nor cause exceptions +during the phase of handling where the trap handler preserves the critical state +information required to handle and resume from the trap. An exception or +interrupt in this critical phase of trap handling may lead to a trap that can +overwrite such critical state. This could result in the loss of data needed to +recover from the initial trap. Further, if an exception occurs in the code path +needed to handle traps, then such a situation may lead to an infinite loop of +traps. To prevent this, trap handlers must be meticulously designed to identify +and safely manage exceptions within their operational flow. +==== + __x__PP fields are *WARL* fields that can hold only privilege mode _x_ and any implemented privilege mode lower than _x_. If privilege mode _x_ is not implemented, then __x__PP must be read-only 0. [NOTE] |