Skip to content

Commit e9abb67

Browse files
Remove Svucrglct, make load cap fault lowest priority, update exception tables, remove Svucrg from first ratification package
1 parent 251db2b commit e9abb67

File tree

9 files changed

+108
-104
lines changed

9 files changed

+108
-104
lines changed

src/cheri/attributes.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ endif::support_varxlen[]
8080

8181
// Extension for CHERI CRG bits
8282
:cheri_priv_crg_ext: Svucrg
83-
:cheri_priv_crg_load_tag_ext: Svucrglct
8483

8584
// Extension for capability levels (flow control)
8685
:cheri_levels1_ext_name: Zylevels1
@@ -172,8 +171,7 @@ endif::support_varxlen[]
172171
:cheri_excep_name_pc: CHERI Instruction Access Fault
173172
:cheri_excep_name_ld: CHERI Load Access Fault
174173
:cheri_excep_name_st: CHERI Store/AMO Access Fault
175-
:cheri_excep_name_pte: CHERI Page Fault
176-
:cheri_excep_name_pte_ld: CHERI Load Page Fault
174+
:cheri_excep_name_pte_ld: CHERI Load Capability Fault
177175
:cheri_excep_name_pte_st: CHERI Store/AMO Page Fault
178176

179177
:cheri_excep_desc_ytag: Authorizing {ctag} is set to 0.

