← Back to Pull requests

Encoding chapter cleanup #1272

Merged
arichardson merged 1 files (84 lines) on Sep 29, 2026 16:56 UTC
View on GitHub
arichardson arichardson commented on Sep 29, 2026 08:12 UTC
Author

  • Small grammar fixes.

  • Fix a reserved one->reserved zero typo (it was correct

  • everywhere else in this chapter)
  • Avoid referring to the encoding as an "in-memory representation"

  • and use <<sentry_cap>> xref of repeating the JALR sealing text.

    Diff: 84 lines (+40 / -44) across 1 files Reviewer: tariqkurd-repo Review duration: 524m
    All Vouch review confidence checks passed
    Residual risk 0.08 = Change Risk (0.30) × (1 − Review Confidence (0.75)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.30 · 84 lines diff across 1 files
    0.30
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.50 · 5 substantive comment(s)
    0.50
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    74%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.266
    Real PR Conversation Timeline
    13 items
    tariqkurd-repo tariqkurd-repo commented on code on Sep 29, 2026 08:30 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -57,25 +57,25 @@ NOTE: T[13:12], T[2:0] and B[2:0] are not specified by the metadata fields and a
     | MW          | {cap_rv64_mw_width}  | Mantissa width for the bounds encoding
     | EW          | {cap_rv64_exp_width} | Exponent width for the bounds encoding
     | CAP_MAX_E   | {cap_rv64_exp_max}   | Maximum exponent value
    -| enableL8    | 0                    | Whether the encoding format includes the `L~8~` bit
    -| AP_MAX      | All ones             | Value of the <<AP-field>> giving maximum permissions
    +| enableL8    | 0                    | Whether the encoding format includes the L~8~ bit
    +| AP_MAX      | All ones             | Value of the <<AP-field>> giving maximum permissions (all implemented permission bits set to 1)
     | AP_ENC      | full1                | Encoding scheme for the <<AP-field>> - all combinations are representable
    -| REP_RANGE   | rc1                  | Whether out of bounds addresses are representable
    +| REP_RANGE   | rc1                  | Whether out-of-bounds addresses are representable
     |==============================================================================
     
     NOTE: All values in <<rvy64_uni_base_name_param_summary>> match the default values specified in <<cap_encoding_param_default_summary>>.
     
    +ifndef::cheri_ratification_v1_only[]
     .{rv64y_uni_base_name} extension summary
     [#rvy64_uni_base_name_ext_summary,width="100%",options=header,]
     |==============================================================================
     | Extension                    | Comment
     | <<section_cheri_hybrid_ext>> | Compatible
     | <<section_zylevels1>>        | Compatible
    -ifndef::cheri_ratification_v1_only[]
     | <<section_zyseal>>           | Will be compatible once new permissions are encoded
    -endif::[]
     | All RV64Y versions of other standard extensions | Compatible
     |==============================================================================
    +endif::[]

    Why not just delete this table

    tariqkurd-repo tariqkurd-repo commented on code on Sep 29, 2026 08:35 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -236,7 +232,7 @@ The metadata uses a floating-point representation to encode the compressed bound
     The following subsections describe how the _base_ and _top_ bounds are decoded from the metadata.
     
     The pseudocode below is normative.
    -In this notation, `/` means "integer division", `[]` are the bit-select operators, `{}` is bit concatenation, `?:` is the conditional operator, and arithmetic is signed.
    +In this notation, `/` means "integer division", `[]` are the bit-select operators, `{}` is bit concatenation, `?:` is the conditional operator, and bit-vectors are treated as unsigned integers except that the exponent `E` and correction factors _c~b~_ and _c~t~_ are signed integers.

    E is 0 to 52, so can be signed or unsigned, why explicitly list it as signed?
    @PeterRugg ?

    tariqkurd-repo tariqkurd-repo commented on code on Sep 29, 2026 08:35 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -309,7 +303,7 @@ T[MW - 1:MW - 2] = B[MW - 1:MW - 2] + LCout + LMSB
     This derivation relies on the equality `T = B + L`, where `L` is the encoded length of the capability.
     `LMSB` is the value of `L[MW - 2]`, which is known from the values of `EF` and `E` (as well as L~8~ when `enableL8=1`).
     `LCout` is the carry out from the lower bits, which is implied by `T[MW - 3:0] < B[MW - 3:0]` since it is
    -guaranteed that the _top_ bound address is larger than the _base_ bound address.
    +guaranteed that the _top_ bound address is greater than or equal to the _base_ bound address.

    is it possible for base=top?
    @PeterRugg ?

    tariqkurd-repo tariqkurd-repo commented on code on Sep 29, 2026 08:43 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -480,42 +464,19 @@ If the address _a'_ is outside the _representable range_, then the derived capab
     
     ==== Practical Information
     
    +This section summarizes key properties of the <<section_cap_representable_check,representable range check>> that follow from the bounds encoding.
    +
     An artifact of the bounds encoding is that if the new address
     causes `top != top'`, then it is also the case that `base != base'`.
     
    -The converse is also true, if `base != base'` then `top != top'`.
    +The converse is also true: if `base != base'`, then `top != top'`.
     
     Therefore, for representable range checking, it is acceptable
     to either check `top == top'` or `base == base'`.
     
    -The _top_ and _base_ capability bounds are formed of two or three sections:
    -
    -* Upper bits from the address
    -** This is only if the other sections do not fill the available bits (`E + MW < XLEN`)
    -* Middle bits from `T` and `B` decoded from the metadata
    -* Lower bits are set to zero
    -** This is only if there is an internal exponent (`EF=0`)
    -
    -.Composition of the decoded _top_ bound address
    -[#comp_addr_bounds,options=header,align="center",cols="2,4,2,2"]
    -|==============================================================================
    -| Configuration   | Upper Section (if E + MW < XLEN) | Middle Section | Lower Section
    -| EF=0            | address[XLEN-1:E + MW] + ct | T[MW - 1:0] | zeroes(E)
    -| EF=1, i.e., E=0 | address[XLEN-1:MW] + ct   2+| T[MW - 1:0]
    -|==============================================================================
    -
    -The _representable range_ defines the range of addresses which do not corrupt
    -the bounds encoding. The encoding was first introduced in
    -xref:section_cap_bounds[xrefstyle=short], and is repeated in a different
    -form in xref:comp_addr_bounds[xrefstyle=short] to aid this description.
    -
    -For the address to be valid for the current bounds encoding, the value
    -in the _Upper Section_ of xref:comp_addr_bounds[xrefstyle=short] _must
    -not change_ as this will change the meaning of the bounds.  This
    -is because `T`, `B` and `E` will be unchanged for the source and
    -destination capabilities.  Therefore, the Middle and Lower sections
    -of the bounds calculation are also unchanged for source and
    -destination capabilities.
    +[#comp_addr_bounds]
    +As shown in <<top_bound_dec>> and <<base_bound_dec>>, `T`, `B`, and `E` are identical for the source and derived capabilities, so the middle (`T`/`B`) and lower (`zeros(E)`) sections of the decoded bounds do not change when the address changes.
    +Therefore, for the new address to remain within the _representable range_, the upper section (`a[XLEN-1:E + MW] + ct` or `a[XLEN-1:E + MW] + cb` when `E + MW < XLEN`) _must not change_.

    please put this whole back, I was very happy with it how it was
    this section has passed review. fixing commas etc. then fine but no structural changes
    the xrefs are _not_ a replacement for the table.

    tariqkurd-repo tariqkurd-repo requested changes on Sep 29, 2026 08:44 UTC
    Changes Requested Reviewer

    minor typographical changes ok, but we really must not be making structural changes at this time and the practical information section was very useful as it was before, please don't change it

    PeterRugg PeterRugg commented on code on Sep 29, 2026 10:35 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -309,7 +303,7 @@ T[MW - 1:MW - 2] = B[MW - 1:MW - 2] + LCout + LMSB
     This derivation relies on the equality `T = B + L`, where `L` is the encoded length of the capability.
     `LMSB` is the value of `L[MW - 2]`, which is known from the values of `EF` and `E` (as well as L~8~ when `enableL8=1`).
     `LCout` is the carry out from the lower bits, which is implied by `T[MW - 3:0] < B[MW - 3:0]` since it is
    -guaranteed that the _top_ bound address is larger than the _base_ bound address.
    +guaranteed that the _top_ bound address is greater than or equal to the _base_ bound address.

    Yes, zero length caps are allowed

    PeterRugg PeterRugg commented on code on Sep 29, 2026 10:36 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -236,7 +232,7 @@ The metadata uses a floating-point representation to encode the compressed bound
     The following subsections describe how the _base_ and _top_ bounds are decoded from the metadata.
     
     The pseudocode below is normative.
    -In this notation, `/` means "integer division", `[]` are the bit-select operators, `{}` is bit concatenation, `?:` is the conditional operator, and arithmetic is signed.
    +In this notation, `/` means "integer division", `[]` are the bit-select operators, `{}` is bit concatenation, `?:` is the conditional operator, and bit-vectors are treated as unsigned integers except that the exponent `E` and correction factors _c~b~_ and _c~t~_ are signed integers.

    Yeah, listing the exponent as signed seems odd. Was there a motivation for that?

    tariqkurd-repo tariqkurd-repo commented on code on Sep 29, 2026 12:25 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -57,25 +57,25 @@ NOTE: T[13:12], T[2:0] and B[2:0] are not specified by the metadata fields and a
     | MW          | {cap_rv64_mw_width}  | Mantissa width for the bounds encoding
     | EW          | {cap_rv64_exp_width} | Exponent width for the bounds encoding
     | CAP_MAX_E   | {cap_rv64_exp_max}   | Maximum exponent value
    -| enableL8    | 0                    | Whether the encoding format includes the `L~8~` bit
    -| AP_MAX      | All ones             | Value of the <<AP-field>> giving maximum permissions
    +| enableL8    | 0                    | Whether the encoding format includes the L~8~ bit
    +| AP_MAX      | All ones             | Value of the <<AP-field>> giving maximum permissions (all implemented permission bits set to 1)
     | AP_ENC      | full1                | Encoding scheme for the <<AP-field>> - all combinations are representable
    -| REP_RANGE   | rc1                  | Whether out of bounds addresses are representable
    +| REP_RANGE   | rc1                  | Whether out-of-bounds addresses are representable
     |==============================================================================
     
     NOTE: All values in <<rvy64_uni_base_name_param_summary>> match the default values specified in <<cap_encoding_param_default_summary>>.
     
    +ifndef::cheri_ratification_v1_only[]
     .{rv64y_uni_base_name} extension summary
     [#rvy64_uni_base_name_ext_summary,width="100%",options=header,]
     |==============================================================================
     | Extension                    | Comment
     | <<section_cheri_hybrid_ext>> | Compatible
     | <<section_zylevels1>>        | Compatible
    -ifndef::cheri_ratification_v1_only[]
     | <<section_zyseal>>           | Will be compatible once new permissions are encoded
    -endif::[]
     | All RV64Y versions of other standard extensions | Compatible
     |==============================================================================
    +endif::[]

    I've reduced this to a note about Zyseal (in ifdefs) in #1271

    arichardson arichardson commented on code on Sep 29, 2026 15:28 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -236,7 +232,7 @@ The metadata uses a floating-point representation to encode the compressed bound
     The following subsections describe how the _base_ and _top_ bounds are decoded from the metadata.
     
     The pseudocode below is normative.
    -In this notation, `/` means "integer division", `[]` are the bit-select operators, `{}` is bit concatenation, `?:` is the conditional operator, and arithmetic is signed.
    +In this notation, `/` means "integer division", `[]` are the bit-select operators, `{}` is bit concatenation, `?:` is the conditional operator, and bit-vectors are treated as unsigned integers except that the exponent `E` and correction factors _c~b~_ and _c~t~_ are signed integers.

    When E overflows it ends up negative since we are subtracting from max.

    Malformed check has this: malformedLSB = (E < 0) ...

    arichardson arichardson commented on code on Sep 29, 2026 15:28 UTC
    Code Review
    src/cheri/rvy64-encoding.adoc:1
    @@ -480,42 +464,19 @@ If the address _a'_ is outside the _representable range_, then the derived capab
     
     ==== Practical Information
     
    +This section summarizes key properties of the <<section_cap_representable_check,representable range check>> that follow from the bounds encoding.
    +
     An artifact of the bounds encoding is that if the new address
     causes `top != top'`, then it is also the case that `base != base'`.
     
    -The converse is also true, if `base != base'` then `top != top'`.
    +The converse is also true: if `base != base'`, then `top != top'`.
     
     Therefore, for representable range checking, it is acceptable
     to either check `top == top'` or `base == base'`.
     
    -The _top_ and _base_ capability bounds are formed of two or three sections:
    -
    -* Upper bits from the address
    -** This is only if the other sections do not fill the available bits (`E + MW < XLEN`)
    -* Middle bits from `T` and `B` decoded from the metadata
    -* Lower bits are set to zero
    -** This is only if there is an internal exponent (`EF=0`)
    -
    -.Composition of the decoded _top_ bound address
    -[#comp_addr_bounds,options=header,align="center",cols="2,4,2,2"]
    -|==============================================================================
    -| Configuration   | Upper Section (if E + MW < XLEN) | Middle Section | Lower Section
    -| EF=0            | address[XLEN-1:E + MW] + ct | T[MW - 1:0] | zeroes(E)
    -| EF=1, i.e., E=0 | address[XLEN-1:MW] + ct   2+| T[MW - 1:0]
    -|==============================================================================
    -
    -The _representable range_ defines the range of addresses which do not corrupt
    -the bounds encoding. The encoding was first introduced in
    -xref:section_cap_bounds[xrefstyle=short], and is repeated in a different
    -form in xref:comp_addr_bounds[xrefstyle=short] to aid this description.
    -
    -For the address to be valid for the current bounds encoding, the value
    -in the _Upper Section_ of xref:comp_addr_bounds[xrefstyle=short] _must
    -not change_ as this will change the meaning of the bounds.  This
    -is because `T`, `B` and `E` will be unchanged for the source and
    -destination capabilities.  Therefore, the Middle and Lower sections
    -of the bounds calculation are also unchanged for source and
    -destination capabilities.
    +[#comp_addr_bounds]
    +As shown in <<top_bound_dec>> and <<base_bound_dec>>, `T`, `B`, and `E` are identical for the source and derived capabilities, so the middle (`T`/`B`) and lower (`zeros(E)`) sections of the decoded bounds do not change when the address changes.
    +Therefore, for the new address to remain within the _representable range_, the upper section (`a[XLEN-1:E + MW] + ct` or `a[XLEN-1:E + MW] + cb` when `E + MW < XLEN`) _must not change_.

    dropping it.

    arichardson arichardson commented on Sep 29, 2026 16:52 UTC
    Author

    Dropped all non-trivial changes other than the one->zero typo.

    tariqkurd-repo tariqkurd-repo approved these changes on Sep 29, 2026 16:53 UTC
    Approved Reviewer

    Approved these changes.

    Assignees
    arichardson arichardson
    Labels
    risk: low confidence: 74.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 29.6% (LOW) · Higher = larger blast radius
    29.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 74.5% · Lower = rushed or shallow review
    74.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.5% · Safe to merge
    7.5%