diff options
author | Andrew Waterman <andrew@sifive.com> | 2020-05-10 01:31:34 -0700 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-05-19 19:57:11 -0700 |
commit | 01df03c1fc536926f41d6f061e85672b8dc7d99f (patch) | |
tree | 6c478eba76794851c6326c73f2f40fec39193e8a /riscv | |
parent | 0c565c6b9b725b63b6fddbcce786c9d876818547 (diff) | |
download | spike-01df03c1fc536926f41d6f061e85672b8dc7d99f.zip spike-01df03c1fc536926f41d6f061e85672b8dc7d99f.tar.gz spike-01df03c1fc536926f41d6f061e85672b8dc7d99f.tar.bz2 |
Implement coarse-grain PMP matching logic
Diffstat (limited to 'riscv')
-rw-r--r-- | riscv/mmu.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/riscv/mmu.cc b/riscv/mmu.cc index 3b0eb0d..b038f23 100644 --- a/riscv/mmu.cc +++ b/riscv/mmu.cc @@ -204,15 +204,15 @@ reg_t mmu_t::pmp_ok(reg_t addr, reg_t len, access_type type, reg_t mode) return true; reg_t base = 0; - for (size_t i = 0; i < proc->state.max_pmp; i++) { - reg_t tor = proc->state.pmpaddr[i] << PMP_SHIFT; + for (size_t i = 0; i < proc->n_pmp; i++) { + reg_t tor = (proc->state.pmpaddr[i] & proc->pmp_tor_mask()) << PMP_SHIFT; uint8_t cfg = proc->state.pmpcfg[i]; if (cfg & PMP_A) { bool is_tor = (cfg & PMP_A) == PMP_TOR; bool is_na4 = (cfg & PMP_A) == PMP_NA4; - reg_t mask = (proc->state.pmpaddr[i] << 1) | (!is_na4); + reg_t mask = (proc->state.pmpaddr[i] << 1) | (!is_na4) | ~proc->pmp_tor_mask(); mask = ~(mask & ~(mask + 1)) << PMP_SHIFT; // Check each 4-byte sector of the access @@ -255,8 +255,8 @@ reg_t mmu_t::pmp_homogeneous(reg_t addr, reg_t len) return true; reg_t base = 0; - for (size_t i = 0; i < proc->state.max_pmp; i++) { - reg_t tor = proc->state.pmpaddr[i] << PMP_SHIFT; + for (size_t i = 0; i < proc->n_pmp; i++) { + reg_t tor = (proc->state.pmpaddr[i] & proc->pmp_tor_mask()) << PMP_SHIFT; uint8_t cfg = proc->state.pmpcfg[i]; if (cfg & PMP_A) { @@ -270,7 +270,7 @@ reg_t mmu_t::pmp_homogeneous(reg_t addr, reg_t len) bool tor_homogeneous = ends_before_lower || begins_after_upper || (begins_after_lower && ends_before_upper); - reg_t mask = (proc->state.pmpaddr[i] << 1) | (!is_na4); + reg_t mask = (proc->state.pmpaddr[i] << 1) | (!is_na4) | ~proc->pmp_tor_mask(); mask = ~(mask & ~(mask + 1)) << PMP_SHIFT; bool mask_homogeneous = ~(mask << 1) & len; bool napot_homogeneous = mask_homogeneous || ((addr ^ tor) / len) != 0; |