Skip to content

Commit de61ee2

Browse files
committed
Update PMP spec to use "memory operation"
This part of the spec was written before the RVWMO section which introduced the "memory operation" nomenclature. This updates the section to talk about memory operations instead of memory accesses. I also reworked the text about CMOs and PMPs because it didn't quite make sense - the access size is irrelevant for PMPs; it's the memory operation size that matters, and that can be anything for CMOs since they are allowed to be decomposed.
1 parent 1bec7d3 commit de61ee2

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

Diff for: src/cmo.adoc

+10-2
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,16 @@ _This specification assumes that the above constraints will typically be met for
337337
main memory regions and may be met for certain I/O regions._
338338
====
339339

340-
Additionally, for the purposes of PMP and PMA checks, the access size of a CMO
341-
instruction equals the size of the cache block accessed by the instruction.
340+
[NOTE]
341+
====
342+
The access size for CMO instructions is equal to the size of the cache
343+
block, however in some cases that access can be decomposed into multiple
344+
memory operations. PMP checks are applied to each memory operation
345+
independently. For example a 64-byte *cbo.zero* that spans two 32-byte PMP
346+
regions would succeed if it was decomposed into two 32-byte memory operations
347+
(and the PMP access control bits are the same in both regions), but if
348+
performed as a single 64-byte memory operation it would cause an access fault.
349+
====
342350

343351
The Zicboz extension introduces an additional supported access type PMA for
344352
cache-block zero instructions. Main memory regions are required to support

Diff for: src/machine.adoc

+24-22
Original file line numberDiff line numberDiff line change
@@ -3233,47 +3233,49 @@ R/W/X permissions apply only to S and U modes.
32333233

32343234
===== Priority and Matching Logic
32353235

3236+
On some implementations, misaligned loads, stores, and instruction
3237+
fetches may be decomposed into multiple memory operations, some of which may
3238+
succeed before an access-fault exception occurs, as described in the RVWMO
3239+
specification. PMP checking is performed on each memory operation independently.
3240+
In particular, a portion of a misaligned store that passes
3241+
the PMP check may become visible, even if another portion fails the PMP check.
3242+
The same behavior may manifest for stores wider than XLEN bits (e.g., the
3243+
FSD instruction in RV32D), even when the store address is naturally aligned.
3244+
32363245
PMP entries are statically prioritized. The lowest-numbered PMP entry
3237-
that matches any byte of an access determines whether that access
3238-
succeeds or fails. The matching PMP entry must match all bytes of an
3239-
access, or the access fails, irrespective of the L, R, W, and X bits.
3246+
that matches any byte of a memory operation determines whether that operation
3247+
succeeds or fails. The matching PMP entry must match all bytes of a memory
3248+
operation, or the operation fails, irrespective of the L, R, W, and X bits.
32403249
For example, if a PMP entry is configured to match the four-byte range
32413250
`0xC`–`0xF`, then an 8-byte access to the range `0x8`–`0xF` will fail,
32423251
assuming that PMP entry is the highest-priority entry that matches those
32433252
addresses.
32443253

3245-
If a PMP entry matches all bytes of an access, then the L, R, W, and X
3246-
bits determine whether the access succeeds or fails. If the L bit is
3247-
clear and the privilege mode of the access is M, the access succeeds.
3254+
If a PMP entry matches all bytes of a memory operation, then the L, R, W, and X
3255+
bits determine whether the operation succeeds or fails. If the L bit is
3256+
clear and the privilege mode of the access is M, the operation succeeds.
32483257
Otherwise, if the L bit is set or the privilege mode of the access is S
3249-
or U, then the access succeeds only if the R, W, or X bit corresponding
3258+
or U, then the operation succeeds only if the R, W, or X bit corresponding
32503259
to the access type is set.
32513260

3252-
If no PMP entry matches an M-mode access, the access succeeds. If no PMP
3253-
entry matches an S-mode or U-mode access, but at least one PMP entry is
3254-
implemented, the access fails.
3261+
If no PMP entry matches an M-mode memory operation, the operation succeeds.
3262+
If no PMP entry matches an S-mode or U-mode memory operation, but at least
3263+
one PMP entry is implemented, the operation fails.
32553264

32563265
[NOTE]
32573266
====
32583267
If at least one PMP entry is implemented, but all PMP entries’ A fields
32593268
are set to OFF, then all S-mode and U-mode memory accesses will fail.
32603269
====
32613270

3262-
Failed accesses generate an instruction, load, or store access-fault
3271+
Failed memory operations generate an instruction, load, or store access-fault
32633272
exception. Note that a single instruction may generate multiple
3264-
accesses, which may not be mutually atomic. An access-fault exception is
3265-
generated if at least one access generated by an instruction fails,
3266-
though other accesses generated by that instruction may succeed with
3273+
memory operations, which may not be mutually atomic. An access-fault exception
3274+
is generated if at least one memory operation generated by an instruction fails,
3275+
though other memory operations generated by that instruction may succeed with
32673276
visible side effects. Notably, instructions that reference virtual
3268-
memory are decomposed into multiple accesses.
3277+
memory are decomposed into multiple memory operations.
32693278

3270-
On some implementations, misaligned loads, stores, and instruction
3271-
fetches may also be decomposed into multiple accesses, some of which may
3272-
succeed before an access-fault exception occurs. In particular, a
3273-
portion of a misaligned store that passes the PMP check may become
3274-
visible, even if another portion fails the PMP check. The same behavior
3275-
may manifest for stores wider than XLEN bits (e.g., the FSD instruction
3276-
in RV32D), even when the store address is naturally aligned.
32773279

32783280
[[pmp-vmem]]
32793281
==== Physical Memory Protection and Paging

0 commit comments

Comments
 (0)