diff options
author | Scott Johnson <scott.johnson@arilinc.com> | 2021-02-23 17:53:53 -0800 |
---|---|---|
committer | Andrew Waterman <aswaterman@gmail.com> | 2021-09-08 07:59:02 -0700 |
commit | 8ad9331df2400933a4b2eb23ca0663a33e4f89aa (patch) | |
tree | 6d4b7f497474973737683bedd8f062de3d458ae1 /riscv/mmu.cc | |
parent | 1e9c399a3699f3bd98badb1956b41cf0c2b4aa4f (diff) | |
download | spike-8ad9331df2400933a4b2eb23ca0663a33e4f89aa.zip spike-8ad9331df2400933a4b2eb23ca0663a33e4f89aa.tar.gz spike-8ad9331df2400933a4b2eb23ca0663a33e4f89aa.tar.bz2 |
Remove unnecessary check for PMP_OFF
Since match4() checks this now.
Diffstat (limited to 'riscv/mmu.cc')
-rw-r--r-- | riscv/mmu.cc | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/riscv/mmu.cc b/riscv/mmu.cc index c315a53..6d1299b 100644 --- a/riscv/mmu.cc +++ b/riscv/mmu.cc @@ -221,31 +221,27 @@ reg_t mmu_t::pmp_ok(reg_t addr, reg_t len, access_type type, reg_t mode) return true; for (size_t i = 0; i < proc->n_pmp; i++) { - uint8_t cfg = proc->state.pmpcfg[i]; - - if (cfg & PMP_A) { - - // Check each 4-byte sector of the access - bool any_match = false; - bool all_match = true; - for (reg_t offset = 0; offset < len; offset += 1 << PMP_SHIFT) { - reg_t cur_addr = addr + offset; - bool match = proc->state.pmpaddr[i]->match4(cur_addr); - any_match |= match; - all_match &= match; - } + // Check each 4-byte sector of the access + bool any_match = false; + bool all_match = true; + for (reg_t offset = 0; offset < len; offset += 1 << PMP_SHIFT) { + reg_t cur_addr = addr + offset; + bool match = proc->state.pmpaddr[i]->match4(cur_addr); + any_match |= match; + all_match &= match; + } - if (any_match) { - // If the PMP matches only a strict subset of the access, fail it - if (!all_match) - return false; + if (any_match) { + // If the PMP matches only a strict subset of the access, fail it + if (!all_match) + return false; - return - (mode == PRV_M && !(cfg & PMP_L)) || - (type == LOAD && (cfg & PMP_R)) || - (type == STORE && (cfg & PMP_W)) || - (type == FETCH && (cfg & PMP_X)); - } + uint8_t cfg = proc->state.pmpcfg[i]; + return + (mode == PRV_M && !(cfg & PMP_L)) || + (type == LOAD && (cfg & PMP_R)) || + (type == STORE && (cfg & PMP_W)) || + (type == FETCH && (cfg & PMP_X)); } } |