You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/cheri/cheri-pte-ext.adoc
+30-26Lines changed: 30 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
[#section_cheri_priv_crg_ext]
2
2
== "{cheri_priv_crg_ext}" Extension, Version 1.0 for {cheri_base64_ext_name}
3
3
4
+
{not_v1_ratification_package}
5
+
4
6
NOTE: _Sv32_ (for RV32) does not have any spare PTE bits, and so no features from this chapter can be implemented.
5
7
6
8
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
62
64
63
65
==== {cheri_excep_name_pte_ld}s
64
66
65
-
66
67
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`.
67
68
68
69
The implementation raises a {cheri_excep_name_pte_ld} when, in addition to the rules above, all of the following are true:
69
70
70
71
. 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}.
72
72
. _pte.crg_ does not equal `sstatus.UCRG`.
73
73
. _pte.u_ is set.
74
74
. Any other platform specific rules have not forced the loaded {ctag} to be clear.
75
+
. The loaded {ctag} is set.
75
76
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.
77
78
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.
79
80
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.
82
84
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.
84
86
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.
91
90
92
91
[[pte_crw_crg_load_summary]]
93
92
.Summary of capability load _pte.crw_ and _pte.crg_ behavior in the PTEs
| 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^
103
102
|===
104
103
105
104
^1^ A future version of this specification may check an SCRG bit in `sstatus` in this case for trapping on kernel pages.
106
105
107
106
NOTE: {cheri_excep_name_pte_ld}s may be used to implement the load-barrier primitive from cite:[cornucopia-reloaded].
108
107
109
-
==== Capability Dirty Tracking
108
+
==== {cheri_excep_name_pte_st}s
109
+
110
+
{cheri_excep_name_pte_st}s are used for:
110
111
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_).
111
114
112
115
When _pte.crw_ is set, the _pte.cd_ bit indicates that a capability was stored to the
113
116
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
134
137
| 0 | 0 | 0 | {cheri_excep_name_pte_st} if the to-be-stored {ctag} is set
135
138
| 0 | 0 | 1 | Reserved
136
139
| 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_)
138
142
| 1 | 1 | X | Normal operation
139
143
|===
140
144
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_.
142
146
ifndef::cheri_standalone_spec[]
143
147
This follows the standard rules in xref:sv32algorithm[xrefstyle=short].
144
148
endif::[]
145
149
146
150
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_, .
148
152
149
153
Capability dirty tracking _always_ checks the {ctag} on stored capabilities when determining whether to raise the {cheri_excep_name_pte_st}.
150
154
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}.
153
157
154
158
NOTE: Capability dirty tracking may be used to implement the store-barrier primitive from cite:[cornucopia-reloaded].
^1^ {pcc} bounds are checked against all bytes of fetched instructions.
209
209
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.
210
210
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}.
214
212
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].
216
214
217
215
ifdef::cheri_standalone_spec[]
218
216
==== Machine Trap Delegation Register (medeleg)
@@ -586,9 +584,9 @@ Such sharing through virtual memory is on the page granularity, so preventing ca
586
584
^*^ _allocated using mmap_
587
585
588
586
[#cheri_pte_fault]
589
-
=== CHERI page faults
587
+
=== CHERI virtual memory related faults
590
588
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:
592
590
593
591
* {cheri_excep_name_pte_ld} (cause value {cheri_excep_cause_pte_ld}), and
594
592
* {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-
597
595
598
596
The _pte.crw_ bit allows {cheri_excep_name_pte_st}s to be raised.
599
597
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.
601
599
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.
603
601
604
602
==== Extending the Page Table Entry Format
605
603
@@ -625,8 +623,8 @@ When the CRW bit is set, capabilities are written as usual.
625
623
626
624
If the CRW bit is clear then, in priority order for AMOs:
627
625
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.
629
626
* 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.
630
628
631
629
[[pte_crw_summary]]
632
630
.Summary of memory access behavior depending on _pte.crw_, in priority order for AMOs.
0 commit comments