From 6159883fea63b01c6ae23f2f2c9efb5d7234669a Mon Sep 17 00:00:00 2001 From: Ved Shanbhogue Date: Mon, 29 Jan 2024 13:13:29 -0600 Subject: Add note about trap handlers --- src/machine.adoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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] -- cgit v1.1