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

apply ACPERM rules in order #427

Merged
merged 21 commits into from
Nov 4, 2024
Merged
Changes from 11 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
61 changes: 29 additions & 32 deletions src/insns/acperm_32bit.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,38 @@ ACPERM performs the following operations:
format shown in xref:acperm_bit_field[xrefstyle=short].
. Calculate the bitwise AND of the bit field with the mask `rs2`.
. If the AP and <<m_bit>> field in `cs1` could not have been produced by <<ACPERM>> then
clear all AP permissions and the <<m_bit>>, and skip the next step
clear all AP permissions, and the <<m_bit>> to {CAP_MODE_VALUE}. Skip the next step.
. Clear AP permissions as required to meet the rules below.
. Encode the AP permissions for MXLEN=32 according to <<cap_perms_encoding32>>.
. Encode the AP permissions for RV32 according to <<cap_perms_encoding32>>.
. Copy `cs1` to `cd`, and update the AP and SDP fields with the newly calculated versions.
. Set `cd.tag=0` if `cs1` is sealed or if any reserved fields of `cs1` are set.
+
Some combinations of permissions cannot be encoded for MXLEN=32, and are not useful when MXLEN=64.
These cases are defined to return useful minimal sets of permissions, which may be no permissions.
+
NOTE: Future extensions may allow more combinations of permissions, especially for MXLEN=64.

The common rules are:

. <<asr_perm>> cannot be set without <<x_perm>> being set
.. Clear <<asr_perm>> unless <<x_perm>> is set
. <<c_perm>> cannot be set without at least one of <<r_perm>> or <<w_perm>> being set.
.. Clear <<c_perm>> unless <<r_perm>> or <<w_perm>> are set.
. <<m_bit>> cannot be set without <<x_perm>> being set
.. Clear <<m_bit>> unless <<x_perm>> is set
. <<lm_perm>> cannot be set without <<c_perm>> being set
.. Clear <<lm_perm>> unless <<c_perm>> is set.
. <<sl_perm>> cannot be set without <<c_perm>> being set
.. Zero <<sl_perm>> unless <<c_perm>> is set.
. <<el_perm>> cannot be set without <<c_perm>> being set
.. Zero <<el_perm>> unless <<c_perm>> is set.

NOTE: The combination of <<x_perm>> clear and <<m_bit>> set is reserved for future extensions.

The MXLEN=32 additional rules are:

. Clear <<asr_perm>> unless _all_ other permissions are set
. Clear <<c_perm>> and <<x_perm>> if <<r_perm>> is not set
. Clear <<w_perm>> if <<c_perm>> _is_ set, but <<lm_perm>> _is not_ set.
. Clear <<x_perm>> if <<x_perm>> and <<r_perm>> are set, and <<c_perm>> and <<w_perm>> are both clear.
. If removing <<lm_perm>> results in unrepresentable permissions, then set <<r_perm>> and <<c_perm>> only.

The rules from <<acperm_rules>> must be followed when removing permissions.

[#acperm_rules]
.ACPERM common rules
[%autowidth,float="center",align="center",cols="3,3,3",options="header"]
|===
| Rule | Permission | Only valid if
| 1 (RV32 only) | <<asr_perm>> | All other permissions are set.
| 2 | <<c_perm>> | <<r_perm>> or <<w_perm>>
| 3 (RV32 only) | <<c_perm>> | <<r_perm>>
| 4 (RV32 only) | <<x_perm>> | <<r_perm>>
| 5 (RV32 only) | <<w_perm>> | not(<<c_perm>>) or <<lm_perm>>
| 6 (RV32 only) | <<x_perm>> | <<w_perm>> or <<c_perm>>
| 7 | <<el_perm>> | <<c_perm>> and <<r_perm>>
| 8 | <<lm_perm>> | <<c_perm>> and <<r_perm>>
| 9 (RV32 only) | <<x_perm>> | <<c_perm>> == <<lm_perm>> == <<el_perm>>
| 10 | <<sl_perm>> | <<c_perm>>
| 11 | <<asr_perm>> | <<x_perm>>
| 12 | <<m_bit>> | <<x_perm>>
|===

The behaviour of currently illegal combinations from <<acperm_rules>> is to clear the permission if invalid (or in the case of <<sl_perm>> set it to 0 (_local_)).

* For RV64 all such combinations may be redefined by future extensions.
* For the RV32 only rules none of these combinations are possible to meet the encoding requirements for <<cap_perms_encoding32>>, or
<<cap_perms_encoding_levels32>> if <<cheri_levels_ext,{cheri_levels_ext_name}>> is implemented. In all cases invalid permissions are cleared.

.Capability permissions bit field
[#acperm_bit_field]
Expand Down
Loading