|
| 1 | +//! mseccfg register |
| 2 | +
|
| 3 | +#[cfg(not(target_arch = "riscv32"))] |
| 4 | +const MASK: usize = 0x3_0000_0707; |
| 5 | +#[cfg(target_arch = "riscv32")] |
| 6 | +const MASK: usize = 0x707; |
| 7 | + |
| 8 | +read_write_csr! { |
| 9 | + /// mseccfg register |
| 10 | + Mseccfg: 0x747, |
| 11 | + mask: MASK, |
| 12 | +} |
| 13 | + |
| 14 | +read_write_csr_field! { |
| 15 | + Mseccfg, |
| 16 | + /// Machine-Mode Lockdown |
| 17 | + /// |
| 18 | + /// # Note |
| 19 | + /// |
| 20 | + /// Defined in in the [Smepmp](https://raw.githubusercontent.com/riscv/riscv-tee/main/Smepmp/Smepmp.pdf) extension. |
| 21 | + mml: 0, |
| 22 | +} |
| 23 | + |
| 24 | +read_write_csr_field! { |
| 25 | + Mseccfg, |
| 26 | + /// Machine-Mode Whitelist Policy |
| 27 | + /// |
| 28 | + /// # Note |
| 29 | + /// |
| 30 | + /// Defined in in the [Smepmp](https://raw.githubusercontent.com/riscv/riscv-tee/main/Smepmp/Smepmp.pdf) extension. |
| 31 | + mmwp: 1, |
| 32 | +} |
| 33 | + |
| 34 | +read_write_csr_field! { |
| 35 | + Mseccfg, |
| 36 | + /// Rule Locking Bypass |
| 37 | + /// |
| 38 | + /// # Note |
| 39 | + /// |
| 40 | + /// Defined in in the [Smepmp](https://raw.githubusercontent.com/riscv/riscv-tee/main/Smepmp/Smepmp.pdf) extension. |
| 41 | + rlb: 2, |
| 42 | +} |
| 43 | + |
| 44 | +read_write_csr_field! { |
| 45 | + Mseccfg, |
| 46 | + /// User-mode seed |
| 47 | + /// |
| 48 | + /// # Note |
| 49 | + /// |
| 50 | + /// Defined in in the [Zkr](https://github.com/riscv/riscv-crypto/releases/download/v1.0.1-scalar/riscv-crypto-spec-scalar-v1.0.1.pdf) extension. |
| 51 | + useed: 8, |
| 52 | +} |
| 53 | + |
| 54 | +read_write_csr_field! { |
| 55 | + Mseccfg, |
| 56 | + /// Supervisor-mode seed |
| 57 | + /// |
| 58 | + /// # Note |
| 59 | + /// |
| 60 | + /// Defined in in the [Zkr](https://github.com/riscv/riscv-crypto/releases/download/v1.0.1-scalar/riscv-crypto-spec-scalar-v1.0.1.pdf) extension. |
| 61 | + sseed: 9, |
| 62 | +} |
| 63 | + |
| 64 | +read_write_csr_field! { |
| 65 | + Mseccfg, |
| 66 | + /// Machine-mode Landing Pad Enable |
| 67 | + /// |
| 68 | + /// # Note |
| 69 | + /// |
| 70 | + /// Defined in in the [Zicfilp](https://github.com/riscv/riscv-cfi/releases/download/v1.0/riscv-cfi.pdf) extension. |
| 71 | + mlpe: 10, |
| 72 | +} |
| 73 | + |
| 74 | +csr_field_enum! { |
| 75 | + /// Pointer Masking Machine-mode |
| 76 | + PMM { |
| 77 | + default: Disabled, |
| 78 | + Disabled = 0, |
| 79 | + EnabledXlen57 = 2, |
| 80 | + EnabledXlen48 = 3, |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +#[cfg(not(target_arch = "riscv32"))] |
| 85 | +read_write_csr_field! { |
| 86 | + Mseccfg, |
| 87 | + /// Pointer Masking Machine-mode |
| 88 | + /// |
| 89 | + /// # Note |
| 90 | + /// |
| 91 | + /// Defined in in the [Smmpm](https://github.com/riscv/riscv-j-extension/releases/download/pointer-masking-ratified/pointer-masking-ratified.pdf) extension. |
| 92 | + pmm, |
| 93 | + PMM: [32:33], |
| 94 | +} |
| 95 | + |
| 96 | +#[cfg(test)] |
| 97 | +mod tests { |
| 98 | + use super::*; |
| 99 | + |
| 100 | + #[test] |
| 101 | + fn test_mseccfg() { |
| 102 | + let mut mseccfg = Mseccfg::from_bits(0); |
| 103 | + |
| 104 | + test_csr_field!(mseccfg, mml); |
| 105 | + test_csr_field!(mseccfg, mmwp); |
| 106 | + test_csr_field!(mseccfg, rlb); |
| 107 | + test_csr_field!(mseccfg, useed); |
| 108 | + test_csr_field!(mseccfg, sseed); |
| 109 | + test_csr_field!(mseccfg, mlpe); |
| 110 | + |
| 111 | + #[cfg(not(target_arch = "riscv32"))] |
| 112 | + { |
| 113 | + test_csr_field!(mseccfg, pmm: PMM::Disabled); |
| 114 | + test_csr_field!(mseccfg, pmm: PMM::EnabledXlen57); |
| 115 | + test_csr_field!(mseccfg, pmm: PMM::EnabledXlen48); |
| 116 | + } |
| 117 | + } |
| 118 | +} |
0 commit comments