src/cheri/cheri-pte-ext.adoc

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[#section_cheri_priv_crg_ext]
22
== "{cheri_priv_crg_ext}" Extension, Version 1.0 for {cheri_base64_ext_name}
33

4+
{not_v1_ratification_package}
5+
46
NOTE: _Sv32_ (for RV32) does not have any spare PTE bits, and so no features from this chapter can be implemented.
57

68
The {cheri_priv_crg_ext} extension is enabled when the `sstatus.CRGE` bit is set.
@@ -62,52 +64,53 @@ When all of the following are true, {cheri_priv_crg_ext} adds two primitives for
6264

6365
==== {cheri_excep_name_pte_ld}s
6466

65-
6667
When _pte.crw_ is set, _pte.crg_ can be used to trap on capability loads or AMOs when it does not match the value of `sstatus.UCRG`.
6768

6869
The implementation raises a {cheri_excep_name_pte_ld} when, in addition to the rules above, all of the following are true:
6970

7071
. A capability load or AMO is executed.
71-
.. Where an AMO can raise both faults, {cheri_excep_name_pte_ld} is prioritized above {cheri_excep_name_pte_st}.
7272
. _pte.crg_ does not equal `sstatus.UCRG`.
7373
. _pte.u_ is set.
7474
. Any other platform specific rules have not forced the loaded {ctag} to be clear.
75+
. The loaded {ctag} is set.
7576

76-
NOTE: An example of a platform specific rule is a hardware engine clearing {ctag}s in memory after a call to free() to offload the CPU, which may have cleared a {ctag} before the CPU loads it.
77+
{cheri_excep_name_pte_ld} is prioritized below {cheri_excep_name_pte_st} as shown in <<exception-priority-cheri>>, as AMOs can raise both.
7778

78-
There is an additional rule if _{cheri_priv_crg_load_tag_ext}_ is implemented:
79+
NOTE: An example of a platform specific rule is a hardware engine clearing {ctag}s in memory after a call to free() to offload the CPU, which may have cleared a {ctag} before the CPU loads it.
7980

80-
[start=5]
81-
. The loaded {ctag} is set.
81+
The {cheri_excep_name_pte_ld} _must_ be taken if the loaded {ctag} is set.
82+
The {cheri_excep_name_pte_ld} _may_ be taken if the loaded {ctag} is not set.
83+
This gives a range of valid implementations.
8284

83-
NOTE: Checking the value of the {ctag} requires taking data dependent exceptions on loaded data for loads or AMOs, and also affects the exception priority, see xref:exception-priority[xrefstyle=short].
85+
NOTE: Checking the value of the {ctag} requires taking data dependent exceptions on loaded capabilities for loads or AMOs.
8486
Ideally all implementations would trap precisely (taking the {ctag} into account) rather than conservatively (on every capability access).
85-
However, this information may not be available in all implementations, and therefore both choices are permitted.
86-
This can be communicated to software by showing presence of the _{cheri_priv_crg_load_tag_ext}_ extension which implies {cheri_priv_crg_ext}.
87-
Implementations which already take synchronous traps on loaded data, such as ECC faults, should implement _{cheri_priv_crg_load_tag_ext}_.
88-
Both choices can be handled correctly by the same software, but {cheri_priv_crg_load_tag_ext} is expected to result in fewer spurious traps.
89-
90-
Even if the _{cheri_priv_crg_load_tag_ext}_ extension is implemented, implementations are still allowed to conservatively fault in some situations in which the {ctag} is not set.
87+
However, this information may not be available in all implementations, and therefore flexibility is permitted.
88+
Implementations which already take synchronous traps on loaded data, such as ECC faults, should check the loaded {ctag}.
89+
The software is required to be tolerant of raising the trap when the {ctag} is not set, resulting in potentially spurious traps.
9190

9291
[[pte_crw_crg_load_summary]]
9392
.Summary of capability load _pte.crw_ and _pte.crg_ behavior in the PTEs
9493
[%autowidth,float="center",align="center",cols="<,<,<,<,<",options="header"]
9594
|===
96-
|_pte.crw_| _pte.cd_| _pte.crg_ | _pte.u_| Load/AMO
97-
| 0 | 0 | 0 | X | Clear loaded {ctag}
98-
| 0 | 0 | 1 | X | Reserved
99-
| 0 | 1 | X | X | Reserved
100-
| 1 | X | {ne} `sstatus.` `UCRG` | 1 | {cheri_excep_name_pte_ld}, or {cheri_excep_name_pte_ld} if {ctag} is set for _{cheri_priv_crg_load_tag_ext}_
101-
| 1 | X | = `sstatus.` `UCRG` | 1 | Normal operation
102-
| 1 | X | X | 0 | Normal operation^1^
95+
|_pte.crw_| _pte.cd_| _pte.crg_ | _pte.u_| Load/AMO
96+
| 0 | 0 | 0 | X | Clear loaded {ctag}
97+
| 0 | 0 | 1 | X | Reserved
98+
| 0 | 1 | X | X | Reserved
99+
| 1 | X | {ne} `sstatus.UCRG` | 1 | {cheri_excep_name_pte_ld} if {ctag} is set
100+
| 1 | X | = `sstatus.UCRG` | 1 | Normal operation
101+
| 1 | X | X | 0 | Normal operation^1^
103102
|===
104103

105104
^1^ A future version of this specification may check an SCRG bit in `sstatus` in this case for trapping on kernel pages.
106105

107106
NOTE: {cheri_excep_name_pte_ld}s may be used to implement the load-barrier primitive from cite:[cornucopia-reloaded].
108107

109-
==== Capability Dirty Tracking
108+
==== {cheri_excep_name_pte_st}s
109+
110+
{cheri_excep_name_pte_st}s are used for:
110111

112+
* Detecting capability writes to pages without capability read/write permission permission (_pte.crw=0_).
113+
* Capability dirty tracking for pages with capability read/write permission permission that are capability clean (_pte.crw=1_, _pte.cd=0_).
111114

112115
When _pte.crw_ is set, the _pte.cd_ bit indicates that a capability was stored to the
113116
virtual page since the last time the _pte.cd_ bit was cleared.
@@ -134,22 +137,23 @@ Two schemes for this are permitted, and the scheme in use is determined by wheth
134137
| 0 | 0 | 0 | {cheri_excep_name_pte_st} if the to-be-stored {ctag} is set
135138
| 0 | 0 | 1 | Reserved
136139
| 0 | 1 | X | Reserved
137-
| 1 | 0 | X | {cheri_excep_name_pte_st} if the to-be-stored {ctag} is set (_Svade_), or hardware _pte.cd_ update (_Svadu_)
140+
| 1 | 0 | X | {cheri_excep_name_pte_st} if the to-be-stored {ctag} is set (_Svade_) +
141+
or hardware _pte.cd_ update (_Svadu_)
138142
| 1 | 1 | X | Normal operation
139143
|===
140144

141-
NOTE: Because the state of _pte.cd=1_ and _pte.crw=0_ is illegal, it is possible for the update of _pte.cd_ to fail if another thread has cleared _pte.crw_.
145+
NOTE: Because Because the state of _pte.cd=1_ and _pte.crw=0_ is _reserved_, , it is possible for the update of _pte.cd_ to fail if another thread has cleared _pte.crw_.
142146
ifndef::cheri_standalone_spec[]
143147
This follows the standard rules in xref:sv32algorithm[xrefstyle=short].
144148
endif::[]
145149

146150
NOTE: For non-capability data, it is possible for a virtual page to be read-only but also dirty (_pte.w=0, pte.d=1_).
147-
The analogous page state is not permitted for capability data as _pte.crw=0, pte.cd=1_ is _reserved_.
151+
The analogous page state is not permitted for capability data as the state of _pte.cd=1_ and _pte.crw=0_ is _reserved_, .
148152

149153
Capability dirty tracking _always_ checks the {ctag} on stored capabilities when determining whether to raise the {cheri_excep_name_pte_st}.
150154

151-
NOTE: Checking the stored {ctag} is less of a burden to the implementation than checking the loaded {ctag} for {cheri_priv_crg_load_tag_ext}, which is why checking the loaded {ctag} is optional behavior.
152-
However, a future extension may reduce the burden further by removing the check on the stored {ctag}.
155+
NOTE: Checking the stored {ctag} is less of a burden to the implementation than checking the loaded {ctag} for {cheri_excep_name_pte_ld}, which is why checking the loaded {ctag} is optional behavior.
156+
However, a future extension may reduce the burden further by removing the check on the to-be-stored {ctag}.
153157

154158
NOTE: Capability dirty tracking may be used to implement the store-barrier primitive from cite:[cornucopia-reloaded].
155159

src/cheri/introduction.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,10 @@ ifdef::support_varxlen[]
106106
endif::support_varxlen[]
107107
|<<section_priv_cheri_vmem,{cheri_priv_vmem_ext}>> | Virtual Memory
108108
|<<section_debug_integration_trig,{cheri_priv_debug_trig}>> | Debug triggers
109-
|<<section_cheri_priv_crg_ext, {cheri_priv_crg_ext}>>^1^ | MMU-based acceleration of capability revocation for heap temporal safety
109+
|<<section_cheri_priv_crg_ext, {cheri_priv_crg_ext}>> | MMU-based acceleration of capability revocation for heap temporal safety
110110
|<<sec_zycheriot_priv>> | CHERIoT privileged extension
111111
|=============================================================================================================================================================
112112

113-
^1^ {cheri_priv_crg_load_tag_ext} is available for improved software revocation performance if {cheri_priv_crg_ext} is implemented.
114-
115113
.Debug stable extensions and specifications
116114
[#debug-extension-status,reftext="Extension Status and Summary"]
117115
[options=header,align=center,width="90%"]

src/cheri/riscv-priv-integration.adoc

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,53 +166,51 @@ The new exception codes and priorities are listed in
166166
xref:mcauses[xrefstyle=short] and xref:exception-priority-cheri[xrefstyle=short] respectively.
167167

168168
[[exception-priority-cheri]]
169-
.Synchronous exception priority in decreasing priority order. Entries added in {cheri_base_ext_name} are in *bold*
170-
[float="center",align="center",cols="<1,>1,<8",options="header"]
169+
.Synchronous exception priority in decreasing priority order for {cheri_base_ext_name}.
170+
[%autowidth,float="center",align="center",cols="<,>,<",options="header",]
171171
|===
172172
|Priority |Exc.Code |Description
173173
|_Highest_ |3 |Instruction address breakpoint
174-
| .>|*{cheri_excep_cause_pc}* .<|*Prior to instruction address translation:* +
175-
*{cheri_excep_name_pc} due to {pcc} checks ({ctag}, execute permission, bounds^1^)*
174+
| .>|{cheri_excep_cause_pc} .<|Prior to instruction address translation: +
175+
{cheri_excep_name_pc} due to {pcc} checks ({ctag}, sealed, execute permission, bounds^1^)
176176
| .>|12, 1 .<|During instruction address translation: +
177177
First encountered page fault or access fault
178178
| .>|1 .<|With physical address for instruction: +
179179
Instruction access fault
180180

181181
| .>|2 +
182-
*{cheri_excep_cause_pc}* +
182+
{cheri_excep_cause_pc} +
183183
0 +
184184
8,9,11 +
185185
3 +
186186
3 .<|Illegal instruction +
187-
*{cheri_excep_name_pc} due to {pcc} <<asr_perm>> clear* +
187+
{cheri_excep_name_pc} due to {pcc} <<asr_perm>> clear +
188188
Instruction address misaligned +
189189
Environment call +
190190
Environment break +
191191
Load/store/AMO address breakpoint
192192

193-
| .>|*{cheri_excep_cause_ls_list}* .<|*Prior to address translation for an explicit memory access:* +
194-
*{cheri_excep_name_ld}, {cheri_excep_name_st} due to capability checks ({ctag}, sealed, permissions, bounds)*
195-
| .>|4,6 .<|*Load/store/AMO capability address misaligned* +
196-
Optionally: +
193+
| .>|{cheri_excep_cause_ls_list} .<|Prior to address translation for an explicit memory access: +
194+
{cheri_excep_name_ld}, {cheri_excep_name_st} due to capability checks ({ctag}, sealed, permissions, bounds)
195+
| .>|4,6 .<|Load/store/AMO capability address misaligned +
196+
197+
| .>|4,6 .<|Optionally: +
197198
Load/store/AMO address misaligned
198-
| .>|*{cheri_excep_cause_pte_ld}, {cheri_excep_cause_pte_st},* 13, 15, 5, 7 .<|During address translation for an explicit memory access: +
199-
First encountered *{cheri_excep_name_pte_ld}^2^, {cheri_excep_name_pte_st}*, page fault or access fault
199+
| .>|{cheri_excep_cause_pte_st}, 13, 15, 5, 7 .<|During address translation for an explicit memory access: +
200+
First encountered {cheri_excep_name_pte_st}, page fault or access fault
200201
| .>|5,7 .<|With physical address for an explicit memory access: +
201202
Load/store/AMO access fault
202-
| .>|4,6 .<|If not higher priority: +
203+
.>| .>|4,6 .<|If not higher priority: +
203204
Load/store/AMO address misaligned
204-
.>|_Lowest_ .>|*{cheri_excep_cause_pte_ld}* .<|*If not higher priority: +
205-
{cheri_excep_name_pte_ld}^3^*
205+
.>|_Lowest_ .>|{cheri_excep_cause_pte_ld} .<|{cheri_excep_name_pte_ld}^2^
206206
|===
207207

208208
^1^ {pcc} bounds are checked against all bytes of fetched instructions.
209209
If the instructions could not be decoded to determine the length, then the <<pcc>> bounds check is made against the minimum sized instruction supported by the implementation which can be executed, when prioritizing against Instruction Access Faults.
210210

211-
^2^ The higher priority {cheri_excep_name_pte_ld} covers capability loads or atomics where the loaded {ctag} _is not_ checked ({cheri_priv_crg_ext} is implemented) .
212-
213-
^3^ The lower priority {cheri_excep_name_pte_ld} covers capability loads or atomics where the loaded {ctag} _is_ checked ({cheri_priv_crg_load_tag_ext} is implemented).
211+
^2^ {cheri_excep_name_pte_ld} is the lowest priority as determining whether to raise the exception may include checking the loaded {ctag}.
214212

215-
NOTE: The full details of the CHERI exceptions are in xref:cheri_exception_combs_descriptions[xrefstyle=short].
213+
NOTE: The full details of {cheri_excep_name_pc}, {cheri_excep_name_ld} and {cheri_excep_name_st} are in xref:cheri_exception_combs_descriptions[xrefstyle=short].
216214

217215
ifdef::cheri_standalone_spec[]
218216
==== Machine Trap Delegation Register (medeleg)
@@ -586,9 +584,9 @@ Such sharing through virtual memory is on the page granularity, so preventing ca
586584
^*^ _allocated using mmap_
587585

588586
[#cheri_pte_fault]
589-
=== CHERI page faults
587+
=== CHERI virtual memory related faults
590588

591-
CHERI adds the concept of _CHERI page faults_. They are split into:
589+
CHERI adds the concept of CHERI virtual memory related faults. They are split into:
592590

593591
* {cheri_excep_name_pte_ld} (cause value {cheri_excep_cause_pte_ld}), and
594592
* {cheri_excep_name_pte_st} (cause value {cheri_excep_cause_pte_st})
@@ -597,9 +595,9 @@ They are prioritized against other fault types as shown in <<exception-priority-
597595

598596
The _pte.crw_ bit allows {cheri_excep_name_pte_st}s to be raised.
599597

600-
NOTE: {cheri_excep_name_pte_ld} faults are at present raised only if <<section_cheri_priv_crg_ext,{cheri_priv_crg_ext}>> is enabled.
598+
NOTE: {cheri_excep_name_pte_ld} faults are at present raised only if {cheri_priv_crg_ext} is enabled.
601599

602-
NOTE: {cheri_excep_name_pte_st} faults are raised under more circumstances if <<section_cheri_priv_crg_ext,{cheri_priv_crg_ext}>> and Svade are both enabled.
600+
NOTE: {cheri_excep_name_pte_st} faults are raised under more circumstances if {cheri_priv_crg_ext} and Svade are both enabled.
603601

604602
==== Extending the Page Table Entry Format
605603

@@ -625,8 +623,8 @@ When the CRW bit is set, capabilities are written as usual.
625623

626624
If the CRW bit is clear then, in priority order for AMOs:
627625

628-
* When a capability load or AMO instruction is executed, the {ctag} of the loaded capability is cleared before it is written to the destination register.
629626
* When a capability store or AMO instruction is executed, and the to-be-stored {ctag} is set, a <<cheri_pte_fault,_{cheri_excep_name_pte_st}_>> exception is raised.
627+
* When a capability load or AMO instruction is executed, the {ctag} of the loaded capability is cleared before it is written to the destination register.
630628

631629
[[pte_crw_summary]]
632630
.Summary of memory access behavior depending on _pte.crw_, in priority order for AMOs.

src/cheri/trigger-integration.adoc

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,53 @@ shown in xref:trigger-exception-priority[xrefstyle=short].
1212
Debug triggers are higher priority than CHERI exceptions to allow debug.
1313

1414
[[trigger-exception-priority]]
15-
.Synchronous exception priority (including triggers) in decreasing priority order. Entries added in {cheri_base_ext_name} are in *bold*
16-
[float="center",align="center",cols="<1,>1,<4,<2",options="header"]
15+
.Synchronous exception priority in decreasing priority order.
16+
[align="center",float="center", cols="^1,<1,<2,<2", options="header"]
1717
|===
18-
|Priority |Exc. Code |Description |Trigger
19-
|_Highest_ |3 +
18+
| Priority | Exception Code | Description | Trigger
19+
| _Highest_
20+
| 3 +
2021
3 +
2122
3 +
22-
3 | | etrigger +
23+
3
24+
|
25+
| etrigger +
2326
icount +
2427
itrigger +
25-
mcontrol/mcontrol6 after (on previous instruction)
26-
27-
| .>|3 .<|Instruction address breakpoint |mcontrol/mcontrol6 execute address before
28-
| .>|*{cheri_excep_cause_pc}* .<|*Prior to instruction address translation:* +
29-
*{cheri_excep_name_pc} due to {pcc} checks (tag, execute permission, and bounds)* |
30-
| .>|12, 1 .<|During instruction address translation: +
31-
First encountered page fault or access fault |
32-
| .>|1 .<|With physical address for instruction: +
33-
Instruction access fault |
34-
35-
| .>|3 .<| |mcontrol/mcontrol6 execute data before
36-
37-
| .>|2 +
28+
mcontrol/mcontrol6 after (on previous instruction) +
29+
|| 3 | Instruction address breakpoint | mcontrol/mcontrol6 execute address before
30+
| .>|{cheri_excep_cause_pc} .<|Prior to instruction address translation: +
31+
{cheri_excep_name_pc} due to {pcc} checks ({ctag}, sealed, execute permission, bounds^1^)|
32+
|| 12, 20, 1 | During instruction address translation: First encountered page fault, guest-page fault, or access fault |
33+
|| 1 | With physical address for instruction: Instruction access fault |
34+
|| 3 || mcontrol/mcontrol6 execute data before
35+
|| 2 +
36+
{cheri_excep_cause_pc} +
37+
22 +
3838
0 +
39-
8,9,11 +
40-
3 .<|Illegal instruction +
39+
8, 9, 10, 11 +
40+
3 +
41+
3 +
42+
| Illegal instruction +
43+
{cheri_excep_name_pc} due to {pcc} <<asr_perm>> clear +
44+
Virtual instruction +
4145
Instruction address misaligned +
4246
Environment call +
43-
Environment break |
47+
Environment break +
48+
Load/Store/AMO address breakpoint
49+
.>| mcontrol/mcontrol6 load/store address before, store data before
4450

45-
| .>|3 .<|Load/store/AMO address breakpoint |mcontrol/mcontrol6 load/store address before
46-
| .>|3 .<| |mcontrol/mcontrol6 store data before
51+
| .>|{cheri_excep_cause_ls_list} .<|Prior to address translation for an explicit memory access: +
52+
{cheri_excep_name_ld}, {cheri_excep_name_st} due to capability checks ({ctag}, sealed, permissions, bounds) |
53+
| .>|4,6 .<|Load/store/AMO capability address misaligned |
4754

48-
| .>|*{cheri_excep_cause_ls_list}* .<|*Prior to address translation for an explicit memory access:* +
49-
*Load/store/AMO capability address misaligned* +
50-
*{cheri_excep_name_ld}, {cheri_excep_name_st} due to capability checks (tag, sealed, permissions and bounds)* |
55+
|| 4, 6 | Optionally: Load/Store/AMO address misaligned |
5156

52-
| .>|4,6 .<|Optionally: +
53-
Load/store/AMO address misaligned |
54-
| .>|*{cheri_excep_cause_pte_ld}*, *{cheri_excep_cause_pte_st}*, 5, 7 .<|During address translation for an explicit memory access: +
55-
First encountered *{cheri_excep_name_pte_ld}, {cheri_excep_name_pte_st}*, page fault or access fault |
56-
| .>|5,7 .<|With physical address for an explicit memory access: +
57-
Load/store/AMO access fault |
58-
| .>|4,6 .<|If not higher priority: +
59-
Load/store/AMO address misaligned |
60-
| .>|*{cheri_excep_cause_pte_ld}* .<|If not higher priority: +
61-
*{cheri_excep_name_pte_ld}* ^3^ |
62-
|_Lowest_ .>|3 .<| |mcontrol/mcontrol6 load data before
57+
||{cheri_excep_cause_pte_st}, 13, 15, 21, 23, 5, 7 | During address translation for an explicit
58+
memory access: First encountered {cheri_excep_name_pte_st}, page fault, guest-page fault, or access
59+
fault |
60+
|| 5, 7 | With physical address for an explicit memory access: Load/store/AMO access fault |
61+
|| 4, 6 | If not higher priority: Load/store/AMO address misaligned |
62+
|| {cheri_excep_cause_pte_ld} |{cheri_excep_name_pte_ld} |
63+
| _Lowest_ | 3 || mcontrol/mcontrol6 load data before
6364
|===
64-
65-
NOTE: See the notes beneath <<exception-priority>> for details about <<section_priv_cheri_vmem,CHERI load page fault>> priority.

0 commit comments

Comments
 (0)