Skip to content
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 extra information into exception reporting #373

Merged
merged 17 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/img/mtval2reg.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[bytefield]
----
(defattrs :plain [:plain {:font-family "M+ 1p Fallback" :font-size 24}])
(def row-height 40)
(def row-header-fn nil)
(def left-margin 100)
(def right-margin 100)
(def boxes-per-row 32)
(draw-column-headers {:height 20 :font-size 18 :labels (reverse ["0" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "MXLEN-1"])})

(draw-box "Addr" {:span 32})

(draw-box "MXLEN" {:span 32 :borders {}})
----
8 changes: 5 additions & 3 deletions src/img/mtvalreg.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
(def left-margin 100)
(def right-margin 100)
(def boxes-per-row 32)
(draw-column-headers {:height 20 :font-size 18 :labels (reverse ["0" "" "" "3" "4" "" "" "" "" "" "" "" "" "" "" "15" "16" "" "" "19" "20" "" "" "" "" "" "" "" "" "" "" "MXLEN-1"])})
(draw-column-headers {:height 20 :font-size 18 :labels (reverse ["0" "" "" "3" "4" "" "" "" "" "9" "10" "" "" "" "" "15" "16" "" "" "19" "20" "" "" "" "" "" "" "" "" "" "" "MXLEN-1"])})

(draw-box "Reserved" {:span 12})
(draw-box "TYPE" {:span 4})
(draw-box "Reserved" {:span 12})
(draw-box "Reserved" {:span 6})
(draw-box "CAP_IDX" {:span 6})
(draw-box "CAUSE" {:span 4})

(draw-box "MXLEN-20" {:span 12 :borders {}})
(draw-box "4" {:span 4 :borders {}})
(draw-box "12" {:span 12 :borders {}})
(draw-box "6" {:span 6 :borders {}})
(draw-box "6" {:span 6 :borders {}})
(draw-box "4" {:span 4 :borders {}})
----
14 changes: 14 additions & 0 deletions src/img/stval2reg.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[bytefield]
----
(defattrs :plain [:plain {:font-family "M+ 1p Fallback" :font-size 24}])
(def row-height 40)
(def row-header-fn nil)
(def left-margin 100)
(def right-margin 100)
(def boxes-per-row 32)
(draw-column-headers {:height 20 :font-size 18 :labels (reverse ["0" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "MXLEN-1"])})

(draw-box "Addr" {:span 32})

(draw-box "MXLEN" {:span 32 :borders {}})
----
tariqkurd-repo marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 5 additions & 3 deletions src/img/stvalreg.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
(def left-margin 100)
(def right-margin 100)
(def boxes-per-row 32)
(draw-column-headers {:height 20 :font-size 18 :labels (reverse ["0" "" "" "3" "4" "" "" "" "" "" "" "" "" "" "" "15" "16" "" "" "19" "20" "" "" "" "" "" "" "" "" "" "" "SXLEN-1"])})
(draw-column-headers {:height 20 :font-size 18 :labels (reverse ["0" "" "" "3" "4" "" "" "" "" "9" "10" "" "" "" "" "15" "16" "" "" "19" "20" "" "" "" "" "" "" "" "" "" "" "SXLEN-1"])})

(draw-box "Reserved" {:span 12})
(draw-box "TYPE" {:span 4})
(draw-box "Reserved" {:span 12})
(draw-box "Reserved" {:span 6})
(draw-box "CAP_IDX" {:span 6})
(draw-box "CAUSE" {:span 4})

(draw-box "SXLEN-20" {:span 12 :borders {}})
(draw-box "4" {:span 4 :borders {}})
(draw-box "12" {:span 12 :borders {}})
(draw-box "6" {:span 6 :borders {}})
(draw-box "6" {:span 6 :borders {}})
(draw-box "4" {:span 4 :borders {}})
----
53 changes: 49 additions & 4 deletions src/riscv-integration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,20 @@ xref:mtval-cheri-causes[xrefstyle=short] respectively.
| 3-15 | Reserved
|==============================================================================

.Encoding of CAP_IDX field
[#mtval-cheri-cap-idx,width=65%,float="center",align="center",options=header,cols="30%,70%"]
|==============================================================================
| CHERI CAP_IDX Code | Description
| 0 | Faulting cap was c0
| 1 | Faulting cap was c1
| ... |
| 30 | Faulting cap was c30
| 31 | Faulting cap was c31
| 32 | Faulting cap was <<ddc>>
| 33 | Faulting cap was <<pcc>>
| 34-63 | Reserved
|==============================================================================

tariqkurd-repo marked this conversation as resolved.
Show resolved Hide resolved
.Encoding of CAUSE field
[#mtval-cheri-causes,width=55%,float="center",align="center",options=header]
|==============================================================================
Expand All @@ -791,6 +805,24 @@ CHERI violations have the following order in priority:
. Invalid address violation
. Bounds violation (_Lowest_)

[#mtval2,reftext="mtval2"]
==== Machine Trap Value Register 2 (mtval2)

The <<mtval2>> register is an MXLEN-bit read-write register, which is added as part of the
Hypervisor extension. {cheri_base_ext_name} also requires the implementation of this CSR.

When a CHERI fault is taken on any data memory access into into M-mode, <<mtval2>> is written
with the MXLEN-bit address which caused the fault. This follows the existing rules for reporting
tariqkurd-repo marked this conversation as resolved.
Show resolved Hide resolved
load/store addresses to <<mtval>> from [riscv-priv-spec].
tariqkurd-repo marked this conversation as resolved.
Show resolved Hide resolved
This reported address can be used together with the CAP_IDX field of <<mtval>> to diagnose the
authorising capability which caused the exception.

<<mtval2>> is set to zero for all PCC faults, and follows the standard rules for non-CHERI exceptions.
tariqkurd-repo marked this conversation as resolved.
Show resolved Hide resolved
tariqkurd-repo marked this conversation as resolved.
Show resolved Hide resolved

.Machine trap value register 2
[#mtval2-format]
include::img/mtval2reg.edn[]

[#supervisor-level-csrs-section]
=== Supervisor-Level CSRs

Expand Down Expand Up @@ -993,10 +1025,23 @@ xref:stval-format[xrefstyle=short] to assist software in handling the trap.
[#stval-format]
include::img/stvalreg.edn[]

TYPE is a CHERI-specific fault type that caused the exception while CAUSE
is the cause of the fault. The possible CHERI types and causes are encoded as
shown in xref:mtval-cheri-type[xrefstyle=short] and
xref:mtval-cheri-causes[xrefstyle=short] respectively.
The fields are identical to <<mtval>> for CHERI exceptions.

[#stval2,reftext="stval2"]
==== Supervisor Trap Value Register 2 (stval2)
andresag01 marked this conversation as resolved.
Show resolved Hide resolved

The <<stval2>> register is an SXLEN-bit read-write register.

The CSR address is 0x14b.

When a fault is taken into S-mode <<stval2>> is updated as for <<mtval2>> for all CHERI memory access traps.
tariqkurd-repo marked this conversation as resolved.
Show resolved Hide resolved
tariqkurd-repo marked this conversation as resolved.
Show resolved Hide resolved
It is set to zero in all other cases.

NOTE: This is not a standard RISC-V CSR, but <<mtval2>> is. 0x14b is the regular location for the CSR.

.Supervisor trap value register 2
[#stval2-format]
include::img/stval2reg.edn[]

=== Unprivileged CSRs

Expand Down
Loading