mem: Make the FSTranslatingPortProxy stop using vtophys.
authorGabe Black <gabeblack@google.com>
Wed, 4 Mar 2020 10:56:57 +0000 (02:56 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 19 Mar 2020 01:11:21 +0000 (01:11 +0000)
That was the only place vtophys was still being used. Instead, use the
data TLB to translate functional, and if that fails try the the
instruction TLB.

Change-Id: Ie5e1e1b5d470f010e25482d785f111dc4292db60
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26233
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/fs_translating_port_proxy.cc
src/mem/fs_translating_port_proxy.hh

index ea62fe65d80a8b5ab1f68dcec78fac09d792189e..b33be4a55576e79fc081151ebada2767aa72d1a1 100644 (file)
 
 #include "mem/fs_translating_port_proxy.hh"
 
-#include "arch/vtophys.hh"
+#include "arch/generic/tlb.hh"
 #include "base/chunk_generator.hh"
 #include "cpu/base.hh"
 #include "cpu/thread_context.hh"
 #include "sim/system.hh"
 
-FSTranslatingPortProxy::FSTranslatingPortProxy(ThreadContext *tc)
-    PortProxy(tc->getCpuPtr()->getSendFunctional(),
-                tc->getSystemPtr()->cacheLineSize()), _tc(tc)
-{
-}
+FSTranslatingPortProxy::FSTranslatingPortProxy(ThreadContext *tc) :
+    PortProxy(tc->getCpuPtr()->getSendFunctional(),
+              tc->getSystemPtr()->cacheLineSize()), _tc(tc),
+              pageBytes(tc->getSystemPtr()->getPageBytes())
+{}
 
 bool
 FSTranslatingPortProxy::tryReadBlob(Addr addr, void *p, int size) const
 {
-    for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done();
+    BaseTLB *dtb = _tc->getDTBPtr();
+    BaseTLB *itb = _tc->getDTBPtr();
+
+    for (ChunkGenerator gen(addr, size, pageBytes); !gen.done();
          gen.next())
     {
-        Addr paddr = TheISA::vtophys(_tc, gen.addr());
+        auto req = std::make_shared<Request>(
+                gen.addr(), gen.size(), 0, Request::funcMasterId, 0,
+                _tc->contextId());
+        if (dtb->translateFunctional(req, _tc, BaseTLB::Read) != NoFault &&
+            itb->translateFunctional(req, _tc, BaseTLB::Read) != NoFault) {
+            return false;
+        }
+
+        PortProxy::readBlobPhys(
+                req->getPaddr(), req->getFlags(), p, gen.size());
 
-        PortProxy::readBlobPhys(paddr, 0, p, gen.size());
         p = static_cast<uint8_t *>(p) + gen.size();
     }
     return true;
@@ -75,12 +86,22 @@ bool
 FSTranslatingPortProxy::tryWriteBlob(
         Addr addr, const void *p, int size) const
 {
-    for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done();
+    BaseTLB *dtb = _tc->getDTBPtr();
+    BaseTLB *itb = _tc->getDTBPtr();
+
+    for (ChunkGenerator gen(addr, size, pageBytes); !gen.done();
          gen.next())
     {
-        Addr paddr = TheISA::vtophys(_tc, gen.addr());
+        auto req = std::make_shared<Request>(
+                gen.addr(), gen.size(), 0, Request::funcMasterId, 0,
+                _tc->contextId());
+        if (dtb->translateFunctional(req, _tc, BaseTLB::Write) != NoFault &&
+            itb->translateFunctional(req, _tc, BaseTLB::Write) != NoFault) {
+            return false;
+        }
 
-        PortProxy::writeBlobPhys(paddr, 0, p, gen.size());
+        PortProxy::writeBlobPhys(
+                req->getPaddr(), req->getFlags(), p, gen.size());
         p = static_cast<const uint8_t *>(p) + gen.size();
     }
     return true;
@@ -89,12 +110,22 @@ FSTranslatingPortProxy::tryWriteBlob(
 bool
 FSTranslatingPortProxy::tryMemsetBlob(Addr address, uint8_t v, int size) const
 {
-    for (ChunkGenerator gen(address, size, TheISA::PageBytes); !gen.done();
+    BaseTLB *dtb = _tc->getDTBPtr();
+    BaseTLB *itb = _tc->getDTBPtr();
+
+    for (ChunkGenerator gen(address, size, pageBytes); !gen.done();
          gen.next())
     {
-        Addr paddr = TheISA::vtophys(_tc, gen.addr());
+        auto req = std::make_shared<Request>(
+                gen.addr(), gen.size(), 0, Request::funcMasterId, 0,
+                _tc->contextId());
+        if (dtb->translateFunctional(req, _tc, BaseTLB::Write) != NoFault &&
+            itb->translateFunctional(req, _tc, BaseTLB::Write) != NoFault) {
+            return false;
+        }
 
-        PortProxy::memsetBlobPhys(paddr, 0, v, gen.size());
+        PortProxy::memsetBlobPhys(
+                req->getPaddr(), req->getFlags(), v, gen.size());
     }
     return true;
 }
index c1c4339b903d509e3d8e863b20e87cd18ff53426..e536a38bce660a578f24341a865cf588098b3ce7 100644 (file)
@@ -71,6 +71,7 @@ class FSTranslatingPortProxy : public PortProxy
 {
   private:
     ThreadContext* _tc;
+    const Addr pageBytes;
 
   public: