Cache Block Zero
Zeros an entire cache block
The block zeroing does not need to be atomic.
`cbo.zero` is ordered by `FENCE` instructions but not `FENCE.I` or `SFENCE.VMA`.
Both PMP and PMA access control must be the same for all bytes in the block; otherwise, `cbo.zero` has UNSPECIFIED behavior.
Zero operations are treated as stores for page and access permissions. If permission checks fail, one of the following exceptions will occur:
* `Store/AMO Guest-Page Fault` if virtual memory translation fails during G-stage translation.
* `Store/AMO Page Fault` if virtual memory translation fails when V=0 or during VS-stage translation * `Store/AMO Access Fault` if a PMP or PMA access check fails.
Because cache blocks are naturally aligned and always fit in a single PMP or PMA regions, the PMP and PMA access checks only need to check a single address in the line.
CBO operations never raise a misaligned address fault.
cbo.zero (xs1)
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 000000000 | 1 | 00 | xs1 | 0 | 1 | 000000000 | 1111 | ||||||||||||||||||||||||
| Variable | Bits | Width |
|---|---|---|
xs1 | [19:15] | 5 |
# Access checks for cbo.zero per envcfg CBZE bits.
# M-mode always has access.
if (CSR[misa].S == 1) {
if (CSR[menvcfg].CBZE == 0) {
# menvcfg.CBZE=0: all non-M modes trap
if (mode() == PrivilegeMode::S || mode() == PrivilegeMode::U) {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
if (CSR[misa].H == 1) {
if (mode() == PrivilegeMode::VS || mode() == PrivilegeMode::VU) {
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
}
}
} else {
# menvcfg.CBZE=1: check lower-level envcfg bits
if (mode() == PrivilegeMode::U && CSR[senvcfg].CBZE == 0) {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
if (CSR[misa].H == 1) {
if (CSR[henvcfg].CBZE == 0) {
if (mode() == PrivilegeMode::VS || mode() == PrivilegeMode::VU) {
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
}
} else if (mode() == PrivilegeMode::VU && CSR[senvcfg].CBZE == 0) {
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
}
}
}
}
XReg mask = CACHE_BLOCK_SIZE - 1;
XReg cache_block_vaddr = X[xs1] & ~mask;
TranslationResult result;
result = translate(cache_block_vaddr, MemoryOperation::Write, effective_ldst_mode(), $encoding);
access_check(result.paddr, CACHE_BLOCK_SIZE*8, cache_block_vaddr, MemoryOperation::Write, ExceptionCode::StoreAmoAccessFault, effective_ldst_mode());
cache_block_zero(result.paddr);
Zicboz
| M | S | U | VS | VU |
|---|---|---|---|---|
| Always | Sometimes | Sometimes | Sometimes | Sometimes |
Version af3eaf9+cheriot.f635218
Data from the RISC-V Unified Database, copyright RISC-V International and contributors.
CHERIoT extensions from the CHERIoT specification and Sail model, copyright Microsoft and the CHERIoT Platform contributors.
This site is provided as a community resource and is NOT affiliated with nor endorsed by RISC-V International.