diff options
author | Ben Marshall <ben-marshall@users.noreply.github.com> | 2021-10-18 10:16:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 10:16:43 +0100 |
commit | 1c7584bb501bb6d4cbc3b95cb22e008220fb537a (patch) | |
tree | e07939a9a859628d02b77a4063c0321dcaaed4d8 /model/riscv_sys_control.sail | |
parent | 9f71c756484a4aac7c211d5ea266f45b0b3942e7 (diff) | |
download | sail-riscv-1c7584bb501bb6d4cbc3b95cb22e008220fb537a.zip sail-riscv-1c7584bb501bb6d4cbc3b95cb22e008220fb537a.tar.gz sail-riscv-1c7584bb501bb6d4cbc3b95cb22e008220fb537a.tar.bz2 |
scalar-crypto: Initial commit of 1.0.0-rc2 spec work. (#99)
Merged scalar-crypto pull request #99 of 1.0.0-rc2 spec work from Ben Marshall. See https://github.com/riscv/sail-riscv/pull/99.
Diffstat (limited to 'model/riscv_sys_control.sail')
-rw-r--r-- | model/riscv_sys_control.sail | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/model/riscv_sys_control.sail b/model/riscv_sys_control.sail index 6a13fdf..a3859ff 100644 --- a/model/riscv_sys_control.sail +++ b/model/riscv_sys_control.sail @@ -157,6 +157,9 @@ function is_CSR_defined (csr : csreg, p : Privilege) -> bool = 0xC81 => haveUsrMode() & (sizeof(xlen) == 32), // timeh 0xC82 => haveUsrMode() & (sizeof(xlen) == 32), // instreth + /* user mode: Zkr */ + 0x015 => haveZkr(), + /* check extensions */ _ => ext_is_CSR_defined(csr, p) } @@ -185,11 +188,32 @@ function check_Counteren(csr : csreg, p : Privilege) -> bool = else true } + +/* Seed may only be accessed if we are doing a write, and access has been + * allowed in the current priv mode + */ +function check_seed_CSR (csr : csreg, p : Privilege, isWrite : bool) -> bool = { + if ~(csr == 0x015) then { + true + } else if ~(isWrite) then { + /* Read-only access to the seed CSR is not allowed */ + false + } else { + match (p) { + Machine => true, + Supervisor => false, /* TODO: base this on mseccfg */ + User => false, /* TODO: base this on mseccfg */ + _ => false + } + } +} + function check_CSR(csr : csreg, p : Privilege, isWrite : bool) -> bool = is_CSR_defined(csr, p) & check_CSR_access(csrAccess(csr), csrPriv(csr), p, isWrite) & check_TVM_SATP(csr, p) & check_Counteren(csr, p) + & check_seed_CSR(csr, p, isWrite) /* Reservation handling for LR/SC. * |