From 5df08fdb0813ebf32c89a71adba10f6b90525921 Mon Sep 17 00:00:00 2001 From: Yu-Cheng Chang Date: Tue, 6 Aug 2024 05:21:48 +0800 Subject: [PATCH] arch-riscv: Move pmpReset implementation to MMU::reset() (#1406) The PMP is part of RISC-V MMU subssystem, it should be put in RiscvISA::MMU::reset() --- src/arch/riscv/faults.cc | 9 +++------ src/arch/riscv/mmu.hh | 8 ++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/arch/riscv/faults.cc b/src/arch/riscv/faults.cc index 5d82750914..d48529d9a7 100644 --- a/src/arch/riscv/faults.cc +++ b/src/arch/riscv/faults.cc @@ -188,13 +188,10 @@ Reset::invoke(ThreadContext *tc, const StaticInstPtr &inst) new_pc->vl(0); tc->pcState(*new_pc); - // Reset PMP Cfg - auto* mmu = dynamic_cast(tc->getMMUPtr()); - if (mmu == nullptr) { - warn("MMU is not Riscv MMU instance, we can't reset PMP"); - return; + auto* mmu = tc->getMMUPtr(); + if (mmu != nullptr) { + mmu->reset(); } - mmu->getPMP()->pmpReset(); } void diff --git a/src/arch/riscv/mmu.hh b/src/arch/riscv/mmu.hh index ebe7e23153..c7a4ff005b 100644 --- a/src/arch/riscv/mmu.hh +++ b/src/arch/riscv/mmu.hh @@ -42,6 +42,7 @@ #include "arch/riscv/isa.hh" #include "arch/riscv/page_size.hh" #include "arch/riscv/pma_checker.hh" +#include "arch/riscv/pmp.hh" #include "arch/riscv/tlb.hh" #include "params/RiscvMMU.hh" @@ -60,6 +61,13 @@ class MMU : public BaseMMU : BaseMMU(p), pma(p.pma_checker) {} + void + reset() override + { + // Reset PMP Cfg + getPMP()->pmpReset(); + } + TranslationGenPtr translateFunctional(Addr start, Addr size, ThreadContext *tc, Mode mode, Request::Flags flags) override