From: Gabe Black Date: Wed, 11 Mar 2020 01:14:56 +0000 (-0700) Subject: riscv: Implement translateFunctional. X-Git-Tag: v20.0.0.0~312 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c38298d93149e4bff129356545771e4b3a24cd1e;p=gem5.git riscv: Implement translateFunctional. Change-Id: Ibe8adea8f66c7de22ee2ab0da54e866cd05fc257 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26547 Reviewed-by: Jason Lowe-Power Reviewed-by: Matthew Poremba Maintainer: Gabe Black Tested-by: kokoro --- diff --git a/src/arch/riscv/tlb.cc b/src/arch/riscv/tlb.cc index aefa2dfb3..1bf557ae5 100644 --- a/src/arch/riscv/tlb.cc +++ b/src/arch/riscv/tlb.cc @@ -380,6 +380,34 @@ TLB::translateTiming(const RequestPtr &req, ThreadContext *tc, translation->finish(translateAtomic(req, tc, mode), req, tc, mode); } +Fault +TLB::translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) +{ + panic_if(FullSystem, + "translateFunctional not implemented for full system."); + + const Addr vaddr = req->getVaddr(); + Process *process = tc->getProcessPtr(); + const auto *pte = process->pTable->lookup(vaddr); + + if (!pte && mode != Execute) { + // Check if we just need to grow the stack. + if (process->fixupStackFault(vaddr)) { + // If we did, lookup the entry for the new page. + pte = process->pTable->lookup(vaddr); + } + } + + if (!pte) + return std::make_shared(req->getVaddr()); + + Addr paddr = pte->paddr | process->pTable->pageOffset(vaddr); + + DPRINTF(TLB, "Translated (functional) %#x -> %#x.\n", vaddr, paddr); + req->setPaddr(paddr); + return NoFault; +} + Fault TLB::finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const diff --git a/src/arch/riscv/tlb.hh b/src/arch/riscv/tlb.hh index bdd318192..c648123a5 100644 --- a/src/arch/riscv/tlb.hh +++ b/src/arch/riscv/tlb.hh @@ -111,6 +111,8 @@ class TLB : public BaseTLB void translateTiming( const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override; + Fault translateFunctional( + const RequestPtr &req, ThreadContext *tc, Mode mode) override; Fault finalizePhysical( const RequestPtr &req, ThreadContext *tc, Mode mode) const override;