62 panic(
"getArgument() only implemented for full system mode.\n");
67 panic(
"getArgument(): Floating point arguments not implemented\n");
70 if (size == (uint16_t)(-1))
71 size =
sizeof(uint64_t);
76 panic(
"getArgument(): No support reading stack args for AArch64\n");
79 if (size == (uint16_t)(-1))
86 if (size ==
sizeof(uint64_t)) {
87 if ((number % 2) != 0)
102 if (size ==
sizeof(uint64_t)) {
104 if ((number % 2) != 0)
106 arg = vp.
read<uint64_t>(sp +
111 arg = vp.
read<uint32_t>(sp +
117 panic(
"getArgument() should always return\n");
145 if (src_mode == Enums::Full) {
181 dynamic_cast<TLB *
>(dest->
getITBPtr())->invalidateMiscReg();
182 dynamic_cast<TLB *
>(dest->
getDTBPtr())->invalidateMiscReg();
231 switch (current_el) {
237 warn_once(
"Trying to read MPIDR at EL0\n");
248 panic(
"Invalid EL for reading MPIDR register\n");
266 assert((0 <= tc->
cpuId()) && (tc->
cpuId() < 256));
286 return id_aa64mmfr1.vh;
308 return id_aa64pfr0.sel2;
343 panic_if(!known,
"EL state is UNKNOWN");
353 (el ==
EL2 || (el ==
EL0 && hcr.tge == 1)));
363 panic_if(el ==
EL2 && !have_el2,
"Asking for EL2 when it doesn't exist");
364 panic_if(el ==
EL3 && !have_el3,
"Asking for EL3 when it doesn't exist");
367 known = aarch32 =
false;
371 known =
true; aarch32 =
false;
374 known =
true; aarch32 =
true;
377 bool aarch32_below_el3 = (have_el3 && scr.rw == 0);
380 bool aarch32_at_el1 = (aarch32_below_el3
385 if (el ==
EL0 && !aarch32_at_el1) {
390 aarch32 = (cpsr.width == 1);
393 aarch32 = (aarch32_below_el3 && el !=
EL3)
394 || (aarch32_at_el1 && (el ==
EL0 || el ==
EL1) );
398 return std::make_pair(known, aarch32);
414 panic(
"Invalid exception level");
445 tbi = selbit? tcr.tbi1 : tcr.tbi0;
446 tbid = selbit? tcr.tbid1 : tcr.tbid0;
453 tbi = selbit? tcr.tbi1 : tcr.tbi0;
454 tbid = selbit? tcr.tbid1 : tcr.tbid0;
473 int res = (tbi && (!tbid || !isInstr))? 55: 63;
478 TCR tcr,
bool isInstr)
480 bool selbit =
bits(addr, 55);
487 uint64_t
mask = ((uint64_t)0x1 << topbit) -1;
490 addr =
bits(addr, topbit, 0);
525 bool trapToHype =
false;
536 trapToHype = ((uint32_t) hstr) & (1 << crn);
537 trapToHype |= hdcr.tpm && (crn == 9) && (crm >= 12);
538 trapToHype |= hcr.tidcp && (
539 ((crn == 9) && ((crm <= 2) || ((crm >= 5) && (crm <= 8)))) ||
540 ((crn == 10) && ((crm <= 1) || (crm == 4) || (crm == 8))) ||
541 ((crn == 11) && ((crm <= 8) || (crm == 15))) );
546 trapToHype = hcptr.tcpac;
552 trapToHype = hcr.tid1;
558 trapToHype = hcr.tid2;
574 trapToHype = hcr.tid3;
579 trapToHype = hcr.tsw;
584 trapToHype = hcr.tpc;
590 trapToHype = hcr.tpu;
610 trapToHype = hcr.ttlb;
613 trapToHype = hcr.tac;
631 trapToHype = hcr.tvm & !isRead;
634 trapToHype = hdcr.tpmcr;
640 if (isa->haveGICv3CpuIfc())
641 trapToHype = hcr.fmo;
648 if (isa->haveGICv3CpuIfc())
649 trapToHype = hcr.imo;
664 HDCR hdcr, HSTR hstr, HCPTR hcptr, uint32_t iss)
672 bool trapToHype =
false;
676 inform(
"trap check M:%x N:%x 1:%x 2:%x hdcr %x, hcptr %x, hstr %x\n",
677 crm, crn, opc1, opc2, hdcr, hcptr, hstr);
678 trapToHype = hdcr.tda && (opc1 == 0);
679 trapToHype |= hcptr.tta && (opc1 == 1);
686 trapToHype = hdcr.tdosa;
690 trapToHype = hdcr.tdra;
693 trapToHype = hcr.tid0;
697 trapToHype = hstr.tjdbx;
701 trapToHype = hstr.ttee;
714 HCR hcr, uint32_t iss)
722 bool trapToHype =
false;
729 trapToHype = ((uint32_t) hstr) & (1 << crm);
749 trapToHype = hcr.tvm & !isRead;
762 CPSR cpsr, SCR scr, NSACR nsacr,
bool checkSecurity)
807 int sysM4To3 =
bits(sysM, 4, 3);
812 }
else if (sysM4To3 == 1) {
815 }
else if (sysM4To3 == 3) {
816 if (
bits(sysM, 1) == 0) {
821 if (
bits(sysM, 0) == 1) {
829 int sysM2 =
bits(sysM, 2);
830 int sysM1 =
bits(sysM, 1);
834 ((sysM2 && !sysM1) << 2) |
835 ((sysM2 && sysM1) << 3) |
840 ok &= mode != cpsr.mode;
845 if (ok && checkSecurity && mode != cpsr.mode) {
853 ok &= (mode !=
MODE_MON) || !scr.ns;
857 ok &= (mode !=
MODE_FIQ) || !nsacr.rfr;
865 ok &= (mode !=
MODE_MON) || !scr.ns;
866 ok &= (mode !=
MODE_FIQ) || !nsacr.rfr;
872 panic(
"unknown Mode 0x%x\n", cpsr.mode);
892 panic(
"Invalid exception level");
916 panic(
"Invalid phys. address range encoding");
937 panic(
"Invalid phys. address range");
#define panic(...)
This implements a cprintf based panic() function.
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
static bool unknownMode(OperatingMode mode)
static ExceptionLevel currEL(ThreadContext *tc)
bool IsSecureEL2Enabled(ThreadContext *tc)
bool HaveVirtHostExt(ThreadContext *tc)
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
virtual BaseTLB * getDTBPtr()=0
virtual TheISA::PCState pcState() const =0
virtual RegVal readIntReg(RegIndex reg_idx) const =0
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
virtual PortProxy & getVirtProxy()=0
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8) ...
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
constexpr unsigned NumVecElemPerVecReg
virtual BaseCPU * getCpuPtr()=0
static Enums::VecRegRenameMode mode(const TheISA::PCState &)
bool mcrMrc14TrapToHyp(const MiscRegIndex miscReg, HCR hcr, CPSR cpsr, SCR scr, HDCR hdcr, HSTR hstr, HCPTR hcptr, uint32_t iss)
virtual RegVal readCCReg(RegIndex reg_idx) const =0
Addr purifyTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, TCR tcr, bool isInstr)
Removes the tag from tagged addresses if that mode is enabled.
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)
ThreadContext is the external interface to all thread state for anything outside of the CPU...
RegVal getMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is returing the value of MPIDR_EL1.
static bool haveEL(ThreadContext *tc, ExceptionLevel el)
Return true if the system implements a specific exception level.
int decodePhysAddrRange64(uint8_t pa_enc)
Returns the n.
bool HaveSecureEL2Ext(ThreadContext *tc)
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
bool isSecureBelowEL3(ThreadContext *tc)
bool isBigEndian64(ThreadContext *tc)
uint8_t encodePhysAddrRange64(int pa_size)
Returns the encoding corresponding to the specified n.
int computeAddrTop(ThreadContext *tc, bool selbit, bool isInstr, TCR tcr, ExceptionLevel el)
int unflattenMiscReg(int reg)
ExceptionLevel s1TranslationRegime(ThreadContext *tc, ExceptionLevel el)
const int ReturnAddressReg
virtual int cpuId() const =0
bool mcrMrc15TrapToHyp(const MiscRegIndex miscReg, ThreadContext *tc, uint32_t iss)
bool multiProc
true if this a multiprocessor system
virtual void pcStateNoRecord(const TheISA::PCState &val)=0
uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
const int StackPointerReg
virtual const VecElem & readVecElemFlat(RegIndex idx, const ElemIndex &elemIdx) const =0
bool mcrrMrrc15TrapToHyp(const MiscRegIndex miscReg, CPSR cpsr, SCR scr, HSTR hstr, HCR hcr, uint32_t iss)
bool SPAlignmentCheckEnabled(ThreadContext *tc)
static ExceptionLevel opModeToEL(OperatingMode mode)
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
virtual BaseTLB * getITBPtr()=0
virtual const VecRegContainer & readVecRegFlat(RegIndex idx) const =0
virtual void setFloatRegFlat(RegIndex idx, RegVal val)=0
static void copyVecRegs(ThreadContext *src, ThreadContext *dest)
const int NumArgumentRegs
virtual void setVecElemFlat(RegIndex idx, const ElemIndex &elemIdx, const VecElem &val)=0
std::pair< bool, bool > ELUsingAArch32K(ThreadContext *tc, ExceptionLevel el)
This function checks whether selected EL provided as an argument is using the AArch32 ISA...
virtual void setCCReg(RegIndex reg_idx, RegVal val)=0
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
virtual BaseISA * getIsaPtr()=0
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Addr roundPage(Addr addr)
#define ULL(N)
uint64_t constant
Addr truncPage(Addr addr)
void sendEvent(ThreadContext *tc)
Send an event (SEV) to a specific PE if there isn't already a pending event.
void skipFunction(ThreadContext *tc)
bool decodeMrsMsrBankedReg(uint8_t sysM, bool r, bool &isIntReg, int ®Idx, CPSR cpsr, SCR scr, NSACR nsacr, bool checkSecurity)
This object is a proxy for a port or other object which implements the functional response protocol...
virtual CheckerCPU * getCheckerCpuPtr()=0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
static bool unknownMode32(OperatingMode mode)
bool longDescFormatInUse(ThreadContext *tc)
ExceptionLevel highestEL() const
Returns the highest implemented exception level.
GenericISA::SimplePCState< MachInst > PCState
static void mcrMrcIssExtract(uint32_t iss, bool &isRead, uint32_t &crm, IntRegIndex &rt, uint32_t &crn, uint32_t &opc1, uint32_t &opc2)
virtual int threadId() const =0
virtual RegVal readIntRegFlat(RegIndex idx) const =0
Flat register interfaces.
TranslatingPortProxy Object Declaration for FS.
virtual uint32_t socketId() const =0
virtual ContextID contextId() const =0
virtual void setVecRegFlat(RegIndex idx, const VecRegContainer &val)=0
bool inAArch64(ThreadContext *tc)
virtual RegVal readFloatRegFlat(RegIndex idx) const =0
virtual void setIntRegFlat(RegIndex idx, RegVal val)=0
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 bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
bool EL2Enabled(ThreadContext *tc)
void copyRegs(ThreadContext *src, ThreadContext *dest)
bool badMode32(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented for AArch3...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
virtual RegVal readMiscReg(RegIndex misc_reg)=0
bool badMode(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented.
void postInterrupt(ThreadID tid, int int_num, int index)
static int intRegInMode(OperatingMode mode, int reg)
bool haveLPAE() const
Returns true if this system implements the Large Physical Address Extension.