From 45829cfe00d6742ad8d68015ed1dd0aa6c2686dd Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 6 Mar 2020 16:38:22 -0800 Subject: [PATCH] x86: Implement translateFunctional. This function is based off of vtophys in the full system case, and off of the page table fill mechanism used in SE mode. It ignores what's already in the TLB, and also ignores protection mechanisms. This may need to be reworked in the future if, for instance, pages still resident in the TLB but not in the page tables need to be considered, but it should work at least for the time being. Change-Id: If21701ca36a30805f4199312933a8afc91f20501 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26405 Reviewed-by: Matthew Poremba Maintainer: Gabe Black Tested-by: kokoro --- src/arch/x86/tlb.cc | 34 ++++++++++++++++++++++++++++++++++ src/arch/x86/tlb.hh | 2 ++ 2 files changed, 36 insertions(+) diff --git a/src/arch/x86/tlb.cc b/src/arch/x86/tlb.cc index 15c431c50..740b6bc96 100644 --- a/src/arch/x86/tlb.cc +++ b/src/arch/x86/tlb.cc @@ -469,6 +469,40 @@ TLB::translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) return TLB::translate(req, tc, NULL, mode, delayedResponse, false); } +Fault +TLB::translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) +{ + unsigned logBytes; + const Addr vaddr = req->getVaddr(); + Addr addr = vaddr; + Addr paddr = 0; + if (FullSystem) { + Fault fault = walker->startFunctional(tc, addr, logBytes, mode); + if (fault != NoFault) + return fault; + paddr = insertBits(addr, logBytes, 0, vaddr); + } else { + 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(vaddr, true, mode, true, false); + + paddr = pte->paddr | process->pTable->pageOffset(vaddr); + } + DPRINTF(TLB, "Translated (functional) %#x -> %#x.\n", vaddr, paddr); + req->setPaddr(paddr); + return NoFault; +} + void TLB::translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) diff --git a/src/arch/x86/tlb.hh b/src/arch/x86/tlb.hh index e5ae56704..f0a671f39 100644 --- a/src/arch/x86/tlb.hh +++ b/src/arch/x86/tlb.hh @@ -124,6 +124,8 @@ namespace X86ISA Fault translateAtomic( const RequestPtr &req, ThreadContext *tc, Mode mode) override; + Fault translateFunctional( + const RequestPtr &req, ThreadContext *tc, Mode mode) override; void translateTiming( const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override; -- 2.30.2