isa.cc revision 12690
17405SAli.Saidi@ARM.com/* 212667Schuan.zhu@arm.com * Copyright (c) 2010-2018 ARM Limited 37405SAli.Saidi@ARM.com * All rights reserved 47405SAli.Saidi@ARM.com * 57405SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall 67405SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual 77405SAli.Saidi@ARM.com * property including but not limited to intellectual property relating 87405SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software 97405SAli.Saidi@ARM.com * licensed hereunder. You may use the software subject to the license 107405SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated 117405SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software, 127405SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form. 137405SAli.Saidi@ARM.com * 147405SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without 157405SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are 167405SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright 177405SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer; 187405SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright 197405SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the 207405SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution; 217405SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its 227405SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from 237405SAli.Saidi@ARM.com * this software without specific prior written permission. 247405SAli.Saidi@ARM.com * 257405SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 267405SAli.Saidi@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 277405SAli.Saidi@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 287405SAli.Saidi@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 297405SAli.Saidi@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 307405SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 317405SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 327405SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 337405SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 347405SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 357405SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 367405SAli.Saidi@ARM.com * 377405SAli.Saidi@ARM.com * Authors: Gabe Black 387405SAli.Saidi@ARM.com * Ali Saidi 397405SAli.Saidi@ARM.com */ 407405SAli.Saidi@ARM.com 417405SAli.Saidi@ARM.com#include "arch/arm/isa.hh" 4210461SAndreas.Sandberg@ARM.com#include "arch/arm/pmu.hh" 439050Schander.sudanthi@arm.com#include "arch/arm/system.hh" 4412406Sgabeblack@google.com#include "arch/arm/tlb.hh" 4512605Sgiacomo.travaglini@arm.com#include "arch/arm/tlbi_op.hh" 4611793Sbrandon.potter@amd.com#include "cpu/base.hh" 478887Sgeoffrey.blake@arm.com#include "cpu/checker/cpu.hh" 488232Snate@binkert.org#include "debug/Arm.hh" 498232Snate@binkert.org#include "debug/MiscRegs.hh" 5010844Sandreas.sandberg@arm.com#include "dev/arm/generic_timer.hh" 519384SAndreas.Sandberg@arm.com#include "params/ArmISA.hh" 527678Sgblack@eecs.umich.edu#include "sim/faults.hh" 538059SAli.Saidi@ARM.com#include "sim/stat_control.hh" 548284SAli.Saidi@ARM.com#include "sim/system.hh" 557405SAli.Saidi@ARM.com 567405SAli.Saidi@ARM.comnamespace ArmISA 577405SAli.Saidi@ARM.com{ 587405SAli.Saidi@ARM.com 599384SAndreas.Sandberg@arm.comISA::ISA(Params *p) 6010461SAndreas.Sandberg@ARM.com : SimObject(p), 6110461SAndreas.Sandberg@ARM.com system(NULL), 6211165SRekai.GonzalezAlberquilla@arm.com _decoderFlavour(p->decoderFlavour), 6312109SRekai.GonzalezAlberquilla@arm.com _vecRegRenameMode(p->vecRegRenameMode), 6412479SCurtis.Dunham@arm.com pmu(p->pmu) 659384SAndreas.Sandberg@arm.com{ 6611770SCurtis.Dunham@arm.com miscRegs[MISCREG_SCTLR_RST] = 0; 6710037SARM gem5 Developers 6810461SAndreas.Sandberg@ARM.com // Hook up a dummy device if we haven't been configured with a 6910461SAndreas.Sandberg@ARM.com // real PMU. By using a dummy device, we don't need to check that 7010461SAndreas.Sandberg@ARM.com // the PMU exist every time we try to access a PMU register. 7110461SAndreas.Sandberg@ARM.com if (!pmu) 7210461SAndreas.Sandberg@ARM.com pmu = &dummyDevice; 7310461SAndreas.Sandberg@ARM.com 7410609Sandreas.sandberg@arm.com // Give all ISA devices a pointer to this ISA 7510609Sandreas.sandberg@arm.com pmu->setISA(this); 7610609Sandreas.sandberg@arm.com 7710037SARM gem5 Developers system = dynamic_cast<ArmSystem *>(p->system); 7810037SARM gem5 Developers 7910037SARM gem5 Developers // Cache system-level properties 8010037SARM gem5 Developers if (FullSystem && system) { 8111771SCurtis.Dunham@arm.com highestELIs64 = system->highestELIs64(); 8210037SARM gem5 Developers haveSecurity = system->haveSecurity(); 8310037SARM gem5 Developers haveLPAE = system->haveLPAE(); 8410037SARM gem5 Developers haveVirtualization = system->haveVirtualization(); 8510037SARM gem5 Developers haveLargeAsid64 = system->haveLargeAsid64(); 8610037SARM gem5 Developers physAddrRange64 = system->physAddrRange64(); 8710037SARM gem5 Developers } else { 8811771SCurtis.Dunham@arm.com highestELIs64 = true; // ArmSystem::highestELIs64 does the same 8910037SARM gem5 Developers haveSecurity = haveLPAE = haveVirtualization = false; 9010037SARM gem5 Developers haveLargeAsid64 = false; 9110037SARM gem5 Developers physAddrRange64 = 32; // dummy value 9210037SARM gem5 Developers } 9310037SARM gem5 Developers 9412477SCurtis.Dunham@arm.com initializeMiscRegMetadata(); 9510037SARM gem5 Developers preUnflattenMiscReg(); 9610037SARM gem5 Developers 979384SAndreas.Sandberg@arm.com clear(); 989384SAndreas.Sandberg@arm.com} 999384SAndreas.Sandberg@arm.com 10012479SCurtis.Dunham@arm.comstd::vector<struct ISA::MiscRegLUTEntry> ISA::lookUpMiscReg(NUM_MISCREGS); 10112479SCurtis.Dunham@arm.com 1029384SAndreas.Sandberg@arm.comconst ArmISAParams * 1039384SAndreas.Sandberg@arm.comISA::params() const 1049384SAndreas.Sandberg@arm.com{ 1059384SAndreas.Sandberg@arm.com return dynamic_cast<const Params *>(_params); 1069384SAndreas.Sandberg@arm.com} 1079384SAndreas.Sandberg@arm.com 1087427Sgblack@eecs.umich.eduvoid 1097427Sgblack@eecs.umich.eduISA::clear() 1107427Sgblack@eecs.umich.edu{ 1119385SAndreas.Sandberg@arm.com const Params *p(params()); 1129385SAndreas.Sandberg@arm.com 1137427Sgblack@eecs.umich.edu SCTLR sctlr_rst = miscRegs[MISCREG_SCTLR_RST]; 1147427Sgblack@eecs.umich.edu memset(miscRegs, 0, sizeof(miscRegs)); 11510037SARM gem5 Developers 11610037SARM gem5 Developers // Initialize configurable default values 11710037SARM gem5 Developers miscRegs[MISCREG_MIDR] = p->midr; 11810037SARM gem5 Developers miscRegs[MISCREG_MIDR_EL1] = p->midr; 11910037SARM gem5 Developers miscRegs[MISCREG_VPIDR] = p->midr; 12010037SARM gem5 Developers 12112690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_ISAR0] = p->id_isar0; 12212690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_ISAR1] = p->id_isar1; 12312690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_ISAR2] = p->id_isar2; 12412690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_ISAR3] = p->id_isar3; 12512690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_ISAR4] = p->id_isar4; 12612690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_ISAR5] = p->id_isar5; 12712690Sgiacomo.travaglini@arm.com 12812690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_MMFR0] = p->id_mmfr0; 12912690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_MMFR1] = p->id_mmfr1; 13012690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_MMFR2] = p->id_mmfr2; 13112690Sgiacomo.travaglini@arm.com miscRegs[MISCREG_ID_MMFR3] = p->id_mmfr3; 13212690Sgiacomo.travaglini@arm.com 13310037SARM gem5 Developers if (FullSystem && system->highestELIs64()) { 13410037SARM gem5 Developers // Initialize AArch64 state 13510037SARM gem5 Developers clear64(p); 13610037SARM gem5 Developers return; 13710037SARM gem5 Developers } 13810037SARM gem5 Developers 13910037SARM gem5 Developers // Initialize AArch32 state... 14010037SARM gem5 Developers 1417427Sgblack@eecs.umich.edu CPSR cpsr = 0; 1427427Sgblack@eecs.umich.edu cpsr.mode = MODE_USER; 1437427Sgblack@eecs.umich.edu miscRegs[MISCREG_CPSR] = cpsr; 1447427Sgblack@eecs.umich.edu updateRegMap(cpsr); 1457427Sgblack@eecs.umich.edu 1467427Sgblack@eecs.umich.edu SCTLR sctlr = 0; 14710037SARM gem5 Developers sctlr.te = (bool) sctlr_rst.te; 14810037SARM gem5 Developers sctlr.nmfi = (bool) sctlr_rst.nmfi; 14910037SARM gem5 Developers sctlr.v = (bool) sctlr_rst.v; 15010037SARM gem5 Developers sctlr.u = 1; 1517427Sgblack@eecs.umich.edu sctlr.xp = 1; 1527427Sgblack@eecs.umich.edu sctlr.rao2 = 1; 1537427Sgblack@eecs.umich.edu sctlr.rao3 = 1; 15410037SARM gem5 Developers sctlr.rao4 = 0xf; // SCTLR[6:3] 15510204SAli.Saidi@ARM.com sctlr.uci = 1; 15610204SAli.Saidi@ARM.com sctlr.dze = 1; 15710037SARM gem5 Developers miscRegs[MISCREG_SCTLR_NS] = sctlr; 1587427Sgblack@eecs.umich.edu miscRegs[MISCREG_SCTLR_RST] = sctlr_rst; 15910037SARM gem5 Developers miscRegs[MISCREG_HCPTR] = 0; 1607427Sgblack@eecs.umich.edu 16110037SARM gem5 Developers // Start with an event in the mailbox 1627427Sgblack@eecs.umich.edu miscRegs[MISCREG_SEV_MAILBOX] = 1; 1637427Sgblack@eecs.umich.edu 16410037SARM gem5 Developers // Separate Instruction and Data TLBs 1657427Sgblack@eecs.umich.edu miscRegs[MISCREG_TLBTR] = 1; 1667427Sgblack@eecs.umich.edu 1677427Sgblack@eecs.umich.edu MVFR0 mvfr0 = 0; 1687427Sgblack@eecs.umich.edu mvfr0.advSimdRegisters = 2; 1697427Sgblack@eecs.umich.edu mvfr0.singlePrecision = 2; 1707427Sgblack@eecs.umich.edu mvfr0.doublePrecision = 2; 1717427Sgblack@eecs.umich.edu mvfr0.vfpExceptionTrapping = 0; 1727427Sgblack@eecs.umich.edu mvfr0.divide = 1; 1737427Sgblack@eecs.umich.edu mvfr0.squareRoot = 1; 1747427Sgblack@eecs.umich.edu mvfr0.shortVectors = 1; 1757427Sgblack@eecs.umich.edu mvfr0.roundingModes = 1; 1767427Sgblack@eecs.umich.edu miscRegs[MISCREG_MVFR0] = mvfr0; 1777427Sgblack@eecs.umich.edu 1787427Sgblack@eecs.umich.edu MVFR1 mvfr1 = 0; 1797427Sgblack@eecs.umich.edu mvfr1.flushToZero = 1; 1807427Sgblack@eecs.umich.edu mvfr1.defaultNaN = 1; 1817427Sgblack@eecs.umich.edu mvfr1.advSimdLoadStore = 1; 1827427Sgblack@eecs.umich.edu mvfr1.advSimdInteger = 1; 1837427Sgblack@eecs.umich.edu mvfr1.advSimdSinglePrecision = 1; 1847427Sgblack@eecs.umich.edu mvfr1.advSimdHalfPrecision = 1; 1857427Sgblack@eecs.umich.edu mvfr1.vfpHalfPrecision = 1; 1867427Sgblack@eecs.umich.edu miscRegs[MISCREG_MVFR1] = mvfr1; 1877427Sgblack@eecs.umich.edu 1887436Sdam.sunwoo@arm.com // Reset values of PRRR and NMRR are implementation dependent 1897436Sdam.sunwoo@arm.com 19010037SARM gem5 Developers // @todo: PRRR and NMRR in secure state? 19110037SARM gem5 Developers miscRegs[MISCREG_PRRR_NS] = 1927436Sdam.sunwoo@arm.com (1 << 19) | // 19 1937436Sdam.sunwoo@arm.com (0 << 18) | // 18 1947436Sdam.sunwoo@arm.com (0 << 17) | // 17 1957436Sdam.sunwoo@arm.com (1 << 16) | // 16 1967436Sdam.sunwoo@arm.com (2 << 14) | // 15:14 1977436Sdam.sunwoo@arm.com (0 << 12) | // 13:12 1987436Sdam.sunwoo@arm.com (2 << 10) | // 11:10 1997436Sdam.sunwoo@arm.com (2 << 8) | // 9:8 2007436Sdam.sunwoo@arm.com (2 << 6) | // 7:6 2017436Sdam.sunwoo@arm.com (2 << 4) | // 5:4 2027436Sdam.sunwoo@arm.com (1 << 2) | // 3:2 2037436Sdam.sunwoo@arm.com 0; // 1:0 20410037SARM gem5 Developers miscRegs[MISCREG_NMRR_NS] = 2057436Sdam.sunwoo@arm.com (1 << 30) | // 31:30 2067436Sdam.sunwoo@arm.com (0 << 26) | // 27:26 2077436Sdam.sunwoo@arm.com (0 << 24) | // 25:24 2087436Sdam.sunwoo@arm.com (3 << 22) | // 23:22 2097436Sdam.sunwoo@arm.com (2 << 20) | // 21:20 2107436Sdam.sunwoo@arm.com (0 << 18) | // 19:18 2117436Sdam.sunwoo@arm.com (0 << 16) | // 17:16 2127436Sdam.sunwoo@arm.com (1 << 14) | // 15:14 2137436Sdam.sunwoo@arm.com (0 << 12) | // 13:12 2147436Sdam.sunwoo@arm.com (2 << 10) | // 11:10 2157436Sdam.sunwoo@arm.com (0 << 8) | // 9:8 2167436Sdam.sunwoo@arm.com (3 << 6) | // 7:6 2177436Sdam.sunwoo@arm.com (2 << 4) | // 5:4 2187436Sdam.sunwoo@arm.com (0 << 2) | // 3:2 2197436Sdam.sunwoo@arm.com 0; // 1:0 2207436Sdam.sunwoo@arm.com 2217644Sali.saidi@arm.com miscRegs[MISCREG_CPACR] = 0; 2228147SAli.Saidi@ARM.com 2239385SAndreas.Sandberg@arm.com miscRegs[MISCREG_FPSID] = p->fpsid; 2249385SAndreas.Sandberg@arm.com 22510037SARM gem5 Developers if (haveLPAE) { 22610037SARM gem5 Developers TTBCR ttbcr = miscRegs[MISCREG_TTBCR_NS]; 22710037SARM gem5 Developers ttbcr.eae = 0; 22810037SARM gem5 Developers miscRegs[MISCREG_TTBCR_NS] = ttbcr; 22910037SARM gem5 Developers // Enforce consistency with system-level settings 23010037SARM gem5 Developers miscRegs[MISCREG_ID_MMFR0] = (miscRegs[MISCREG_ID_MMFR0] & ~0xf) | 0x5; 23110037SARM gem5 Developers } 23210037SARM gem5 Developers 23310037SARM gem5 Developers if (haveSecurity) { 23410037SARM gem5 Developers miscRegs[MISCREG_SCTLR_S] = sctlr; 23510037SARM gem5 Developers miscRegs[MISCREG_SCR] = 0; 23610037SARM gem5 Developers miscRegs[MISCREG_VBAR_S] = 0; 23710037SARM gem5 Developers } else { 23810037SARM gem5 Developers // we're always non-secure 23910037SARM gem5 Developers miscRegs[MISCREG_SCR] = 1; 24010037SARM gem5 Developers } 2418147SAli.Saidi@ARM.com 2427427Sgblack@eecs.umich.edu //XXX We need to initialize the rest of the state. 2437427Sgblack@eecs.umich.edu} 2447427Sgblack@eecs.umich.edu 24510037SARM gem5 Developersvoid 24610037SARM gem5 DevelopersISA::clear64(const ArmISAParams *p) 24710037SARM gem5 Developers{ 24810037SARM gem5 Developers CPSR cpsr = 0; 24910037SARM gem5 Developers Addr rvbar = system->resetAddr64(); 25010037SARM gem5 Developers switch (system->highestEL()) { 25110037SARM gem5 Developers // Set initial EL to highest implemented EL using associated stack 25210037SARM gem5 Developers // pointer (SP_ELx); set RVBAR_ELx to implementation defined reset 25310037SARM gem5 Developers // value 25410037SARM gem5 Developers case EL3: 25510037SARM gem5 Developers cpsr.mode = MODE_EL3H; 25610037SARM gem5 Developers miscRegs[MISCREG_RVBAR_EL3] = rvbar; 25710037SARM gem5 Developers break; 25810037SARM gem5 Developers case EL2: 25910037SARM gem5 Developers cpsr.mode = MODE_EL2H; 26010037SARM gem5 Developers miscRegs[MISCREG_RVBAR_EL2] = rvbar; 26110037SARM gem5 Developers break; 26210037SARM gem5 Developers case EL1: 26310037SARM gem5 Developers cpsr.mode = MODE_EL1H; 26410037SARM gem5 Developers miscRegs[MISCREG_RVBAR_EL1] = rvbar; 26510037SARM gem5 Developers break; 26610037SARM gem5 Developers default: 26710037SARM gem5 Developers panic("Invalid highest implemented exception level"); 26810037SARM gem5 Developers break; 26910037SARM gem5 Developers } 27010037SARM gem5 Developers 27110037SARM gem5 Developers // Initialize rest of CPSR 27210037SARM gem5 Developers cpsr.daif = 0xf; // Mask all interrupts 27310037SARM gem5 Developers cpsr.ss = 0; 27410037SARM gem5 Developers cpsr.il = 0; 27510037SARM gem5 Developers miscRegs[MISCREG_CPSR] = cpsr; 27610037SARM gem5 Developers updateRegMap(cpsr); 27710037SARM gem5 Developers 27810037SARM gem5 Developers // Initialize other control registers 27910037SARM gem5 Developers miscRegs[MISCREG_MPIDR_EL1] = 0x80000000; 28010037SARM gem5 Developers if (haveSecurity) { 28111770SCurtis.Dunham@arm.com miscRegs[MISCREG_SCTLR_EL3] = 0x30c50830; 28210037SARM gem5 Developers miscRegs[MISCREG_SCR_EL3] = 0x00000030; // RES1 fields 28311574SCurtis.Dunham@arm.com } else if (haveVirtualization) { 28411770SCurtis.Dunham@arm.com // also MISCREG_SCTLR_EL2 (by mapping) 28511770SCurtis.Dunham@arm.com miscRegs[MISCREG_HSCTLR] = 0x30c50830; 28610037SARM gem5 Developers } else { 28711770SCurtis.Dunham@arm.com // also MISCREG_SCTLR_EL1 (by mapping) 28811770SCurtis.Dunham@arm.com miscRegs[MISCREG_SCTLR_NS] = 0x30d00800 | 0x00050030; // RES1 | init 28910037SARM gem5 Developers // Always non-secure 29010037SARM gem5 Developers miscRegs[MISCREG_SCR_EL3] = 1; 29110037SARM gem5 Developers } 29210037SARM gem5 Developers 29310037SARM gem5 Developers // Initialize configurable id registers 29410037SARM gem5 Developers miscRegs[MISCREG_ID_AA64AFR0_EL1] = p->id_aa64afr0_el1; 29510037SARM gem5 Developers miscRegs[MISCREG_ID_AA64AFR1_EL1] = p->id_aa64afr1_el1; 29610461SAndreas.Sandberg@ARM.com miscRegs[MISCREG_ID_AA64DFR0_EL1] = 29710461SAndreas.Sandberg@ARM.com (p->id_aa64dfr0_el1 & 0xfffffffffffff0ffULL) | 29810461SAndreas.Sandberg@ARM.com (p->pmu ? 0x0000000000000100ULL : 0); // Enable PMUv3 29910461SAndreas.Sandberg@ARM.com 30010037SARM gem5 Developers miscRegs[MISCREG_ID_AA64DFR1_EL1] = p->id_aa64dfr1_el1; 30110037SARM gem5 Developers miscRegs[MISCREG_ID_AA64ISAR0_EL1] = p->id_aa64isar0_el1; 30210037SARM gem5 Developers miscRegs[MISCREG_ID_AA64ISAR1_EL1] = p->id_aa64isar1_el1; 30310037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1] = p->id_aa64mmfr0_el1; 30410037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR1_EL1] = p->id_aa64mmfr1_el1; 30510037SARM gem5 Developers 30610461SAndreas.Sandberg@ARM.com miscRegs[MISCREG_ID_DFR0_EL1] = 30710461SAndreas.Sandberg@ARM.com (p->pmu ? 0x03000000ULL : 0); // Enable PMUv3 30810461SAndreas.Sandberg@ARM.com 30910461SAndreas.Sandberg@ARM.com miscRegs[MISCREG_ID_DFR0] = miscRegs[MISCREG_ID_DFR0_EL1]; 31010461SAndreas.Sandberg@ARM.com 31110037SARM gem5 Developers // Enforce consistency with system-level settings... 31210037SARM gem5 Developers 31310037SARM gem5 Developers // EL3 31410037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1] = insertBits( 31510037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1], 15, 12, 31611574SCurtis.Dunham@arm.com haveSecurity ? 0x2 : 0x0); 31710037SARM gem5 Developers // EL2 31810037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1] = insertBits( 31910037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1], 11, 8, 32011574SCurtis.Dunham@arm.com haveVirtualization ? 0x2 : 0x0); 32110037SARM gem5 Developers // Large ASID support 32210037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1] = insertBits( 32310037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1], 7, 4, 32410037SARM gem5 Developers haveLargeAsid64 ? 0x2 : 0x0); 32510037SARM gem5 Developers // Physical address size 32610037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1] = insertBits( 32710037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1], 3, 0, 32810037SARM gem5 Developers encodePhysAddrRange64(physAddrRange64)); 32910037SARM gem5 Developers} 33010037SARM gem5 Developers 3317405SAli.Saidi@ARM.comMiscReg 33210035Sandreas.hansson@arm.comISA::readMiscRegNoEffect(int misc_reg) const 3337405SAli.Saidi@ARM.com{ 3347405SAli.Saidi@ARM.com assert(misc_reg < NumMiscRegs); 3357614Sminkyu.jeong@arm.com 33612478SCurtis.Dunham@arm.com const auto ® = lookUpMiscReg[misc_reg]; // bit masks 33712478SCurtis.Dunham@arm.com const auto &map = getMiscIndices(misc_reg); 33812478SCurtis.Dunham@arm.com int lower = map.first, upper = map.second; 33912478SCurtis.Dunham@arm.com // NB!: apply architectural masks according to desired register, 34012478SCurtis.Dunham@arm.com // despite possibly getting value from different (mapped) register. 34112478SCurtis.Dunham@arm.com auto val = !upper ? miscRegs[lower] : ((miscRegs[lower] & mask(32)) 34212478SCurtis.Dunham@arm.com |(miscRegs[upper] << 32)); 34312478SCurtis.Dunham@arm.com if (val & reg.res0()) { 34412478SCurtis.Dunham@arm.com DPRINTF(MiscRegs, "Reading MiscReg %s with set res0 bits: %#x\n", 34512478SCurtis.Dunham@arm.com miscRegName[misc_reg], val & reg.res0()); 34612478SCurtis.Dunham@arm.com } 34712478SCurtis.Dunham@arm.com if ((val & reg.res1()) != reg.res1()) { 34812478SCurtis.Dunham@arm.com DPRINTF(MiscRegs, "Reading MiscReg %s with clear res1 bits: %#x\n", 34912478SCurtis.Dunham@arm.com miscRegName[misc_reg], (val & reg.res1()) ^ reg.res1()); 35012478SCurtis.Dunham@arm.com } 35112478SCurtis.Dunham@arm.com return (val & ~reg.raz()) | reg.rao(); // enforce raz/rao 3527405SAli.Saidi@ARM.com} 3537405SAli.Saidi@ARM.com 3547405SAli.Saidi@ARM.com 3557405SAli.Saidi@ARM.comMiscReg 3567405SAli.Saidi@ARM.comISA::readMiscReg(int misc_reg, ThreadContext *tc) 3577405SAli.Saidi@ARM.com{ 35810037SARM gem5 Developers CPSR cpsr = 0; 35910037SARM gem5 Developers PCState pc = 0; 36010037SARM gem5 Developers SCR scr = 0; 3619050Schander.sudanthi@arm.com 3627405SAli.Saidi@ARM.com if (misc_reg == MISCREG_CPSR) { 36310037SARM gem5 Developers cpsr = miscRegs[misc_reg]; 36410037SARM gem5 Developers pc = tc->pcState(); 3657720Sgblack@eecs.umich.edu cpsr.j = pc.jazelle() ? 1 : 0; 3667720Sgblack@eecs.umich.edu cpsr.t = pc.thumb() ? 1 : 0; 3677405SAli.Saidi@ARM.com return cpsr; 3687405SAli.Saidi@ARM.com } 3697757SAli.Saidi@ARM.com 37010037SARM gem5 Developers#ifndef NDEBUG 37110037SARM gem5 Developers if (!miscRegInfo[misc_reg][MISCREG_IMPLEMENTED]) { 37210037SARM gem5 Developers if (miscRegInfo[misc_reg][MISCREG_WARN_NOT_FAIL]) 37310037SARM gem5 Developers warn("Unimplemented system register %s read.\n", 37410037SARM gem5 Developers miscRegName[misc_reg]); 37510037SARM gem5 Developers else 37610037SARM gem5 Developers panic("Unimplemented system register %s read.\n", 37710037SARM gem5 Developers miscRegName[misc_reg]); 37810037SARM gem5 Developers } 37910037SARM gem5 Developers#endif 38010037SARM gem5 Developers 38110037SARM gem5 Developers switch (unflattenMiscReg(misc_reg)) { 38210037SARM gem5 Developers case MISCREG_HCR: 38310037SARM gem5 Developers { 38410037SARM gem5 Developers if (!haveVirtualization) 38510037SARM gem5 Developers return 0; 38610037SARM gem5 Developers else 38710037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_HCR); 38810037SARM gem5 Developers } 38910037SARM gem5 Developers case MISCREG_CPACR: 39010037SARM gem5 Developers { 39110037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 39210037SARM gem5 Developers CPACR cpacrMask = 0; 39310037SARM gem5 Developers // Only cp10, cp11, and ase are implemented, nothing else should 39410037SARM gem5 Developers // be readable? (straight copy from the write code) 39510037SARM gem5 Developers cpacrMask.cp10 = ones; 39610037SARM gem5 Developers cpacrMask.cp11 = ones; 39710037SARM gem5 Developers cpacrMask.asedis = ones; 39810037SARM gem5 Developers 39910037SARM gem5 Developers // Security Extensions may limit the readability of CPACR 40010037SARM gem5 Developers if (haveSecurity) { 40110037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 40210037SARM gem5 Developers cpsr = readMiscRegNoEffect(MISCREG_CPSR); 40312667Schuan.zhu@arm.com if (scr.ns && (cpsr.mode != MODE_MON) && ELIs32(tc, EL3)) { 40410037SARM gem5 Developers NSACR nsacr = readMiscRegNoEffect(MISCREG_NSACR); 40510037SARM gem5 Developers // NB: Skipping the full loop, here 40610037SARM gem5 Developers if (!nsacr.cp10) cpacrMask.cp10 = 0; 40710037SARM gem5 Developers if (!nsacr.cp11) cpacrMask.cp11 = 0; 40810037SARM gem5 Developers } 40910037SARM gem5 Developers } 41010037SARM gem5 Developers MiscReg val = readMiscRegNoEffect(MISCREG_CPACR); 41110037SARM gem5 Developers val &= cpacrMask; 41210037SARM gem5 Developers DPRINTF(MiscRegs, "Reading misc reg %s: %#x\n", 41310037SARM gem5 Developers miscRegName[misc_reg], val); 41410037SARM gem5 Developers return val; 41510037SARM gem5 Developers } 4168284SAli.Saidi@ARM.com case MISCREG_MPIDR: 41710037SARM gem5 Developers cpsr = readMiscRegNoEffect(MISCREG_CPSR); 41810037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 41910037SARM gem5 Developers if ((cpsr.mode == MODE_HYP) || inSecureState(scr, cpsr)) { 42010037SARM gem5 Developers return getMPIDR(system, tc); 4219050Schander.sudanthi@arm.com } else { 42210037SARM gem5 Developers return readMiscReg(MISCREG_VMPIDR, tc); 42310037SARM gem5 Developers } 42410037SARM gem5 Developers break; 42510037SARM gem5 Developers case MISCREG_MPIDR_EL1: 42610037SARM gem5 Developers // @todo in the absence of v8 virtualization support just return MPIDR_EL1 42710037SARM gem5 Developers return getMPIDR(system, tc) & 0xffffffff; 42810037SARM gem5 Developers case MISCREG_VMPIDR: 42910037SARM gem5 Developers // top bit defined as RES1 43010037SARM gem5 Developers return readMiscRegNoEffect(misc_reg) | 0x80000000; 43110037SARM gem5 Developers case MISCREG_ID_AFR0: // not implemented, so alias MIDR 43210037SARM gem5 Developers case MISCREG_REVIDR: // not implemented, so alias MIDR 43310037SARM gem5 Developers case MISCREG_MIDR: 43410037SARM gem5 Developers cpsr = readMiscRegNoEffect(MISCREG_CPSR); 43510037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 43610037SARM gem5 Developers if ((cpsr.mode == MODE_HYP) || inSecureState(scr, cpsr)) { 43710037SARM gem5 Developers return readMiscRegNoEffect(misc_reg); 43810037SARM gem5 Developers } else { 43910037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_VPIDR); 4409050Schander.sudanthi@arm.com } 4418284SAli.Saidi@ARM.com break; 44210037SARM gem5 Developers case MISCREG_JOSCR: // Jazelle trivial implementation, RAZ/WI 44310037SARM gem5 Developers case MISCREG_JMCR: // Jazelle trivial implementation, RAZ/WI 44410037SARM gem5 Developers case MISCREG_JIDR: // Jazelle trivial implementation, RAZ/WI 44510037SARM gem5 Developers case MISCREG_AIDR: // AUX ID set to 0 44610037SARM gem5 Developers case MISCREG_TCMTR: // No TCM's 44710037SARM gem5 Developers return 0; 44810037SARM gem5 Developers 4497405SAli.Saidi@ARM.com case MISCREG_CLIDR: 4507731SAli.Saidi@ARM.com warn_once("The clidr register always reports 0 caches.\n"); 4518468Swade.walker@arm.com warn_once("clidr LoUIS field of 0b001 to match current " 4528468Swade.walker@arm.com "ARM implementations.\n"); 4538468Swade.walker@arm.com return 0x00200000; 4547405SAli.Saidi@ARM.com case MISCREG_CCSIDR: 4557731SAli.Saidi@ARM.com warn_once("The ccsidr register isn't implemented and " 4567405SAli.Saidi@ARM.com "always reads as 0.\n"); 4577405SAli.Saidi@ARM.com break; 45811809Sbaz21@cam.ac.uk case MISCREG_CTR: // AArch32, ARMv7, top bit set 45911809Sbaz21@cam.ac.uk case MISCREG_CTR_EL0: // AArch64 4609130Satgutier@umich.edu { 4619130Satgutier@umich.edu //all caches have the same line size in gem5 4629130Satgutier@umich.edu //4 byte words in ARM 4639130Satgutier@umich.edu unsigned lineSizeWords = 4649814Sandreas.hansson@arm.com tc->getSystemPtr()->cacheLineSize() / 4; 4659130Satgutier@umich.edu unsigned log2LineSizeWords = 0; 4669130Satgutier@umich.edu 4679130Satgutier@umich.edu while (lineSizeWords >>= 1) { 4689130Satgutier@umich.edu ++log2LineSizeWords; 4699130Satgutier@umich.edu } 4709130Satgutier@umich.edu 4719130Satgutier@umich.edu CTR ctr = 0; 4729130Satgutier@umich.edu //log2 of minimun i-cache line size (words) 4739130Satgutier@umich.edu ctr.iCacheLineSize = log2LineSizeWords; 4749130Satgutier@umich.edu //b11 - gem5 uses pipt 4759130Satgutier@umich.edu ctr.l1IndexPolicy = 0x3; 4769130Satgutier@umich.edu //log2 of minimum d-cache line size (words) 4779130Satgutier@umich.edu ctr.dCacheLineSize = log2LineSizeWords; 4789130Satgutier@umich.edu //log2 of max reservation size (words) 4799130Satgutier@umich.edu ctr.erg = log2LineSizeWords; 4809130Satgutier@umich.edu //log2 of max writeback size (words) 4819130Satgutier@umich.edu ctr.cwg = log2LineSizeWords; 4829130Satgutier@umich.edu //b100 - gem5 format is ARMv7 4839130Satgutier@umich.edu ctr.format = 0x4; 4849130Satgutier@umich.edu 4859130Satgutier@umich.edu return ctr; 4869130Satgutier@umich.edu } 4877583SAli.Saidi@arm.com case MISCREG_ACTLR: 4887583SAli.Saidi@arm.com warn("Not doing anything for miscreg ACTLR\n"); 4897583SAli.Saidi@arm.com break; 49010461SAndreas.Sandberg@ARM.com 49110461SAndreas.Sandberg@ARM.com case MISCREG_PMXEVTYPER_PMCCFILTR: 49210461SAndreas.Sandberg@ARM.com case MISCREG_PMINTENSET_EL1 ... MISCREG_PMOVSSET_EL0: 49310461SAndreas.Sandberg@ARM.com case MISCREG_PMEVCNTR0_EL0 ... MISCREG_PMEVTYPER5_EL0: 49410461SAndreas.Sandberg@ARM.com case MISCREG_PMCR ... MISCREG_PMOVSSET: 49510461SAndreas.Sandberg@ARM.com return pmu->readMiscReg(misc_reg); 49610461SAndreas.Sandberg@ARM.com 4978302SAli.Saidi@ARM.com case MISCREG_CPSR_Q: 4988302SAli.Saidi@ARM.com panic("shouldn't be reading this register seperately\n"); 4997783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_QC: 5007783SGiacomo.Gabrielli@arm.com return readMiscRegNoEffect(MISCREG_FPSCR) & ~FpscrQcMask; 5017783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_EXC: 5027783SGiacomo.Gabrielli@arm.com return readMiscRegNoEffect(MISCREG_FPSCR) & ~FpscrExcMask; 50310037SARM gem5 Developers case MISCREG_FPSR: 50410037SARM gem5 Developers { 50510037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 50610037SARM gem5 Developers FPSCR fpscrMask = 0; 50710037SARM gem5 Developers fpscrMask.ioc = ones; 50810037SARM gem5 Developers fpscrMask.dzc = ones; 50910037SARM gem5 Developers fpscrMask.ofc = ones; 51010037SARM gem5 Developers fpscrMask.ufc = ones; 51110037SARM gem5 Developers fpscrMask.ixc = ones; 51210037SARM gem5 Developers fpscrMask.idc = ones; 51310037SARM gem5 Developers fpscrMask.qc = ones; 51410037SARM gem5 Developers fpscrMask.v = ones; 51510037SARM gem5 Developers fpscrMask.c = ones; 51610037SARM gem5 Developers fpscrMask.z = ones; 51710037SARM gem5 Developers fpscrMask.n = ones; 51810037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_FPSCR) & (uint32_t)fpscrMask; 51910037SARM gem5 Developers } 52010037SARM gem5 Developers case MISCREG_FPCR: 52110037SARM gem5 Developers { 52210037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 52310037SARM gem5 Developers FPSCR fpscrMask = 0; 52410037SARM gem5 Developers fpscrMask.len = ones; 52510037SARM gem5 Developers fpscrMask.stride = ones; 52610037SARM gem5 Developers fpscrMask.rMode = ones; 52710037SARM gem5 Developers fpscrMask.fz = ones; 52810037SARM gem5 Developers fpscrMask.dn = ones; 52910037SARM gem5 Developers fpscrMask.ahp = ones; 53010037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_FPSCR) & (uint32_t)fpscrMask; 53110037SARM gem5 Developers } 53210037SARM gem5 Developers case MISCREG_NZCV: 53310037SARM gem5 Developers { 53410037SARM gem5 Developers CPSR cpsr = 0; 53510338SCurtis.Dunham@arm.com cpsr.nz = tc->readCCReg(CCREG_NZ); 53610338SCurtis.Dunham@arm.com cpsr.c = tc->readCCReg(CCREG_C); 53710338SCurtis.Dunham@arm.com cpsr.v = tc->readCCReg(CCREG_V); 53810037SARM gem5 Developers return cpsr; 53910037SARM gem5 Developers } 54010037SARM gem5 Developers case MISCREG_DAIF: 54110037SARM gem5 Developers { 54210037SARM gem5 Developers CPSR cpsr = 0; 54310037SARM gem5 Developers cpsr.daif = (uint8_t) ((CPSR) miscRegs[MISCREG_CPSR]).daif; 54410037SARM gem5 Developers return cpsr; 54510037SARM gem5 Developers } 54610037SARM gem5 Developers case MISCREG_SP_EL0: 54710037SARM gem5 Developers { 54810037SARM gem5 Developers return tc->readIntReg(INTREG_SP0); 54910037SARM gem5 Developers } 55010037SARM gem5 Developers case MISCREG_SP_EL1: 55110037SARM gem5 Developers { 55210037SARM gem5 Developers return tc->readIntReg(INTREG_SP1); 55310037SARM gem5 Developers } 55410037SARM gem5 Developers case MISCREG_SP_EL2: 55510037SARM gem5 Developers { 55610037SARM gem5 Developers return tc->readIntReg(INTREG_SP2); 55710037SARM gem5 Developers } 55810037SARM gem5 Developers case MISCREG_SPSEL: 55910037SARM gem5 Developers { 56010037SARM gem5 Developers return miscRegs[MISCREG_CPSR] & 0x1; 56110037SARM gem5 Developers } 56210037SARM gem5 Developers case MISCREG_CURRENTEL: 56310037SARM gem5 Developers { 56410037SARM gem5 Developers return miscRegs[MISCREG_CPSR] & 0xc; 56510037SARM gem5 Developers } 5668549Sdaniel.johnson@arm.com case MISCREG_L2CTLR: 5678868SMatt.Horsnell@arm.com { 5688868SMatt.Horsnell@arm.com // mostly unimplemented, just set NumCPUs field from sim and return 5698868SMatt.Horsnell@arm.com L2CTLR l2ctlr = 0; 5708868SMatt.Horsnell@arm.com // b00:1CPU to b11:4CPUs 5718868SMatt.Horsnell@arm.com l2ctlr.numCPUs = tc->getSystemPtr()->numContexts() - 1; 5728868SMatt.Horsnell@arm.com return l2ctlr; 5738868SMatt.Horsnell@arm.com } 5748868SMatt.Horsnell@arm.com case MISCREG_DBGDIDR: 5758868SMatt.Horsnell@arm.com /* For now just implement the version number. 57610461SAndreas.Sandberg@ARM.com * ARMv7, v7.1 Debug architecture (0b0101 --> 0x5) 5778868SMatt.Horsnell@arm.com */ 57810461SAndreas.Sandberg@ARM.com return 0x5 << 16; 57910037SARM gem5 Developers case MISCREG_DBGDSCRint: 5808868SMatt.Horsnell@arm.com return 0; 58110037SARM gem5 Developers case MISCREG_ISR: 58211150Smitch.hayenga@arm.com return tc->getCpuPtr()->getInterruptController(tc->threadId())->getISR( 58310037SARM gem5 Developers readMiscRegNoEffect(MISCREG_HCR), 58410037SARM gem5 Developers readMiscRegNoEffect(MISCREG_CPSR), 58510037SARM gem5 Developers readMiscRegNoEffect(MISCREG_SCR)); 58610037SARM gem5 Developers case MISCREG_ISR_EL1: 58711150Smitch.hayenga@arm.com return tc->getCpuPtr()->getInterruptController(tc->threadId())->getISR( 58810037SARM gem5 Developers readMiscRegNoEffect(MISCREG_HCR_EL2), 58910037SARM gem5 Developers readMiscRegNoEffect(MISCREG_CPSR), 59010037SARM gem5 Developers readMiscRegNoEffect(MISCREG_SCR_EL3)); 59110037SARM gem5 Developers case MISCREG_DCZID_EL0: 59210037SARM gem5 Developers return 0x04; // DC ZVA clear 64-byte chunks 59310037SARM gem5 Developers case MISCREG_HCPTR: 59410037SARM gem5 Developers { 59510037SARM gem5 Developers MiscReg val = readMiscRegNoEffect(misc_reg); 59610037SARM gem5 Developers // The trap bit associated with CP14 is defined as RAZ 59710037SARM gem5 Developers val &= ~(1 << 14); 59810037SARM gem5 Developers // If a CP bit in NSACR is 0 then the corresponding bit in 59910037SARM gem5 Developers // HCPTR is RAO/WI 60010037SARM gem5 Developers bool secure_lookup = haveSecurity && 60110037SARM gem5 Developers inSecureState(readMiscRegNoEffect(MISCREG_SCR), 60210037SARM gem5 Developers readMiscRegNoEffect(MISCREG_CPSR)); 60310037SARM gem5 Developers if (!secure_lookup) { 60410037SARM gem5 Developers MiscReg mask = readMiscRegNoEffect(MISCREG_NSACR); 60510037SARM gem5 Developers val |= (mask ^ 0x7FFF) & 0xBFFF; 60610037SARM gem5 Developers } 60710037SARM gem5 Developers // Set the bits for unimplemented coprocessors to RAO/WI 60810037SARM gem5 Developers val |= 0x33FF; 60910037SARM gem5 Developers return (val); 61010037SARM gem5 Developers } 61110037SARM gem5 Developers case MISCREG_HDFAR: // alias for secure DFAR 61210037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_DFAR_S); 61310037SARM gem5 Developers case MISCREG_HIFAR: // alias for secure IFAR 61410037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_IFAR_S); 61510037SARM gem5 Developers case MISCREG_HVBAR: // bottom bits reserved 61610037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_HVBAR) & 0xFFFFFFE0; 61711769SCurtis.Dunham@arm.com case MISCREG_SCTLR: 61811769SCurtis.Dunham@arm.com return (readMiscRegNoEffect(misc_reg) & 0x72DD39FF) | 0x00C00818; 61910037SARM gem5 Developers case MISCREG_SCTLR_EL1: 62011770SCurtis.Dunham@arm.com return (readMiscRegNoEffect(misc_reg) & 0x37DDDBBF) | 0x30D00800; 62111770SCurtis.Dunham@arm.com case MISCREG_SCTLR_EL2: 62210037SARM gem5 Developers case MISCREG_SCTLR_EL3: 62311770SCurtis.Dunham@arm.com case MISCREG_HSCTLR: 62411769SCurtis.Dunham@arm.com return (readMiscRegNoEffect(misc_reg) & 0x32CD183F) | 0x30C50830; 62510844Sandreas.sandberg@arm.com 62611772SCurtis.Dunham@arm.com case MISCREG_ID_PFR0: 62711772SCurtis.Dunham@arm.com // !ThumbEE | !Jazelle | Thumb | ARM 62811772SCurtis.Dunham@arm.com return 0x00000031; 62911772SCurtis.Dunham@arm.com case MISCREG_ID_PFR1: 63011774SCurtis.Dunham@arm.com { // Timer | Virti | !M Profile | TrustZone | ARMv4 63111774SCurtis.Dunham@arm.com bool haveTimer = (system->getGenericTimer() != NULL); 63211774SCurtis.Dunham@arm.com return 0x00000001 63311774SCurtis.Dunham@arm.com | (haveSecurity ? 0x00000010 : 0x0) 63411774SCurtis.Dunham@arm.com | (haveVirtualization ? 0x00001000 : 0x0) 63511774SCurtis.Dunham@arm.com | (haveTimer ? 0x00010000 : 0x0); 63611774SCurtis.Dunham@arm.com } 63711773SCurtis.Dunham@arm.com case MISCREG_ID_AA64PFR0_EL1: 63811773SCurtis.Dunham@arm.com return 0x0000000000000002 // AArch{64,32} supported at EL0 63911773SCurtis.Dunham@arm.com | 0x0000000000000020 // EL1 64011773SCurtis.Dunham@arm.com | (haveVirtualization ? 0x0000000000000200 : 0) // EL2 64111773SCurtis.Dunham@arm.com | (haveSecurity ? 0x0000000000002000 : 0); // EL3 64211773SCurtis.Dunham@arm.com case MISCREG_ID_AA64PFR1_EL1: 64311773SCurtis.Dunham@arm.com return 0; // bits [63:0] RES0 (reserved for future use) 64411772SCurtis.Dunham@arm.com 64510037SARM gem5 Developers // Generic Timer registers 64610844Sandreas.sandberg@arm.com case MISCREG_CNTFRQ ... MISCREG_CNTHP_CTL: 64710844Sandreas.sandberg@arm.com case MISCREG_CNTPCT ... MISCREG_CNTHP_CVAL: 64810844Sandreas.sandberg@arm.com case MISCREG_CNTKCTL_EL1 ... MISCREG_CNTV_CVAL_EL0: 64910844Sandreas.sandberg@arm.com case MISCREG_CNTVOFF_EL2 ... MISCREG_CNTPS_CVAL_EL1: 65010844Sandreas.sandberg@arm.com return getGenericTimer(tc).readMiscReg(misc_reg); 65110844Sandreas.sandberg@arm.com 65210188Sgeoffrey.blake@arm.com default: 65310037SARM gem5 Developers break; 65410037SARM gem5 Developers 6557405SAli.Saidi@ARM.com } 6567405SAli.Saidi@ARM.com return readMiscRegNoEffect(misc_reg); 6577405SAli.Saidi@ARM.com} 6587405SAli.Saidi@ARM.com 6597405SAli.Saidi@ARM.comvoid 6607405SAli.Saidi@ARM.comISA::setMiscRegNoEffect(int misc_reg, const MiscReg &val) 6617405SAli.Saidi@ARM.com{ 6627405SAli.Saidi@ARM.com assert(misc_reg < NumMiscRegs); 6637614Sminkyu.jeong@arm.com 66412478SCurtis.Dunham@arm.com const auto ® = lookUpMiscReg[misc_reg]; // bit masks 66512478SCurtis.Dunham@arm.com const auto &map = getMiscIndices(misc_reg); 66612478SCurtis.Dunham@arm.com int lower = map.first, upper = map.second; 66712478SCurtis.Dunham@arm.com 66812478SCurtis.Dunham@arm.com auto v = (val & ~reg.wi()) | reg.rao(); 66911771SCurtis.Dunham@arm.com if (upper > 0) { 67012478SCurtis.Dunham@arm.com miscRegs[lower] = bits(v, 31, 0); 67112478SCurtis.Dunham@arm.com miscRegs[upper] = bits(v, 63, 32); 67210037SARM gem5 Developers DPRINTF(MiscRegs, "Writing to misc reg %d (%d:%d) : %#x\n", 67312478SCurtis.Dunham@arm.com misc_reg, lower, upper, v); 67410037SARM gem5 Developers } else { 67512478SCurtis.Dunham@arm.com miscRegs[lower] = v; 67610037SARM gem5 Developers DPRINTF(MiscRegs, "Writing to misc reg %d (%d) : %#x\n", 67712478SCurtis.Dunham@arm.com misc_reg, lower, v); 67810037SARM gem5 Developers } 6797405SAli.Saidi@ARM.com} 6807405SAli.Saidi@ARM.com 6817405SAli.Saidi@ARM.comvoid 6827405SAli.Saidi@ARM.comISA::setMiscReg(int misc_reg, const MiscReg &val, ThreadContext *tc) 6837405SAli.Saidi@ARM.com{ 6847749SAli.Saidi@ARM.com 6857405SAli.Saidi@ARM.com MiscReg newVal = val; 68610037SARM gem5 Developers bool secure_lookup; 68710037SARM gem5 Developers SCR scr; 6888284SAli.Saidi@ARM.com 6897405SAli.Saidi@ARM.com if (misc_reg == MISCREG_CPSR) { 6907405SAli.Saidi@ARM.com updateRegMap(val); 6917749SAli.Saidi@ARM.com 6927749SAli.Saidi@ARM.com 6937749SAli.Saidi@ARM.com CPSR old_cpsr = miscRegs[MISCREG_CPSR]; 6947749SAli.Saidi@ARM.com int old_mode = old_cpsr.mode; 6957405SAli.Saidi@ARM.com CPSR cpsr = val; 69612510Sgiacomo.travaglini@arm.com if (old_mode != cpsr.mode || cpsr.il != old_cpsr.il) { 69712406Sgabeblack@google.com getITBPtr(tc)->invalidateMiscReg(); 69812406Sgabeblack@google.com getDTBPtr(tc)->invalidateMiscReg(); 6997749SAli.Saidi@ARM.com } 7007749SAli.Saidi@ARM.com 7017614Sminkyu.jeong@arm.com DPRINTF(Arm, "Updating CPSR from %#x to %#x f:%d i:%d a:%d mode:%#x\n", 7027614Sminkyu.jeong@arm.com miscRegs[misc_reg], cpsr, cpsr.f, cpsr.i, cpsr.a, cpsr.mode); 7037720Sgblack@eecs.umich.edu PCState pc = tc->pcState(); 7047720Sgblack@eecs.umich.edu pc.nextThumb(cpsr.t); 7057720Sgblack@eecs.umich.edu pc.nextJazelle(cpsr.j); 7068887Sgeoffrey.blake@arm.com 7078887Sgeoffrey.blake@arm.com // Follow slightly different semantics if a CheckerCPU object 7088887Sgeoffrey.blake@arm.com // is connected 7098887Sgeoffrey.blake@arm.com CheckerCPU *checker = tc->getCheckerCpuPtr(); 7108887Sgeoffrey.blake@arm.com if (checker) { 7118887Sgeoffrey.blake@arm.com tc->pcStateNoRecord(pc); 7128887Sgeoffrey.blake@arm.com } else { 7138887Sgeoffrey.blake@arm.com tc->pcState(pc); 7148887Sgeoffrey.blake@arm.com } 7157408Sgblack@eecs.umich.edu } else { 71610037SARM gem5 Developers#ifndef NDEBUG 71710037SARM gem5 Developers if (!miscRegInfo[misc_reg][MISCREG_IMPLEMENTED]) { 71810037SARM gem5 Developers if (miscRegInfo[misc_reg][MISCREG_WARN_NOT_FAIL]) 71910037SARM gem5 Developers warn("Unimplemented system register %s write with %#x.\n", 72010037SARM gem5 Developers miscRegName[misc_reg], val); 72110037SARM gem5 Developers else 72210037SARM gem5 Developers panic("Unimplemented system register %s write with %#x.\n", 72310037SARM gem5 Developers miscRegName[misc_reg], val); 72410037SARM gem5 Developers } 72510037SARM gem5 Developers#endif 72610037SARM gem5 Developers switch (unflattenMiscReg(misc_reg)) { 7277408Sgblack@eecs.umich.edu case MISCREG_CPACR: 7287408Sgblack@eecs.umich.edu { 7298206SWilliam.Wang@arm.com 7308206SWilliam.Wang@arm.com const uint32_t ones = (uint32_t)(-1); 7318206SWilliam.Wang@arm.com CPACR cpacrMask = 0; 7328206SWilliam.Wang@arm.com // Only cp10, cp11, and ase are implemented, nothing else should 7338206SWilliam.Wang@arm.com // be writable 7348206SWilliam.Wang@arm.com cpacrMask.cp10 = ones; 7358206SWilliam.Wang@arm.com cpacrMask.cp11 = ones; 7368206SWilliam.Wang@arm.com cpacrMask.asedis = ones; 73710037SARM gem5 Developers 73810037SARM gem5 Developers // Security Extensions may limit the writability of CPACR 73910037SARM gem5 Developers if (haveSecurity) { 74010037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 74110037SARM gem5 Developers CPSR cpsr = readMiscRegNoEffect(MISCREG_CPSR); 74212667Schuan.zhu@arm.com if (scr.ns && (cpsr.mode != MODE_MON) && ELIs32(tc, EL3)) { 74310037SARM gem5 Developers NSACR nsacr = readMiscRegNoEffect(MISCREG_NSACR); 74410037SARM gem5 Developers // NB: Skipping the full loop, here 74510037SARM gem5 Developers if (!nsacr.cp10) cpacrMask.cp10 = 0; 74610037SARM gem5 Developers if (!nsacr.cp11) cpacrMask.cp11 = 0; 74710037SARM gem5 Developers } 74810037SARM gem5 Developers } 74910037SARM gem5 Developers 75010037SARM gem5 Developers MiscReg old_val = readMiscRegNoEffect(MISCREG_CPACR); 7518206SWilliam.Wang@arm.com newVal &= cpacrMask; 75210037SARM gem5 Developers newVal |= old_val & ~cpacrMask; 75310037SARM gem5 Developers DPRINTF(MiscRegs, "Writing misc reg %s: %#x\n", 75410037SARM gem5 Developers miscRegName[misc_reg], newVal); 75510037SARM gem5 Developers } 75610037SARM gem5 Developers break; 75710037SARM gem5 Developers case MISCREG_CPTR_EL2: 75810037SARM gem5 Developers { 75910037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 76010037SARM gem5 Developers CPTR cptrMask = 0; 76110037SARM gem5 Developers cptrMask.tcpac = ones; 76210037SARM gem5 Developers cptrMask.tta = ones; 76310037SARM gem5 Developers cptrMask.tfp = ones; 76410037SARM gem5 Developers newVal &= cptrMask; 76510037SARM gem5 Developers cptrMask = 0; 76610037SARM gem5 Developers cptrMask.res1_13_12_el2 = ones; 76710037SARM gem5 Developers cptrMask.res1_9_0_el2 = ones; 76810037SARM gem5 Developers newVal |= cptrMask; 76910037SARM gem5 Developers DPRINTF(MiscRegs, "Writing misc reg %s: %#x\n", 77010037SARM gem5 Developers miscRegName[misc_reg], newVal); 77110037SARM gem5 Developers } 77210037SARM gem5 Developers break; 77310037SARM gem5 Developers case MISCREG_CPTR_EL3: 77410037SARM gem5 Developers { 77510037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 77610037SARM gem5 Developers CPTR cptrMask = 0; 77710037SARM gem5 Developers cptrMask.tcpac = ones; 77810037SARM gem5 Developers cptrMask.tta = ones; 77910037SARM gem5 Developers cptrMask.tfp = ones; 78010037SARM gem5 Developers newVal &= cptrMask; 7818206SWilliam.Wang@arm.com DPRINTF(MiscRegs, "Writing misc reg %s: %#x\n", 7828206SWilliam.Wang@arm.com miscRegName[misc_reg], newVal); 7837408Sgblack@eecs.umich.edu } 7847408Sgblack@eecs.umich.edu break; 7857408Sgblack@eecs.umich.edu case MISCREG_CSSELR: 7867731SAli.Saidi@ARM.com warn_once("The csselr register isn't implemented.\n"); 7878206SWilliam.Wang@arm.com return; 78810037SARM gem5 Developers 78910037SARM gem5 Developers case MISCREG_DC_ZVA_Xt: 79010037SARM gem5 Developers warn("Calling DC ZVA! Not Implemeted! Expect WEIRD results\n"); 79110037SARM gem5 Developers return; 79210037SARM gem5 Developers 7937408Sgblack@eecs.umich.edu case MISCREG_FPSCR: 7947408Sgblack@eecs.umich.edu { 7957408Sgblack@eecs.umich.edu const uint32_t ones = (uint32_t)(-1); 7967408Sgblack@eecs.umich.edu FPSCR fpscrMask = 0; 7977408Sgblack@eecs.umich.edu fpscrMask.ioc = ones; 7987408Sgblack@eecs.umich.edu fpscrMask.dzc = ones; 7997408Sgblack@eecs.umich.edu fpscrMask.ofc = ones; 8007408Sgblack@eecs.umich.edu fpscrMask.ufc = ones; 8017408Sgblack@eecs.umich.edu fpscrMask.ixc = ones; 8027408Sgblack@eecs.umich.edu fpscrMask.idc = ones; 80310037SARM gem5 Developers fpscrMask.ioe = ones; 80410037SARM gem5 Developers fpscrMask.dze = ones; 80510037SARM gem5 Developers fpscrMask.ofe = ones; 80610037SARM gem5 Developers fpscrMask.ufe = ones; 80710037SARM gem5 Developers fpscrMask.ixe = ones; 80810037SARM gem5 Developers fpscrMask.ide = ones; 8097408Sgblack@eecs.umich.edu fpscrMask.len = ones; 8107408Sgblack@eecs.umich.edu fpscrMask.stride = ones; 8117408Sgblack@eecs.umich.edu fpscrMask.rMode = ones; 8127408Sgblack@eecs.umich.edu fpscrMask.fz = ones; 8137408Sgblack@eecs.umich.edu fpscrMask.dn = ones; 8147408Sgblack@eecs.umich.edu fpscrMask.ahp = ones; 8157408Sgblack@eecs.umich.edu fpscrMask.qc = ones; 8167408Sgblack@eecs.umich.edu fpscrMask.v = ones; 8177408Sgblack@eecs.umich.edu fpscrMask.c = ones; 8187408Sgblack@eecs.umich.edu fpscrMask.z = ones; 8197408Sgblack@eecs.umich.edu fpscrMask.n = ones; 8207408Sgblack@eecs.umich.edu newVal = (newVal & (uint32_t)fpscrMask) | 82110037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_FPSCR) & 82210037SARM gem5 Developers ~(uint32_t)fpscrMask); 8239377Sgblack@eecs.umich.edu tc->getDecoderPtr()->setContext(newVal); 8247408Sgblack@eecs.umich.edu } 8257408Sgblack@eecs.umich.edu break; 82610037SARM gem5 Developers case MISCREG_FPSR: 82710037SARM gem5 Developers { 82810037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 82910037SARM gem5 Developers FPSCR fpscrMask = 0; 83010037SARM gem5 Developers fpscrMask.ioc = ones; 83110037SARM gem5 Developers fpscrMask.dzc = ones; 83210037SARM gem5 Developers fpscrMask.ofc = ones; 83310037SARM gem5 Developers fpscrMask.ufc = ones; 83410037SARM gem5 Developers fpscrMask.ixc = ones; 83510037SARM gem5 Developers fpscrMask.idc = ones; 83610037SARM gem5 Developers fpscrMask.qc = ones; 83710037SARM gem5 Developers fpscrMask.v = ones; 83810037SARM gem5 Developers fpscrMask.c = ones; 83910037SARM gem5 Developers fpscrMask.z = ones; 84010037SARM gem5 Developers fpscrMask.n = ones; 84110037SARM gem5 Developers newVal = (newVal & (uint32_t)fpscrMask) | 84210037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_FPSCR) & 84310037SARM gem5 Developers ~(uint32_t)fpscrMask); 84410037SARM gem5 Developers misc_reg = MISCREG_FPSCR; 84510037SARM gem5 Developers } 84610037SARM gem5 Developers break; 84710037SARM gem5 Developers case MISCREG_FPCR: 84810037SARM gem5 Developers { 84910037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 85010037SARM gem5 Developers FPSCR fpscrMask = 0; 85110037SARM gem5 Developers fpscrMask.len = ones; 85210037SARM gem5 Developers fpscrMask.stride = ones; 85310037SARM gem5 Developers fpscrMask.rMode = ones; 85410037SARM gem5 Developers fpscrMask.fz = ones; 85510037SARM gem5 Developers fpscrMask.dn = ones; 85610037SARM gem5 Developers fpscrMask.ahp = ones; 85710037SARM gem5 Developers newVal = (newVal & (uint32_t)fpscrMask) | 85810037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_FPSCR) & 85910037SARM gem5 Developers ~(uint32_t)fpscrMask); 86010037SARM gem5 Developers misc_reg = MISCREG_FPSCR; 86110037SARM gem5 Developers } 86210037SARM gem5 Developers break; 8638302SAli.Saidi@ARM.com case MISCREG_CPSR_Q: 8648302SAli.Saidi@ARM.com { 8658302SAli.Saidi@ARM.com assert(!(newVal & ~CpsrMaskQ)); 86610037SARM gem5 Developers newVal = readMiscRegNoEffect(MISCREG_CPSR) | newVal; 8678302SAli.Saidi@ARM.com misc_reg = MISCREG_CPSR; 8688302SAli.Saidi@ARM.com } 8698302SAli.Saidi@ARM.com break; 8707783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_QC: 8717783SGiacomo.Gabrielli@arm.com { 87210037SARM gem5 Developers newVal = readMiscRegNoEffect(MISCREG_FPSCR) | 87310037SARM gem5 Developers (newVal & FpscrQcMask); 8747783SGiacomo.Gabrielli@arm.com misc_reg = MISCREG_FPSCR; 8757783SGiacomo.Gabrielli@arm.com } 8767783SGiacomo.Gabrielli@arm.com break; 8777783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_EXC: 8787783SGiacomo.Gabrielli@arm.com { 87910037SARM gem5 Developers newVal = readMiscRegNoEffect(MISCREG_FPSCR) | 88010037SARM gem5 Developers (newVal & FpscrExcMask); 8817783SGiacomo.Gabrielli@arm.com misc_reg = MISCREG_FPSCR; 8827783SGiacomo.Gabrielli@arm.com } 8837783SGiacomo.Gabrielli@arm.com break; 8847408Sgblack@eecs.umich.edu case MISCREG_FPEXC: 8857408Sgblack@eecs.umich.edu { 8868206SWilliam.Wang@arm.com // vfpv3 architecture, section B.6.1 of DDI04068 8878206SWilliam.Wang@arm.com // bit 29 - valid only if fpexc[31] is 0 8887408Sgblack@eecs.umich.edu const uint32_t fpexcMask = 0x60000000; 8897408Sgblack@eecs.umich.edu newVal = (newVal & fpexcMask) | 89010037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_FPEXC) & ~fpexcMask); 8917408Sgblack@eecs.umich.edu } 8927408Sgblack@eecs.umich.edu break; 89310037SARM gem5 Developers case MISCREG_HCR: 89410037SARM gem5 Developers { 89510037SARM gem5 Developers if (!haveVirtualization) 89610037SARM gem5 Developers return; 89710037SARM gem5 Developers } 89810037SARM gem5 Developers break; 89910037SARM gem5 Developers case MISCREG_IFSR: 90010037SARM gem5 Developers { 90110037SARM gem5 Developers // ARM ARM (ARM DDI 0406C.b) B4.1.96 90210037SARM gem5 Developers const uint32_t ifsrMask = 90310037SARM gem5 Developers mask(31, 13) | mask(11, 11) | mask(8, 6); 90410037SARM gem5 Developers newVal = newVal & ~ifsrMask; 90510037SARM gem5 Developers } 90610037SARM gem5 Developers break; 90710037SARM gem5 Developers case MISCREG_DFSR: 90810037SARM gem5 Developers { 90910037SARM gem5 Developers // ARM ARM (ARM DDI 0406C.b) B4.1.52 91010037SARM gem5 Developers const uint32_t dfsrMask = mask(31, 14) | mask(8, 8); 91110037SARM gem5 Developers newVal = newVal & ~dfsrMask; 91210037SARM gem5 Developers } 91310037SARM gem5 Developers break; 91410037SARM gem5 Developers case MISCREG_AMAIR0: 91510037SARM gem5 Developers case MISCREG_AMAIR1: 91610037SARM gem5 Developers { 91710037SARM gem5 Developers // ARM ARM (ARM DDI 0406C.b) B4.1.5 91810037SARM gem5 Developers // Valid only with LPAE 91910037SARM gem5 Developers if (!haveLPAE) 92010037SARM gem5 Developers return; 92110037SARM gem5 Developers DPRINTF(MiscRegs, "Writing AMAIR: %#x\n", newVal); 92210037SARM gem5 Developers } 92310037SARM gem5 Developers break; 92410037SARM gem5 Developers case MISCREG_SCR: 92512406Sgabeblack@google.com getITBPtr(tc)->invalidateMiscReg(); 92612406Sgabeblack@google.com getDTBPtr(tc)->invalidateMiscReg(); 92710037SARM gem5 Developers break; 9287408Sgblack@eecs.umich.edu case MISCREG_SCTLR: 9297408Sgblack@eecs.umich.edu { 9307408Sgblack@eecs.umich.edu DPRINTF(MiscRegs, "Writing SCTLR: %#x\n", newVal); 93110037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 93212639Sgiacomo.travaglini@arm.com 93312639Sgiacomo.travaglini@arm.com MiscRegIndex sctlr_idx; 93412639Sgiacomo.travaglini@arm.com if (haveSecurity && !highestELIs64 && !scr.ns) { 93512639Sgiacomo.travaglini@arm.com sctlr_idx = MISCREG_SCTLR_S; 93612639Sgiacomo.travaglini@arm.com } else { 93712639Sgiacomo.travaglini@arm.com sctlr_idx = MISCREG_SCTLR_NS; 93812639Sgiacomo.travaglini@arm.com } 93912639Sgiacomo.travaglini@arm.com 94010037SARM gem5 Developers SCTLR sctlr = miscRegs[sctlr_idx]; 9417408Sgblack@eecs.umich.edu SCTLR new_sctlr = newVal; 94210037SARM gem5 Developers new_sctlr.nmfi = ((bool)sctlr.nmfi) && !haveVirtualization; 94310037SARM gem5 Developers miscRegs[sctlr_idx] = (MiscReg)new_sctlr; 94412406Sgabeblack@google.com getITBPtr(tc)->invalidateMiscReg(); 94512406Sgabeblack@google.com getDTBPtr(tc)->invalidateMiscReg(); 9467408Sgblack@eecs.umich.edu } 9479385SAndreas.Sandberg@arm.com case MISCREG_MIDR: 9489385SAndreas.Sandberg@arm.com case MISCREG_ID_PFR0: 9499385SAndreas.Sandberg@arm.com case MISCREG_ID_PFR1: 95010461SAndreas.Sandberg@ARM.com case MISCREG_ID_DFR0: 9519385SAndreas.Sandberg@arm.com case MISCREG_ID_MMFR0: 9529385SAndreas.Sandberg@arm.com case MISCREG_ID_MMFR1: 9539385SAndreas.Sandberg@arm.com case MISCREG_ID_MMFR2: 9549385SAndreas.Sandberg@arm.com case MISCREG_ID_MMFR3: 9559385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR0: 9569385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR1: 9579385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR2: 9589385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR3: 9599385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR4: 9609385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR5: 9619385SAndreas.Sandberg@arm.com 9629385SAndreas.Sandberg@arm.com case MISCREG_MPIDR: 9639385SAndreas.Sandberg@arm.com case MISCREG_FPSID: 9647408Sgblack@eecs.umich.edu case MISCREG_TLBTR: 9657408Sgblack@eecs.umich.edu case MISCREG_MVFR0: 9667408Sgblack@eecs.umich.edu case MISCREG_MVFR1: 96710037SARM gem5 Developers 96810037SARM gem5 Developers case MISCREG_ID_AA64AFR0_EL1: 96910037SARM gem5 Developers case MISCREG_ID_AA64AFR1_EL1: 97010037SARM gem5 Developers case MISCREG_ID_AA64DFR0_EL1: 97110037SARM gem5 Developers case MISCREG_ID_AA64DFR1_EL1: 97210037SARM gem5 Developers case MISCREG_ID_AA64ISAR0_EL1: 97310037SARM gem5 Developers case MISCREG_ID_AA64ISAR1_EL1: 97410037SARM gem5 Developers case MISCREG_ID_AA64MMFR0_EL1: 97510037SARM gem5 Developers case MISCREG_ID_AA64MMFR1_EL1: 97610037SARM gem5 Developers case MISCREG_ID_AA64PFR0_EL1: 97710037SARM gem5 Developers case MISCREG_ID_AA64PFR1_EL1: 9789385SAndreas.Sandberg@arm.com // ID registers are constants. 9797408Sgblack@eecs.umich.edu return; 9809385SAndreas.Sandberg@arm.com 98112605Sgiacomo.travaglini@arm.com // TLB Invalidate All 98212605Sgiacomo.travaglini@arm.com case MISCREG_TLBIALL: // TLBI all entries, EL0&1, 98312605Sgiacomo.travaglini@arm.com { 98412605Sgiacomo.travaglini@arm.com assert32(tc); 98512605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 98612605Sgiacomo.travaglini@arm.com 98712605Sgiacomo.travaglini@arm.com TLBIALL tlbiOp(EL1, haveSecurity && !scr.ns); 98812605Sgiacomo.travaglini@arm.com tlbiOp(tc); 98912605Sgiacomo.travaglini@arm.com return; 99012605Sgiacomo.travaglini@arm.com } 99112605Sgiacomo.travaglini@arm.com // TLB Invalidate All, Inner Shareable 9927408Sgblack@eecs.umich.edu case MISCREG_TLBIALLIS: 99312605Sgiacomo.travaglini@arm.com { 99412605Sgiacomo.travaglini@arm.com assert32(tc); 99512605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 99612605Sgiacomo.travaglini@arm.com 99712605Sgiacomo.travaglini@arm.com TLBIALL tlbiOp(EL1, haveSecurity && !scr.ns); 99812605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 99912605Sgiacomo.travaglini@arm.com return; 100012605Sgiacomo.travaglini@arm.com } 100112605Sgiacomo.travaglini@arm.com // Instruction TLB Invalidate All 10027408Sgblack@eecs.umich.edu case MISCREG_ITLBIALL: 100312605Sgiacomo.travaglini@arm.com { 100412605Sgiacomo.travaglini@arm.com assert32(tc); 100512605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 100612605Sgiacomo.travaglini@arm.com 100712605Sgiacomo.travaglini@arm.com ITLBIALL tlbiOp(EL1, haveSecurity && !scr.ns); 100812605Sgiacomo.travaglini@arm.com tlbiOp(tc); 100912605Sgiacomo.travaglini@arm.com return; 101012605Sgiacomo.travaglini@arm.com } 101112605Sgiacomo.travaglini@arm.com // Data TLB Invalidate All 10127408Sgblack@eecs.umich.edu case MISCREG_DTLBIALL: 101312605Sgiacomo.travaglini@arm.com { 101412605Sgiacomo.travaglini@arm.com assert32(tc); 101512605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 101612605Sgiacomo.travaglini@arm.com 101712605Sgiacomo.travaglini@arm.com DTLBIALL tlbiOp(EL1, haveSecurity && !scr.ns); 101812605Sgiacomo.travaglini@arm.com tlbiOp(tc); 101912605Sgiacomo.travaglini@arm.com return; 102012605Sgiacomo.travaglini@arm.com } 102112605Sgiacomo.travaglini@arm.com // TLB Invalidate by VA 102212605Sgiacomo.travaglini@arm.com // mcr tlbimval(is) is invalidating all matching entries 102312605Sgiacomo.travaglini@arm.com // regardless of the level of lookup, since in gem5 we cache 102412605Sgiacomo.travaglini@arm.com // in the tlb the last level of lookup only. 102512605Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVA: 102612576Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVAL: 102712605Sgiacomo.travaglini@arm.com { 102812605Sgiacomo.travaglini@arm.com assert32(tc); 102912605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 103012605Sgiacomo.travaglini@arm.com 103112605Sgiacomo.travaglini@arm.com TLBIMVA tlbiOp(EL1, 103212605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 103312605Sgiacomo.travaglini@arm.com mbits(newVal, 31, 12), 103412605Sgiacomo.travaglini@arm.com bits(newVal, 7,0)); 103512605Sgiacomo.travaglini@arm.com 103612605Sgiacomo.travaglini@arm.com tlbiOp(tc); 103712605Sgiacomo.travaglini@arm.com return; 103812605Sgiacomo.travaglini@arm.com } 103912605Sgiacomo.travaglini@arm.com // TLB Invalidate by VA, Inner Shareable 104012605Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVAIS: 104112576Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVALIS: 104212605Sgiacomo.travaglini@arm.com { 104312605Sgiacomo.travaglini@arm.com assert32(tc); 104412605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 104512605Sgiacomo.travaglini@arm.com 104612605Sgiacomo.travaglini@arm.com TLBIMVA tlbiOp(EL1, 104712605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 104812605Sgiacomo.travaglini@arm.com mbits(newVal, 31, 12), 104912605Sgiacomo.travaglini@arm.com bits(newVal, 7,0)); 105012605Sgiacomo.travaglini@arm.com 105112605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 105212605Sgiacomo.travaglini@arm.com return; 105312605Sgiacomo.travaglini@arm.com } 105412605Sgiacomo.travaglini@arm.com // TLB Invalidate by ASID match 105512605Sgiacomo.travaglini@arm.com case MISCREG_TLBIASID: 105612605Sgiacomo.travaglini@arm.com { 105712605Sgiacomo.travaglini@arm.com assert32(tc); 105812605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 105912605Sgiacomo.travaglini@arm.com 106012605Sgiacomo.travaglini@arm.com TLBIASID tlbiOp(EL1, 106112605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 106212605Sgiacomo.travaglini@arm.com bits(newVal, 7,0)); 106312605Sgiacomo.travaglini@arm.com 106412605Sgiacomo.travaglini@arm.com tlbiOp(tc); 106512605Sgiacomo.travaglini@arm.com return; 106612605Sgiacomo.travaglini@arm.com } 106712605Sgiacomo.travaglini@arm.com // TLB Invalidate by ASID match, Inner Shareable 10687408Sgblack@eecs.umich.edu case MISCREG_TLBIASIDIS: 106912605Sgiacomo.travaglini@arm.com { 107012605Sgiacomo.travaglini@arm.com assert32(tc); 107112605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 107212605Sgiacomo.travaglini@arm.com 107312605Sgiacomo.travaglini@arm.com TLBIASID tlbiOp(EL1, 107412605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 107512605Sgiacomo.travaglini@arm.com bits(newVal, 7,0)); 107612605Sgiacomo.travaglini@arm.com 107712605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 107812605Sgiacomo.travaglini@arm.com return; 107912605Sgiacomo.travaglini@arm.com } 108012605Sgiacomo.travaglini@arm.com // mcr tlbimvaal(is) is invalidating all matching entries 108112605Sgiacomo.travaglini@arm.com // regardless of the level of lookup, since in gem5 we cache 108212605Sgiacomo.travaglini@arm.com // in the tlb the last level of lookup only. 108312605Sgiacomo.travaglini@arm.com // TLB Invalidate by VA, All ASID 108412605Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVAA: 108512576Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVAAL: 108612605Sgiacomo.travaglini@arm.com { 108712605Sgiacomo.travaglini@arm.com assert32(tc); 108812605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 108912605Sgiacomo.travaglini@arm.com 109012605Sgiacomo.travaglini@arm.com TLBIMVAA tlbiOp(EL1, haveSecurity && !scr.ns, 109112605Sgiacomo.travaglini@arm.com mbits(newVal, 31,12), false); 109212605Sgiacomo.travaglini@arm.com 109312605Sgiacomo.travaglini@arm.com tlbiOp(tc); 109412605Sgiacomo.travaglini@arm.com return; 109512605Sgiacomo.travaglini@arm.com } 109612605Sgiacomo.travaglini@arm.com // TLB Invalidate by VA, All ASID, Inner Shareable 109712605Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVAAIS: 109812576Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVAALIS: 109912605Sgiacomo.travaglini@arm.com { 110012605Sgiacomo.travaglini@arm.com assert32(tc); 110112605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 110212605Sgiacomo.travaglini@arm.com 110312605Sgiacomo.travaglini@arm.com TLBIMVAA tlbiOp(EL1, haveSecurity && !scr.ns, 110412605Sgiacomo.travaglini@arm.com mbits(newVal, 31,12), false); 110512605Sgiacomo.travaglini@arm.com 110612605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 110712605Sgiacomo.travaglini@arm.com return; 110812605Sgiacomo.travaglini@arm.com } 110912605Sgiacomo.travaglini@arm.com // mcr tlbimvalh(is) is invalidating all matching entries 111012605Sgiacomo.travaglini@arm.com // regardless of the level of lookup, since in gem5 we cache 111112605Sgiacomo.travaglini@arm.com // in the tlb the last level of lookup only. 111212605Sgiacomo.travaglini@arm.com // TLB Invalidate by VA, Hyp mode 111312605Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVAH: 111412576Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVALH: 111512605Sgiacomo.travaglini@arm.com { 111612605Sgiacomo.travaglini@arm.com assert32(tc); 111712605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 111812605Sgiacomo.travaglini@arm.com 111912605Sgiacomo.travaglini@arm.com TLBIMVAA tlbiOp(EL1, haveSecurity && !scr.ns, 112012605Sgiacomo.travaglini@arm.com mbits(newVal, 31,12), true); 112112605Sgiacomo.travaglini@arm.com 112212605Sgiacomo.travaglini@arm.com tlbiOp(tc); 112312605Sgiacomo.travaglini@arm.com return; 112412605Sgiacomo.travaglini@arm.com } 112512605Sgiacomo.travaglini@arm.com // TLB Invalidate by VA, Hyp mode, Inner Shareable 112612605Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVAHIS: 112712576Sgiacomo.travaglini@arm.com case MISCREG_TLBIMVALHIS: 112812605Sgiacomo.travaglini@arm.com { 112912605Sgiacomo.travaglini@arm.com assert32(tc); 113012605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 113112605Sgiacomo.travaglini@arm.com 113212605Sgiacomo.travaglini@arm.com TLBIMVAA tlbiOp(EL1, haveSecurity && !scr.ns, 113312605Sgiacomo.travaglini@arm.com mbits(newVal, 31,12), true); 113412605Sgiacomo.travaglini@arm.com 113512605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 113612605Sgiacomo.travaglini@arm.com return; 113712605Sgiacomo.travaglini@arm.com } 113812605Sgiacomo.travaglini@arm.com // mcr tlbiipas2l(is) is invalidating all matching entries 113912605Sgiacomo.travaglini@arm.com // regardless of the level of lookup, since in gem5 we cache 114012605Sgiacomo.travaglini@arm.com // in the tlb the last level of lookup only. 114112605Sgiacomo.travaglini@arm.com // TLB Invalidate by Intermediate Physical Address, Stage 2 114212605Sgiacomo.travaglini@arm.com case MISCREG_TLBIIPAS2: 114312577Sgiacomo.travaglini@arm.com case MISCREG_TLBIIPAS2L: 114412605Sgiacomo.travaglini@arm.com { 114512605Sgiacomo.travaglini@arm.com assert32(tc); 114612605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 114712605Sgiacomo.travaglini@arm.com 114812605Sgiacomo.travaglini@arm.com TLBIIPA tlbiOp(EL1, 114912605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 115012605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 35, 0)) << 12); 115112605Sgiacomo.travaglini@arm.com 115212605Sgiacomo.travaglini@arm.com tlbiOp(tc); 115312605Sgiacomo.travaglini@arm.com return; 115412605Sgiacomo.travaglini@arm.com } 115512605Sgiacomo.travaglini@arm.com // TLB Invalidate by Intermediate Physical Address, Stage 2, 115612605Sgiacomo.travaglini@arm.com // Inner Shareable 115712605Sgiacomo.travaglini@arm.com case MISCREG_TLBIIPAS2IS: 115812577Sgiacomo.travaglini@arm.com case MISCREG_TLBIIPAS2LIS: 115912605Sgiacomo.travaglini@arm.com { 116012605Sgiacomo.travaglini@arm.com assert32(tc); 116112605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 116212605Sgiacomo.travaglini@arm.com 116312605Sgiacomo.travaglini@arm.com TLBIIPA tlbiOp(EL1, 116412605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 116512605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 35, 0)) << 12); 116612605Sgiacomo.travaglini@arm.com 116712605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 116812605Sgiacomo.travaglini@arm.com return; 116912605Sgiacomo.travaglini@arm.com } 117012605Sgiacomo.travaglini@arm.com // Instruction TLB Invalidate by VA 117110037SARM gem5 Developers case MISCREG_ITLBIMVA: 117212605Sgiacomo.travaglini@arm.com { 117312605Sgiacomo.travaglini@arm.com assert32(tc); 117412605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 117512605Sgiacomo.travaglini@arm.com 117612605Sgiacomo.travaglini@arm.com ITLBIMVA tlbiOp(EL1, 117712605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 117812605Sgiacomo.travaglini@arm.com mbits(newVal, 31, 12), 117912605Sgiacomo.travaglini@arm.com bits(newVal, 7,0)); 118012605Sgiacomo.travaglini@arm.com 118112605Sgiacomo.travaglini@arm.com tlbiOp(tc); 118212605Sgiacomo.travaglini@arm.com return; 118312605Sgiacomo.travaglini@arm.com } 118412605Sgiacomo.travaglini@arm.com // Data TLB Invalidate by VA 118510037SARM gem5 Developers case MISCREG_DTLBIMVA: 118612605Sgiacomo.travaglini@arm.com { 118712605Sgiacomo.travaglini@arm.com assert32(tc); 118812605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 118912605Sgiacomo.travaglini@arm.com 119012605Sgiacomo.travaglini@arm.com DTLBIMVA tlbiOp(EL1, 119112605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 119212605Sgiacomo.travaglini@arm.com mbits(newVal, 31, 12), 119312605Sgiacomo.travaglini@arm.com bits(newVal, 7,0)); 119412605Sgiacomo.travaglini@arm.com 119512605Sgiacomo.travaglini@arm.com tlbiOp(tc); 119612605Sgiacomo.travaglini@arm.com return; 119712605Sgiacomo.travaglini@arm.com } 119812605Sgiacomo.travaglini@arm.com // Instruction TLB Invalidate by ASID match 119910037SARM gem5 Developers case MISCREG_ITLBIASID: 120012605Sgiacomo.travaglini@arm.com { 120112605Sgiacomo.travaglini@arm.com assert32(tc); 120212605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 120312605Sgiacomo.travaglini@arm.com 120412605Sgiacomo.travaglini@arm.com ITLBIASID tlbiOp(EL1, 120512605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 120612605Sgiacomo.travaglini@arm.com bits(newVal, 7,0)); 120712605Sgiacomo.travaglini@arm.com 120812605Sgiacomo.travaglini@arm.com tlbiOp(tc); 120912605Sgiacomo.travaglini@arm.com return; 121012605Sgiacomo.travaglini@arm.com } 121112605Sgiacomo.travaglini@arm.com // Data TLB Invalidate by ASID match 121210037SARM gem5 Developers case MISCREG_DTLBIASID: 121312605Sgiacomo.travaglini@arm.com { 121412605Sgiacomo.travaglini@arm.com assert32(tc); 121512605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 121612605Sgiacomo.travaglini@arm.com 121712605Sgiacomo.travaglini@arm.com DTLBIASID tlbiOp(EL1, 121812605Sgiacomo.travaglini@arm.com haveSecurity && !scr.ns, 121912605Sgiacomo.travaglini@arm.com bits(newVal, 7,0)); 122012605Sgiacomo.travaglini@arm.com 122112605Sgiacomo.travaglini@arm.com tlbiOp(tc); 122212605Sgiacomo.travaglini@arm.com return; 122312605Sgiacomo.travaglini@arm.com } 122412605Sgiacomo.travaglini@arm.com // TLB Invalidate All, Non-Secure Non-Hyp 122510037SARM gem5 Developers case MISCREG_TLBIALLNSNH: 122612605Sgiacomo.travaglini@arm.com { 122712605Sgiacomo.travaglini@arm.com assert32(tc); 122812605Sgiacomo.travaglini@arm.com 122912605Sgiacomo.travaglini@arm.com TLBIALLN tlbiOp(EL1, false); 123012605Sgiacomo.travaglini@arm.com tlbiOp(tc); 123112605Sgiacomo.travaglini@arm.com return; 123212605Sgiacomo.travaglini@arm.com } 123312605Sgiacomo.travaglini@arm.com // TLB Invalidate All, Non-Secure Non-Hyp, Inner Shareable 123410037SARM gem5 Developers case MISCREG_TLBIALLNSNHIS: 123512605Sgiacomo.travaglini@arm.com { 123612605Sgiacomo.travaglini@arm.com assert32(tc); 123712605Sgiacomo.travaglini@arm.com 123812605Sgiacomo.travaglini@arm.com TLBIALLN tlbiOp(EL1, false); 123912605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 124012605Sgiacomo.travaglini@arm.com return; 124112605Sgiacomo.travaglini@arm.com } 124212605Sgiacomo.travaglini@arm.com // TLB Invalidate All, Hyp mode 124310037SARM gem5 Developers case MISCREG_TLBIALLH: 124412605Sgiacomo.travaglini@arm.com { 124512605Sgiacomo.travaglini@arm.com assert32(tc); 124612605Sgiacomo.travaglini@arm.com 124712605Sgiacomo.travaglini@arm.com TLBIALLN tlbiOp(EL1, true); 124812605Sgiacomo.travaglini@arm.com tlbiOp(tc); 124912605Sgiacomo.travaglini@arm.com return; 125012605Sgiacomo.travaglini@arm.com } 125112605Sgiacomo.travaglini@arm.com // TLB Invalidate All, Hyp mode, Inner Shareable 125210037SARM gem5 Developers case MISCREG_TLBIALLHIS: 125312605Sgiacomo.travaglini@arm.com { 125412605Sgiacomo.travaglini@arm.com assert32(tc); 125512605Sgiacomo.travaglini@arm.com 125612605Sgiacomo.travaglini@arm.com TLBIALLN tlbiOp(EL1, true); 125712605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 125812605Sgiacomo.travaglini@arm.com return; 125912605Sgiacomo.travaglini@arm.com } 126012605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate All, EL3 126112605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_ALLE3: 126212605Sgiacomo.travaglini@arm.com { 126312605Sgiacomo.travaglini@arm.com assert64(tc); 126412605Sgiacomo.travaglini@arm.com 126512605Sgiacomo.travaglini@arm.com TLBIALL tlbiOp(EL3, true); 126612605Sgiacomo.travaglini@arm.com tlbiOp(tc); 126712605Sgiacomo.travaglini@arm.com return; 126812605Sgiacomo.travaglini@arm.com } 126912605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate All, EL3, Inner Shareable 127010037SARM gem5 Developers case MISCREG_TLBI_ALLE3IS: 127112605Sgiacomo.travaglini@arm.com { 127212605Sgiacomo.travaglini@arm.com assert64(tc); 127312605Sgiacomo.travaglini@arm.com 127412605Sgiacomo.travaglini@arm.com TLBIALL tlbiOp(EL3, true); 127512605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 127612605Sgiacomo.travaglini@arm.com return; 127712605Sgiacomo.travaglini@arm.com } 127810037SARM gem5 Developers // @todo: uncomment this to enable Virtualization 127910037SARM gem5 Developers // case MISCREG_TLBI_ALLE2IS: 128010037SARM gem5 Developers // case MISCREG_TLBI_ALLE2: 128112605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate All, EL1 128210037SARM gem5 Developers case MISCREG_TLBI_ALLE1: 128310037SARM gem5 Developers case MISCREG_TLBI_VMALLE1: 128410037SARM gem5 Developers case MISCREG_TLBI_VMALLS12E1: 128510037SARM gem5 Developers // @todo: handle VMID and stage 2 to enable Virtualization 128612605Sgiacomo.travaglini@arm.com { 128712605Sgiacomo.travaglini@arm.com assert64(tc); 128812605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 128912605Sgiacomo.travaglini@arm.com 129012605Sgiacomo.travaglini@arm.com TLBIALL tlbiOp(EL1, haveSecurity && !scr.ns); 129112605Sgiacomo.travaglini@arm.com tlbiOp(tc); 129212605Sgiacomo.travaglini@arm.com return; 129312605Sgiacomo.travaglini@arm.com } 129412605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate All, EL1, Inner Shareable 129512605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_ALLE1IS: 129612605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VMALLE1IS: 129712605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VMALLS12E1IS: 129812605Sgiacomo.travaglini@arm.com // @todo: handle VMID and stage 2 to enable Virtualization 129912605Sgiacomo.travaglini@arm.com { 130012605Sgiacomo.travaglini@arm.com assert64(tc); 130112605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 130212605Sgiacomo.travaglini@arm.com 130312605Sgiacomo.travaglini@arm.com TLBIALL tlbiOp(EL1, haveSecurity && !scr.ns); 130412605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 130512605Sgiacomo.travaglini@arm.com return; 130612605Sgiacomo.travaglini@arm.com } 130712605Sgiacomo.travaglini@arm.com // VAEx(IS) and VALEx(IS) are the same because TLBs 130812605Sgiacomo.travaglini@arm.com // only store entries 130910037SARM gem5 Developers // from the last level of translation table walks 131010037SARM gem5 Developers // @todo: handle VMID to enable Virtualization 131112605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by VA, EL3 131212605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VAE3_Xt: 131312605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VALE3_Xt: 131412605Sgiacomo.travaglini@arm.com { 131512605Sgiacomo.travaglini@arm.com assert64(tc); 131612605Sgiacomo.travaglini@arm.com 131712605Sgiacomo.travaglini@arm.com TLBIMVA tlbiOp(EL3, true, 131812605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 43, 0)) << 12, 131912605Sgiacomo.travaglini@arm.com 0xbeef); 132012605Sgiacomo.travaglini@arm.com tlbiOp(tc); 132112605Sgiacomo.travaglini@arm.com return; 132212605Sgiacomo.travaglini@arm.com } 132312605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by VA, EL3, Inner Shareable 132410037SARM gem5 Developers case MISCREG_TLBI_VAE3IS_Xt: 132510037SARM gem5 Developers case MISCREG_TLBI_VALE3IS_Xt: 132612605Sgiacomo.travaglini@arm.com { 132712605Sgiacomo.travaglini@arm.com assert64(tc); 132812605Sgiacomo.travaglini@arm.com 132912605Sgiacomo.travaglini@arm.com TLBIMVA tlbiOp(EL3, true, 133012605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 43, 0)) << 12, 133112605Sgiacomo.travaglini@arm.com 0xbeef); 133212605Sgiacomo.travaglini@arm.com 133312605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 133412605Sgiacomo.travaglini@arm.com return; 133512605Sgiacomo.travaglini@arm.com } 133612605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by VA, EL2 133712605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VAE2_Xt: 133812605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VALE2_Xt: 133912605Sgiacomo.travaglini@arm.com { 134012605Sgiacomo.travaglini@arm.com assert64(tc); 134112605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 134212605Sgiacomo.travaglini@arm.com 134312605Sgiacomo.travaglini@arm.com TLBIMVA tlbiOp(EL2, haveSecurity && !scr.ns, 134412605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 43, 0)) << 12, 134512605Sgiacomo.travaglini@arm.com 0xbeef); 134612605Sgiacomo.travaglini@arm.com tlbiOp(tc); 134712605Sgiacomo.travaglini@arm.com return; 134812605Sgiacomo.travaglini@arm.com } 134912605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by VA, EL2, Inner Shareable 135010037SARM gem5 Developers case MISCREG_TLBI_VAE2IS_Xt: 135110037SARM gem5 Developers case MISCREG_TLBI_VALE2IS_Xt: 135212605Sgiacomo.travaglini@arm.com { 135312605Sgiacomo.travaglini@arm.com assert64(tc); 135412605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 135512605Sgiacomo.travaglini@arm.com 135612605Sgiacomo.travaglini@arm.com TLBIMVA tlbiOp(EL2, haveSecurity && !scr.ns, 135712605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 43, 0)) << 12, 135812605Sgiacomo.travaglini@arm.com 0xbeef); 135912605Sgiacomo.travaglini@arm.com 136012605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 136112605Sgiacomo.travaglini@arm.com return; 136212605Sgiacomo.travaglini@arm.com } 136312605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by VA, EL1 136412605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VAE1_Xt: 136512605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VALE1_Xt: 136612605Sgiacomo.travaglini@arm.com { 136712605Sgiacomo.travaglini@arm.com assert64(tc); 136812605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 136912605Sgiacomo.travaglini@arm.com auto asid = haveLargeAsid64 ? bits(newVal, 63, 48) : 137012605Sgiacomo.travaglini@arm.com bits(newVal, 55, 48); 137112605Sgiacomo.travaglini@arm.com 137212605Sgiacomo.travaglini@arm.com TLBIMVA tlbiOp(EL1, haveSecurity && !scr.ns, 137312605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 43, 0)) << 12, 137412605Sgiacomo.travaglini@arm.com asid); 137512605Sgiacomo.travaglini@arm.com 137612605Sgiacomo.travaglini@arm.com tlbiOp(tc); 137712605Sgiacomo.travaglini@arm.com return; 137812605Sgiacomo.travaglini@arm.com } 137912605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by VA, EL1, Inner Shareable 138010037SARM gem5 Developers case MISCREG_TLBI_VAE1IS_Xt: 138110037SARM gem5 Developers case MISCREG_TLBI_VALE1IS_Xt: 138212605Sgiacomo.travaglini@arm.com { 138312605Sgiacomo.travaglini@arm.com assert64(tc); 138412605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 138512605Sgiacomo.travaglini@arm.com auto asid = haveLargeAsid64 ? bits(newVal, 63, 48) : 138612605Sgiacomo.travaglini@arm.com bits(newVal, 55, 48); 138712605Sgiacomo.travaglini@arm.com 138812605Sgiacomo.travaglini@arm.com TLBIMVA tlbiOp(EL1, haveSecurity && !scr.ns, 138912605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 43, 0)) << 12, 139012605Sgiacomo.travaglini@arm.com asid); 139112605Sgiacomo.travaglini@arm.com 139212605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 139312605Sgiacomo.travaglini@arm.com return; 139412605Sgiacomo.travaglini@arm.com } 139512605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by ASID, EL1 139610037SARM gem5 Developers // @todo: handle VMID to enable Virtualization 139712605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_ASIDE1_Xt: 139812605Sgiacomo.travaglini@arm.com { 139912605Sgiacomo.travaglini@arm.com assert64(tc); 140012605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 140112605Sgiacomo.travaglini@arm.com auto asid = haveLargeAsid64 ? bits(newVal, 63, 48) : 140212605Sgiacomo.travaglini@arm.com bits(newVal, 55, 48); 140312605Sgiacomo.travaglini@arm.com 140412605Sgiacomo.travaglini@arm.com TLBIASID tlbiOp(EL1, haveSecurity && !scr.ns, asid); 140512605Sgiacomo.travaglini@arm.com tlbiOp(tc); 140612605Sgiacomo.travaglini@arm.com return; 140712605Sgiacomo.travaglini@arm.com } 140812605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by ASID, EL1, Inner Shareable 140910037SARM gem5 Developers case MISCREG_TLBI_ASIDE1IS_Xt: 141012605Sgiacomo.travaglini@arm.com { 141112605Sgiacomo.travaglini@arm.com assert64(tc); 141212605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 141312605Sgiacomo.travaglini@arm.com auto asid = haveLargeAsid64 ? bits(newVal, 63, 48) : 141412605Sgiacomo.travaglini@arm.com bits(newVal, 55, 48); 141512605Sgiacomo.travaglini@arm.com 141612605Sgiacomo.travaglini@arm.com TLBIASID tlbiOp(EL1, haveSecurity && !scr.ns, asid); 141712605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 141812605Sgiacomo.travaglini@arm.com return; 141912605Sgiacomo.travaglini@arm.com } 142010037SARM gem5 Developers // VAAE1(IS) and VAALE1(IS) are the same because TLBs only store 142110037SARM gem5 Developers // entries from the last level of translation table walks 142212605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by VA, All ASID, EL1 142312605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VAAE1_Xt: 142412605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_VAALE1_Xt: 142512605Sgiacomo.travaglini@arm.com { 142612605Sgiacomo.travaglini@arm.com assert64(tc); 142712605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 142812605Sgiacomo.travaglini@arm.com 142912605Sgiacomo.travaglini@arm.com TLBIMVAA tlbiOp(EL1, haveSecurity && !scr.ns, 143012605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 43, 0)) << 12, false); 143112605Sgiacomo.travaglini@arm.com 143212605Sgiacomo.travaglini@arm.com tlbiOp(tc); 143312605Sgiacomo.travaglini@arm.com return; 143412605Sgiacomo.travaglini@arm.com } 143512605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by VA, All ASID, EL1, Inner Shareable 143610037SARM gem5 Developers case MISCREG_TLBI_VAAE1IS_Xt: 143710037SARM gem5 Developers case MISCREG_TLBI_VAALE1IS_Xt: 143812605Sgiacomo.travaglini@arm.com { 143912605Sgiacomo.travaglini@arm.com assert64(tc); 144012605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 144112605Sgiacomo.travaglini@arm.com 144212605Sgiacomo.travaglini@arm.com TLBIMVAA tlbiOp(EL1, haveSecurity && !scr.ns, 144312605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 43, 0)) << 12, false); 144412605Sgiacomo.travaglini@arm.com 144512605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 144612605Sgiacomo.travaglini@arm.com return; 144712605Sgiacomo.travaglini@arm.com } 144812605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by Intermediate Physical Address, 144912605Sgiacomo.travaglini@arm.com // Stage 2, EL1 145012605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_IPAS2E1_Xt: 145112605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_IPAS2LE1_Xt: 145212605Sgiacomo.travaglini@arm.com { 145312605Sgiacomo.travaglini@arm.com assert64(tc); 145412605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 145512605Sgiacomo.travaglini@arm.com 145612605Sgiacomo.travaglini@arm.com TLBIIPA tlbiOp(EL1, haveSecurity && !scr.ns, 145712605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 35, 0)) << 12); 145812605Sgiacomo.travaglini@arm.com 145912605Sgiacomo.travaglini@arm.com tlbiOp(tc); 146012605Sgiacomo.travaglini@arm.com return; 146112605Sgiacomo.travaglini@arm.com } 146212605Sgiacomo.travaglini@arm.com // AArch64 TLB Invalidate by Intermediate Physical Address, 146312605Sgiacomo.travaglini@arm.com // Stage 2, EL1, Inner Shareable 146412605Sgiacomo.travaglini@arm.com case MISCREG_TLBI_IPAS2E1IS_Xt: 146510037SARM gem5 Developers case MISCREG_TLBI_IPAS2LE1IS_Xt: 146612605Sgiacomo.travaglini@arm.com { 146712605Sgiacomo.travaglini@arm.com assert64(tc); 146812605Sgiacomo.travaglini@arm.com scr = readMiscReg(MISCREG_SCR, tc); 146912605Sgiacomo.travaglini@arm.com 147012605Sgiacomo.travaglini@arm.com TLBIIPA tlbiOp(EL1, haveSecurity && !scr.ns, 147112605Sgiacomo.travaglini@arm.com static_cast<Addr>(bits(newVal, 35, 0)) << 12); 147212605Sgiacomo.travaglini@arm.com 147312605Sgiacomo.travaglini@arm.com tlbiOp.broadcast(tc); 147412605Sgiacomo.travaglini@arm.com return; 147512605Sgiacomo.travaglini@arm.com } 14767583SAli.Saidi@arm.com case MISCREG_ACTLR: 14777583SAli.Saidi@arm.com warn("Not doing anything for write of miscreg ACTLR\n"); 14787583SAli.Saidi@arm.com break; 147910461SAndreas.Sandberg@ARM.com 148010461SAndreas.Sandberg@ARM.com case MISCREG_PMXEVTYPER_PMCCFILTR: 148110461SAndreas.Sandberg@ARM.com case MISCREG_PMINTENSET_EL1 ... MISCREG_PMOVSSET_EL0: 148210461SAndreas.Sandberg@ARM.com case MISCREG_PMEVCNTR0_EL0 ... MISCREG_PMEVTYPER5_EL0: 148310461SAndreas.Sandberg@ARM.com case MISCREG_PMCR ... MISCREG_PMOVSSET: 148410461SAndreas.Sandberg@ARM.com pmu->setMiscReg(misc_reg, newVal); 14857583SAli.Saidi@arm.com break; 148610461SAndreas.Sandberg@ARM.com 148710461SAndreas.Sandberg@ARM.com 148810037SARM gem5 Developers case MISCREG_HSTR: // TJDBX, now redifined to be RES0 148910037SARM gem5 Developers { 149010037SARM gem5 Developers HSTR hstrMask = 0; 149110037SARM gem5 Developers hstrMask.tjdbx = 1; 149210037SARM gem5 Developers newVal &= ~((uint32_t) hstrMask); 149310037SARM gem5 Developers break; 149410037SARM gem5 Developers } 149510037SARM gem5 Developers case MISCREG_HCPTR: 149610037SARM gem5 Developers { 149710037SARM gem5 Developers // If a CP bit in NSACR is 0 then the corresponding bit in 149810037SARM gem5 Developers // HCPTR is RAO/WI. Same applies to NSASEDIS 149910037SARM gem5 Developers secure_lookup = haveSecurity && 150010037SARM gem5 Developers inSecureState(readMiscRegNoEffect(MISCREG_SCR), 150110037SARM gem5 Developers readMiscRegNoEffect(MISCREG_CPSR)); 150210037SARM gem5 Developers if (!secure_lookup) { 150310037SARM gem5 Developers MiscReg oldValue = readMiscRegNoEffect(MISCREG_HCPTR); 150410037SARM gem5 Developers MiscReg mask = (readMiscRegNoEffect(MISCREG_NSACR) ^ 0x7FFF) & 0xBFFF; 150510037SARM gem5 Developers newVal = (newVal & ~mask) | (oldValue & mask); 150610037SARM gem5 Developers } 150710037SARM gem5 Developers break; 150810037SARM gem5 Developers } 150910037SARM gem5 Developers case MISCREG_HDFAR: // alias for secure DFAR 151010037SARM gem5 Developers misc_reg = MISCREG_DFAR_S; 151110037SARM gem5 Developers break; 151210037SARM gem5 Developers case MISCREG_HIFAR: // alias for secure IFAR 151310037SARM gem5 Developers misc_reg = MISCREG_IFAR_S; 151410037SARM gem5 Developers break; 151510037SARM gem5 Developers case MISCREG_ATS1CPR: 151610037SARM gem5 Developers case MISCREG_ATS1CPW: 151710037SARM gem5 Developers case MISCREG_ATS1CUR: 151810037SARM gem5 Developers case MISCREG_ATS1CUW: 151910037SARM gem5 Developers case MISCREG_ATS12NSOPR: 152010037SARM gem5 Developers case MISCREG_ATS12NSOPW: 152110037SARM gem5 Developers case MISCREG_ATS12NSOUR: 152210037SARM gem5 Developers case MISCREG_ATS12NSOUW: 152310037SARM gem5 Developers case MISCREG_ATS1HR: 152410037SARM gem5 Developers case MISCREG_ATS1HW: 15257436Sdam.sunwoo@arm.com { 152611608Snikos.nikoleris@arm.com Request::Flags flags = 0; 152710037SARM gem5 Developers BaseTLB::Mode mode = BaseTLB::Read; 152810037SARM gem5 Developers TLB::ArmTranslationType tranType = TLB::NormalTran; 15297436Sdam.sunwoo@arm.com Fault fault; 15307436Sdam.sunwoo@arm.com switch(misc_reg) { 153110037SARM gem5 Developers case MISCREG_ATS1CPR: 153210037SARM gem5 Developers flags = TLB::MustBeOne; 153310037SARM gem5 Developers tranType = TLB::S1CTran; 153410037SARM gem5 Developers mode = BaseTLB::Read; 153510037SARM gem5 Developers break; 153610037SARM gem5 Developers case MISCREG_ATS1CPW: 153710037SARM gem5 Developers flags = TLB::MustBeOne; 153810037SARM gem5 Developers tranType = TLB::S1CTran; 153910037SARM gem5 Developers mode = BaseTLB::Write; 154010037SARM gem5 Developers break; 154110037SARM gem5 Developers case MISCREG_ATS1CUR: 154210037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 154310037SARM gem5 Developers tranType = TLB::S1CTran; 154410037SARM gem5 Developers mode = BaseTLB::Read; 154510037SARM gem5 Developers break; 154610037SARM gem5 Developers case MISCREG_ATS1CUW: 154710037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 154810037SARM gem5 Developers tranType = TLB::S1CTran; 154910037SARM gem5 Developers mode = BaseTLB::Write; 155010037SARM gem5 Developers break; 155110037SARM gem5 Developers case MISCREG_ATS12NSOPR: 155210037SARM gem5 Developers if (!haveSecurity) 155310037SARM gem5 Developers panic("Security Extensions required for ATS12NSOPR"); 155410037SARM gem5 Developers flags = TLB::MustBeOne; 155510037SARM gem5 Developers tranType = TLB::S1S2NsTran; 155610037SARM gem5 Developers mode = BaseTLB::Read; 155710037SARM gem5 Developers break; 155810037SARM gem5 Developers case MISCREG_ATS12NSOPW: 155910037SARM gem5 Developers if (!haveSecurity) 156010037SARM gem5 Developers panic("Security Extensions required for ATS12NSOPW"); 156110037SARM gem5 Developers flags = TLB::MustBeOne; 156210037SARM gem5 Developers tranType = TLB::S1S2NsTran; 156310037SARM gem5 Developers mode = BaseTLB::Write; 156410037SARM gem5 Developers break; 156510037SARM gem5 Developers case MISCREG_ATS12NSOUR: 156610037SARM gem5 Developers if (!haveSecurity) 156710037SARM gem5 Developers panic("Security Extensions required for ATS12NSOUR"); 156810037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 156910037SARM gem5 Developers tranType = TLB::S1S2NsTran; 157010037SARM gem5 Developers mode = BaseTLB::Read; 157110037SARM gem5 Developers break; 157210037SARM gem5 Developers case MISCREG_ATS12NSOUW: 157310037SARM gem5 Developers if (!haveSecurity) 157410037SARM gem5 Developers panic("Security Extensions required for ATS12NSOUW"); 157510037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 157610037SARM gem5 Developers tranType = TLB::S1S2NsTran; 157710037SARM gem5 Developers mode = BaseTLB::Write; 157810037SARM gem5 Developers break; 157910037SARM gem5 Developers case MISCREG_ATS1HR: // only really useful from secure mode. 158010037SARM gem5 Developers flags = TLB::MustBeOne; 158110037SARM gem5 Developers tranType = TLB::HypMode; 158210037SARM gem5 Developers mode = BaseTLB::Read; 158310037SARM gem5 Developers break; 158410037SARM gem5 Developers case MISCREG_ATS1HW: 158510037SARM gem5 Developers flags = TLB::MustBeOne; 158610037SARM gem5 Developers tranType = TLB::HypMode; 158710037SARM gem5 Developers mode = BaseTLB::Write; 158810037SARM gem5 Developers break; 15897436Sdam.sunwoo@arm.com } 159010037SARM gem5 Developers // If we're in timing mode then doing the translation in 159110037SARM gem5 Developers // functional mode then we're slightly distorting performance 159210037SARM gem5 Developers // results obtained from simulations. The translation should be 159310037SARM gem5 Developers // done in the same mode the core is running in. NOTE: This 159410037SARM gem5 Developers // can't be an atomic translation because that causes problems 159510037SARM gem5 Developers // with unexpected atomic snoop requests. 159610037SARM gem5 Developers warn("Translating via MISCREG(%d) in functional mode! Fix Me!\n", misc_reg); 159711560Sandreas.sandberg@arm.com Request req(0, val, 0, flags, Request::funcMasterId, 159811435Smitch.hayenga@arm.com tc->pcState().pc(), tc->contextId()); 159912406Sgabeblack@google.com fault = getDTBPtr(tc)->translateFunctional( 160012406Sgabeblack@google.com &req, tc, mode, tranType); 160110037SARM gem5 Developers TTBCR ttbcr = readMiscRegNoEffect(MISCREG_TTBCR); 160210037SARM gem5 Developers HCR hcr = readMiscRegNoEffect(MISCREG_HCR); 160310037SARM gem5 Developers 160410037SARM gem5 Developers MiscReg newVal; 16057436Sdam.sunwoo@arm.com if (fault == NoFault) { 160610653Sandreas.hansson@arm.com Addr paddr = req.getPaddr(); 160710037SARM gem5 Developers if (haveLPAE && (ttbcr.eae || tranType & TLB::HypMode || 160810037SARM gem5 Developers ((tranType & TLB::S1S2NsTran) && hcr.vm) )) { 160910037SARM gem5 Developers newVal = (paddr & mask(39, 12)) | 161012406Sgabeblack@google.com (getDTBPtr(tc)->getAttr()); 161110037SARM gem5 Developers } else { 161210037SARM gem5 Developers newVal = (paddr & 0xfffff000) | 161312406Sgabeblack@google.com (getDTBPtr(tc)->getAttr()); 161410037SARM gem5 Developers } 16157436Sdam.sunwoo@arm.com DPRINTF(MiscRegs, 16167436Sdam.sunwoo@arm.com "MISCREG: Translated addr 0x%08x: PAR: 0x%08x\n", 161710037SARM gem5 Developers val, newVal); 161810037SARM gem5 Developers } else { 161912524Sgiacomo.travaglini@arm.com ArmFault *armFault = static_cast<ArmFault *>(fault.get()); 162012570Sgiacomo.travaglini@arm.com armFault->update(tc); 162110037SARM gem5 Developers // Set fault bit and FSR 162210037SARM gem5 Developers FSR fsr = armFault->getFsr(tc); 162310037SARM gem5 Developers 162410037SARM gem5 Developers newVal = ((fsr >> 9) & 1) << 11; 162510037SARM gem5 Developers if (newVal) { 162610037SARM gem5 Developers // LPAE - rearange fault status 162710037SARM gem5 Developers newVal |= ((fsr >> 0) & 0x3f) << 1; 162810037SARM gem5 Developers } else { 162910037SARM gem5 Developers // VMSA - rearange fault status 163010037SARM gem5 Developers newVal |= ((fsr >> 0) & 0xf) << 1; 163110037SARM gem5 Developers newVal |= ((fsr >> 10) & 0x1) << 5; 163210037SARM gem5 Developers newVal |= ((fsr >> 12) & 0x1) << 6; 163310037SARM gem5 Developers } 163410037SARM gem5 Developers newVal |= 0x1; // F bit 163510037SARM gem5 Developers newVal |= ((armFault->iss() >> 7) & 0x1) << 8; 163610037SARM gem5 Developers newVal |= armFault->isStage2() ? 0x200 : 0; 163710037SARM gem5 Developers DPRINTF(MiscRegs, 163810037SARM gem5 Developers "MISCREG: Translated addr 0x%08x fault fsr %#x: PAR: 0x%08x\n", 163910037SARM gem5 Developers val, fsr, newVal); 16407436Sdam.sunwoo@arm.com } 164110037SARM gem5 Developers setMiscRegNoEffect(MISCREG_PAR, newVal); 16427436Sdam.sunwoo@arm.com return; 16437436Sdam.sunwoo@arm.com } 164410037SARM gem5 Developers case MISCREG_TTBCR: 164510037SARM gem5 Developers { 164610037SARM gem5 Developers TTBCR ttbcr = readMiscRegNoEffect(MISCREG_TTBCR); 164710037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 164810037SARM gem5 Developers TTBCR ttbcrMask = 0; 164910037SARM gem5 Developers TTBCR ttbcrNew = newVal; 165010037SARM gem5 Developers 165110037SARM gem5 Developers // ARM DDI 0406C.b, ARMv7-32 165210037SARM gem5 Developers ttbcrMask.n = ones; // T0SZ 165310037SARM gem5 Developers if (haveSecurity) { 165410037SARM gem5 Developers ttbcrMask.pd0 = ones; 165510037SARM gem5 Developers ttbcrMask.pd1 = ones; 165610037SARM gem5 Developers } 165710037SARM gem5 Developers ttbcrMask.epd0 = ones; 165810037SARM gem5 Developers ttbcrMask.irgn0 = ones; 165910037SARM gem5 Developers ttbcrMask.orgn0 = ones; 166010037SARM gem5 Developers ttbcrMask.sh0 = ones; 166110037SARM gem5 Developers ttbcrMask.ps = ones; // T1SZ 166210037SARM gem5 Developers ttbcrMask.a1 = ones; 166310037SARM gem5 Developers ttbcrMask.epd1 = ones; 166410037SARM gem5 Developers ttbcrMask.irgn1 = ones; 166510037SARM gem5 Developers ttbcrMask.orgn1 = ones; 166610037SARM gem5 Developers ttbcrMask.sh1 = ones; 166710037SARM gem5 Developers if (haveLPAE) 166810037SARM gem5 Developers ttbcrMask.eae = ones; 166910037SARM gem5 Developers 167010037SARM gem5 Developers if (haveLPAE && ttbcrNew.eae) { 167110037SARM gem5 Developers newVal = newVal & ttbcrMask; 167210037SARM gem5 Developers } else { 167310037SARM gem5 Developers newVal = (newVal & ttbcrMask) | (ttbcr & (~ttbcrMask)); 167410037SARM gem5 Developers } 167512666Sgiacomo.travaglini@arm.com // Invalidate TLB MiscReg 167612666Sgiacomo.travaglini@arm.com getITBPtr(tc)->invalidateMiscReg(); 167712666Sgiacomo.travaglini@arm.com getDTBPtr(tc)->invalidateMiscReg(); 167812666Sgiacomo.travaglini@arm.com break; 167910037SARM gem5 Developers } 168010037SARM gem5 Developers case MISCREG_TTBR0: 168110037SARM gem5 Developers case MISCREG_TTBR1: 168210037SARM gem5 Developers { 168310037SARM gem5 Developers TTBCR ttbcr = readMiscRegNoEffect(MISCREG_TTBCR); 168410037SARM gem5 Developers if (haveLPAE) { 168510037SARM gem5 Developers if (ttbcr.eae) { 168610037SARM gem5 Developers // ARMv7 bit 63-56, 47-40 reserved, UNK/SBZP 168710037SARM gem5 Developers // ARMv8 AArch32 bit 63-56 only 168810037SARM gem5 Developers uint64_t ttbrMask = mask(63,56) | mask(47,40); 168910037SARM gem5 Developers newVal = (newVal & (~ttbrMask)); 169010037SARM gem5 Developers } 169110037SARM gem5 Developers } 169212666Sgiacomo.travaglini@arm.com // Invalidate TLB MiscReg 169312406Sgabeblack@google.com getITBPtr(tc)->invalidateMiscReg(); 169412406Sgabeblack@google.com getDTBPtr(tc)->invalidateMiscReg(); 169512666Sgiacomo.travaglini@arm.com break; 169610508SAli.Saidi@ARM.com } 169712666Sgiacomo.travaglini@arm.com case MISCREG_SCTLR_EL1: 16987749SAli.Saidi@ARM.com case MISCREG_CONTEXTIDR: 16997749SAli.Saidi@ARM.com case MISCREG_PRRR: 17007749SAli.Saidi@ARM.com case MISCREG_NMRR: 170110037SARM gem5 Developers case MISCREG_MAIR0: 170210037SARM gem5 Developers case MISCREG_MAIR1: 17037749SAli.Saidi@ARM.com case MISCREG_DACR: 170410037SARM gem5 Developers case MISCREG_VTTBR: 170510037SARM gem5 Developers case MISCREG_SCR_EL3: 170611575SDylan.Johnson@ARM.com case MISCREG_HCR_EL2: 170710037SARM gem5 Developers case MISCREG_TCR_EL1: 170810037SARM gem5 Developers case MISCREG_TCR_EL2: 170910037SARM gem5 Developers case MISCREG_TCR_EL3: 171010508SAli.Saidi@ARM.com case MISCREG_SCTLR_EL2: 171110508SAli.Saidi@ARM.com case MISCREG_SCTLR_EL3: 171211573SDylan.Johnson@ARM.com case MISCREG_HSCTLR: 171310037SARM gem5 Developers case MISCREG_TTBR0_EL1: 171410037SARM gem5 Developers case MISCREG_TTBR1_EL1: 171510037SARM gem5 Developers case MISCREG_TTBR0_EL2: 171612675Sgiacomo.travaglini@arm.com case MISCREG_TTBR1_EL2: 171710037SARM gem5 Developers case MISCREG_TTBR0_EL3: 171812406Sgabeblack@google.com getITBPtr(tc)->invalidateMiscReg(); 171912406Sgabeblack@google.com getDTBPtr(tc)->invalidateMiscReg(); 17207749SAli.Saidi@ARM.com break; 172110037SARM gem5 Developers case MISCREG_NZCV: 172210037SARM gem5 Developers { 172310037SARM gem5 Developers CPSR cpsr = val; 172410037SARM gem5 Developers 172510338SCurtis.Dunham@arm.com tc->setCCReg(CCREG_NZ, cpsr.nz); 172610338SCurtis.Dunham@arm.com tc->setCCReg(CCREG_C, cpsr.c); 172710338SCurtis.Dunham@arm.com tc->setCCReg(CCREG_V, cpsr.v); 172810037SARM gem5 Developers } 172910037SARM gem5 Developers break; 173010037SARM gem5 Developers case MISCREG_DAIF: 173110037SARM gem5 Developers { 173210037SARM gem5 Developers CPSR cpsr = miscRegs[MISCREG_CPSR]; 173310037SARM gem5 Developers cpsr.daif = (uint8_t) ((CPSR) newVal).daif; 173410037SARM gem5 Developers newVal = cpsr; 173510037SARM gem5 Developers misc_reg = MISCREG_CPSR; 173610037SARM gem5 Developers } 173710037SARM gem5 Developers break; 173810037SARM gem5 Developers case MISCREG_SP_EL0: 173910037SARM gem5 Developers tc->setIntReg(INTREG_SP0, newVal); 174010037SARM gem5 Developers break; 174110037SARM gem5 Developers case MISCREG_SP_EL1: 174210037SARM gem5 Developers tc->setIntReg(INTREG_SP1, newVal); 174310037SARM gem5 Developers break; 174410037SARM gem5 Developers case MISCREG_SP_EL2: 174510037SARM gem5 Developers tc->setIntReg(INTREG_SP2, newVal); 174610037SARM gem5 Developers break; 174710037SARM gem5 Developers case MISCREG_SPSEL: 174810037SARM gem5 Developers { 174910037SARM gem5 Developers CPSR cpsr = miscRegs[MISCREG_CPSR]; 175010037SARM gem5 Developers cpsr.sp = (uint8_t) ((CPSR) newVal).sp; 175110037SARM gem5 Developers newVal = cpsr; 175210037SARM gem5 Developers misc_reg = MISCREG_CPSR; 175310037SARM gem5 Developers } 175410037SARM gem5 Developers break; 175510037SARM gem5 Developers case MISCREG_CURRENTEL: 175610037SARM gem5 Developers { 175710037SARM gem5 Developers CPSR cpsr = miscRegs[MISCREG_CPSR]; 175810037SARM gem5 Developers cpsr.el = (uint8_t) ((CPSR) newVal).el; 175910037SARM gem5 Developers newVal = cpsr; 176010037SARM gem5 Developers misc_reg = MISCREG_CPSR; 176110037SARM gem5 Developers } 176210037SARM gem5 Developers break; 176310037SARM gem5 Developers case MISCREG_AT_S1E1R_Xt: 176410037SARM gem5 Developers case MISCREG_AT_S1E1W_Xt: 176510037SARM gem5 Developers case MISCREG_AT_S1E0R_Xt: 176610037SARM gem5 Developers case MISCREG_AT_S1E0W_Xt: 176710037SARM gem5 Developers case MISCREG_AT_S1E2R_Xt: 176810037SARM gem5 Developers case MISCREG_AT_S1E2W_Xt: 176910037SARM gem5 Developers case MISCREG_AT_S12E1R_Xt: 177010037SARM gem5 Developers case MISCREG_AT_S12E1W_Xt: 177110037SARM gem5 Developers case MISCREG_AT_S12E0R_Xt: 177210037SARM gem5 Developers case MISCREG_AT_S12E0W_Xt: 177310037SARM gem5 Developers case MISCREG_AT_S1E3R_Xt: 177410037SARM gem5 Developers case MISCREG_AT_S1E3W_Xt: 177510037SARM gem5 Developers { 177610037SARM gem5 Developers RequestPtr req = new Request; 177711608Snikos.nikoleris@arm.com Request::Flags flags = 0; 177810037SARM gem5 Developers BaseTLB::Mode mode = BaseTLB::Read; 177910037SARM gem5 Developers TLB::ArmTranslationType tranType = TLB::NormalTran; 178010037SARM gem5 Developers Fault fault; 178110037SARM gem5 Developers switch(misc_reg) { 178210037SARM gem5 Developers case MISCREG_AT_S1E1R_Xt: 178310037SARM gem5 Developers flags = TLB::MustBeOne; 178411577SDylan.Johnson@ARM.com tranType = TLB::S1E1Tran; 178510037SARM gem5 Developers mode = BaseTLB::Read; 178610037SARM gem5 Developers break; 178710037SARM gem5 Developers case MISCREG_AT_S1E1W_Xt: 178810037SARM gem5 Developers flags = TLB::MustBeOne; 178911577SDylan.Johnson@ARM.com tranType = TLB::S1E1Tran; 179010037SARM gem5 Developers mode = BaseTLB::Write; 179110037SARM gem5 Developers break; 179210037SARM gem5 Developers case MISCREG_AT_S1E0R_Xt: 179310037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 179411577SDylan.Johnson@ARM.com tranType = TLB::S1E0Tran; 179510037SARM gem5 Developers mode = BaseTLB::Read; 179610037SARM gem5 Developers break; 179710037SARM gem5 Developers case MISCREG_AT_S1E0W_Xt: 179810037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 179911577SDylan.Johnson@ARM.com tranType = TLB::S1E0Tran; 180010037SARM gem5 Developers mode = BaseTLB::Write; 180110037SARM gem5 Developers break; 180210037SARM gem5 Developers case MISCREG_AT_S1E2R_Xt: 180310037SARM gem5 Developers flags = TLB::MustBeOne; 180411577SDylan.Johnson@ARM.com tranType = TLB::S1E2Tran; 180510037SARM gem5 Developers mode = BaseTLB::Read; 180610037SARM gem5 Developers break; 180710037SARM gem5 Developers case MISCREG_AT_S1E2W_Xt: 180810037SARM gem5 Developers flags = TLB::MustBeOne; 180911577SDylan.Johnson@ARM.com tranType = TLB::S1E2Tran; 181010037SARM gem5 Developers mode = BaseTLB::Write; 181110037SARM gem5 Developers break; 181210037SARM gem5 Developers case MISCREG_AT_S12E0R_Xt: 181310037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 181411577SDylan.Johnson@ARM.com tranType = TLB::S12E0Tran; 181510037SARM gem5 Developers mode = BaseTLB::Read; 181610037SARM gem5 Developers break; 181710037SARM gem5 Developers case MISCREG_AT_S12E0W_Xt: 181810037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 181911577SDylan.Johnson@ARM.com tranType = TLB::S12E0Tran; 182010037SARM gem5 Developers mode = BaseTLB::Write; 182110037SARM gem5 Developers break; 182210037SARM gem5 Developers case MISCREG_AT_S12E1R_Xt: 182310037SARM gem5 Developers flags = TLB::MustBeOne; 182411577SDylan.Johnson@ARM.com tranType = TLB::S12E1Tran; 182510037SARM gem5 Developers mode = BaseTLB::Read; 182610037SARM gem5 Developers break; 182710037SARM gem5 Developers case MISCREG_AT_S12E1W_Xt: 182810037SARM gem5 Developers flags = TLB::MustBeOne; 182911577SDylan.Johnson@ARM.com tranType = TLB::S12E1Tran; 183010037SARM gem5 Developers mode = BaseTLB::Write; 183110037SARM gem5 Developers break; 183210037SARM gem5 Developers case MISCREG_AT_S1E3R_Xt: 183310037SARM gem5 Developers flags = TLB::MustBeOne; 183411577SDylan.Johnson@ARM.com tranType = TLB::S1E3Tran; 183510037SARM gem5 Developers mode = BaseTLB::Read; 183610037SARM gem5 Developers break; 183710037SARM gem5 Developers case MISCREG_AT_S1E3W_Xt: 183810037SARM gem5 Developers flags = TLB::MustBeOne; 183911577SDylan.Johnson@ARM.com tranType = TLB::S1E3Tran; 184010037SARM gem5 Developers mode = BaseTLB::Write; 184110037SARM gem5 Developers break; 184210037SARM gem5 Developers } 184310037SARM gem5 Developers // If we're in timing mode then doing the translation in 184410037SARM gem5 Developers // functional mode then we're slightly distorting performance 184510037SARM gem5 Developers // results obtained from simulations. The translation should be 184610037SARM gem5 Developers // done in the same mode the core is running in. NOTE: This 184710037SARM gem5 Developers // can't be an atomic translation because that causes problems 184810037SARM gem5 Developers // with unexpected atomic snoop requests. 184910037SARM gem5 Developers warn("Translating via MISCREG(%d) in functional mode! Fix Me!\n", misc_reg); 185011560Sandreas.sandberg@arm.com req->setVirt(0, val, 0, flags, Request::funcMasterId, 185110037SARM gem5 Developers tc->pcState().pc()); 185211435Smitch.hayenga@arm.com req->setContext(tc->contextId()); 185312406Sgabeblack@google.com fault = getDTBPtr(tc)->translateFunctional(req, tc, mode, 185412406Sgabeblack@google.com tranType); 185510037SARM gem5 Developers 185610037SARM gem5 Developers MiscReg newVal; 185710037SARM gem5 Developers if (fault == NoFault) { 185810037SARM gem5 Developers Addr paddr = req->getPaddr(); 185912406Sgabeblack@google.com uint64_t attr = getDTBPtr(tc)->getAttr(); 186010037SARM gem5 Developers uint64_t attr1 = attr >> 56; 186110037SARM gem5 Developers if (!attr1 || attr1 ==0x44) { 186210037SARM gem5 Developers attr |= 0x100; 186310037SARM gem5 Developers attr &= ~ uint64_t(0x80); 186410037SARM gem5 Developers } 186510037SARM gem5 Developers newVal = (paddr & mask(47, 12)) | attr; 186610037SARM gem5 Developers DPRINTF(MiscRegs, 186710037SARM gem5 Developers "MISCREG: Translated addr %#x: PAR_EL1: %#xx\n", 186810037SARM gem5 Developers val, newVal); 186910037SARM gem5 Developers } else { 187012524Sgiacomo.travaglini@arm.com ArmFault *armFault = static_cast<ArmFault *>(fault.get()); 187112570Sgiacomo.travaglini@arm.com armFault->update(tc); 187210037SARM gem5 Developers // Set fault bit and FSR 187310037SARM gem5 Developers FSR fsr = armFault->getFsr(tc); 187410037SARM gem5 Developers 187511577SDylan.Johnson@ARM.com CPSR cpsr = tc->readMiscReg(MISCREG_CPSR); 187611577SDylan.Johnson@ARM.com if (cpsr.width) { // AArch32 187711577SDylan.Johnson@ARM.com newVal = ((fsr >> 9) & 1) << 11; 187811577SDylan.Johnson@ARM.com // rearrange fault status 187911577SDylan.Johnson@ARM.com newVal |= ((fsr >> 0) & 0x3f) << 1; 188011577SDylan.Johnson@ARM.com newVal |= 0x1; // F bit 188111577SDylan.Johnson@ARM.com newVal |= ((armFault->iss() >> 7) & 0x1) << 8; 188211577SDylan.Johnson@ARM.com newVal |= armFault->isStage2() ? 0x200 : 0; 188311577SDylan.Johnson@ARM.com } else { // AArch64 188411577SDylan.Johnson@ARM.com newVal = 1; // F bit 188511577SDylan.Johnson@ARM.com newVal |= fsr << 1; // FST 188611577SDylan.Johnson@ARM.com // TODO: DDI 0487A.f D7-2083, AbortFault's s1ptw bit. 188711577SDylan.Johnson@ARM.com newVal |= armFault->isStage2() ? 1 << 8 : 0; // PTW 188811577SDylan.Johnson@ARM.com newVal |= armFault->isStage2() ? 1 << 9 : 0; // S 188911577SDylan.Johnson@ARM.com newVal |= 1 << 11; // RES1 189011577SDylan.Johnson@ARM.com } 189110037SARM gem5 Developers DPRINTF(MiscRegs, 189210037SARM gem5 Developers "MISCREG: Translated addr %#x fault fsr %#x: PAR: %#x\n", 189310037SARM gem5 Developers val, fsr, newVal); 189410037SARM gem5 Developers } 189510037SARM gem5 Developers delete req; 189610037SARM gem5 Developers setMiscRegNoEffect(MISCREG_PAR_EL1, newVal); 189710037SARM gem5 Developers return; 189810037SARM gem5 Developers } 189910037SARM gem5 Developers case MISCREG_SPSR_EL3: 190010037SARM gem5 Developers case MISCREG_SPSR_EL2: 190110037SARM gem5 Developers case MISCREG_SPSR_EL1: 190210037SARM gem5 Developers // Force bits 23:21 to 0 190310037SARM gem5 Developers newVal = val & ~(0x7 << 21); 190410037SARM gem5 Developers break; 19058549Sdaniel.johnson@arm.com case MISCREG_L2CTLR: 19068549Sdaniel.johnson@arm.com warn("miscreg L2CTLR (%s) written with %#x. ignored...\n", 19078549Sdaniel.johnson@arm.com miscRegName[misc_reg], uint32_t(val)); 190810037SARM gem5 Developers break; 190910037SARM gem5 Developers 191010037SARM gem5 Developers // Generic Timer registers 191110844Sandreas.sandberg@arm.com case MISCREG_CNTFRQ ... MISCREG_CNTHP_CTL: 191210844Sandreas.sandberg@arm.com case MISCREG_CNTPCT ... MISCREG_CNTHP_CVAL: 191310844Sandreas.sandberg@arm.com case MISCREG_CNTKCTL_EL1 ... MISCREG_CNTV_CVAL_EL0: 191410844Sandreas.sandberg@arm.com case MISCREG_CNTVOFF_EL2 ... MISCREG_CNTPS_CVAL_EL1: 191510844Sandreas.sandberg@arm.com getGenericTimer(tc).setMiscReg(misc_reg, newVal); 191610037SARM gem5 Developers break; 19177405SAli.Saidi@ARM.com } 19187405SAli.Saidi@ARM.com } 19197405SAli.Saidi@ARM.com setMiscRegNoEffect(misc_reg, newVal); 19207405SAli.Saidi@ARM.com} 19217405SAli.Saidi@ARM.com 192210844Sandreas.sandberg@arm.comBaseISADevice & 192310844Sandreas.sandberg@arm.comISA::getGenericTimer(ThreadContext *tc) 192410037SARM gem5 Developers{ 192510844Sandreas.sandberg@arm.com // We only need to create an ISA interface the first time we try 192610844Sandreas.sandberg@arm.com // to access the timer. 192710844Sandreas.sandberg@arm.com if (timer) 192810844Sandreas.sandberg@arm.com return *timer.get(); 192910844Sandreas.sandberg@arm.com 193010844Sandreas.sandberg@arm.com assert(system); 193110844Sandreas.sandberg@arm.com GenericTimer *generic_timer(system->getGenericTimer()); 193210844Sandreas.sandberg@arm.com if (!generic_timer) { 193310844Sandreas.sandberg@arm.com panic("Trying to get a generic timer from a system that hasn't " 193410844Sandreas.sandberg@arm.com "been configured to use a generic timer.\n"); 193510037SARM gem5 Developers } 193610037SARM gem5 Developers 193711150Smitch.hayenga@arm.com timer.reset(new GenericTimerISA(*generic_timer, tc->contextId())); 193810844Sandreas.sandberg@arm.com return *timer.get(); 193910037SARM gem5 Developers} 194010037SARM gem5 Developers 19417405SAli.Saidi@ARM.com} 19429384SAndreas.Sandberg@arm.com 19439384SAndreas.Sandberg@arm.comArmISA::ISA * 19449384SAndreas.Sandberg@arm.comArmISAParams::create() 19459384SAndreas.Sandberg@arm.com{ 19469384SAndreas.Sandberg@arm.com return new ArmISA::ISA(this); 19479384SAndreas.Sandberg@arm.com} 1948