Go to the documentation of this file.
98 route_to_el2 = (hdcr.tde == 1 || hcr.tge == 1);
102 route_to_el2 = (mdcr.tde == 1 || hcr.tge == 1);
105 route_to_el2 =
false;
140 switch (current_el) {
146 warn_once(
"Trying to read MPIDR at EL0\n");
157 panic(
"Invalid EL for reading MPIDR register\n");
175 assert((0 <= tc->
cpuId()) && (tc->
cpuId() < 256));
178 RegVal mpidr = 0x80000000;
219 return id_aa64isar1.api | id_aa64isar1.apa |
220 id_aa64isar1.gpi | id_aa64isar1.gpa;
227 return id_aa64mmfr1.vh;
234 return (
bool)mm_fr2.varange;
256 return id_aa64pfr0.sel2;
292 panic_if(!known,
"EL state is UNKNOWN");
334 panic_if(
el ==
EL2 && !have_el2,
"Asking for EL2 when it doesn't exist");
335 panic_if(
el ==
EL3 && !have_el3,
"Asking for EL3 when it doesn't exist");
338 known = aarch32 =
false;
342 known =
true; aarch32 =
false;
343 }
else if (secure &&
el ==
EL2) {
344 known =
true; aarch32 =
false;
347 known =
true; aarch32 =
true;
349 known =
true; aarch32 =
false;
352 bool aarch32_below_el3 = have_el3 && scr.rw == 0 &&
357 bool aarch32_at_el1 = (aarch32_below_el3 ||
358 (have_el2 && (sec_el2 || !secure) &&
359 hcr.rw == 0 && !(hcr.e2h && hcr.tge &&
363 if (
el ==
EL0 && !aarch32_at_el1) {
367 aarch32 = (cpsr.width == 1);
370 aarch32 = (aarch32_below_el3 &&
el !=
EL3)
371 || (aarch32_at_el1 && (
el ==
EL0 ||
el ==
EL1) );
375 return std::make_pair(known, aarch32);
383 panic_if(!known,
"EL state is UNKNOWN");
400 panic(
"Invalid exception level");
431 tbi = selbit? tcr.tbi1 : tcr.tbi0;
432 tbid = selbit? tcr.tbid1 : tcr.tbid0;
439 tbi = selbit? tcr.tbi1 : tcr.tbi0;
440 tbid = selbit? tcr.tbid1 : tcr.tbid0;
459 int res = (
tbi && (!
tbid || !isInstr))? 55: 63;
464 TCR tcr,
bool isInstr)
472 uint64_t
mask = ((uint64_t)0x1 << topbit) -1;
507 return std::make_shared<HypervisorTrap>(machInst,
imm,
ec);
521 bool trapToHype =
false;
532 trapToHype = ((uint32_t) hstr) & (1 << crn);
533 trapToHype |= hdcr.tpm && (crn == 9) && (crm >= 12);
534 trapToHype |= hcr.tidcp && (
535 ((crn == 9) && ((crm <= 2) || ((crm >= 5) && (crm <= 8)))) ||
536 ((crn == 10) && ((crm <= 1) || (crm == 4) || (crm == 8))) ||
537 ((crn == 11) && ((crm <= 8) || (crm == 15))) );
542 trapToHype = hcptr.tcpac;
548 trapToHype = hcr.tid1;
554 trapToHype = hcr.tid2;
572 trapToHype = hcr.tid3;
577 trapToHype = hcr.tsw;
582 trapToHype = hcr.tpc;
588 trapToHype = hcr.tpu;
608 trapToHype = hcr.ttlb;
611 trapToHype = hcr.tac;
629 trapToHype = hcr.tvm & !isRead;
632 trapToHype = hdcr.tpmcr;
638 if (isa->haveGICv3CpuIfc())
639 trapToHype = hcr.fmo;
646 if (isa->haveGICv3CpuIfc())
647 trapToHype = hcr.imo;
670 HDCR hdcr, HSTR hstr, HCPTR hcptr, uint32_t iss)
678 bool trapToHype =
false;
682 inform(
"trap check M:%x N:%x 1:%x 2:%x hdcr %x, hcptr %x, hstr %x\n",
683 crm, crn, opc1,
opc2, hdcr, hcptr, hstr);
684 trapToHype = hdcr.tda && (opc1 == 0);
685 trapToHype |= hcptr.tta && (opc1 == 1);
692 trapToHype = hdcr.tdosa;
696 trapToHype = hdcr.tdra;
699 trapToHype = hcr.tid0;
703 trapToHype = hstr.tjdbx;
707 trapToHype = hstr.ttee;
724 return std::make_shared<HypervisorTrap>(machInst,
imm,
ec);
738 bool trapToHype =
false;
750 trapToHype = ((uint32_t) hstr) & (1 << crm);
770 trapToHype = hcr.tvm & !isRead;
796 return std::make_shared<SupervisorTrap>(machInst,
imm,
ec);
799 return std::make_shared<HypervisorTrap>(machInst,
imm,
ec);
849 if (
ELIs32(tc,
EL1) && trap_cond && hcr.tge) {
872 return !cnthctl.el1pcten;
874 return !cnthctl.el1pcen;
891 return !(
EL2Enabled(tc) && hcr.e2h && hcr.tge) && trap_cond &&
908 return !cntkctl.el0pcten && !cntkctl.el0vcten;
911 return !cntkctl.el0pcten;
914 return !cntkctl.el0vcten;
917 return !cntkctl.el0pten;
920 return !cntkctl.el0vten;
983 return (!
ELIs32(tc,
EL1) && !hcr.e2h && trap_cond_el1 && hcr.tge) ||
984 (
ELIs32(tc,
EL1) && trap_cond_el1 && hcr.tge) ||
985 (hcr.e2h && hcr.tge && trap_cond_el2);
999 return !hcr.e2h && trap_cond_1;
1002 return (!hcr.e2h && trap_cond_0) ||
1003 (hcr.e2h && !hcr.tge && trap_cond_1);
1025 return (!hcr.e2h && trap_cond_0) ||
1026 (hcr.e2h && trap_cond_1);
1039 return !
ELIs32(tc,
EL1) && !(hcr.e2h && hcr.tge) && trap_cond;
1050 return !cnthctl.el0pcten && !cnthctl.el0vcten;
1053 return !cnthctl.el0pcten;
1056 return !cnthctl.el0vcten;
1059 return !cnthctl.el0pten;
1062 return !cnthctl.el0vten;
1076 const CNTHCTL cnthctl = cnthctl_val;
1077 const CNTHCTL_E2H cnthctl_e2h = cnthctl_val;
1081 return hcr.e2h ? !cnthctl_e2h.el1pcten : !cnthctl.el1pcten;
1087 return hcr.e2h ? cnthctl_e2h.el1tvct : cnthctl.el1tvct;
1090 return hcr.e2h ? !cnthctl_e2h.el1pten :
false;
1096 return hcr.e2h ? cnthctl_e2h.el1tvt : cnthctl.el1tvt;
1108 return !cnthctl.el1pcen;
1119 return currEL(tc) ==
EL1 && !scr.ns && !scr.st;
1129 CPSR cpsr, SCR scr, NSACR nsacr,
bool checkSecurity)
1174 int sysM4To3 =
bits(sysM, 4, 3);
1176 if (sysM4To3 == 0) {
1179 }
else if (sysM4To3 == 1) {
1182 }
else if (sysM4To3 == 3) {
1183 if (
bits(sysM, 1) == 0) {
1188 if (
bits(sysM, 0) == 1) {
1196 int sysM2 =
bits(sysM, 2);
1197 int sysM1 =
bits(sysM, 1);
1201 ((sysM2 && !sysM1) << 2) |
1202 ((sysM2 && sysM1) << 3) |
1207 ok &=
mode != cpsr.mode;
1212 if (ok && checkSecurity &&
mode != cpsr.mode) {
1239 panic(
"unknown Mode 0x%x\n", cpsr.mode);
1251 bool have_nv_ext =
false;
1254 have_nv_ext && hcr.nv == 1 && hcr.nv1 == 1);
1256 currEL(tc) ==
EL2 && hcr.e2h == 1 && hcr.tge == 1;
1259 bool user_access_override =
false;
1260 return (unpriv_el1 || unpriv_el2) && !user_access_override;
1282 panic(
"Invalid exception level");
1306 panic(
"Invalid phys. address range encoding");
1329 panic(
"Invalid phys. address range");
Fault AArch64AArch32SystemAccessTrap(const MiscRegIndex miscReg, ExtMachInst machInst, ThreadContext *tc, uint32_t imm, ExceptionClass ec)
bool condGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
static int intRegInMode(OperatingMode mode, int reg)
virtual RegVal readMiscReg(RegIndex misc_reg)=0
constexpr decltype(nullptr) NoFault
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
bool haveLPAE() const
Returns true if this system implements the Large Physical Address Extension.
int decodePhysAddrRange64(uint8_t pa_enc)
Returns the n.
@ EC_TRAPPED_CP15_MCR_MRC
bool isGenericTimerVirtSystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
uint8_t encodePhysAddrRange64(int pa_size)
Returns the encoding corresponding to the specified n.
constexpr void replaceBits(T &val, unsigned first, unsigned last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
bool isSecureBelowEL3(ThreadContext *tc)
static ExceptionLevel currEL(const ThreadContext *tc)
bool condGenericTimerPhysHypTrap(const MiscRegIndex miscReg, ThreadContext *tc)
bool mcrMrc15TrapToHyp(const MiscRegIndex miscReg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
Fault mcrMrc15Trap(const MiscRegIndex miscReg, ExtMachInst machInst, ThreadContext *tc, uint32_t imm)
@ MISCREG_ID_AA64MMFR0_EL1
static ExceptionLevel opModeToEL(OperatingMode mode)
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 ...
Fault mcrrMrrc15Trap(const MiscRegIndex miscReg, ExtMachInst machInst, ThreadContext *tc, uint32_t imm)
bool inAArch64(ThreadContext *tc)
bool mcrrMrrc15TrapToHyp(const MiscRegIndex miscReg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
bool badMode(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented.
virtual int cpuId() const =0
Addr truncPage(Addr addr)
bool isGenericTimerSystemAccessTrapEL3(const MiscRegIndex miscReg, ThreadContext *tc)
bool condGenericTimerSystemAccessTrapEL1(const MiscRegIndex miscReg, ThreadContext *tc)
std::pair< bool, bool > ELUsingAArch32K(ThreadContext *tc, ExceptionLevel el)
This function checks whether selected EL provided as an argument is using the AArch32 ISA.
bool HaveLVA(ThreadContext *tc)
Addr purifyTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, TCR tcr, bool isInstr)
Removes the tag from tagged addresses if that mode is enabled.
bool HavePACExt(ThreadContext *tc)
static bool unknownMode32(OperatingMode mode)
static RegVal getAff1(ArmSystem *arm_sys, ThreadContext *tc)
bool multiProc
true if this a multiprocessor system
static RegVal getAff2(ArmSystem *arm_sys, ThreadContext *tc)
ArmISA::ExceptionLevel highestEL() const
Returns the highest implemented exception level.
virtual uint32_t socketId() const =0
virtual BaseISA * getIsaPtr()=0
bool isGenericTimerPhysEL0SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
bool isGenericTimerHypTrap(const MiscRegIndex miscReg, ThreadContext *tc, ExceptionClass *ec)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
@ MISCREG_ID_AA64MMFR2_EL1
std::shared_ptr< FaultBase > Fault
bool HaveVirtHostExt(ThreadContext *tc)
Addr roundPage(Addr addr)
static bool unknownMode(OperatingMode mode)
@ EC_TRAPPED_CP15_MCRR_MRRC
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
int computeAddrTop(ThreadContext *tc, bool selbit, bool isInstr, TCR tcr, ExceptionLevel el)
bool condGenericTimerCommonEL1SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
bool isGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
RegVal getAffinity(ArmSystem *arm_sys, ThreadContext *tc)
Retrieves MPIDR_EL1.
bool EL2Enabled(ThreadContext *tc)
bool isAArch64AArch32SystemAccessTrapEL1(const MiscRegIndex miscReg, ThreadContext *tc)
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
bool SPAlignmentCheckEnabled(ThreadContext *tc)
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
ExceptionLevel s1TranslationRegime(ThreadContext *tc, ExceptionLevel el)
bool isGenericTimerSystemAccessTrapEL1(const MiscRegIndex miscReg, ThreadContext *tc)
@ MISCREG_ID_AA64MMFR1_EL1
ExceptionLevel debugTargetFrom(ThreadContext *tc, bool secure)
void postInterrupt(ThreadID tid, int int_num, int index)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool isSecure(ThreadContext *tc)
std::pair< bool, bool > ELStateUsingAArch32K(ThreadContext *tc, ExceptionLevel el, bool secure)
@ MISCREG_ID_AA64ISAR1_EL1
bool IsSecureEL2Enabled(ThreadContext *tc)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
bool decodeMrsMsrBankedReg(uint8_t sysM, bool r, bool &isIntReg, int ®Idx, CPSR cpsr, SCR scr, NSACR nsacr, bool checkSecurity)
bool isUnpriviledgeAccess(ThreadContext *tc)
static RegVal getAff0(ArmSystem *arm_sys, ThreadContext *tc)
bool isGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
void sendEvent(ThreadContext *tc)
Send an event (SEV) to a specific PE if there isn't already a pending event.
bool ELStateUsingAArch32(ThreadContext *tc, ExceptionLevel el, bool secure)
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
bool longDescFormatInUse(ThreadContext *tc)
static bool inSecureState(SCR scr, CPSR cpsr)
bool mcrMrc14TrapToHyp(const MiscRegIndex miscReg, HCR hcr, CPSR cpsr, SCR scr, HDCR hdcr, HSTR hstr, HCPTR hcptr, uint32_t iss)
bool HaveSecureEL2Ext(ThreadContext *tc)
bool badMode32(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented for AArch3...
bool isGenericTimerPhysHypTrap(const MiscRegIndex miscReg, ThreadContext *tc, ExceptionClass *ec)
bool isAArch64AArch32SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
bool haveAArch32EL(ThreadContext *tc, ExceptionLevel el)
virtual BaseCPU * getCpuPtr()=0
virtual int threadId() const =0
bool isGenericTimerCommonEL0HypTrap(const MiscRegIndex miscReg, ThreadContext *tc, ExceptionClass *ec)
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
@ MISCREG_ID_AA64PFR0_EL1
bool condGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
bool isBigEndian64(const ThreadContext *tc)
bool isGenericTimerSystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
RegVal readMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is either returing the value of MPIDR_EL1 (by calling getMPIDR),...
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
int unflattenMiscReg(int reg)
RegVal getMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is returning the value of MPIDR_EL1.
#define panic(...)
This implements a cprintf based panic() function.
static void mcrMrcIssExtract(uint32_t iss, bool &isRead, uint32_t &crm, IntRegIndex &rt, uint32_t &crn, uint32_t &opc1, uint32_t &opc2)
Generated on Tue Sep 7 2021 14:53:42 for gem5 by doxygen 1.8.17