tlb.hh revision 12735
16019Shines@cs.fsu.edu/* 211577SDylan.Johnson@ARM.com * Copyright (c) 2010-2013, 2016 ARM Limited 37399SAli.Saidi@ARM.com * All rights reserved 47399SAli.Saidi@ARM.com * 57399SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall 67399SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual 77399SAli.Saidi@ARM.com * property including but not limited to intellectual property relating 87399SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software 97399SAli.Saidi@ARM.com * licensed hereunder. You may use the software subject to the license 107399SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated 117399SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software, 127399SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form. 137399SAli.Saidi@ARM.com * 146019Shines@cs.fsu.edu * Copyright (c) 2001-2005 The Regents of The University of Michigan 156019Shines@cs.fsu.edu * All rights reserved. 166019Shines@cs.fsu.edu * 176019Shines@cs.fsu.edu * Redistribution and use in source and binary forms, with or without 186019Shines@cs.fsu.edu * modification, are permitted provided that the following conditions are 196019Shines@cs.fsu.edu * met: redistributions of source code must retain the above copyright 206019Shines@cs.fsu.edu * notice, this list of conditions and the following disclaimer; 216019Shines@cs.fsu.edu * redistributions in binary form must reproduce the above copyright 226019Shines@cs.fsu.edu * notice, this list of conditions and the following disclaimer in the 236019Shines@cs.fsu.edu * documentation and/or other materials provided with the distribution; 246019Shines@cs.fsu.edu * neither the name of the copyright holders nor the names of its 256019Shines@cs.fsu.edu * contributors may be used to endorse or promote products derived from 266019Shines@cs.fsu.edu * this software without specific prior written permission. 276019Shines@cs.fsu.edu * 286019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 296019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 306019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 316019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 326019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 336019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 346019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 356019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 366019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 376019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 386019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 396019Shines@cs.fsu.edu * 407399SAli.Saidi@ARM.com * Authors: Ali Saidi 416019Shines@cs.fsu.edu */ 426019Shines@cs.fsu.edu 436019Shines@cs.fsu.edu#ifndef __ARCH_ARM_TLB_HH__ 446019Shines@cs.fsu.edu#define __ARCH_ARM_TLB_HH__ 456019Shines@cs.fsu.edu 466019Shines@cs.fsu.edu 476019Shines@cs.fsu.edu#include "arch/arm/isa_traits.hh" 488229Snate@binkert.org#include "arch/arm/pagetable.hh" 496019Shines@cs.fsu.edu#include "arch/arm/utility.hh" 506019Shines@cs.fsu.edu#include "arch/arm/vtophys.hh" 5110687SAndreas.Sandberg@ARM.com#include "arch/generic/tlb.hh" 526019Shines@cs.fsu.edu#include "base/statistics.hh" 536019Shines@cs.fsu.edu#include "mem/request.hh" 546116Snate@binkert.org#include "params/ArmTLB.hh" 5510463SAndreas.Sandberg@ARM.com#include "sim/probe/pmu.hh" 566019Shines@cs.fsu.edu 576019Shines@cs.fsu.educlass ThreadContext; 586019Shines@cs.fsu.edu 596019Shines@cs.fsu.edunamespace ArmISA { 606019Shines@cs.fsu.edu 617404SAli.Saidi@ARM.comclass TableWalker; 6210037SARM gem5 Developersclass Stage2LookUp; 6310037SARM gem5 Developersclass Stage2MMU; 6411395Sandreas.sandberg@arm.comclass TLB; 6511395Sandreas.sandberg@arm.com 6611395Sandreas.sandberg@arm.comclass TlbTestInterface 6711395Sandreas.sandberg@arm.com{ 6811395Sandreas.sandberg@arm.com public: 6911395Sandreas.sandberg@arm.com TlbTestInterface() {} 7011395Sandreas.sandberg@arm.com virtual ~TlbTestInterface() {} 7111395Sandreas.sandberg@arm.com 7211395Sandreas.sandberg@arm.com /** 7311395Sandreas.sandberg@arm.com * Check if a TLB translation should be forced to fail. 7411395Sandreas.sandberg@arm.com * 7511395Sandreas.sandberg@arm.com * @param req Request requiring a translation. 7611395Sandreas.sandberg@arm.com * @param is_priv Access from a privileged mode (i.e., not EL0) 7711395Sandreas.sandberg@arm.com * @param mode Access type 7811395Sandreas.sandberg@arm.com * @param domain Domain type 7911395Sandreas.sandberg@arm.com */ 8011395Sandreas.sandberg@arm.com virtual Fault translationCheck(RequestPtr req, bool is_priv, 8111395Sandreas.sandberg@arm.com BaseTLB::Mode mode, 8211395Sandreas.sandberg@arm.com TlbEntry::DomainType domain) = 0; 8311395Sandreas.sandberg@arm.com 8411395Sandreas.sandberg@arm.com /** 8511395Sandreas.sandberg@arm.com * Check if a page table walker access should be forced to fail. 8611395Sandreas.sandberg@arm.com * 8711395Sandreas.sandberg@arm.com * @param pa Physical address the walker is accessing 8811395Sandreas.sandberg@arm.com * @param size Walker access size 8911395Sandreas.sandberg@arm.com * @param va Virtual address that initiated the walk 9011395Sandreas.sandberg@arm.com * @param is_secure Access from secure state 9111395Sandreas.sandberg@arm.com * @param is_priv Access from a privileged mode (i.e., not EL0) 9211395Sandreas.sandberg@arm.com * @param mode Access type 9311395Sandreas.sandberg@arm.com * @param domain Domain type 9411395Sandreas.sandberg@arm.com * @param lookup_level Page table walker level 9511395Sandreas.sandberg@arm.com */ 9611395Sandreas.sandberg@arm.com virtual Fault walkCheck(Addr pa, Addr size, Addr va, bool is_secure, 9711395Sandreas.sandberg@arm.com Addr is_priv, BaseTLB::Mode mode, 9811395Sandreas.sandberg@arm.com TlbEntry::DomainType domain, 9911395Sandreas.sandberg@arm.com LookupLevel lookup_level) = 0; 10011395Sandreas.sandberg@arm.com}; 1017404SAli.Saidi@ARM.com 1026019Shines@cs.fsu.educlass TLB : public BaseTLB 1036019Shines@cs.fsu.edu{ 1047294Sgblack@eecs.umich.edu public: 1057294Sgblack@eecs.umich.edu enum ArmFlags { 10610037SARM gem5 Developers AlignmentMask = 0x7, 1077294Sgblack@eecs.umich.edu 1087294Sgblack@eecs.umich.edu AlignByte = 0x0, 1097294Sgblack@eecs.umich.edu AlignHalfWord = 0x1, 11010037SARM gem5 Developers AlignWord = 0x2, 11110037SARM gem5 Developers AlignDoubleWord = 0x3, 11210037SARM gem5 Developers AlignQuadWord = 0x4, 11310037SARM gem5 Developers AlignOctWord = 0x5, 1147294Sgblack@eecs.umich.edu 11510037SARM gem5 Developers AllowUnaligned = 0x8, 1167404SAli.Saidi@ARM.com // Priv code operating as if it wasn't 11710037SARM gem5 Developers UserMode = 0x10, 1187294Sgblack@eecs.umich.edu // Because zero otherwise looks like a valid setting and may be used 1197294Sgblack@eecs.umich.edu // accidentally, this bit must be non-zero to show it was used on 1207294Sgblack@eecs.umich.edu // purpose. 12110037SARM gem5 Developers MustBeOne = 0x40 12210037SARM gem5 Developers }; 12310037SARM gem5 Developers 12410037SARM gem5 Developers enum ArmTranslationType { 12510037SARM gem5 Developers NormalTran = 0, 12610037SARM gem5 Developers S1CTran = 0x1, 12710037SARM gem5 Developers HypMode = 0x2, 12810037SARM gem5 Developers // Secure code operating as if it wasn't (required by some Address 12910037SARM gem5 Developers // Translate operations) 13011577SDylan.Johnson@ARM.com S1S2NsTran = 0x4, 13111577SDylan.Johnson@ARM.com // Address translation instructions (eg AT S1E0R_Xt) need to be handled 13211577SDylan.Johnson@ARM.com // in special ways during translation because they could need to act 13311577SDylan.Johnson@ARM.com // like a different EL than the current EL. The following flags are 13411577SDylan.Johnson@ARM.com // for these instructions 13511577SDylan.Johnson@ARM.com S1E0Tran = 0x8, 13611577SDylan.Johnson@ARM.com S1E1Tran = 0x10, 13711577SDylan.Johnson@ARM.com S1E2Tran = 0x20, 13811577SDylan.Johnson@ARM.com S1E3Tran = 0x40, 13911577SDylan.Johnson@ARM.com S12E0Tran = 0x80, 14011577SDylan.Johnson@ARM.com S12E1Tran = 0x100 1417294Sgblack@eecs.umich.edu }; 14212735Sandreas.sandberg@arm.com 14312735Sandreas.sandberg@arm.com /** 14412735Sandreas.sandberg@arm.com * Determine the EL to use for the purpose of a translation given 14512735Sandreas.sandberg@arm.com * a specific translation type. If the translation type doesn't 14612735Sandreas.sandberg@arm.com * specify an EL, we use the current EL. 14712735Sandreas.sandberg@arm.com */ 14812735Sandreas.sandberg@arm.com static ExceptionLevel tranTypeEL(CPSR cpsr, ArmTranslationType type); 14912735Sandreas.sandberg@arm.com 1506019Shines@cs.fsu.edu protected: 15110037SARM gem5 Developers TlbEntry* table; // the Page Table 15210037SARM gem5 Developers int size; // TLB Size 15310037SARM gem5 Developers bool isStage2; // Indicates this TLB is part of the second stage MMU 15410037SARM gem5 Developers bool stage2Req; // Indicates whether a stage 2 lookup is also required 15510037SARM gem5 Developers uint64_t _attr; // Memory attributes for last accessed TLB entry 15610037SARM gem5 Developers bool directToStage2; // Indicates whether all translation requests should 15710037SARM gem5 Developers // be routed directly to the stage 2 TLB 1587436Sdam.sunwoo@arm.com 1597404SAli.Saidi@ARM.com TableWalker *tableWalker; 16010037SARM gem5 Developers TLB *stage2Tlb; 16110037SARM gem5 Developers Stage2MMU *stage2Mmu; 1626019Shines@cs.fsu.edu 16311395Sandreas.sandberg@arm.com TlbTestInterface *test; 16411395Sandreas.sandberg@arm.com 1657399SAli.Saidi@ARM.com // Access Stats 1667734SAli.Saidi@ARM.com mutable Stats::Scalar instHits; 1677734SAli.Saidi@ARM.com mutable Stats::Scalar instMisses; 1687734SAli.Saidi@ARM.com mutable Stats::Scalar readHits; 1697734SAli.Saidi@ARM.com mutable Stats::Scalar readMisses; 1707734SAli.Saidi@ARM.com mutable Stats::Scalar writeHits; 1717734SAli.Saidi@ARM.com mutable Stats::Scalar writeMisses; 1727734SAli.Saidi@ARM.com mutable Stats::Scalar inserts; 1737734SAli.Saidi@ARM.com mutable Stats::Scalar flushTlb; 1747734SAli.Saidi@ARM.com mutable Stats::Scalar flushTlbMva; 1757734SAli.Saidi@ARM.com mutable Stats::Scalar flushTlbMvaAsid; 1767734SAli.Saidi@ARM.com mutable Stats::Scalar flushTlbAsid; 1777734SAli.Saidi@ARM.com mutable Stats::Scalar flushedEntries; 1787734SAli.Saidi@ARM.com mutable Stats::Scalar alignFaults; 1797734SAli.Saidi@ARM.com mutable Stats::Scalar prefetchFaults; 1807734SAli.Saidi@ARM.com mutable Stats::Scalar domainFaults; 1817734SAli.Saidi@ARM.com mutable Stats::Scalar permsFaults; 1827734SAli.Saidi@ARM.com 1837734SAli.Saidi@ARM.com Stats::Formula readAccesses; 1847734SAli.Saidi@ARM.com Stats::Formula writeAccesses; 1857734SAli.Saidi@ARM.com Stats::Formula instAccesses; 1866019Shines@cs.fsu.edu Stats::Formula hits; 1876019Shines@cs.fsu.edu Stats::Formula misses; 1886019Shines@cs.fsu.edu Stats::Formula accesses; 1896019Shines@cs.fsu.edu 19010463SAndreas.Sandberg@ARM.com /** PMU probe for TLB refills */ 19110463SAndreas.Sandberg@ARM.com ProbePoints::PMUUPtr ppRefills; 19210463SAndreas.Sandberg@ARM.com 1937697SAli.Saidi@ARM.com int rangeMRU; //On lookup, only move entries ahead when outside rangeMRU 1947404SAli.Saidi@ARM.com 1956019Shines@cs.fsu.edu public: 19610037SARM gem5 Developers TLB(const ArmTLBParams *p); 19710037SARM gem5 Developers TLB(const Params *p, int _size, TableWalker *_walker); 1986019Shines@cs.fsu.edu 1999535Smrinmoy.ghosh@arm.com /** Lookup an entry in the TLB 2009535Smrinmoy.ghosh@arm.com * @param vpn virtual address 2019535Smrinmoy.ghosh@arm.com * @param asn context id/address space id to use 20210037SARM gem5 Developers * @param vmid The virtual machine ID used for stage 2 translation 20310037SARM gem5 Developers * @param secure if the lookup is secure 20410037SARM gem5 Developers * @param hyp if the lookup is done from hyp mode 2059535Smrinmoy.ghosh@arm.com * @param functional if the lookup should modify state 20610037SARM gem5 Developers * @param ignore_asn if on lookup asn should be ignored 20710037SARM gem5 Developers * @return pointer to TLB entry if it exists 2089535Smrinmoy.ghosh@arm.com */ 20910037SARM gem5 Developers TlbEntry *lookup(Addr vpn, uint16_t asn, uint8_t vmid, bool hyp, 21010037SARM gem5 Developers bool secure, bool functional, 21110037SARM gem5 Developers bool ignore_asn, uint8_t target_el); 2129535Smrinmoy.ghosh@arm.com 2136019Shines@cs.fsu.edu virtual ~TLB(); 21410037SARM gem5 Developers 21511169Sandreas.hansson@arm.com void takeOverFrom(BaseTLB *otlb) override; 21610194SGeoffrey.Blake@arm.com 21710037SARM gem5 Developers /// setup all the back pointers 21811169Sandreas.hansson@arm.com void init() override; 21910037SARM gem5 Developers 22011395Sandreas.sandberg@arm.com void setTestInterface(SimObject *ti); 22111395Sandreas.sandberg@arm.com 22210717Sandreas.hansson@arm.com TableWalker *getTableWalker() { return tableWalker; } 22310717Sandreas.hansson@arm.com 22410717Sandreas.hansson@arm.com void setMMU(Stage2MMU *m, MasterID master_id); 22510037SARM gem5 Developers 2266019Shines@cs.fsu.edu int getsize() const { return size; } 2276019Shines@cs.fsu.edu 2287404SAli.Saidi@ARM.com void insert(Addr vaddr, TlbEntry &pte); 2297404SAli.Saidi@ARM.com 23010037SARM gem5 Developers Fault getTE(TlbEntry **te, RequestPtr req, ThreadContext *tc, Mode mode, 23110037SARM gem5 Developers Translation *translation, bool timing, bool functional, 23210037SARM gem5 Developers bool is_secure, ArmTranslationType tranType); 23310037SARM gem5 Developers 23410037SARM gem5 Developers Fault getResultTe(TlbEntry **te, RequestPtr req, ThreadContext *tc, 23510037SARM gem5 Developers Mode mode, Translation *translation, bool timing, 23610037SARM gem5 Developers bool functional, TlbEntry *mergeTe); 23710037SARM gem5 Developers 23810037SARM gem5 Developers Fault checkPermissions(TlbEntry *te, RequestPtr req, Mode mode); 23910037SARM gem5 Developers Fault checkPermissions64(TlbEntry *te, RequestPtr req, Mode mode, 24010037SARM gem5 Developers ThreadContext *tc); 24110037SARM gem5 Developers 24210037SARM gem5 Developers 24310037SARM gem5 Developers /** Reset the entire TLB 24410037SARM gem5 Developers * @param secure_lookup if the operation affects the secure world 24510037SARM gem5 Developers */ 24610037SARM gem5 Developers void flushAllSecurity(bool secure_lookup, uint8_t target_el, 24710037SARM gem5 Developers bool ignore_el = false); 24810037SARM gem5 Developers 24910037SARM gem5 Developers /** Remove all entries in the non secure world, depending on whether they 25010037SARM gem5 Developers * were allocated in hyp mode or not 25110037SARM gem5 Developers * @param hyp if the opperation affects hyp mode 25210037SARM gem5 Developers */ 25310037SARM gem5 Developers void flushAllNs(bool hyp, uint8_t target_el, bool ignore_el = false); 25410037SARM gem5 Developers 25510037SARM gem5 Developers 25610037SARM gem5 Developers /** Reset the entire TLB. Used for CPU switching to prevent stale 25710037SARM gem5 Developers * translations after multiple switches 25810037SARM gem5 Developers */ 25911169Sandreas.hansson@arm.com void flushAll() override 26010037SARM gem5 Developers { 26110037SARM gem5 Developers flushAllSecurity(false, 0, true); 26210037SARM gem5 Developers flushAllSecurity(true, 0, true); 26310037SARM gem5 Developers } 2647404SAli.Saidi@ARM.com 2657404SAli.Saidi@ARM.com /** Remove any entries that match both a va and asn 2667404SAli.Saidi@ARM.com * @param mva virtual address to flush 2677404SAli.Saidi@ARM.com * @param asn contextid/asn to flush on match 26810037SARM gem5 Developers * @param secure_lookup if the operation affects the secure world 2697404SAli.Saidi@ARM.com */ 27010037SARM gem5 Developers void flushMvaAsid(Addr mva, uint64_t asn, bool secure_lookup, 27110037SARM gem5 Developers uint8_t target_el); 2727404SAli.Saidi@ARM.com 2737404SAli.Saidi@ARM.com /** Remove any entries that match the asn 2747404SAli.Saidi@ARM.com * @param asn contextid/asn to flush on match 27510037SARM gem5 Developers * @param secure_lookup if the operation affects the secure world 2767404SAli.Saidi@ARM.com */ 27710037SARM gem5 Developers void flushAsid(uint64_t asn, bool secure_lookup, uint8_t target_el); 2787404SAli.Saidi@ARM.com 2797404SAli.Saidi@ARM.com /** Remove all entries that match the va regardless of asn 2807404SAli.Saidi@ARM.com * @param mva address to flush from cache 28110037SARM gem5 Developers * @param secure_lookup if the operation affects the secure world 28210037SARM gem5 Developers * @param hyp if the operation affects hyp mode 2837404SAli.Saidi@ARM.com */ 28410037SARM gem5 Developers void flushMva(Addr mva, bool secure_lookup, bool hyp, uint8_t target_el); 2857404SAli.Saidi@ARM.com 28611584SDylan.Johnson@ARM.com /** 28711584SDylan.Johnson@ARM.com * Invalidate all entries in the stage 2 TLB that match the given ipa 28811584SDylan.Johnson@ARM.com * and the current VMID 28911584SDylan.Johnson@ARM.com * @param ipa the address to invalidate 29011584SDylan.Johnson@ARM.com * @param secure_lookup if the operation affects the secure world 29111584SDylan.Johnson@ARM.com * @param hyp if the operation affects hyp mode 29211584SDylan.Johnson@ARM.com */ 29311584SDylan.Johnson@ARM.com void flushIpaVmid(Addr ipa, bool secure_lookup, bool hyp, uint8_t target_el); 29411584SDylan.Johnson@ARM.com 29511584SDylan.Johnson@ARM.com Fault trickBoxCheck(RequestPtr req, Mode mode, TlbEntry::DomainType domain); 29611584SDylan.Johnson@ARM.com Fault walkTrickBoxCheck(Addr pa, bool is_secure, Addr va, Addr sz, bool is_exec, 29711584SDylan.Johnson@ARM.com bool is_write, TlbEntry::DomainType domain, LookupLevel lookup_level); 29811584SDylan.Johnson@ARM.com 29910037SARM gem5 Developers void printTlb() const; 3007404SAli.Saidi@ARM.com 30111169Sandreas.hansson@arm.com void demapPage(Addr vaddr, uint64_t asn) override 3026019Shines@cs.fsu.edu { 30310037SARM gem5 Developers // needed for x86 only 30410037SARM gem5 Developers panic("demapPage() is not implemented.\n"); 3056019Shines@cs.fsu.edu } 3066019Shines@cs.fsu.edu 3077694SAli.Saidi@ARM.com /** 3087694SAli.Saidi@ARM.com * Do a functional lookup on the TLB (for debugging) 3097694SAli.Saidi@ARM.com * and don't modify any internal state 3107694SAli.Saidi@ARM.com * @param tc thread context to get the context id from 3117694SAli.Saidi@ARM.com * @param vaddr virtual address to translate 3127694SAli.Saidi@ARM.com * @param pa returned physical address 3137694SAli.Saidi@ARM.com * @return if the translation was successful 3147694SAli.Saidi@ARM.com */ 3157694SAli.Saidi@ARM.com bool translateFunctional(ThreadContext *tc, Addr vaddr, Addr &paddr); 3167694SAli.Saidi@ARM.com 3178733Sgeoffrey.blake@arm.com /** 3188733Sgeoffrey.blake@arm.com * Do a functional lookup on the TLB (for checker cpu) that 3198733Sgeoffrey.blake@arm.com * behaves like a normal lookup without modifying any page table state. 3208733Sgeoffrey.blake@arm.com */ 32110037SARM gem5 Developers Fault translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode, 32212419Sgabeblack@google.com ArmTranslationType tranType); 32312419Sgabeblack@google.com Fault 32412419Sgabeblack@google.com translateFunctional(RequestPtr req, ThreadContext *tc, Mode mode) override 32512419Sgabeblack@google.com { 32612419Sgabeblack@google.com return translateFunctional(req, tc, mode, NormalTran); 32712419Sgabeblack@google.com } 3288733Sgeoffrey.blake@arm.com 3297436Sdam.sunwoo@arm.com /** Accessor functions for memory attributes for last accessed TLB entry 3307436Sdam.sunwoo@arm.com */ 3317436Sdam.sunwoo@arm.com void 33210037SARM gem5 Developers setAttr(uint64_t attr) 3337436Sdam.sunwoo@arm.com { 3347436Sdam.sunwoo@arm.com _attr = attr; 3357436Sdam.sunwoo@arm.com } 33610037SARM gem5 Developers 33710037SARM gem5 Developers uint64_t 3387436Sdam.sunwoo@arm.com getAttr() const 3397436Sdam.sunwoo@arm.com { 3407436Sdam.sunwoo@arm.com return _attr; 3417436Sdam.sunwoo@arm.com } 3427436Sdam.sunwoo@arm.com 3437404SAli.Saidi@ARM.com Fault translateFs(RequestPtr req, ThreadContext *tc, Mode mode, 3448733Sgeoffrey.blake@arm.com Translation *translation, bool &delay, 34510037SARM gem5 Developers bool timing, ArmTranslationType tranType, bool functional = false); 3467404SAli.Saidi@ARM.com Fault translateSe(RequestPtr req, ThreadContext *tc, Mode mode, 3477404SAli.Saidi@ARM.com Translation *translation, bool &delay, bool timing); 34810037SARM gem5 Developers Fault translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode, 34912406Sgabeblack@google.com ArmTranslationType tranType); 35012406Sgabeblack@google.com Fault 35112406Sgabeblack@google.com translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode) override 35212406Sgabeblack@google.com { 35312406Sgabeblack@google.com return translateAtomic(req, tc, mode, NormalTran); 35412406Sgabeblack@google.com } 35512406Sgabeblack@google.com void translateTiming( 35612406Sgabeblack@google.com RequestPtr req, ThreadContext *tc, 35710037SARM gem5 Developers Translation *translation, Mode mode, 35812406Sgabeblack@google.com ArmTranslationType tranType); 35912406Sgabeblack@google.com void 36012406Sgabeblack@google.com translateTiming(RequestPtr req, ThreadContext *tc, 36112406Sgabeblack@google.com Translation *translation, Mode mode) override 36212406Sgabeblack@google.com { 36312406Sgabeblack@google.com translateTiming(req, tc, translation, mode, NormalTran); 36412406Sgabeblack@google.com } 36510037SARM gem5 Developers Fault translateComplete(RequestPtr req, ThreadContext *tc, 36610037SARM gem5 Developers Translation *translation, Mode mode, ArmTranslationType tranType, 36710037SARM gem5 Developers bool callFromS2); 36812406Sgabeblack@google.com Fault finalizePhysical( 36912406Sgabeblack@google.com RequestPtr req, ThreadContext *tc, Mode mode) const override; 3706116Snate@binkert.org 37111168Sandreas.hansson@arm.com void drainResume() override; 3729439SAndreas.Sandberg@ARM.com 3736019Shines@cs.fsu.edu // Checkpointing 37411168Sandreas.hansson@arm.com void serialize(CheckpointOut &cp) const override; 37511168Sandreas.hansson@arm.com void unserialize(CheckpointIn &cp) override; 3766019Shines@cs.fsu.edu 37711169Sandreas.hansson@arm.com void regStats() override; 3787749SAli.Saidi@ARM.com 37911168Sandreas.hansson@arm.com void regProbePoints() override; 38010463SAndreas.Sandberg@ARM.com 3818922Swilliam.wang@arm.com /** 3828922Swilliam.wang@arm.com * Get the table walker master port. This is used for migrating 3838922Swilliam.wang@arm.com * port connections during a CPU takeOverFrom() call. For 3848922Swilliam.wang@arm.com * architectures that do not have a table walker, NULL is 3858922Swilliam.wang@arm.com * returned, hence the use of a pointer rather than a 3868922Swilliam.wang@arm.com * reference. For ARM this method will always return a valid port 3878922Swilliam.wang@arm.com * pointer. 3888922Swilliam.wang@arm.com * 3898922Swilliam.wang@arm.com * @return A pointer to the walker master port 3908922Swilliam.wang@arm.com */ 39111169Sandreas.hansson@arm.com BaseMasterPort* getMasterPort() override; 3927781SAli.Saidi@ARM.com 3937749SAli.Saidi@ARM.com // Caching misc register values here. 3947749SAli.Saidi@ARM.com // Writing to misc registers needs to invalidate them. 3957749SAli.Saidi@ARM.com // translateFunctional/translateSe/translateFs checks if they are 3967749SAli.Saidi@ARM.com // invalid and call updateMiscReg if necessary. 3977749SAli.Saidi@ARM.comprotected: 39810854SNathanael.Premillieu@arm.com CPSR cpsr; 39910037SARM gem5 Developers bool aarch64; 40010037SARM gem5 Developers ExceptionLevel aarch64EL; 4017749SAli.Saidi@ARM.com SCTLR sctlr; 40210037SARM gem5 Developers SCR scr; 4037749SAli.Saidi@ARM.com bool isPriv; 40410037SARM gem5 Developers bool isSecure; 40510037SARM gem5 Developers bool isHyp; 40610037SARM gem5 Developers TTBCR ttbcr; 40710037SARM gem5 Developers uint16_t asid; 40810037SARM gem5 Developers uint8_t vmid; 4097749SAli.Saidi@ARM.com PRRR prrr; 4107749SAli.Saidi@ARM.com NMRR nmrr; 41110037SARM gem5 Developers HCR hcr; 4127749SAli.Saidi@ARM.com uint32_t dacr; 4137749SAli.Saidi@ARM.com bool miscRegValid; 41411152Smitch.hayenga@arm.com ContextID miscRegContext; 41510037SARM gem5 Developers ArmTranslationType curTranType; 41610037SARM gem5 Developers 41710037SARM gem5 Developers // Cached copies of system-level properties 41810037SARM gem5 Developers bool haveLPAE; 41910037SARM gem5 Developers bool haveVirtualization; 42010037SARM gem5 Developers bool haveLargeAsid64; 42110037SARM gem5 Developers 42212005Sandreas.sandberg@arm.com AddrRange m5opRange; 42312005Sandreas.sandberg@arm.com 42410037SARM gem5 Developers void updateMiscReg(ThreadContext *tc, 42510037SARM gem5 Developers ArmTranslationType tranType = NormalTran); 42610037SARM gem5 Developers 4277749SAli.Saidi@ARM.compublic: 4288299Schander.sudanthi@arm.com const Params * 4298299Schander.sudanthi@arm.com params() const 4308299Schander.sudanthi@arm.com { 4318299Schander.sudanthi@arm.com return dynamic_cast<const Params *>(_params); 4328299Schander.sudanthi@arm.com } 4337749SAli.Saidi@ARM.com inline void invalidateMiscReg() { miscRegValid = false; } 43410037SARM gem5 Developers 43510037SARM gem5 Developersprivate: 43610037SARM gem5 Developers /** Remove any entries that match both a va and asn 43710037SARM gem5 Developers * @param mva virtual address to flush 43810037SARM gem5 Developers * @param asn contextid/asn to flush on match 43910037SARM gem5 Developers * @param secure_lookup if the operation affects the secure world 44010037SARM gem5 Developers * @param hyp if the operation affects hyp mode 44110037SARM gem5 Developers * @param ignore_asn if the flush should ignore the asn 44210037SARM gem5 Developers */ 44310037SARM gem5 Developers void _flushMva(Addr mva, uint64_t asn, bool secure_lookup, 44410037SARM gem5 Developers bool hyp, bool ignore_asn, uint8_t target_el); 44510037SARM gem5 Developers 44610037SARM gem5 Developers bool checkELMatch(uint8_t target_el, uint8_t tentry_el, bool ignore_el); 44711395Sandreas.sandberg@arm.com 44811395Sandreas.sandberg@arm.com public: /* Testing */ 44911395Sandreas.sandberg@arm.com Fault testTranslation(RequestPtr req, Mode mode, 45011395Sandreas.sandberg@arm.com TlbEntry::DomainType domain); 45111395Sandreas.sandberg@arm.com Fault testWalk(Addr pa, Addr size, Addr va, bool is_secure, Mode mode, 45211395Sandreas.sandberg@arm.com TlbEntry::DomainType domain, 45311395Sandreas.sandberg@arm.com LookupLevel lookup_level); 4546019Shines@cs.fsu.edu}; 4556019Shines@cs.fsu.edu 45612605Sgiacomo.travaglini@arm.comtemplate<typename T> 45712605Sgiacomo.travaglini@arm.comTLB * 45812605Sgiacomo.travaglini@arm.comgetITBPtr(T *tc) 45912605Sgiacomo.travaglini@arm.com{ 46012605Sgiacomo.travaglini@arm.com auto tlb = static_cast<TLB *>(tc->getITBPtr()); 46112605Sgiacomo.travaglini@arm.com assert(tlb); 46212605Sgiacomo.travaglini@arm.com return tlb; 46312605Sgiacomo.travaglini@arm.com} 46412605Sgiacomo.travaglini@arm.com 46512605Sgiacomo.travaglini@arm.comtemplate<typename T> 46612605Sgiacomo.travaglini@arm.comTLB * 46712605Sgiacomo.travaglini@arm.comgetDTBPtr(T *tc) 46812605Sgiacomo.travaglini@arm.com{ 46912605Sgiacomo.travaglini@arm.com auto tlb = static_cast<TLB *>(tc->getDTBPtr()); 47012605Sgiacomo.travaglini@arm.com assert(tlb); 47112605Sgiacomo.travaglini@arm.com return tlb; 47212605Sgiacomo.travaglini@arm.com} 47312605Sgiacomo.travaglini@arm.com 4747811Ssteve.reinhardt@amd.com} // namespace ArmISA 4756019Shines@cs.fsu.edu 4766019Shines@cs.fsu.edu#endif // __ARCH_ARM_TLB_HH__ 477