51 #include "debug/Arm.hh" 52 #include "debug/MiscRegs.hh" 56 #include "params/ArmISA.hh" 65 _decoderFlavour(p->decoderFlavour), _vecRegRenameMode(Enums::Full),
66 pmu(p->pmu), haveGICv3CPUInterface(false), impdefAsNop(p->impdef_nop),
103 sveVL = p->sve_vl_se;
148 mvfr0.advSimdRegisters = 2;
149 mvfr0.singlePrecision = 2;
150 mvfr0.doublePrecision = 2;
151 mvfr0.vfpExceptionTrapping = 0;
153 mvfr0.squareRoot = 1;
154 mvfr0.shortVectors = 1;
155 mvfr0.roundingModes = 1;
159 mvfr1.flushToZero = 1;
160 mvfr1.defaultNaN = 1;
161 mvfr1.advSimdLoadStore = 1;
162 mvfr1.advSimdInteger = 1;
163 mvfr1.advSimdSinglePrecision = 1;
164 mvfr1.advSimdHalfPrecision = 1;
165 mvfr1.vfpHalfPrecision = 1;
226 sctlr.te = (bool) sctlr_rst.te;
227 sctlr.nmfi = (
bool) sctlr_rst.nmfi;
228 sctlr.v = (bool) sctlr_rst.v;
286 panic(
"Invalid highest implemented exception level");
356 (p->id_aa64dfr0_el1 & 0xfffffffffffff0ff
ULL) |
357 (p->pmu ? 0x0000000000000100ULL : 0);
367 (p->pmu ? 0x03000000
ULL : 0);
389 miscRegs[MISCREG_ID_AA64PFR0_EL1], 11, 8,
393 miscRegs[MISCREG_ID_AA64PFR0_EL1], 35, 32,
401 miscRegs[MISCREG_ID_AA64MMFR0_EL1], 3, 0,
409 miscRegs[MISCREG_ID_AA64ISAR0_EL1], 23, 20,
443 int lower = map.first, upper = map.second;
449 DPRINTF(MiscRegs,
"Reading MiscReg %s with set res0 bits: %#x\n",
453 DPRINTF(MiscRegs,
"Reading MiscReg %s with clear res1 bits: %#x\n",
470 cpsr.j = pc.jazelle() ? 1 : 0;
471 cpsr.t = pc.thumb() ? 1 : 0;
478 warn(
"Unimplemented system register %s read.\n",
481 panic(
"Unimplemented system register %s read.\n",
494 const uint32_t ones = (uint32_t)(-1);
498 cpacrMask.cp10 = ones;
499 cpacrMask.cp11 = ones;
500 cpacrMask.asedis = ones;
509 if (!nsacr.cp10) cpacrMask.cp10 = 0;
510 if (!nsacr.cp11) cpacrMask.cp11 = 0;
515 DPRINTF(MiscRegs,
"Reading misc reg %s: %#x\n",
545 warn_once(
"The clidr register always reports 0 caches.\n");
546 warn_once(
"clidr LoUIS field of 0b001 to match current " 547 "ARM implementations.\n");
550 warn_once(
"The ccsidr register isn't implemented and " 551 "always reads as 0.\n");
558 unsigned lineSizeWords =
560 unsigned log2LineSizeWords = 0;
562 while (lineSizeWords >>= 1) {
568 ctr.iCacheLineSize = log2LineSizeWords;
570 ctr.l1IndexPolicy = 0x3;
572 ctr.dCacheLineSize = log2LineSizeWords;
574 ctr.erg = log2LineSizeWords;
576 ctr.cwg = log2LineSizeWords;
583 warn(
"Not doing anything for miscreg ACTLR\n");
593 panic(
"shouldn't be reading this register seperately\n");
600 const uint32_t ones = (uint32_t)(-1);
602 fpscrMask.ioc = ones;
603 fpscrMask.dzc = ones;
604 fpscrMask.ofc = ones;
605 fpscrMask.ufc = ones;
606 fpscrMask.ixc = ones;
607 fpscrMask.idc = ones;
617 const uint32_t ones = (uint32_t)(-1);
619 fpscrMask.len = ones;
620 fpscrMask.fz16 = ones;
621 fpscrMask.stride = ones;
622 fpscrMask.rMode = ones;
625 fpscrMask.ahp = ones;
711 if (!secure_lookup) {
713 val |= (mask ^ 0x7FFF) & 0xBFFF;
733 | (haveTimer ? 0x00010000 : 0x0);
736 return 0x0000000000000002 |
740 (
haveSVE ? 0x0000000100000000 : 0) |
774 int lower = map.first, upper = map.second;
776 auto v = (val & ~
reg.wi()) |
reg.rao();
780 DPRINTF(MiscRegs,
"Writing to misc reg %d (%d:%d) : %#x\n",
781 misc_reg, lower, upper,
v);
784 DPRINTF(MiscRegs,
"Writing to misc reg %d (%d) : %#x\n",
802 int old_mode = old_cpsr.mode;
804 if (old_mode != cpsr.mode || cpsr.il != old_cpsr.il) {
809 if (cpsr.pan != old_cpsr.pan) {
813 DPRINTF(Arm,
"Updating CPSR from %#x to %#x f:%d i:%d a:%d mode:%#x\n",
814 miscRegs[misc_reg], cpsr, cpsr.f, cpsr.i, cpsr.a, cpsr.mode);
816 pc.nextThumb(cpsr.t);
817 pc.nextJazelle(cpsr.j);
818 pc.illegalExec(cpsr.il == 1);
834 warn(
"Unimplemented system register %s write with %#x.\n",
837 panic(
"Unimplemented system register %s write with %#x.\n",
845 const uint32_t ones = (uint32_t)(-1);
849 cpacrMask.cp10 = ones;
850 cpacrMask.cp11 = ones;
851 cpacrMask.asedis = ones;
860 if (!nsacr.cp10) cpacrMask.cp10 = 0;
861 if (!nsacr.cp11) cpacrMask.cp11 = 0;
867 newVal |= old_val & ~cpacrMask;
868 DPRINTF(MiscRegs,
"Writing misc reg %s: %#x\n",
874 const uint32_t ones = (uint32_t)(-1);
876 cpacrMask.tta = ones;
877 cpacrMask.fpen = ones;
879 cpacrMask.zen = ones;
882 DPRINTF(MiscRegs,
"Writing misc reg %s: %#x\n",
888 const uint32_t ones = (uint32_t)(-1);
890 cptrMask.tcpac = ones;
898 cptrMask.res1_13_12_el2 = ones;
899 cptrMask.res1_7_0_el2 = ones;
901 cptrMask.res1_8_el2 = ones;
903 cptrMask.res1_9_el2 = ones;
905 DPRINTF(MiscRegs,
"Writing misc reg %s: %#x\n",
911 const uint32_t ones = (uint32_t)(-1);
913 cptrMask.tcpac = ones;
920 DPRINTF(MiscRegs,
"Writing misc reg %s: %#x\n",
925 warn_once(
"The csselr register isn't implemented.\n");
929 warn(
"Calling DC ZVA! Not Implemeted! Expect WEIRD results\n");
934 const uint32_t ones = (uint32_t)(-1);
936 fpscrMask.ioc = ones;
937 fpscrMask.dzc = ones;
938 fpscrMask.ofc = ones;
939 fpscrMask.ufc = ones;
940 fpscrMask.ixc = ones;
941 fpscrMask.idc = ones;
942 fpscrMask.ioe = ones;
943 fpscrMask.dze = ones;
944 fpscrMask.ofe = ones;
945 fpscrMask.ufe = ones;
946 fpscrMask.ixe = ones;
947 fpscrMask.ide = ones;
948 fpscrMask.len = ones;
949 fpscrMask.fz16 = ones;
950 fpscrMask.stride = ones;
951 fpscrMask.rMode = ones;
954 fpscrMask.ahp = ones;
960 newVal = (newVal & (uint32_t)fpscrMask) |
962 ~(uint32_t)fpscrMask);
968 const uint32_t ones = (uint32_t)(-1);
970 fpscrMask.ioc = ones;
971 fpscrMask.dzc = ones;
972 fpscrMask.ofc = ones;
973 fpscrMask.ufc = ones;
974 fpscrMask.ixc = ones;
975 fpscrMask.idc = ones;
981 newVal = (newVal & (uint32_t)fpscrMask) |
983 ~(uint32_t)fpscrMask);
989 const uint32_t ones = (uint32_t)(-1);
991 fpscrMask.len = ones;
992 fpscrMask.fz16 = ones;
993 fpscrMask.stride = ones;
994 fpscrMask.rMode = ones;
997 fpscrMask.ahp = ones;
998 newVal = (newVal & (uint32_t)fpscrMask) |
1000 ~(uint32_t)fpscrMask);
1029 const uint32_t fpexcMask = 0x60000000;
1030 newVal = (newVal & fpexcMask) |
1042 const uint32_t ifsrMask =
1044 newVal = newVal & ~ifsrMask;
1050 const uint32_t dfsrMask =
mask(31, 14) |
mask(8, 8);
1051 newVal = newVal & ~dfsrMask;
1061 DPRINTF(MiscRegs,
"Writing AMAIR: %#x\n", newVal);
1070 DPRINTF(MiscRegs,
"Writing SCTLR: %#x\n", newVal);
1081 SCTLR new_sctlr = newVal;
1174 mbits(newVal, 31, 12),
1189 mbits(newVal, 31, 12),
1232 mbits(newVal, 31,12));
1245 mbits(newVal, 31,12));
1261 mbits(newVal, 31,12));
1274 mbits(newVal, 31,12));
1291 static_cast<Addr>(
bits(newVal, 35, 0)) << 12);
1306 static_cast<Addr>(
bits(newVal, 35, 0)) << 12);
1319 mbits(newVal, 31, 12),
1333 mbits(newVal, 31, 12),
1467 static_cast<Addr>(
bits(newVal, 43, 0)) << 12,
1479 static_cast<Addr>(
bits(newVal, 43, 0)) << 12,
1493 static_cast<Addr>(
bits(newVal, 43, 0)) << 12,
1506 static_cast<Addr>(
bits(newVal, 43, 0)) << 12,
1519 bits(newVal, 55, 48);
1522 static_cast<Addr>(bits(newVal, 43, 0)) << 12,
1535 bits(newVal, 55, 48);
1538 static_cast<Addr>(bits(newVal, 43, 0)) << 12,
1551 bits(newVal, 55, 48);
1563 bits(newVal, 55, 48);
1579 static_cast<Addr>(
bits(newVal, 43, 0)) << 12);
1592 static_cast<Addr>(
bits(newVal, 43, 0)) << 12);
1606 static_cast<Addr>(
bits(newVal, 35, 0)) << 12);
1620 static_cast<Addr>(
bits(newVal, 35, 0)) << 12);
1626 warn(
"Not doing anything for write of miscreg ACTLR\n");
1641 newVal &= ~((uint32_t) hstrMask);
1651 if (!secure_lookup) {
1655 newVal = (newVal & ~mask) | (oldValue & mask);
1703 panic(
"Security Extensions required for ATS12NSOPR");
1710 panic(
"Security Extensions required for ATS12NSOPW");
1717 panic(
"Security Extensions required for ATS12NSOUR");
1724 panic(
"Security Extensions required for ATS12NSOUW");
1746 warn(
"Translating via %s in functional mode! Fix Me!\n",
1749 auto req = std::make_shared<Request>(
1754 req, tc, mode, tranType);
1761 Addr paddr = req->getPaddr();
1764 newVal = (paddr &
mask(39, 12)) |
1767 newVal = (paddr & 0xfffff000) |
1771 "MISCREG: Translated addr 0x%08x: PAR: 0x%08x\n",
1777 FSR fsr = armFault->
getFsr(tc);
1779 newVal = ((fsr >> 9) & 1) << 11;
1782 newVal |= ((fsr >> 0) & 0x3f) << 1;
1785 newVal |= ((fsr >> 0) & 0xf) << 1;
1786 newVal |= ((fsr >> 10) & 0x1) << 5;
1787 newVal |= ((fsr >> 12) & 0x1) << 6;
1790 newVal |= ((armFault->
iss() >> 7) & 0x1) << 8;
1791 newVal |= armFault->
isStage2() ? 0x200 : 0;
1793 "MISCREG: Translated addr 0x%08x fault fsr %#x: PAR: 0x%08x\n",
1802 const uint32_t ones = (uint32_t)(-1);
1803 TTBCR ttbcrMask = 0;
1804 TTBCR ttbcrNew = newVal;
1809 ttbcrMask.pd0 = ones;
1810 ttbcrMask.pd1 = ones;
1812 ttbcrMask.epd0 = ones;
1813 ttbcrMask.irgn0 = ones;
1814 ttbcrMask.orgn0 = ones;
1815 ttbcrMask.sh0 = ones;
1816 ttbcrMask.ps = ones;
1817 ttbcrMask.a1 = ones;
1818 ttbcrMask.epd1 = ones;
1819 ttbcrMask.irgn1 = ones;
1820 ttbcrMask.orgn1 = ones;
1821 ttbcrMask.sh1 = ones;
1823 ttbcrMask.eae = ones;
1826 newVal = newVal & ttbcrMask;
1828 newVal = (newVal & ttbcrMask) | (ttbcr & (~ttbcrMask));
1843 uint64_t ttbrMask =
mask(63,56) |
mask(47,40);
1844 newVal = (newVal & (~ttbrMask));
1888 cpsr.daif = (uint8_t) ((CPSR) newVal).
daif;
1905 cpsr.sp = (uint8_t) ((CPSR) newVal).
sp;
1913 cpsr.el = (uint8_t) ((CPSR) newVal).
el;
1924 cpsr.pan = (uint8_t) ((CPSR) newVal).
pan;
1942 RequestPtr req = std::make_shared<Request>();
2015 warn(
"Translating via %s in functional mode! Fix Me!\n",
2026 Addr paddr = req->getPaddr();
2028 uint64_t attr1 = attr >> 56;
2029 if (!attr1 || attr1 ==0x44) {
2031 attr &= ~ uint64_t(0x80);
2033 newVal = (paddr &
mask(47, 12)) | attr;
2035 "MISCREG: Translated addr %#x: PAR_EL1: %#xx\n",
2041 FSR fsr = armFault->
getFsr(tc);
2045 newVal = ((fsr >> 9) & 1) << 11;
2047 newVal |= ((fsr >> 0) & 0x3f) << 1;
2049 newVal |= ((armFault->
iss() >> 7) & 0x1) << 8;
2050 newVal |= armFault->
isStage2() ? 0x200 : 0;
2055 newVal |= armFault->
isStage2() ? 1 << 8 : 0;
2056 newVal |= armFault->
isStage2() ? 1 << 9 : 0;
2060 "MISCREG: Translated addr %#x fault fsr %#x: PAR: %#x\n",
2071 ~(0x5 << 21) : ~(0x7 << 21);
2073 newVal = val & spsr_mask;
2077 warn(
"miscreg L2CTLR (%s) written with %#x. ignored...\n",
2113 return *
timer.get();
2117 if (!generic_timer) {
2118 panic(
"Trying to get a generic timer from a system that hasn't " 2119 "been configured to use a generic timer.\n");
2123 timer->setThreadContext(tc);
2125 return *
timer.get();
2143 "A ThreadContext is needed to determine the SVE vector length " 2144 "in full-system mode");
2158 (el ==
EL0 || el ==
EL1)) {
2161 static_cast<unsigned>(
2170 static_cast<unsigned>(
2174 len = std::min(len,
sveVL - 1);
2176 return (len + 1) * 128;
2182 auto vv = vc.
as<uint64_t>();
2183 for (
int i = 2;
i < eCount; ++
i) {
2194 case EL2: hyp();
break;
2195 case EL3: mon();
break;
2203 ArmISAParams::create()
#define panic(...)
This implements a cprintf based panic() function.
virtual System * getSystemPtr()=0
unsigned sveVL
SVE vector length in quadwords.
bitset< NUM_MISCREG_INFOS > miscRegInfo[NUM_MISCREGS]
BaseISADevice & getGenericTimer(ThreadContext *tc)
decltype(nullptr) constexpr NoFault
bool haveGICv3CPUInterface
virtual void setISA(ISA *isa)
virtual TheISA::Decoder * getDecoderPtr()=0
The file contains the definition of a set of TLB Invalidate Instructions.
Instruction TLB Invalidate All.
This module implements the global system counter and the local per-CPU architected timers as specifie...
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
void clear32(const ArmISAParams *p, const SCTLR &sctlr_rst)
VecRegT< VecElem, NumElems, true > as() const
View interposers.
Vector Register Abstraction This generic class is the model in a particularization of MVC...
virtual TheISA::PCState pcState() const =0
virtual RegVal readIntReg(RegIndex reg_idx) const =0
virtual RegVal readMiscReg(int misc_reg)=0
Read a system register belonging to this device.
RegVal readMiscRegNoEffect(int misc_reg) const
std::shared_ptr< Request > RequestPtr
bool havePAN() const
Returns true if Priviledge Access Never is implemented.
Instruction TLB Invalidate by VA.
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8) ...
Base class for devices that use the MiscReg interfaces.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
void preUnflattenMiscReg()
virtual BaseCPU * getCpuPtr()=0
static std::vector< struct MiscRegLUTEntry > lookUpMiscReg
Metadata table accessible via the value of the register.
virtual FSR getFsr(ThreadContext *tc) const
const char *const miscRegName[]
virtual RegVal readCCReg(RegIndex reg_idx) const =0
void clear64(const ArmISAParams *p)
RegVal readMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is either returing the value of MPIDR_EL1 (by calling getMPIDR), or it is issuing a read to VMPIDR_EL2 (as it happens in virtualized systems)
TLB Invalidate by VA, All ASID.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
unsigned getCurSveVecLenInBits(ThreadContext *tc) const
virtual void setThreadContext(ThreadContext *tc)
bool haveSVE() const
Returns true if SVE is implemented (ARMv8)
void setMiscRegNoEffect(int misc_reg, RegVal val)
Data TLB Invalidate by ASID match.
Instruction TLB Invalidate by ASID match.
uint8_t encodePhysAddrRange64(int pa_size)
Returns the encoding corresponding to the specified n.
int unflattenMiscReg(int reg)
void initializeMiscRegMetadata()
const Enums::VecRegRenameMode _vecRegRenameMode
virtual void pcStateNoRecord(const TheISA::PCState &val)=0
RegVal miscRegs[NumMiscRegs]
void initID64(const ArmISAParams *p)
unsigned sveVL() const
Returns the SVE vector length at reset, in quadwords.
BaseGic * getGIC() const
Get a pointer to the system's GIC.
chain highest(ArmSystem *const sys) const
std::pair< int, int > getMiscIndices(int misc_reg) const
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
BaseISADevice & getGICv3CPUInterface(ThreadContext *tc)
unsigned numContexts() const
static const uint32_t CpsrMaskQ
T insertBits(T val, int first, int last, B bit_val)
Returns val with bits first to last set to the LSBs of bit_val.
virtual void setMiscReg(int misc_reg, RegVal val)=0
Write to a system register belonging to this device.
std::unique_ptr< BaseISADevice > timer
std::unique_ptr< BaseISADevice > gicv3CpuInterface
bool translateFunctional(ThreadContext *tc, Addr vaddr, Addr &paddr)
Do a functional lookup on the TLB (for debugging) and don't modify any internal state.
virtual void setCCReg(RegIndex reg_idx, RegVal val)=0
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
#define ULL(N)
uint64_t constant
Gicv3CPUInterface * getCPUInterface(int cpu_id) const
This master id is used for functional requests that don't come from a particular device.
bool haveCrypto() const
Returns true if this system implements the Crypto Extension.
void initID32(const ArmISAParams *p)
virtual bool isStage2() const
TLB Invalidate by ASID match.
void assert32(ThreadContext *tc)
const Params * params() const
virtual uint32_t iss() const =0
DummyISADevice dummyDevice
Dummy device for to handle non-existing ISA devices.
TLB Invalidate All, Non-Secure.
virtual CheckerCPU * getCheckerCpuPtr()=0
uint8_t physAddrRange() const
Returns the supported physical address range in bits.
ExceptionLevel highestEL() const
Returns the highest implemented exception level.
GenericISA::SimplePCState< MachInst > PCState
virtual int threadId() const =0
void setMiscReg(int misc_reg, RegVal val, ThreadContext *tc)
void broadcast(ThreadContext *tc)
Broadcast the TLB Invalidate operation to all TLBs in the Arm system.
const SimObjectParams * _params
Cached copy of the object parameters.
virtual ContextID contextId() const =0
BaseInterrupts * getInterruptController(ThreadID tid)
bool haveLSE() const
Returns true if LSE is implemented (ARMv8.1)
GenericTimer * getGenericTimer() const
Get a pointer to the system's generic timer model.
void assert64(ThreadContext *tc)
static const uint32_t FpscrExcMask
void update(ThreadContext *tc)
RegVal readMiscReg(int misc_reg, ThreadContext *tc)
bool inSecureState(ThreadContext *tc)
bool ELIsInHost(ThreadContext *tc, ExceptionLevel el)
Returns true if the current exception level el is executing a Host OS or an application of a Host OS ...
T mbits(T val, int first, int last)
Mask off the given bits in place like bits() but without shifting.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
bool haveLargeAsid64() const
Returns true if ASID is 16 bits in AArch64 (ARMv8)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Addr resetAddr() const
Returns the reset address if the highest implemented exception level is 64 bits (ARMv8) ...
virtual RegVal readMiscReg(RegIndex misc_reg)=0
std::shared_ptr< FaultBase > Fault
void updateRegMap(CPSR cpsr)
TLB Invalidate by Intermediate Physical Address.
Data TLB Invalidate by VA.
static void zeroSveVecRegUpperPart(VecRegContainer &vc, unsigned eCount)
static const uint32_t FpscrQcMask
bool haveLPAE() const
Returns true if this system implements the Large Physical Address Extension.
unsigned int cacheLineSize() const
Get the cache line size of the system.
virtual void startup()
startup() is the final initialization call before simulation.