From 7e0f15e1c0bd273ba15045d57b56229e67c8ee07 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 4 Mar 2020 02:56:57 -0800 Subject: [PATCH] mem: Make the FSTranslatingPortProxy stop using vtophys. 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 Reviewed-by: Nikos Nikoleris Maintainer: Gabe Black Tested-by: kokoro --- src/mem/fs_translating_port_proxy.cc | 61 +++++++++++++++++++++------- src/mem/fs_translating_port_proxy.hh | 1 + 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/mem/fs_translating_port_proxy.cc b/src/mem/fs_translating_port_proxy.cc index ea62fe65d..b33be4a55 100644 --- a/src/mem/fs_translating_port_proxy.cc +++ b/src/mem/fs_translating_port_proxy.cc @@ -45,27 +45,38 @@ #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( + 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(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( + 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(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( + 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; } diff --git a/src/mem/fs_translating_port_proxy.hh b/src/mem/fs_translating_port_proxy.hh index c1c4339b9..e536a38bc 100644 --- a/src/mem/fs_translating_port_proxy.hh +++ b/src/mem/fs_translating_port_proxy.hh @@ -71,6 +71,7 @@ class FSTranslatingPortProxy : public PortProxy { private: ThreadContext* _tc; + const Addr pageBytes; public: -- 2.30.2