diff options
author | Andrew Waterman <andrew@sifive.com> | 2019-02-28 13:07:07 -0800 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2019-02-28 13:58:46 -0800 |
commit | 5b08bf5c3cc236ed6baf6d4f2964d8efe5b1705c (patch) | |
tree | 9099ea396f13c46f298f799a7645860e39e67993 /riscv/mmu.cc | |
parent | da8ab7d18d79a921ccf00b4793eac9124d7b4a75 (diff) | |
download | riscv-isa-sim-5b08bf5c3cc236ed6baf6d4f2964d8efe5b1705c.zip riscv-isa-sim-5b08bf5c3cc236ed6baf6d4f2964d8efe5b1705c.tar.gz riscv-isa-sim-5b08bf5c3cc236ed6baf6d4f2964d8efe5b1705c.tar.bz2 |
Further fix PMP checks for partially-matching accesses (#270)
ee6fe6501a21ea8d167b6a5048527ba9eb924878 didn't get this right,
as it failed to add the offset to the address when checking each
4-byte sector of the access against hte PMPs.
Diffstat (limited to 'riscv/mmu.cc')
-rw-r--r-- | riscv/mmu.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/riscv/mmu.cc b/riscv/mmu.cc index 78d00f9..506b99f 100644 --- a/riscv/mmu.cc +++ b/riscv/mmu.cc @@ -193,9 +193,10 @@ reg_t mmu_t::pmp_ok(reg_t addr, reg_t len, access_type type, reg_t mode) // Check each 4-byte sector of the access bool any_match = false; bool all_match = true; - for (reg_t i = 0; i < len; i += (1 << PMP_SHIFT)) { - bool napot_match = ((addr ^ tor) & mask) == 0; - bool tor_match = base <= addr && addr < tor; + for (reg_t offset = 0; offset < len; offset += 1 << PMP_SHIFT) { + reg_t cur_addr = addr + offset; + bool napot_match = ((cur_addr ^ tor) & mask) == 0; + bool tor_match = base <= cur_addr && cur_addr < tor; bool match = is_tor ? tor_match : napot_match; any_match |= match; all_match &= match; |