arch-riscv: Replace any getDTBPtr/getITBPtr usage
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Sun, 13 Sep 2020 11:44:18 +0000 (12:44 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Tue, 27 Oct 2020 09:46:08 +0000 (09:46 +0000)
The getMMUPtr should be used instead

JIRA: https://gem5.atlassian.net/browse/GEM5-790

Change-Id: I46282b43b53b7dc9f9c6bb959d4aa23ee6808a6b
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34980
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/riscv/isa/decoder.isa
src/arch/riscv/isa/includes.isa
src/arch/riscv/mmu.hh
src/arch/riscv/remote_gdb.cc
src/arch/riscv/tlb.cc

index b39005ff319a38480e8f6f33126d50401a40f17d..5ef68fe1fb3dadf7c1b660d018b523c4495bc0ff 100644 (file)
@@ -1848,8 +1848,7 @@ decode QUADRANT default Unknown::unknown() {
                                         "sfence in user mode or TVM enabled",
                                         machInst);
                         }
-                        xc->tcBase()->getITBPtr()->demapPage(Rs1, Rs2);
-                        xc->tcBase()->getDTBPtr()->demapPage(Rs1, Rs2);
+                        xc->tcBase()->getMMUPtr()->demapPage(Rs1, Rs2);
                     }}, IsNonSpeculative, IsSerializeAfter, No_OpClass);
                     0x18: mret({{
                         if (xc->readMiscReg(MISCREG_PRV) != PRV_M) {
index 16114c95b6c33ec0d1c4e834b62dd29ff81cfef8..009f1434d124ae177bd4e48d85adfaaff74177e4 100644 (file)
@@ -61,7 +61,7 @@ output decoder {{
 
 #include "arch/riscv/decoder.hh"
 #include "arch/riscv/faults.hh"
-#include "arch/riscv/tlb.hh"
+#include "arch/riscv/mmu.hh"
 #include "base/cprintf.hh"
 #include "base/loader/symtab.hh"
 #include "cpu/thread_context.hh"
@@ -81,6 +81,7 @@ output exec {{
 
 #include "arch/generic/memhelpers.hh"
 #include "arch/riscv/faults.hh"
+#include "arch/riscv/mmu.hh"
 #include "arch/riscv/registers.hh"
 #include "arch/riscv/utility.hh"
 #include "base/condcodes.hh"
index d10ce137abc63286feddea751947957d6c665924..322f0afb871540b9b5376a38f7d30c200e849541 100644 (file)
@@ -39,6 +39,8 @@
 #define __ARCH_RISCV_MMU_HH__
 
 #include "arch/generic/mmu.hh"
+#include "arch/riscv/isa.hh"
+#include "arch/riscv/tlb.hh"
 
 #include "params/RiscvMMU.hh"
 
@@ -50,6 +52,18 @@ class MMU : public BaseMMU
     MMU(const RiscvMMUParams &p)
       : BaseMMU(p)
     {}
+
+    PrivilegeMode
+    getMemPriv(ThreadContext *tc, BaseTLB::Mode mode)
+    {
+        return static_cast<TLB*>(dtb)->getMemPriv(tc, mode);
+    }
+
+    Walker *
+    getDataWalker()
+    {
+        return static_cast<TLB*>(dtb)->getWalker();
+    }
 };
 
 } // namespace RiscvISA
index 7da666d2eabbb31f3e55937063e381899ea6c5f9..0e4c544ba22261920a291e19a6d20f65b1a4a8c0 100644 (file)
 
 #include <string>
 
+#include "arch/riscv/mmu.hh"
 #include "arch/riscv/pagetable_walker.hh"
 #include "arch/riscv/registers.hh"
-#include "arch/riscv/tlb.hh"
 #include "cpu/thread_state.hh"
 #include "debug/GDBAcc.hh"
 #include "mem/page_table.hh"
@@ -155,15 +155,15 @@ RemoteGDB::acc(Addr va, size_t len)
 {
     if (FullSystem)
     {
-        TLB *tlb = dynamic_cast<TLB *>(context()->getDTBPtr());
+        MMU *mmu = static_cast<MMU *>(context()->getMMUPtr());
         unsigned logBytes;
         Addr paddr = va;
 
-        PrivilegeMode pmode = tlb->getMemPriv(context(), BaseTLB::Read);
+        PrivilegeMode pmode = mmu->getMemPriv(context(), BaseTLB::Read);
         SATP satp = context()->readMiscReg(MISCREG_SATP);
         if (pmode != PrivilegeMode::PRV_M &&
             satp.mode != AddrXlateMode::BARE) {
-            Walker *walker = tlb->getWalker();
+            Walker *walker = mmu->getDataWalker();
             Fault fault = walker->startFunctional(
                     context(), paddr, logBytes, BaseTLB::Read);
             if (fault != NoFault)
index 883a6ca5169032b0d6e90bee82927937664acacf..62517e90cf07cc015fd0982ee5d245921765a8b5 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "arch/riscv/faults.hh"
 #include "arch/riscv/fs_workload.hh"
+#include "arch/riscv/mmu.hh"
 #include "arch/riscv/pagetable.hh"
 #include "arch/riscv/pagetable_walker.hh"
 #include "arch/riscv/pra_constants.hh"
@@ -411,13 +412,13 @@ TLB::translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode)
     Addr paddr = vaddr;
 
     if (FullSystem) {
-        TLB *tlb = dynamic_cast<TLB *>(tc->getDTBPtr());
+        MMU *mmu = static_cast<MMU *>(tc->getMMUPtr());
 
-        PrivilegeMode pmode = tlb->getMemPriv(tc, mode);
+        PrivilegeMode pmode = mmu->getMemPriv(tc, mode);
         SATP satp = tc->readMiscReg(MISCREG_SATP);
         if (pmode != PrivilegeMode::PRV_M &&
             satp.mode != AddrXlateMode::BARE) {
-            Walker *walker = tlb->getWalker();
+            Walker *walker = mmu->getDataWalker();
             unsigned logBytes;
             Fault fault = walker->startFunctional(
                     tc, paddr, logBytes, mode);