tlb.cc revision 11584
12SN/A/* 210466Sandreas.hansson@arm.com * Copyright (c) 2010-2013, 2016 ARM Limited 38703Sandreas.hansson@arm.com * All rights reserved 48703Sandreas.hansson@arm.com * 58703Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68703Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78703Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88703Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98703Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108703Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118703Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128703Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138703Sandreas.hansson@arm.com * 141762SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan 157897Shestness@cs.utexas.edu * All rights reserved. 162SN/A * 172SN/A * Redistribution and use in source and binary forms, with or without 182SN/A * modification, are permitted provided that the following conditions are 192SN/A * met: redistributions of source code must retain the above copyright 202SN/A * notice, this list of conditions and the following disclaimer; 212SN/A * redistributions in binary form must reproduce the above copyright 222SN/A * notice, this list of conditions and the following disclaimer in the 232SN/A * documentation and/or other materials provided with the distribution; 242SN/A * neither the name of the copyright holders nor the names of its 252SN/A * contributors may be used to endorse or promote products derived from 262SN/A * this software without specific prior written permission. 272SN/A * 282SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392SN/A * 402665Ssaidi@eecs.umich.edu * Authors: Ali Saidi 412665Ssaidi@eecs.umich.edu * Nathan Binkert 422665Ssaidi@eecs.umich.edu * Steve Reinhardt 432665Ssaidi@eecs.umich.edu */ 447897Shestness@cs.utexas.edu 452SN/A#include "arch/arm/tlb.hh" 462SN/A 472SN/A#include <memory> 482SN/A#include <string> 492SN/A#include <vector> 502SN/A 5111911SBrandon.Potter@amd.com#include "arch/arm/faults.hh" 529645SAndreas.Sandberg@ARM.com#include "arch/arm/pagetable.hh" 5375SN/A#include "arch/arm/system.hh" 542SN/A#include "arch/arm/table_walker.hh" 5510466Sandreas.hansson@arm.com#include "arch/arm/stage2_lookup.hh" 562439SN/A#include "arch/arm/stage2_mmu.hh" 57603SN/A#include "arch/arm/utility.hh" 5810466Sandreas.hansson@arm.com#include "base/inifile.hh" 594762Snate@binkert.org#include "base/str.hh" 608703Sandreas.hansson@arm.com#include "base/trace.hh" 6111911SBrandon.Potter@amd.com#include "cpu/base.hh" 622520SN/A#include "cpu/thread_context.hh" 639847Sandreas.hansson@arm.com#include "debug/Checkpoint.hh" 644762Snate@binkert.org#include "debug/TLB.hh" 6511911SBrandon.Potter@amd.com#include "debug/TLBVerbose.hh" 6611909SBrandon.Potter@amd.com#include "mem/page_table.hh" 676658Snate@binkert.org#include "params/ArmTLB.hh" 6810494Sandreas.hansson@arm.com#include "sim/full_system.hh" 6910494Sandreas.hansson@arm.com#include "sim/process.hh" 7010494Sandreas.hansson@arm.com 7110494Sandreas.hansson@arm.comusing namespace std; 7210494Sandreas.hansson@arm.comusing namespace ArmISA; 7310494Sandreas.hansson@arm.com 7411911SBrandon.Potter@amd.comTLB::TLB(const ArmTLBParams *p) 7510494Sandreas.hansson@arm.com : BaseTLB(p), table(new TlbEntry[p->size]), size(p->size), 7610494Sandreas.hansson@arm.com isStage2(p->is_stage2), stage2Req(false), _attr(0), 778769Sgblack@eecs.umich.edu directToStage2(false), tableWalker(p->walker), stage2Tlb(NULL), 788769Sgblack@eecs.umich.edu stage2Mmu(NULL), test(nullptr), rangeMRU(1), 7911839SCurtis.Dunham@arm.com aarch64(false), aarch64EL(EL0), isPriv(false), isSecure(false), 801634SN/A isHyp(false), asid(0), vmid(0), dacr(0), 818769Sgblack@eecs.umich.edu miscRegValid(false), miscRegContext(0), curTranType(NormalTran) 822SN/A{ 838703Sandreas.hansson@arm.com tableWalker->setTlb(this); 842SN/A 858703Sandreas.hansson@arm.com // Cache system-level properties 868703Sandreas.hansson@arm.com haveLPAE = tableWalker->haveLPAE(); 878703Sandreas.hansson@arm.com haveVirtualization = tableWalker->haveVirtualization(); 888703Sandreas.hansson@arm.com haveLargeAsid64 = tableWalker->haveLargeAsid64(); 898703Sandreas.hansson@arm.com} 908703Sandreas.hansson@arm.com 918703Sandreas.hansson@arm.comTLB::~TLB() 928922Swilliam.wang@arm.com{ 938703Sandreas.hansson@arm.com delete[] table; 948703Sandreas.hansson@arm.com} 958703Sandreas.hansson@arm.com 968703Sandreas.hansson@arm.comvoid 978703Sandreas.hansson@arm.comTLB::init() 988703Sandreas.hansson@arm.com{ 998703Sandreas.hansson@arm.com if (stage2Mmu && !isStage2) 1008922Swilliam.wang@arm.com stage2Tlb = stage2Mmu->stage2Tlb(); 1018703Sandreas.hansson@arm.com} 10211169Sandreas.hansson@arm.com 1038703Sandreas.hansson@arm.comvoid 10411169Sandreas.hansson@arm.comTLB::setMMU(Stage2MMU *m, MasterID master_id) 1058922Swilliam.wang@arm.com{ 1068703Sandreas.hansson@arm.com stage2Mmu = m; 1078703Sandreas.hansson@arm.com tableWalker->setMMU(m, master_id); 1088703Sandreas.hansson@arm.com} 1098703Sandreas.hansson@arm.com 110603SN/Abool 1112901Ssaidi@eecs.umich.eduTLB::translateFunctional(ThreadContext *tc, Addr va, Addr &pa) 1128703Sandreas.hansson@arm.com{ 1138706Sandreas.hansson@arm.com updateMiscReg(tc); 1148706Sandreas.hansson@arm.com 1158706Sandreas.hansson@arm.com if (directToStage2) { 11611169Sandreas.hansson@arm.com assert(stage2Tlb); 1178706Sandreas.hansson@arm.com return stage2Tlb->translateFunctional(tc, va, pa); 1188706Sandreas.hansson@arm.com } 1198852Sandreas.hansson@arm.com 1208703Sandreas.hansson@arm.com TlbEntry *e = lookup(va, asid, vmid, isHyp, isSecure, true, false, 1218703Sandreas.hansson@arm.com aarch64 ? aarch64EL : EL1); 1228703Sandreas.hansson@arm.com if (!e) 1238703Sandreas.hansson@arm.com return false; 1248852Sandreas.hansson@arm.com pa = e->pAddr(va); 1258703Sandreas.hansson@arm.com return true; 1268922Swilliam.wang@arm.com} 1278703Sandreas.hansson@arm.com 1288703Sandreas.hansson@arm.comFault 1298703Sandreas.hansson@arm.comTLB::finalizePhysical(RequestPtr req, ThreadContext *tc, Mode mode) const 1308703Sandreas.hansson@arm.com{ 1319294Sandreas.hansson@arm.com return NoFault; 13211169Sandreas.hansson@arm.com} 1338703Sandreas.hansson@arm.com 1349524SAndreas.Sandberg@ARM.comTlbEntry* 1359524SAndreas.Sandberg@ARM.comTLB::lookup(Addr va, uint16_t asn, uint8_t vmid, bool hyp, bool secure, 1369524SAndreas.Sandberg@ARM.com bool functional, bool ignore_asn, uint8_t target_el) 1379524SAndreas.Sandberg@ARM.com{ 1389524SAndreas.Sandberg@ARM.com 1399524SAndreas.Sandberg@ARM.com TlbEntry *retval = NULL; 1409524SAndreas.Sandberg@ARM.com 1419524SAndreas.Sandberg@ARM.com // Maintaining LRU array 1429524SAndreas.Sandberg@ARM.com int x = 0; 1439524SAndreas.Sandberg@ARM.com while (retval == NULL && x < size) { 1449524SAndreas.Sandberg@ARM.com if ((!ignore_asn && table[x].match(va, asn, vmid, hyp, secure, false, 1459524SAndreas.Sandberg@ARM.com target_el)) || 1469524SAndreas.Sandberg@ARM.com (ignore_asn && table[x].match(va, vmid, hyp, secure, target_el))) { 1474762Snate@binkert.org // We only move the hit entry ahead when the position is higher 1482901Ssaidi@eecs.umich.edu // than rangeMRU 1499524SAndreas.Sandberg@ARM.com if (x > rangeMRU && !functional) { 1509524SAndreas.Sandberg@ARM.com TlbEntry tmp_entry = table[x]; 1519524SAndreas.Sandberg@ARM.com for (int i = x; i > 0; i--) 1529524SAndreas.Sandberg@ARM.com table[i] = table[i - 1]; 1539524SAndreas.Sandberg@ARM.com table[0] = tmp_entry; 1549524SAndreas.Sandberg@ARM.com retval = &table[0]; 1559524SAndreas.Sandberg@ARM.com } else { 1569524SAndreas.Sandberg@ARM.com retval = &table[x]; 1579524SAndreas.Sandberg@ARM.com } 1589524SAndreas.Sandberg@ARM.com break; 1599524SAndreas.Sandberg@ARM.com } 1609524SAndreas.Sandberg@ARM.com ++x; 1619524SAndreas.Sandberg@ARM.com } 1629524SAndreas.Sandberg@ARM.com 1639524SAndreas.Sandberg@ARM.com DPRINTF(TLBVerbose, "Lookup %#x, asn %#x -> %s vmn 0x%x hyp %d secure %d " 1649524SAndreas.Sandberg@ARM.com "ppn %#x size: %#x pa: %#x ap:%d ns:%d nstid:%d g:%d asid: %d " 1659524SAndreas.Sandberg@ARM.com "el: %d\n", 1669524SAndreas.Sandberg@ARM.com va, asn, retval ? "hit" : "miss", vmid, hyp, secure, 1679524SAndreas.Sandberg@ARM.com retval ? retval->pfn : 0, retval ? retval->size : 0, 1689524SAndreas.Sandberg@ARM.com retval ? retval->pAddr(va) : 0, retval ? retval->ap : 0, 1699524SAndreas.Sandberg@ARM.com retval ? retval->ns : 0, retval ? retval->nstid : 0, 1709524SAndreas.Sandberg@ARM.com retval ? retval->global : 0, retval ? retval->asid : 0, 1719524SAndreas.Sandberg@ARM.com retval ? retval->el : 0); 1729524SAndreas.Sandberg@ARM.com 1739524SAndreas.Sandberg@ARM.com return retval; 1749524SAndreas.Sandberg@ARM.com} 1759524SAndreas.Sandberg@ARM.com 1769524SAndreas.Sandberg@ARM.com// insert a new TLB entry 1779524SAndreas.Sandberg@ARM.comvoid 1789524SAndreas.Sandberg@ARM.comTLB::insert(Addr addr, TlbEntry &entry) 1799524SAndreas.Sandberg@ARM.com{ 1809524SAndreas.Sandberg@ARM.com DPRINTF(TLB, "Inserting entry into TLB with pfn:%#x size:%#x vpn: %#x" 1819524SAndreas.Sandberg@ARM.com " asid:%d vmid:%d N:%d global:%d valid:%d nc:%d xn:%d" 1829524SAndreas.Sandberg@ARM.com " ap:%#x domain:%#x ns:%d nstid:%d isHyp:%d\n", entry.pfn, 1839524SAndreas.Sandberg@ARM.com entry.size, entry.vpn, entry.asid, entry.vmid, entry.N, 1849524SAndreas.Sandberg@ARM.com entry.global, entry.valid, entry.nonCacheable, entry.xn, 1859524SAndreas.Sandberg@ARM.com entry.ap, static_cast<uint8_t>(entry.domain), entry.ns, entry.nstid, 1862901Ssaidi@eecs.umich.edu entry.isHyp); 1874762Snate@binkert.org 1889524SAndreas.Sandberg@ARM.com if (table[size - 1].valid) 1892901Ssaidi@eecs.umich.edu DPRINTF(TLB, " - Replacing Valid entry %#x, asn %d vmn %d ppn %#x " 1909814Sandreas.hansson@arm.com "size: %#x ap:%d ns:%d nstid:%d g:%d isHyp:%d el: %d\n", 1919814Sandreas.hansson@arm.com table[size-1].vpn << table[size-1].N, table[size-1].asid, 1929814Sandreas.hansson@arm.com table[size-1].vmid, table[size-1].pfn << table[size-1].N, 1939814Sandreas.hansson@arm.com table[size-1].size, table[size-1].ap, table[size-1].ns, 1949814Sandreas.hansson@arm.com table[size-1].nstid, table[size-1].global, table[size-1].isHyp, 1959850Sandreas.hansson@arm.com table[size-1].el); 1962SN/A 1979850Sandreas.hansson@arm.com //inserting to MRU position and evicting the LRU one 1982SN/A 1992680Sktlim@umich.edu for (int i = size - 1; i > 0; --i) 2005714Shsul@eecs.umich.edu table[i] = table[i-1]; 20111146Smitch.hayenga@arm.com table[0] = entry; 2021806SN/A 20311005Sandreas.sandberg@arm.com inserts++; 2045713Shsul@eecs.umich.edu ppRefills->notify(1); 2055713Shsul@eecs.umich.edu} 2065713Shsul@eecs.umich.edu 2075713Shsul@eecs.umich.eduvoid 2085714Shsul@eecs.umich.eduTLB::printTlb() const 2091806SN/A{ 2106227Snate@binkert.org int x = 0; 2115714Shsul@eecs.umich.edu TlbEntry *te; 2121806SN/A DPRINTF(TLB, "Current TLB contents:\n"); 213180SN/A while (x < size) { 2146029Ssteve.reinhardt@amd.com te = &table[x]; 2156029Ssteve.reinhardt@amd.com if (te->valid) 2166029Ssteve.reinhardt@amd.com DPRINTF(TLB, " * %s\n", te->print()); 2176029Ssteve.reinhardt@amd.com ++x; 2188765Sgblack@eecs.umich.edu } 2198765Sgblack@eecs.umich.edu} 2202378SN/A 2212378SN/Avoid 2222520SN/ATLB::flushAllSecurity(bool secure_lookup, uint8_t target_el, bool ignore_el) 2232520SN/A{ 2248852Sandreas.hansson@arm.com DPRINTF(TLB, "Flushing all TLB entries (%s lookup)\n", 2252520SN/A (secure_lookup ? "secure" : "non-secure")); 2261885SN/A int x = 0; 2271070SN/A TlbEntry *te; 228954SN/A while (x < size) { 2291070SN/A te = &table[x]; 2301070SN/A if (te->valid && secure_lookup == !te->nstid && 2311070SN/A (te->vmid == vmid || secure_lookup) && 23211838SCurtis.Dunham@arm.com checkELMatch(target_el, te->el, ignore_el)) { 2331070SN/A 2341070SN/A DPRINTF(TLB, " - %s\n", te->print()); 2351070SN/A te->valid = false; 2361070SN/A flushedEntries++; 2371070SN/A } 2381070SN/A ++x; 2391070SN/A } 2401070SN/A 2417580SAli.Saidi@arm.com flushTlb++; 2427580SAli.Saidi@arm.com 2437580SAli.Saidi@arm.com // If there's a second stage TLB (and we're not it) then flush it as well 2447580SAli.Saidi@arm.com // if we're currently in hyp mode 2457580SAli.Saidi@arm.com if (!isStage2 && isHyp) { 2467580SAli.Saidi@arm.com stage2Tlb->flushAllSecurity(secure_lookup, true); 2477580SAli.Saidi@arm.com } 2487580SAli.Saidi@arm.com} 24910037SARM gem5 Developers 25011838SCurtis.Dunham@arm.comvoid 25111838SCurtis.Dunham@arm.comTLB::flushAllNs(bool hyp, uint8_t target_el, bool ignore_el) 25210037SARM gem5 Developers{ 25310037SARM gem5 Developers DPRINTF(TLB, "Flushing all NS TLB entries (%s lookup)\n", 25410037SARM gem5 Developers (hyp ? "hyp" : "non-hyp")); 25510037SARM gem5 Developers int x = 0; 2564997Sgblack@eecs.umich.edu TlbEntry *te; 25711839SCurtis.Dunham@arm.com while (x < size) { 25811839SCurtis.Dunham@arm.com te = &table[x]; 25911839SCurtis.Dunham@arm.com if (te->valid && te->nstid && te->isHyp == hyp && 26011839SCurtis.Dunham@arm.com checkELMatch(target_el, te->el, ignore_el)) { 26111839SCurtis.Dunham@arm.com 26211839SCurtis.Dunham@arm.com DPRINTF(TLB, " - %s\n", te->print()); 26311839SCurtis.Dunham@arm.com flushedEntries++; 26411839SCurtis.Dunham@arm.com te->valid = false; 26512100SCurtis.Dunham@arm.com } 26612100SCurtis.Dunham@arm.com ++x; 26712100SCurtis.Dunham@arm.com } 2688931Sandreas.hansson@arm.com 2698931Sandreas.hansson@arm.com flushTlb++; 2708931Sandreas.hansson@arm.com 2715795Ssaidi@eecs.umich.edu // If there's a second stage TLB (and we're not it) then flush it as well 2728931Sandreas.hansson@arm.com if (!isStage2 && !hyp) { 2735795Ssaidi@eecs.umich.edu stage2Tlb->flushAllNs(false, true); 2745795Ssaidi@eecs.umich.edu } 2758931Sandreas.hansson@arm.com} 2768931Sandreas.hansson@arm.com 2778931Sandreas.hansson@arm.comvoid 2788931Sandreas.hansson@arm.comTLB::flushMvaAsid(Addr mva, uint64_t asn, bool secure_lookup, uint8_t target_el) 2798931Sandreas.hansson@arm.com{ 2808931Sandreas.hansson@arm.com DPRINTF(TLB, "Flushing TLB entries with mva: %#x, asid: %#x " 2818931Sandreas.hansson@arm.com "(%s lookup)\n", mva, asn, (secure_lookup ? 2828931Sandreas.hansson@arm.com "secure" : "non-secure")); 2838931Sandreas.hansson@arm.com _flushMva(mva, asn, secure_lookup, false, false, target_el); 2848931Sandreas.hansson@arm.com flushTlbMvaAsid++; 2855795Ssaidi@eecs.umich.edu} 28610467Sandreas.hansson@arm.com 28710467Sandreas.hansson@arm.comvoid 28810467Sandreas.hansson@arm.comTLB::flushAsid(uint64_t asn, bool secure_lookup, uint8_t target_el) 28910467Sandreas.hansson@arm.com{ 29010467Sandreas.hansson@arm.com DPRINTF(TLB, "Flushing TLB entries with asid: %#x (%s lookup)\n", asn, 29110466Sandreas.hansson@arm.com (secure_lookup ? "secure" : "non-secure")); 29210466Sandreas.hansson@arm.com 29310466Sandreas.hansson@arm.com int x = 0 ; 29410466Sandreas.hansson@arm.com TlbEntry *te; 29510466Sandreas.hansson@arm.com 29610466Sandreas.hansson@arm.com while (x < size) { 29711838SCurtis.Dunham@arm.com te = &table[x]; 29810466Sandreas.hansson@arm.com if (te->valid && te->asid == asn && secure_lookup == !te->nstid && 29910466Sandreas.hansson@arm.com (te->vmid == vmid || secure_lookup) && 30010466Sandreas.hansson@arm.com checkELMatch(target_el, te->el, false)) { 30111420Sdavid.guillen@arm.com 30211420Sdavid.guillen@arm.com te->valid = false; 30311420Sdavid.guillen@arm.com DPRINTF(TLB, " - %s\n", te->print()); 30411420Sdavid.guillen@arm.com flushedEntries++; 30511420Sdavid.guillen@arm.com } 3061885SN/A ++x; 3078931Sandreas.hansson@arm.com } 30811839SCurtis.Dunham@arm.com flushTlbAsid++; 30911839SCurtis.Dunham@arm.com} 3108931Sandreas.hansson@arm.com 3118931Sandreas.hansson@arm.comvoid 3124762Snate@binkert.orgTLB::flushMva(Addr mva, bool secure_lookup, bool hyp, uint8_t target_el) 3139814Sandreas.hansson@arm.com{ 3149814Sandreas.hansson@arm.com DPRINTF(TLB, "Flushing TLB entries with mva: %#x (%s lookup)\n", mva, 3159814Sandreas.hansson@arm.com (secure_lookup ? "secure" : "non-secure")); 3167914SBrad.Beckmann@amd.com _flushMva(mva, 0xbeef, secure_lookup, hyp, true, target_el); 3177914SBrad.Beckmann@amd.com flushTlbMva++; 3188666SPrakash.Ramrakhyani@arm.com} 3197914SBrad.Beckmann@amd.com 3207914SBrad.Beckmann@amd.comvoid 32111838SCurtis.Dunham@arm.comTLB::_flushMva(Addr mva, uint64_t asn, bool secure_lookup, bool hyp, 3228832SAli.Saidi@ARM.com bool ignore_asn, uint8_t target_el) 3238832SAli.Saidi@ARM.com{ 3248832SAli.Saidi@ARM.com TlbEntry *te; 3258832SAli.Saidi@ARM.com // D5.7.2: Sign-extend address to 64 bits 3268832SAli.Saidi@ARM.com mva = sext<56>(mva); 3278832SAli.Saidi@ARM.com te = lookup(mva, asn, vmid, hyp, secure_lookup, false, ignore_asn, 32811420Sdavid.guillen@arm.com target_el); 32911420Sdavid.guillen@arm.com while (te != NULL) { 3307914SBrad.Beckmann@amd.com if (secure_lookup == !te->nstid) { 3318832SAli.Saidi@ARM.com DPRINTF(TLB, " - %s\n", te->print()); 3328832SAli.Saidi@ARM.com te->valid = false; 3338832SAli.Saidi@ARM.com flushedEntries++; 3348832SAli.Saidi@ARM.com } 33511838SCurtis.Dunham@arm.com te = lookup(mva, asn, vmid, hyp, secure_lookup, false, ignore_asn, 33611838SCurtis.Dunham@arm.com target_el); 3378832SAli.Saidi@ARM.com } 3388832SAli.Saidi@ARM.com} 3398832SAli.Saidi@ARM.com 3408832SAli.Saidi@ARM.comvoid 3418832SAli.Saidi@ARM.comTLB::flushIpaVmid(Addr ipa, bool secure_lookup, bool hyp, uint8_t target_el) 3428832SAli.Saidi@ARM.com{ 3438832SAli.Saidi@ARM.com assert(!isStage2); 3448832SAli.Saidi@ARM.com stage2Tlb->_flushMva(ipa, 0xbeef, secure_lookup, hyp, true, target_el); 3458832SAli.Saidi@ARM.com} 3468832SAli.Saidi@ARM.com 3478832SAli.Saidi@ARM.combool 3488832SAli.Saidi@ARM.comTLB::checkELMatch(uint8_t target_el, uint8_t tentry_el, bool ignore_el) 3498832SAli.Saidi@ARM.com{ 3508832SAli.Saidi@ARM.com bool elMatch = true; 3518832SAli.Saidi@ARM.com if (!ignore_el) { 35211169Sandreas.hansson@arm.com if (target_el == 2 || target_el == 3) { 3537914SBrad.Beckmann@amd.com elMatch = (tentry_el == target_el); 3547914SBrad.Beckmann@amd.com } else { 3557914SBrad.Beckmann@amd.com elMatch = (tentry_el == 0) || (tentry_el == 1); 3567914SBrad.Beckmann@amd.com } 3578666SPrakash.Ramrakhyani@arm.com } 3587914SBrad.Beckmann@amd.com return elMatch; 3597914SBrad.Beckmann@amd.com} 3607914SBrad.Beckmann@amd.com 3617914SBrad.Beckmann@amd.comvoid 3627914SBrad.Beckmann@amd.comTLB::drainResume() 3637914SBrad.Beckmann@amd.com{ 3647914SBrad.Beckmann@amd.com // We might have unserialized something or switched CPUs, so make 3657914SBrad.Beckmann@amd.com // sure to re-read the misc regs. 3667914SBrad.Beckmann@amd.com miscRegValid = false; 36710037SARM gem5 Developers} 3687914SBrad.Beckmann@amd.com 3697914SBrad.Beckmann@amd.comvoid 3707914SBrad.Beckmann@amd.comTLB::takeOverFrom(BaseTLB *_otlb) 3717914SBrad.Beckmann@amd.com{ 3727914SBrad.Beckmann@amd.com TLB *otlb = dynamic_cast<TLB*>(_otlb); 3737914SBrad.Beckmann@amd.com /* Make sure we actually have a valid type */ 3747914SBrad.Beckmann@amd.com if (otlb) { 3757914SBrad.Beckmann@amd.com _attr = otlb->_attr; 3767914SBrad.Beckmann@amd.com haveLPAE = otlb->haveLPAE; 3777914SBrad.Beckmann@amd.com directToStage2 = otlb->directToStage2; 37810037SARM gem5 Developers stage2Req = otlb->stage2Req; 3797914SBrad.Beckmann@amd.com 3807914SBrad.Beckmann@amd.com /* Sync the stage2 MMU if they exist in both 3817914SBrad.Beckmann@amd.com * the old CPU and the new 3827914SBrad.Beckmann@amd.com */ 3837914SBrad.Beckmann@amd.com if (!isStage2 && 38410037SARM gem5 Developers stage2Tlb && otlb->stage2Tlb) { 3857914SBrad.Beckmann@amd.com stage2Tlb->takeOverFrom(otlb->stage2Tlb); 3867914SBrad.Beckmann@amd.com } 3877914SBrad.Beckmann@amd.com } else { 3887914SBrad.Beckmann@amd.com panic("Incompatible TLB type!"); 3897914SBrad.Beckmann@amd.com } 3902901Ssaidi@eecs.umich.edu} 3918666SPrakash.Ramrakhyani@arm.com 3928666SPrakash.Ramrakhyani@arm.comvoid 3938666SPrakash.Ramrakhyani@arm.comTLB::serialize(CheckpointOut &cp) const 3948666SPrakash.Ramrakhyani@arm.com{ 3958666SPrakash.Ramrakhyani@arm.com DPRINTF(Checkpoint, "Serializing Arm TLB\n"); 3968666SPrakash.Ramrakhyani@arm.com 3978666SPrakash.Ramrakhyani@arm.com SERIALIZE_SCALAR(_attr); 3988666SPrakash.Ramrakhyani@arm.com SERIALIZE_SCALAR(haveLPAE); 3991885SN/A SERIALIZE_SCALAR(directToStage2); 4001885SN/A SERIALIZE_SCALAR(stage2Req); 4011885SN/A 4021885SN/A int num_entries = size; 4031885SN/A SERIALIZE_SCALAR(num_entries); 4048769Sgblack@eecs.umich.edu for (int i = 0; i < size; i++) 4058769Sgblack@eecs.umich.edu table[i].serializeSection(cp, csprintf("TlbEntry%d", i)); 4068769Sgblack@eecs.umich.edu} 4078769Sgblack@eecs.umich.edu 4081885SN/Avoid 4099645SAndreas.Sandberg@ARM.comTLB::unserialize(CheckpointIn &cp) 4101885SN/A{ 4111885SN/A DPRINTF(Checkpoint, "Unserializing Arm TLB\n"); 4121885SN/A 4139645SAndreas.Sandberg@ARM.com UNSERIALIZE_SCALAR(_attr); 4149645SAndreas.Sandberg@ARM.com UNSERIALIZE_SCALAR(haveLPAE); 4159645SAndreas.Sandberg@ARM.com UNSERIALIZE_SCALAR(directToStage2); 4169645SAndreas.Sandberg@ARM.com UNSERIALIZE_SCALAR(stage2Req); 4179645SAndreas.Sandberg@ARM.com 4189645SAndreas.Sandberg@ARM.com int num_entries; 4199645SAndreas.Sandberg@ARM.com UNSERIALIZE_SCALAR(num_entries); 4209645SAndreas.Sandberg@ARM.com for (int i = 0; i < min(size, num_entries); i++) 4211885SN/A table[i].unserializeSection(cp, csprintf("TlbEntry%d", i)); 4229645SAndreas.Sandberg@ARM.com} 4239645SAndreas.Sandberg@ARM.com 4249645SAndreas.Sandberg@ARM.comvoid 4251885SN/ATLB::regStats() 4269855Sandreas.hansson@arm.com{ 4271885SN/A BaseTLB::regStats(); 4289850Sandreas.hansson@arm.com instHits 4291885SN/A .name(name() + ".inst_hits") 4309645SAndreas.Sandberg@ARM.com .desc("ITB inst hits") 4319645SAndreas.Sandberg@ARM.com ; 4321885SN/A 4331885SN/A instMisses 4349850Sandreas.hansson@arm.com .name(name() + ".inst_misses") 4351885SN/A .desc("ITB inst misses") 4361885SN/A ; 4371885SN/A 4381885SN/A instAccesses 4391885SN/A .name(name() + ".inst_accesses") 4409645SAndreas.Sandberg@ARM.com .desc("ITB inst accesses") 4411885SN/A ; 4429645SAndreas.Sandberg@ARM.com 4431885SN/A readHits 4441885SN/A .name(name() + ".read_hits") 4459645SAndreas.Sandberg@ARM.com .desc("DTB read hits") 4469645SAndreas.Sandberg@ARM.com ; 4479645SAndreas.Sandberg@ARM.com 4489645SAndreas.Sandberg@ARM.com readMisses 4499645SAndreas.Sandberg@ARM.com .name(name() + ".read_misses") 4509645SAndreas.Sandberg@ARM.com .desc("DTB read misses") 4519645SAndreas.Sandberg@ARM.com ; 4529645SAndreas.Sandberg@ARM.com 4539645SAndreas.Sandberg@ARM.com readAccesses 4549645SAndreas.Sandberg@ARM.com .name(name() + ".read_accesses") 4559645SAndreas.Sandberg@ARM.com .desc("DTB read accesses") 4569645SAndreas.Sandberg@ARM.com ; 4579645SAndreas.Sandberg@ARM.com 4589645SAndreas.Sandberg@ARM.com writeHits 4599645SAndreas.Sandberg@ARM.com .name(name() + ".write_hits") 4609645SAndreas.Sandberg@ARM.com .desc("DTB write hits") 4619645SAndreas.Sandberg@ARM.com ; 4629645SAndreas.Sandberg@ARM.com 4639645SAndreas.Sandberg@ARM.com writeMisses 4649645SAndreas.Sandberg@ARM.com .name(name() + ".write_misses") 4659645SAndreas.Sandberg@ARM.com .desc("DTB write misses") 4669645SAndreas.Sandberg@ARM.com ; 4679645SAndreas.Sandberg@ARM.com 4689645SAndreas.Sandberg@ARM.com writeAccesses 4699645SAndreas.Sandberg@ARM.com .name(name() + ".write_accesses") 4709645SAndreas.Sandberg@ARM.com .desc("DTB write accesses") 4719645SAndreas.Sandberg@ARM.com ; 4729645SAndreas.Sandberg@ARM.com 4739645SAndreas.Sandberg@ARM.com hits 4749645SAndreas.Sandberg@ARM.com .name(name() + ".hits") 4759645SAndreas.Sandberg@ARM.com .desc("DTB hits") 4769645SAndreas.Sandberg@ARM.com ; 4779645SAndreas.Sandberg@ARM.com 4789645SAndreas.Sandberg@ARM.com misses 4799645SAndreas.Sandberg@ARM.com .name(name() + ".misses") 4809645SAndreas.Sandberg@ARM.com .desc("DTB misses") 4819645SAndreas.Sandberg@ARM.com ; 4829645SAndreas.Sandberg@ARM.com 4839645SAndreas.Sandberg@ARM.com accesses 4849645SAndreas.Sandberg@ARM.com .name(name() + ".accesses") 4859645SAndreas.Sandberg@ARM.com .desc("DTB accesses") 4869645SAndreas.Sandberg@ARM.com ; 4879645SAndreas.Sandberg@ARM.com 4889645SAndreas.Sandberg@ARM.com flushTlb 48977SN/A .name(name() + ".flush_tlb") 4906658Snate@binkert.org .desc("Number of times complete TLB was flushed") 4911070SN/A ; 4923960Sgblack@eecs.umich.edu 4931070SN/A flushTlbMva 4941070SN/A .name(name() + ".flush_tlb_mva") 4954762Snate@binkert.org .desc("Number of times TLB was flushed by MVA") 4961070SN/A ; 4972158SN/A 4982158SN/A flushTlbMvaAsid 4991070SN/A .name(name() + ".flush_tlb_mva_asid") 5002158SN/A .desc("Number of times TLB was flushed by MVA & ASID") 5011070SN/A ; 5022SN/A 5032SN/A flushTlbAsid 50411169Sandreas.hansson@arm.com .name(name() + ".flush_tlb_asid") 5051129SN/A .desc("Number of times TLB was flushed by ASID") 5062158SN/A ; 5072158SN/A 5081070SN/A flushedEntries 5092378SN/A .name(name() + ".flush_entries") 5101070SN/A .desc("Number of entries that have been flushed from TLB") 51111838SCurtis.Dunham@arm.com ; 5121070SN/A 5131070SN/A alignFaults 5141070SN/A .name(name() + ".align_faults") 5151070SN/A .desc("Number of TLB faults due to alignment restrictions") 5161070SN/A ; 51711838SCurtis.Dunham@arm.com 5181070SN/A prefetchFaults 5191070SN/A .name(name() + ".prefetch_faults") 5201070SN/A .desc("Number of TLB faults due to prefetch") 5211070SN/A ; 5221070SN/A 52311838SCurtis.Dunham@arm.com domainFaults 5241070SN/A .name(name() + ".domain_faults") 5251070SN/A .desc("Number of TLB faults due to domain restrictions") 5261070SN/A ; 5271070SN/A 5288601Ssteve.reinhardt@amd.com permsFaults 5298601Ssteve.reinhardt@amd.com .name(name() + ".perms_faults") 5308601Ssteve.reinhardt@amd.com .desc("Number of TLB faults due to permissions restrictions") 5312378SN/A ; 53211005Sandreas.sandberg@arm.com 53311005Sandreas.sandberg@arm.com instAccesses = instHits + instMisses; 53411005Sandreas.sandberg@arm.com readAccesses = readHits + readMisses; 5351070SN/A writeAccesses = writeHits + writeMisses; 53611168Sandreas.hansson@arm.com hits = readHits + writeHits + instHits; 53711168Sandreas.hansson@arm.com misses = readMisses + writeMisses + instMisses; 5389342SAndreas.Sandberg@arm.com accesses = readAccesses + writeAccesses + instAccesses; 53911168Sandreas.hansson@arm.com} 5402SN/A 54177SN/Avoid 5427897Shestness@cs.utexas.eduTLB::regProbePoints() 5437897Shestness@cs.utexas.edu{ 5448666SPrakash.Ramrakhyani@arm.com ppRefills.reset(new ProbePoints::PMU(getProbeManager(), "Refills")); 5458666SPrakash.Ramrakhyani@arm.com} 5467897Shestness@cs.utexas.edu 5472SN/AFault 5482SN/ATLB::translateSe(RequestPtr req, ThreadContext *tc, Mode mode, 5492SN/A Translation *translation, bool &delay, bool timing) 5502SN/A{ 5512SN/A updateMiscReg(tc); 5522SN/A Addr vaddr_tainted = req->getVaddr(); 5532SN/A Addr vaddr = 0; 5542SN/A if (aarch64) 5552SN/A vaddr = purifyTaggedAddr(vaddr_tainted, tc, aarch64EL, ttbcr); 5562SN/A else 5572158SN/A vaddr = vaddr_tainted; 55811911SBrandon.Potter@amd.com uint32_t flags = req->getFlags(); 5599112Smarc.orr@gmail.com 56011885Sbrandon.potter@amd.com bool is_fetch = (mode == Execute); 56111885Sbrandon.potter@amd.com bool is_write = (mode == Write); 56211885Sbrandon.potter@amd.com 56311885Sbrandon.potter@amd.com if (!is_fetch) { 56411885Sbrandon.potter@amd.com assert(flags & MustBeOne); 56511909SBrandon.Potter@amd.com if (sctlr.a || !(flags & AllowUnaligned)) { 56611909SBrandon.Potter@amd.com if (vaddr & mask(flags & AlignmentMask)) { 56711909SBrandon.Potter@amd.com // LPAE is always disabled in SE mode 56811909SBrandon.Potter@amd.com return std::make_shared<DataAbort>( 5699292Sandreas.hansson@arm.com vaddr_tainted, 5709292Sandreas.hansson@arm.com TlbEntry::DomainType::NoAccess, is_write, 5719292Sandreas.hansson@arm.com ArmFault::AlignmentFault, isStage2, 5729292Sandreas.hansson@arm.com ArmFault::VmsaTran); 57311838SCurtis.Dunham@arm.com } 5749292Sandreas.hansson@arm.com } 5759292Sandreas.hansson@arm.com } 5769292Sandreas.hansson@arm.com 5779292Sandreas.hansson@arm.com Addr paddr; 57810905Sandreas.sandberg@arm.com Process *p = tc->getProcessPtr(); 5799292Sandreas.hansson@arm.com 5809292Sandreas.hansson@arm.com if (!p->pTable->translate(vaddr, paddr)) 5819292Sandreas.hansson@arm.com return std::make_shared<GenericPageTableFault>(vaddr_tainted); 5829292Sandreas.hansson@arm.com req->setPaddr(paddr); 5839292Sandreas.hansson@arm.com 5849292Sandreas.hansson@arm.com return NoFault; 5859292Sandreas.hansson@arm.com} 5869292Sandreas.hansson@arm.com 58710905Sandreas.sandberg@arm.comFault 5882158SN/ATLB::checkPermissions(TlbEntry *te, RequestPtr req, Mode mode) 5892SN/A{ 5902SN/A Addr vaddr = req->getVaddr(); // 32-bit don't have to purify 5919554Sandreas.hansson@arm.com uint32_t flags = req->getFlags(); 5929554Sandreas.hansson@arm.com bool is_fetch = (mode == Execute); 5932SN/A bool is_write = (mode == Write); 594 bool is_priv = isPriv && !(flags & UserMode); 595 596 // Get the translation type from the actuall table entry 597 ArmFault::TranMethod tranMethod = te->longDescFormat ? ArmFault::LpaeTran 598 : ArmFault::VmsaTran; 599 600 // If this is the second stage of translation and the request is for a 601 // stage 1 page table walk then we need to check the HCR.PTW bit. This 602 // allows us to generate a fault if the request targets an area marked 603 // as a device or strongly ordered. 604 if (isStage2 && req->isPTWalk() && hcr.ptw && 605 (te->mtype != TlbEntry::MemoryType::Normal)) { 606 return std::make_shared<DataAbort>( 607 vaddr, te->domain, is_write, 608 ArmFault::PermissionLL + te->lookupLevel, 609 isStage2, tranMethod); 610 } 611 612 // Generate an alignment fault for unaligned data accesses to device or 613 // strongly ordered memory 614 if (!is_fetch) { 615 if (te->mtype != TlbEntry::MemoryType::Normal) { 616 if (vaddr & mask(flags & AlignmentMask)) { 617 alignFaults++; 618 return std::make_shared<DataAbort>( 619 vaddr, TlbEntry::DomainType::NoAccess, is_write, 620 ArmFault::AlignmentFault, isStage2, 621 tranMethod); 622 } 623 } 624 } 625 626 if (te->nonCacheable) { 627 // Prevent prefetching from I/O devices. 628 if (req->isPrefetch()) { 629 // Here we can safely use the fault status for the short 630 // desc. format in all cases 631 return std::make_shared<PrefetchAbort>( 632 vaddr, ArmFault::PrefetchUncacheable, 633 isStage2, tranMethod); 634 } 635 } 636 637 if (!te->longDescFormat) { 638 switch ((dacr >> (static_cast<uint8_t>(te->domain) * 2)) & 0x3) { 639 case 0: 640 domainFaults++; 641 DPRINTF(TLB, "TLB Fault: Data abort on domain. DACR: %#x" 642 " domain: %#x write:%d\n", dacr, 643 static_cast<uint8_t>(te->domain), is_write); 644 if (is_fetch) 645 return std::make_shared<PrefetchAbort>( 646 vaddr, 647 ArmFault::DomainLL + te->lookupLevel, 648 isStage2, tranMethod); 649 else 650 return std::make_shared<DataAbort>( 651 vaddr, te->domain, is_write, 652 ArmFault::DomainLL + te->lookupLevel, 653 isStage2, tranMethod); 654 case 1: 655 // Continue with permissions check 656 break; 657 case 2: 658 panic("UNPRED domain\n"); 659 case 3: 660 return NoFault; 661 } 662 } 663 664 // The 'ap' variable is AP[2:0] or {AP[2,1],1b'0}, i.e. always three bits 665 uint8_t ap = te->longDescFormat ? te->ap << 1 : te->ap; 666 uint8_t hap = te->hap; 667 668 if (sctlr.afe == 1 || te->longDescFormat) 669 ap |= 1; 670 671 bool abt; 672 bool isWritable = true; 673 // If this is a stage 2 access (eg for reading stage 1 page table entries) 674 // then don't perform the AP permissions check, we stil do the HAP check 675 // below. 676 if (isStage2) { 677 abt = false; 678 } else { 679 switch (ap) { 680 case 0: 681 DPRINTF(TLB, "Access permissions 0, checking rs:%#x\n", 682 (int)sctlr.rs); 683 if (!sctlr.xp) { 684 switch ((int)sctlr.rs) { 685 case 2: 686 abt = is_write; 687 break; 688 case 1: 689 abt = is_write || !is_priv; 690 break; 691 case 0: 692 case 3: 693 default: 694 abt = true; 695 break; 696 } 697 } else { 698 abt = true; 699 } 700 break; 701 case 1: 702 abt = !is_priv; 703 break; 704 case 2: 705 abt = !is_priv && is_write; 706 isWritable = is_priv; 707 break; 708 case 3: 709 abt = false; 710 break; 711 case 4: 712 panic("UNPRED premissions\n"); 713 case 5: 714 abt = !is_priv || is_write; 715 isWritable = false; 716 break; 717 case 6: 718 case 7: 719 abt = is_write; 720 isWritable = false; 721 break; 722 default: 723 panic("Unknown permissions %#x\n", ap); 724 } 725 } 726 727 bool hapAbt = is_write ? !(hap & 2) : !(hap & 1); 728 bool xn = te->xn || (isWritable && sctlr.wxn) || 729 (ap == 3 && sctlr.uwxn && is_priv); 730 if (is_fetch && (abt || xn || 731 (te->longDescFormat && te->pxn && is_priv) || 732 (isSecure && te->ns && scr.sif))) { 733 permsFaults++; 734 DPRINTF(TLB, "TLB Fault: Prefetch abort on permission check. AP:%d " 735 "priv:%d write:%d ns:%d sif:%d sctlr.afe: %d \n", 736 ap, is_priv, is_write, te->ns, scr.sif,sctlr.afe); 737 return std::make_shared<PrefetchAbort>( 738 vaddr, 739 ArmFault::PermissionLL + te->lookupLevel, 740 isStage2, tranMethod); 741 } else if (abt | hapAbt) { 742 permsFaults++; 743 DPRINTF(TLB, "TLB Fault: Data abort on permission check. AP:%d priv:%d" 744 " write:%d\n", ap, is_priv, is_write); 745 return std::make_shared<DataAbort>( 746 vaddr, te->domain, is_write, 747 ArmFault::PermissionLL + te->lookupLevel, 748 isStage2 | !abt, tranMethod); 749 } 750 return NoFault; 751} 752 753 754Fault 755TLB::checkPermissions64(TlbEntry *te, RequestPtr req, Mode mode, 756 ThreadContext *tc) 757{ 758 assert(aarch64); 759 760 Addr vaddr_tainted = req->getVaddr(); 761 Addr vaddr = purifyTaggedAddr(vaddr_tainted, tc, aarch64EL, ttbcr); 762 763 uint32_t flags = req->getFlags(); 764 bool is_fetch = (mode == Execute); 765 bool is_write = (mode == Write); 766 bool is_priv M5_VAR_USED = isPriv && !(flags & UserMode); 767 768 updateMiscReg(tc, curTranType); 769 770 // If this is the second stage of translation and the request is for a 771 // stage 1 page table walk then we need to check the HCR.PTW bit. This 772 // allows us to generate a fault if the request targets an area marked 773 // as a device or strongly ordered. 774 if (isStage2 && req->isPTWalk() && hcr.ptw && 775 (te->mtype != TlbEntry::MemoryType::Normal)) { 776 return std::make_shared<DataAbort>( 777 vaddr_tainted, te->domain, is_write, 778 ArmFault::PermissionLL + te->lookupLevel, 779 isStage2, ArmFault::LpaeTran); 780 } 781 782 // Generate an alignment fault for unaligned accesses to device or 783 // strongly ordered memory 784 if (!is_fetch) { 785 if (te->mtype != TlbEntry::MemoryType::Normal) { 786 if (vaddr & mask(flags & AlignmentMask)) { 787 alignFaults++; 788 return std::make_shared<DataAbort>( 789 vaddr_tainted, 790 TlbEntry::DomainType::NoAccess, is_write, 791 ArmFault::AlignmentFault, isStage2, 792 ArmFault::LpaeTran); 793 } 794 } 795 } 796 797 if (te->nonCacheable) { 798 // Prevent prefetching from I/O devices. 799 if (req->isPrefetch()) { 800 // Here we can safely use the fault status for the short 801 // desc. format in all cases 802 return std::make_shared<PrefetchAbort>( 803 vaddr_tainted, 804 ArmFault::PrefetchUncacheable, 805 isStage2, ArmFault::LpaeTran); 806 } 807 } 808 809 uint8_t ap = 0x3 & (te->ap); // 2-bit access protection field 810 bool grant = false; 811 812 uint8_t xn = te->xn; 813 uint8_t pxn = te->pxn; 814 bool r = !is_write && !is_fetch; 815 bool w = is_write; 816 bool x = is_fetch; 817 DPRINTF(TLBVerbose, "Checking permissions: ap:%d, xn:%d, pxn:%d, r:%d, " 818 "w:%d, x:%d\n", ap, xn, pxn, r, w, x); 819 820 if (isStage2) { 821 assert(ArmSystem::haveVirtualization(tc) && aarch64EL != EL2); 822 // In stage 2 we use the hypervisor access permission bits. 823 // The following permissions are described in ARM DDI 0487A.f 824 // D4-1802 825 uint8_t hap = 0x3 & te->hap; 826 if (is_fetch) { 827 // sctlr.wxn overrides the xn bit 828 grant = !sctlr.wxn && !xn; 829 } else if (is_write) { 830 grant = hap & 0x2; 831 } else { // is_read 832 grant = hap & 0x1; 833 } 834 } else { 835 switch (aarch64EL) { 836 case EL0: 837 { 838 uint8_t perm = (ap << 2) | (xn << 1) | pxn; 839 switch (perm) { 840 case 0: 841 case 1: 842 case 8: 843 case 9: 844 grant = x; 845 break; 846 case 4: 847 case 5: 848 grant = r || w || (x && !sctlr.wxn); 849 break; 850 case 6: 851 case 7: 852 grant = r || w; 853 break; 854 case 12: 855 case 13: 856 grant = r || x; 857 break; 858 case 14: 859 case 15: 860 grant = r; 861 break; 862 default: 863 grant = false; 864 } 865 } 866 break; 867 case EL1: 868 { 869 uint8_t perm = (ap << 2) | (xn << 1) | pxn; 870 switch (perm) { 871 case 0: 872 case 2: 873 grant = r || w || (x && !sctlr.wxn); 874 break; 875 case 1: 876 case 3: 877 case 4: 878 case 5: 879 case 6: 880 case 7: 881 // regions that are writeable at EL0 should not be 882 // executable at EL1 883 grant = r || w; 884 break; 885 case 8: 886 case 10: 887 case 12: 888 case 14: 889 grant = r || x; 890 break; 891 case 9: 892 case 11: 893 case 13: 894 case 15: 895 grant = r; 896 break; 897 default: 898 grant = false; 899 } 900 } 901 break; 902 case EL2: 903 case EL3: 904 { 905 uint8_t perm = (ap & 0x2) | xn; 906 switch (perm) { 907 case 0: 908 grant = r || w || (x && !sctlr.wxn) ; 909 break; 910 case 1: 911 grant = r || w; 912 break; 913 case 2: 914 grant = r || x; 915 break; 916 case 3: 917 grant = r; 918 break; 919 default: 920 grant = false; 921 } 922 } 923 break; 924 } 925 } 926 927 if (!grant) { 928 if (is_fetch) { 929 permsFaults++; 930 DPRINTF(TLB, "TLB Fault: Prefetch abort on permission check. " 931 "AP:%d priv:%d write:%d ns:%d sif:%d " 932 "sctlr.afe: %d\n", 933 ap, is_priv, is_write, te->ns, scr.sif, sctlr.afe); 934 // Use PC value instead of vaddr because vaddr might be aligned to 935 // cache line and should not be the address reported in FAR 936 return std::make_shared<PrefetchAbort>( 937 req->getPC(), 938 ArmFault::PermissionLL + te->lookupLevel, 939 isStage2, ArmFault::LpaeTran); 940 } else { 941 permsFaults++; 942 DPRINTF(TLB, "TLB Fault: Data abort on permission check. AP:%d " 943 "priv:%d write:%d\n", ap, is_priv, is_write); 944 return std::make_shared<DataAbort>( 945 vaddr_tainted, te->domain, is_write, 946 ArmFault::PermissionLL + te->lookupLevel, 947 isStage2, ArmFault::LpaeTran); 948 } 949 } 950 951 return NoFault; 952} 953 954Fault 955TLB::translateFs(RequestPtr req, ThreadContext *tc, Mode mode, 956 Translation *translation, bool &delay, bool timing, 957 TLB::ArmTranslationType tranType, bool functional) 958{ 959 // No such thing as a functional timing access 960 assert(!(timing && functional)); 961 962 updateMiscReg(tc, tranType); 963 964 Addr vaddr_tainted = req->getVaddr(); 965 Addr vaddr = 0; 966 if (aarch64) 967 vaddr = purifyTaggedAddr(vaddr_tainted, tc, aarch64EL, ttbcr); 968 else 969 vaddr = vaddr_tainted; 970 uint32_t flags = req->getFlags(); 971 972 bool is_fetch = (mode == Execute); 973 bool is_write = (mode == Write); 974 bool long_desc_format = aarch64 || longDescFormatInUse(tc); 975 ArmFault::TranMethod tranMethod = long_desc_format ? ArmFault::LpaeTran 976 : ArmFault::VmsaTran; 977 978 req->setAsid(asid); 979 980 DPRINTF(TLBVerbose, "CPSR is priv:%d UserMode:%d secure:%d S1S2NsTran:%d\n", 981 isPriv, flags & UserMode, isSecure, tranType & S1S2NsTran); 982 983 DPRINTF(TLB, "translateFs addr %#x, mode %d, st2 %d, scr %#x sctlr %#x " 984 "flags %#x tranType 0x%x\n", vaddr_tainted, mode, isStage2, 985 scr, sctlr, flags, tranType); 986 987 if ((req->isInstFetch() && (!sctlr.i)) || 988 ((!req->isInstFetch()) && (!sctlr.c))){ 989 req->setFlags(Request::UNCACHEABLE | Request::STRICT_ORDER); 990 } 991 if (!is_fetch) { 992 assert(flags & MustBeOne); 993 if (sctlr.a || !(flags & AllowUnaligned)) { 994 if (vaddr & mask(flags & AlignmentMask)) { 995 alignFaults++; 996 return std::make_shared<DataAbort>( 997 vaddr_tainted, 998 TlbEntry::DomainType::NoAccess, is_write, 999 ArmFault::AlignmentFault, isStage2, 1000 tranMethod); 1001 } 1002 } 1003 } 1004 1005 // If guest MMU is off or hcr.vm=0 go straight to stage2 1006 if ((isStage2 && !hcr.vm) || (!isStage2 && !sctlr.m)) { 1007 1008 req->setPaddr(vaddr); 1009 // When the MMU is off the security attribute corresponds to the 1010 // security state of the processor 1011 if (isSecure) 1012 req->setFlags(Request::SECURE); 1013 1014 // @todo: double check this (ARM ARM issue C B3.2.1) 1015 if (long_desc_format || sctlr.tre == 0) { 1016 req->setFlags(Request::UNCACHEABLE | Request::STRICT_ORDER); 1017 } else { 1018 if (nmrr.ir0 == 0 || nmrr.or0 == 0 || prrr.tr0 != 0x2) 1019 req->setFlags(Request::UNCACHEABLE | Request::STRICT_ORDER); 1020 } 1021 1022 // Set memory attributes 1023 TlbEntry temp_te; 1024 temp_te.ns = !isSecure; 1025 if (isStage2 || hcr.dc == 0 || isSecure || 1026 (isHyp && !(tranType & S1CTran))) { 1027 1028 temp_te.mtype = is_fetch ? TlbEntry::MemoryType::Normal 1029 : TlbEntry::MemoryType::StronglyOrdered; 1030 temp_te.innerAttrs = 0x0; 1031 temp_te.outerAttrs = 0x0; 1032 temp_te.shareable = true; 1033 temp_te.outerShareable = true; 1034 } else { 1035 temp_te.mtype = TlbEntry::MemoryType::Normal; 1036 temp_te.innerAttrs = 0x3; 1037 temp_te.outerAttrs = 0x3; 1038 temp_te.shareable = false; 1039 temp_te.outerShareable = false; 1040 } 1041 temp_te.setAttributes(long_desc_format); 1042 DPRINTF(TLBVerbose, "(No MMU) setting memory attributes: shareable: " 1043 "%d, innerAttrs: %d, outerAttrs: %d, isStage2: %d\n", 1044 temp_te.shareable, temp_te.innerAttrs, temp_te.outerAttrs, 1045 isStage2); 1046 setAttr(temp_te.attributes); 1047 1048 return testTranslation(req, mode, TlbEntry::DomainType::NoAccess); 1049 } 1050 1051 DPRINTF(TLBVerbose, "Translating %s=%#x context=%d\n", 1052 isStage2 ? "IPA" : "VA", vaddr_tainted, asid); 1053 // Translation enabled 1054 1055 TlbEntry *te = NULL; 1056 TlbEntry mergeTe; 1057 Fault fault = getResultTe(&te, req, tc, mode, translation, timing, 1058 functional, &mergeTe); 1059 // only proceed if we have a valid table entry 1060 if ((te == NULL) && (fault == NoFault)) delay = true; 1061 1062 // If we have the table entry transfer some of the attributes to the 1063 // request that triggered the translation 1064 if (te != NULL) { 1065 // Set memory attributes 1066 DPRINTF(TLBVerbose, 1067 "Setting memory attributes: shareable: %d, innerAttrs: %d, " 1068 "outerAttrs: %d, mtype: %d, isStage2: %d\n", 1069 te->shareable, te->innerAttrs, te->outerAttrs, 1070 static_cast<uint8_t>(te->mtype), isStage2); 1071 setAttr(te->attributes); 1072 1073 if (te->nonCacheable) 1074 req->setFlags(Request::UNCACHEABLE); 1075 1076 // Require requests to be ordered if the request goes to 1077 // strongly ordered or device memory (i.e., anything other 1078 // than normal memory requires strict order). 1079 if (te->mtype != TlbEntry::MemoryType::Normal) 1080 req->setFlags(Request::STRICT_ORDER); 1081 1082 Addr pa = te->pAddr(vaddr); 1083 req->setPaddr(pa); 1084 1085 if (isSecure && !te->ns) { 1086 req->setFlags(Request::SECURE); 1087 } 1088 if ((!is_fetch) && (vaddr & mask(flags & AlignmentMask)) && 1089 (te->mtype != TlbEntry::MemoryType::Normal)) { 1090 // Unaligned accesses to Device memory should always cause an 1091 // abort regardless of sctlr.a 1092 alignFaults++; 1093 return std::make_shared<DataAbort>( 1094 vaddr_tainted, 1095 TlbEntry::DomainType::NoAccess, is_write, 1096 ArmFault::AlignmentFault, isStage2, 1097 tranMethod); 1098 } 1099 1100 // Check for a trickbox generated address fault 1101 if (fault == NoFault) 1102 fault = testTranslation(req, mode, te->domain); 1103 } 1104 1105 // Generate Illegal Inst Set State fault if IL bit is set in CPSR 1106 if (fault == NoFault) { 1107 if (aarch64 && is_fetch && cpsr.il == 1) { 1108 return std::make_shared<IllegalInstSetStateFault>(); 1109 } 1110 } 1111 1112 return fault; 1113} 1114 1115Fault 1116TLB::translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode, 1117 TLB::ArmTranslationType tranType) 1118{ 1119 updateMiscReg(tc, tranType); 1120 1121 if (directToStage2) { 1122 assert(stage2Tlb); 1123 return stage2Tlb->translateAtomic(req, tc, mode, tranType); 1124 } 1125 1126 bool delay = false; 1127 Fault fault; 1128 if (FullSystem) 1129 fault = translateFs(req, tc, mode, NULL, delay, false, tranType); 1130 else 1131 fault = translateSe(req, tc, mode, NULL, delay, false); 1132 assert(!delay); 1133 return fault; 1134} 1135 1136Fault 1137TLB::translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode, 1138 TLB::ArmTranslationType tranType) 1139{ 1140 updateMiscReg(tc, tranType); 1141 1142 if (directToStage2) { 1143 assert(stage2Tlb); 1144 return stage2Tlb->translateFunctional(req, tc, mode, tranType); 1145 } 1146 1147 bool delay = false; 1148 Fault fault; 1149 if (FullSystem) 1150 fault = translateFs(req, tc, mode, NULL, delay, false, tranType, true); 1151 else 1152 fault = translateSe(req, tc, mode, NULL, delay, false); 1153 assert(!delay); 1154 return fault; 1155} 1156 1157Fault 1158TLB::translateTiming(RequestPtr req, ThreadContext *tc, 1159 Translation *translation, Mode mode, TLB::ArmTranslationType tranType) 1160{ 1161 updateMiscReg(tc, tranType); 1162 1163 if (directToStage2) { 1164 assert(stage2Tlb); 1165 return stage2Tlb->translateTiming(req, tc, translation, mode, tranType); 1166 } 1167 1168 assert(translation); 1169 1170 return translateComplete(req, tc, translation, mode, tranType, isStage2); 1171} 1172 1173Fault 1174TLB::translateComplete(RequestPtr req, ThreadContext *tc, 1175 Translation *translation, Mode mode, TLB::ArmTranslationType tranType, 1176 bool callFromS2) 1177{ 1178 bool delay = false; 1179 Fault fault; 1180 if (FullSystem) 1181 fault = translateFs(req, tc, mode, translation, delay, true, tranType); 1182 else 1183 fault = translateSe(req, tc, mode, translation, delay, true); 1184 DPRINTF(TLBVerbose, "Translation returning delay=%d fault=%d\n", delay, fault != 1185 NoFault); 1186 // If we have a translation, and we're not in the middle of doing a stage 1187 // 2 translation tell the translation that we've either finished or its 1188 // going to take a while. By not doing this when we're in the middle of a 1189 // stage 2 translation we prevent marking the translation as delayed twice, 1190 // one when the translation starts and again when the stage 1 translation 1191 // completes. 1192 if (translation && (callFromS2 || !stage2Req || req->hasPaddr() || fault != NoFault)) { 1193 if (!delay) 1194 translation->finish(fault, req, tc, mode); 1195 else 1196 translation->markDelayed(); 1197 } 1198 return fault; 1199} 1200 1201BaseMasterPort* 1202TLB::getMasterPort() 1203{ 1204 return &stage2Mmu->getPort(); 1205} 1206 1207void 1208TLB::updateMiscReg(ThreadContext *tc, ArmTranslationType tranType) 1209{ 1210 // check if the regs have changed, or the translation mode is different. 1211 // NOTE: the tran type doesn't affect stage 2 TLB's as they only handle 1212 // one type of translation anyway 1213 if (miscRegValid && miscRegContext == tc->contextId() && 1214 ((tranType == curTranType) || isStage2)) { 1215 return; 1216 } 1217 1218 DPRINTF(TLBVerbose, "TLB variables changed!\n"); 1219 cpsr = tc->readMiscReg(MISCREG_CPSR); 1220 1221 // Dependencies: SCR/SCR_EL3, CPSR 1222 isSecure = inSecureState(tc) && 1223 !(tranType & HypMode) && !(tranType & S1S2NsTran); 1224 1225 const OperatingMode op_mode = (OperatingMode) (uint8_t)cpsr.mode; 1226 aarch64 = opModeIs64(op_mode) || 1227 (opModeToEL(op_mode) == EL0 && ELIs64(tc, EL1)); 1228 1229 if (aarch64) { // AArch64 1230 // determine EL we need to translate in 1231 switch (tranType) { 1232 case S1E0Tran: 1233 case S12E0Tran: 1234 aarch64EL = EL0; 1235 break; 1236 case S1E1Tran: 1237 case S12E1Tran: 1238 aarch64EL = EL1; 1239 break; 1240 case S1E2Tran: 1241 aarch64EL = EL2; 1242 break; 1243 case S1E3Tran: 1244 aarch64EL = EL3; 1245 break; 1246 case NormalTran: 1247 case S1CTran: 1248 case S1S2NsTran: 1249 case HypMode: 1250 aarch64EL = (ExceptionLevel) (uint8_t) cpsr.el; 1251 break; 1252 } 1253 1254 switch (aarch64EL) { 1255 case EL0: 1256 case EL1: 1257 { 1258 sctlr = tc->readMiscReg(MISCREG_SCTLR_EL1); 1259 ttbcr = tc->readMiscReg(MISCREG_TCR_EL1); 1260 uint64_t ttbr_asid = ttbcr.a1 ? 1261 tc->readMiscReg(MISCREG_TTBR1_EL1) : 1262 tc->readMiscReg(MISCREG_TTBR0_EL1); 1263 asid = bits(ttbr_asid, 1264 (haveLargeAsid64 && ttbcr.as) ? 63 : 55, 48); 1265 } 1266 break; 1267 case EL2: 1268 sctlr = tc->readMiscReg(MISCREG_SCTLR_EL2); 1269 ttbcr = tc->readMiscReg(MISCREG_TCR_EL2); 1270 asid = -1; 1271 break; 1272 case EL3: 1273 sctlr = tc->readMiscReg(MISCREG_SCTLR_EL3); 1274 ttbcr = tc->readMiscReg(MISCREG_TCR_EL3); 1275 asid = -1; 1276 break; 1277 } 1278 hcr = tc->readMiscReg(MISCREG_HCR_EL2); 1279 scr = tc->readMiscReg(MISCREG_SCR_EL3); 1280 isPriv = aarch64EL != EL0; 1281 if (haveVirtualization) { 1282 vmid = bits(tc->readMiscReg(MISCREG_VTTBR_EL2), 55, 48); 1283 isHyp = tranType & HypMode; 1284 isHyp &= (tranType & S1S2NsTran) == 0; 1285 isHyp &= (tranType & S1CTran) == 0; 1286 // Work out if we should skip the first stage of translation and go 1287 // directly to stage 2. This value is cached so we don't have to 1288 // compute it for every translation. 1289 stage2Req = isStage2 || 1290 (hcr.vm && !isHyp && !isSecure && 1291 !(tranType & S1CTran) && (aarch64EL < EL2) && 1292 !(tranType & S1E1Tran)); // <--- FIX THIS HACK 1293 directToStage2 = !isStage2 && stage2Req && !sctlr.m; 1294 } else { 1295 vmid = 0; 1296 isHyp = false; 1297 directToStage2 = false; 1298 stage2Req = false; 1299 } 1300 } else { // AArch32 1301 sctlr = tc->readMiscReg(flattenMiscRegNsBanked(MISCREG_SCTLR, tc, 1302 !isSecure)); 1303 ttbcr = tc->readMiscReg(flattenMiscRegNsBanked(MISCREG_TTBCR, tc, 1304 !isSecure)); 1305 scr = tc->readMiscReg(MISCREG_SCR); 1306 isPriv = cpsr.mode != MODE_USER; 1307 if (longDescFormatInUse(tc)) { 1308 uint64_t ttbr_asid = tc->readMiscReg( 1309 flattenMiscRegNsBanked(ttbcr.a1 ? MISCREG_TTBR1 1310 : MISCREG_TTBR0, 1311 tc, !isSecure)); 1312 asid = bits(ttbr_asid, 55, 48); 1313 } else { // Short-descriptor translation table format in use 1314 CONTEXTIDR context_id = tc->readMiscReg(flattenMiscRegNsBanked( 1315 MISCREG_CONTEXTIDR, tc,!isSecure)); 1316 asid = context_id.asid; 1317 } 1318 prrr = tc->readMiscReg(flattenMiscRegNsBanked(MISCREG_PRRR, tc, 1319 !isSecure)); 1320 nmrr = tc->readMiscReg(flattenMiscRegNsBanked(MISCREG_NMRR, tc, 1321 !isSecure)); 1322 dacr = tc->readMiscReg(flattenMiscRegNsBanked(MISCREG_DACR, tc, 1323 !isSecure)); 1324 hcr = tc->readMiscReg(MISCREG_HCR); 1325 1326 if (haveVirtualization) { 1327 vmid = bits(tc->readMiscReg(MISCREG_VTTBR), 55, 48); 1328 isHyp = cpsr.mode == MODE_HYP; 1329 isHyp |= tranType & HypMode; 1330 isHyp &= (tranType & S1S2NsTran) == 0; 1331 isHyp &= (tranType & S1CTran) == 0; 1332 if (isHyp) { 1333 sctlr = tc->readMiscReg(MISCREG_HSCTLR); 1334 } 1335 // Work out if we should skip the first stage of translation and go 1336 // directly to stage 2. This value is cached so we don't have to 1337 // compute it for every translation. 1338 stage2Req = hcr.vm && !isStage2 && !isHyp && !isSecure && 1339 !(tranType & S1CTran); 1340 directToStage2 = stage2Req && !sctlr.m; 1341 } else { 1342 vmid = 0; 1343 stage2Req = false; 1344 isHyp = false; 1345 directToStage2 = false; 1346 } 1347 } 1348 miscRegValid = true; 1349 miscRegContext = tc->contextId(); 1350 curTranType = tranType; 1351} 1352 1353Fault 1354TLB::getTE(TlbEntry **te, RequestPtr req, ThreadContext *tc, Mode mode, 1355 Translation *translation, bool timing, bool functional, 1356 bool is_secure, TLB::ArmTranslationType tranType) 1357{ 1358 bool is_fetch = (mode == Execute); 1359 bool is_write = (mode == Write); 1360 1361 Addr vaddr_tainted = req->getVaddr(); 1362 Addr vaddr = 0; 1363 ExceptionLevel target_el = aarch64 ? aarch64EL : EL1; 1364 if (aarch64) { 1365 vaddr = purifyTaggedAddr(vaddr_tainted, tc, target_el, ttbcr); 1366 } else { 1367 vaddr = vaddr_tainted; 1368 } 1369 *te = lookup(vaddr, asid, vmid, isHyp, is_secure, false, false, target_el); 1370 if (*te == NULL) { 1371 if (req->isPrefetch()) { 1372 // if the request is a prefetch don't attempt to fill the TLB or go 1373 // any further with the memory access (here we can safely use the 1374 // fault status for the short desc. format in all cases) 1375 prefetchFaults++; 1376 return std::make_shared<PrefetchAbort>( 1377 vaddr_tainted, ArmFault::PrefetchTLBMiss, isStage2); 1378 } 1379 1380 if (is_fetch) 1381 instMisses++; 1382 else if (is_write) 1383 writeMisses++; 1384 else 1385 readMisses++; 1386 1387 // start translation table walk, pass variables rather than 1388 // re-retreaving in table walker for speed 1389 DPRINTF(TLB, "TLB Miss: Starting hardware table walker for %#x(%d:%d)\n", 1390 vaddr_tainted, asid, vmid); 1391 Fault fault; 1392 fault = tableWalker->walk(req, tc, asid, vmid, isHyp, mode, 1393 translation, timing, functional, is_secure, 1394 tranType, stage2Req); 1395 // for timing mode, return and wait for table walk, 1396 if (timing || fault != NoFault) { 1397 return fault; 1398 } 1399 1400 *te = lookup(vaddr, asid, vmid, isHyp, is_secure, false, false, target_el); 1401 if (!*te) 1402 printTlb(); 1403 assert(*te); 1404 } else { 1405 if (is_fetch) 1406 instHits++; 1407 else if (is_write) 1408 writeHits++; 1409 else 1410 readHits++; 1411 } 1412 return NoFault; 1413} 1414 1415Fault 1416TLB::getResultTe(TlbEntry **te, RequestPtr req, ThreadContext *tc, Mode mode, 1417 Translation *translation, bool timing, bool functional, 1418 TlbEntry *mergeTe) 1419{ 1420 Fault fault; 1421 1422 if (isStage2) { 1423 // We are already in the stage 2 TLB. Grab the table entry for stage 1424 // 2 only. We are here because stage 1 translation is disabled. 1425 TlbEntry *s2Te = NULL; 1426 // Get the stage 2 table entry 1427 fault = getTE(&s2Te, req, tc, mode, translation, timing, functional, 1428 isSecure, curTranType); 1429 // Check permissions of stage 2 1430 if ((s2Te != NULL) && (fault = NoFault)) { 1431 if(aarch64) 1432 fault = checkPermissions64(s2Te, req, mode, tc); 1433 else 1434 fault = checkPermissions(s2Te, req, mode); 1435 } 1436 *te = s2Te; 1437 return fault; 1438 } 1439 1440 TlbEntry *s1Te = NULL; 1441 1442 Addr vaddr_tainted = req->getVaddr(); 1443 1444 // Get the stage 1 table entry 1445 fault = getTE(&s1Te, req, tc, mode, translation, timing, functional, 1446 isSecure, curTranType); 1447 // only proceed if we have a valid table entry 1448 if ((s1Te != NULL) && (fault == NoFault)) { 1449 // Check stage 1 permissions before checking stage 2 1450 if (aarch64) 1451 fault = checkPermissions64(s1Te, req, mode, tc); 1452 else 1453 fault = checkPermissions(s1Te, req, mode); 1454 if (stage2Req & (fault == NoFault)) { 1455 Stage2LookUp *s2Lookup = new Stage2LookUp(this, stage2Tlb, *s1Te, 1456 req, translation, mode, timing, functional, curTranType); 1457 fault = s2Lookup->getTe(tc, mergeTe); 1458 if (s2Lookup->isComplete()) { 1459 *te = mergeTe; 1460 // We've finished with the lookup so delete it 1461 delete s2Lookup; 1462 } else { 1463 // The lookup hasn't completed, so we can't delete it now. We 1464 // get round this by asking the object to self delete when the 1465 // translation is complete. 1466 s2Lookup->setSelfDelete(); 1467 } 1468 } else { 1469 // This case deals with an S1 hit (or bypass), followed by 1470 // an S2 hit-but-perms issue 1471 if (isStage2) { 1472 DPRINTF(TLBVerbose, "s2TLB: reqVa %#x, reqPa %#x, fault %p\n", 1473 vaddr_tainted, req->hasPaddr() ? req->getPaddr() : ~0, fault); 1474 if (fault != NoFault) { 1475 ArmFault *armFault = reinterpret_cast<ArmFault *>(fault.get()); 1476 armFault->annotate(ArmFault::S1PTW, false); 1477 armFault->annotate(ArmFault::OVA, vaddr_tainted); 1478 } 1479 } 1480 *te = s1Te; 1481 } 1482 } 1483 return fault; 1484} 1485 1486void 1487TLB::setTestInterface(SimObject *_ti) 1488{ 1489 if (!_ti) { 1490 test = nullptr; 1491 } else { 1492 TlbTestInterface *ti(dynamic_cast<TlbTestInterface *>(_ti)); 1493 fatal_if(!ti, "%s is not a valid ARM TLB tester\n", _ti->name()); 1494 test = ti; 1495 } 1496} 1497 1498Fault 1499TLB::testTranslation(RequestPtr req, Mode mode, TlbEntry::DomainType domain) 1500{ 1501 if (!test || !req->hasSize() || req->getSize() == 0) { 1502 return NoFault; 1503 } else { 1504 return test->translationCheck(req, isPriv, mode, domain); 1505 } 1506} 1507 1508Fault 1509TLB::testWalk(Addr pa, Addr size, Addr va, bool is_secure, Mode mode, 1510 TlbEntry::DomainType domain, LookupLevel lookup_level) 1511{ 1512 if (!test) { 1513 return NoFault; 1514 } else { 1515 return test->walkCheck(pa, size, va, is_secure, isPriv, mode, 1516 domain, lookup_level); 1517 } 1518} 1519 1520 1521ArmISA::TLB * 1522ArmTLBParams::create() 1523{ 1524 return new ArmISA::TLB(this); 1525} 1526