diff options
author | Jerry Zhao <jerryz123@berkeley.edu> | 2023-01-04 09:54:45 -0800 |
---|---|---|
committer | Jerry Zhao <jerryz123@berkeley.edu> | 2023-01-04 11:02:14 -0800 |
commit | 469405129d5b28dd5e730de7bbf1173b0f841849 (patch) | |
tree | 8d1e0d4daa9ac936bf108a1fb041b2f777310eba /riscv/mmu.cc | |
parent | d50a0f00220d15f26eea9f65cd1ad2f097b96414 (diff) | |
download | riscv-isa-sim-469405129d5b28dd5e730de7bbf1173b0f841849.zip riscv-isa-sim-469405129d5b28dd5e730de7bbf1173b0f841849.tar.gz riscv-isa-sim-469405129d5b28dd5e730de7bbf1173b0f841849.tar.bz2 |
Respect --mmu-dirty flag instead of --enable-dirty
Diffstat (limited to 'riscv/mmu.cc')
-rw-r--r-- | riscv/mmu.cc | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/riscv/mmu.cc b/riscv/mmu.cc index 7d11bab..e5f8a1f 100644 --- a/riscv/mmu.cc +++ b/riscv/mmu.cc @@ -413,16 +413,17 @@ reg_t mmu_t::s2xlate(reg_t gva, reg_t gpa, access_type type, access_type trap_ty break; } else { reg_t ad = PTE_A | ((type == STORE) * PTE_D); -#ifdef RISCV_ENABLE_DIRTY - // set accessed and possibly dirty bits. + if ((pte & ad) != ad) { - pte_store(pte_paddr, pte | ad, gva, virt, type, vm.ptesize); + if (proc->cfg->dirty_enabled) { + // set accessed and possibly dirty bits + pte_store(pte_paddr, pte | ad, gva, virt, type, vm.ptesize); + } else { + // take exception if access or possibly dirty bit is not set. + break; + } } -#else - // take exception if access or possibly dirty bit is not set. - if ((pte & ad) != ad) - break; -#endif + reg_t vpn = gpa >> PGSHIFT; reg_t page_mask = (reg_t(1) << PGSHIFT) - 1; @@ -500,16 +501,17 @@ reg_t mmu_t::walk(reg_t addr, access_type type, reg_t mode, bool virt, bool hlvx break; } else { reg_t ad = PTE_A | ((type == STORE) * PTE_D); -#ifdef RISCV_ENABLE_DIRTY - // set accessed and possibly dirty bits. + if ((pte & ad) != ad) { - pte_store(pte_paddr, pte | ad, addr, virt, type, vm.ptesize); + if (proc->cfg->dirty_enabled) { + // set accessed and possibly dirty bits. + pte_store(pte_paddr, pte | ad, addr, virt, type, vm.ptesize); + } else { + // take exception if access or possibly dirty bit is not set. + break; + } } -#else - // take exception if access or possibly dirty bit is not set. - if ((pte & ad) != ad) - break; -#endif + // for superpage or Svnapot NAPOT mappings, make a fake leaf PTE for the TLB's benefit. reg_t vpn = addr >> PGSHIFT; |