Go to the documentation of this file.
97 (!secure ||
HaveExt(tc, ArmExtension::FEAT_SEL2))) {
100 route_to_el2 = (mdcr.tde == 1 || hcr.tge == 1);
102 route_to_el2 =
false;
142 switch (current_el) {
148 warn_once(
"Trying to read MPIDR at EL0\n");
159 panic(
"Invalid EL for reading MPIDR register\n");
177 assert((0 <= tc->
cpuId()) && (tc->
cpuId() < 256));
180 RegVal mpidr = 0x80000000;
215 aff.aff0 =
getAff0(arm_sys, tc);
216 aff.aff1 =
getAff1(arm_sys, tc);
217 aff.aff2 =
getAff2(arm_sys, tc);
249 return !
ELIs32(tc,
EL3) &&
static_cast<SCR
>(
276 panic_if(!known,
"EL state is UNKNOWN");
286 HaveExt(tc, ArmExtension::FEAT_VHE) &&
319 panic_if(
el ==
EL2 && !have_el2,
"Asking for EL2 when it doesn't exist");
320 panic_if(
el ==
EL3 && !have_el3,
"Asking for EL3 when it doesn't exist");
323 known = aarch32 =
false;
327 known =
true; aarch32 =
false;
328 }
else if (secure &&
el ==
EL2) {
329 known =
true; aarch32 =
false;
332 known =
true; aarch32 =
true;
334 known =
true; aarch32 =
false;
337 bool aarch32_below_el3 = have_el3 && scr.rw == 0 &&
338 (!secure || !
HaveExt(tc, ArmExtension::FEAT_SEL2) || !scr.eel2);
341 bool sec_el2 =
HaveExt(tc, ArmExtension::FEAT_SEL2) && scr.eel2;
342 bool aarch32_at_el1 = (aarch32_below_el3 ||
343 (have_el2 && (sec_el2 || !secure) &&
345 !(hcr.e2h && hcr.tge &&
346 HaveExt(tc, ArmExtension::FEAT_VHE))));
349 if (
el ==
EL0 && !aarch32_at_el1) {
353 aarch32 = (cpsr.width == 1);
356 aarch32 = (aarch32_below_el3 &&
el !=
EL3) ||
357 (aarch32_at_el1 && (
el ==
EL0 ||
el ==
EL1) );
361 return std::make_pair(known, aarch32);
368 panic_if(!known,
"EL state is UNKNOWN");
385 panic(
"Invalid exception level");
416 tbi = selbit? tcr.tbi1 : tcr.tbi0;
417 tbid = selbit? tcr.tbid1 : tcr.tbid0;
424 tbi = selbit? tcr.tbi1 : tcr.tbi0;
425 tbid = selbit? tcr.tbid1 : tcr.tbid0;
444 int res = (
tbi && (!
tbid || !is_instr))? 55: 63;
455 uint64_t
mask = ((uint64_t)0x1 << topbit) -1;
465 TCR tcr,
bool is_instr)
500 return std::make_shared<HypervisorTrap>(mach_inst,
imm,
ec);
514 bool trap_to_hyp =
false;
523 trap_to_hyp = ((uint32_t) hstr) & (1 << crn);
524 trap_to_hyp |= hdcr.tpm && (crn == 9) && (crm >= 12);
525 trap_to_hyp |= hcr.tidcp && (
526 ((crn == 9) && ((crm <= 2) || ((crm >= 5) && (crm <= 8)))) ||
527 ((crn == 10) && ((crm <= 1) || (crm == 4) || (crm == 8))) ||
528 ((crn == 11) && ((crm <= 8) || (crm == 15))));
533 trap_to_hyp = hcptr.tcpac;
539 trap_to_hyp = hcr.tid1;
545 trap_to_hyp = hcr.tid2;
563 trap_to_hyp = hcr.tid3;
568 trap_to_hyp = hcr.tsw;
573 trap_to_hyp = hcr.tpc;
579 trap_to_hyp = hcr.tpu;
599 trap_to_hyp = hcr.ttlb;
602 trap_to_hyp = hcr.tac;
620 trap_to_hyp = hcr.tvm & !is_read;
623 trap_to_hyp = hdcr.tpmcr;
627 trap_to_hyp = hcr.fmo;
631 trap_to_hyp = hcr.imo;
666 bool trap_to_hyp =
false;
670 inform(
"trap check M:%x N:%x 1:%x 2:%x hdcr %x, hcptr %x, hstr %x\n",
671 crm, crn, opc1,
opc2, hdcr, hcptr, hstr);
672 trap_to_hyp = hdcr.tda && (opc1 == 0);
673 trap_to_hyp |= hcptr.tta && (opc1 == 1);
680 trap_to_hyp = hdcr.tdosa;
684 trap_to_hyp = hdcr.tdra;
687 trap_to_hyp = hcr.tid0;
691 trap_to_hyp = hstr.tjdbx;
695 trap_to_hyp = hstr.ttee;
712 return std::make_shared<HypervisorTrap>(mach_inst,
imm,
ec);
726 bool trap_to_hyp =
false;
736 trap_to_hyp = ((uint32_t)hstr) & (1 << crm);
756 trap_to_hyp = hcr.tvm & !is_read;
783 return std::make_shared<SupervisorTrap>(mach_inst,
imm,
ec);
786 return std::make_shared<HypervisorTrap>(mach_inst,
imm,
ec);
836 if (
ELIs32(tc,
EL1) && trap_cond && hcr.tge) {
859 return !cnthctl.el1pcten;
861 return !cnthctl.el1pcen;
878 return !(
EL2Enabled(tc) && hcr.e2h && hcr.tge) && trap_cond &&
895 return !cntkctl.el0pcten && !cntkctl.el0vcten;
898 return !cntkctl.el0pcten;
901 return !cntkctl.el0vcten;
904 return !cntkctl.el0pten;
907 return !cntkctl.el0vten;
970 return (!
ELIs32(tc,
EL1) && !hcr.e2h && trap_cond_el1 && hcr.tge) ||
971 (
ELIs32(tc,
EL1) && trap_cond_el1 && hcr.tge) ||
972 (hcr.e2h && hcr.tge && trap_cond_el2);
988 return !hcr.e2h && trap_cond_1;
991 return (!hcr.e2h && trap_cond_0) ||
992 (hcr.e2h && !hcr.tge && trap_cond_1);
1016 return (!hcr.e2h && trap_cond_0) ||
1017 (hcr.e2h && trap_cond_1);
1031 return !
ELIs32(tc,
EL1) && !(hcr.e2h && hcr.tge) && trap_cond;
1042 return !cnthctl.el0pcten && !cnthctl.el0vcten;
1045 return !cnthctl.el0pcten;
1048 return !cnthctl.el0vcten;
1051 return !cnthctl.el0pten;
1054 return !cnthctl.el0vten;
1068 const CNTHCTL cnthctl = cnthctl_val;
1069 const CNTHCTL_E2H cnthctl_e2h = cnthctl_val;
1073 return hcr.e2h ? !cnthctl_e2h.el1pcten : !cnthctl.el1pcten;
1079 return hcr.e2h ? cnthctl_e2h.el1tvct : cnthctl.el1tvct;
1082 return hcr.e2h ? !cnthctl_e2h.el1pten :
false;
1088 return hcr.e2h ? cnthctl_e2h.el1tvt : cnthctl.el1tvt;
1100 return !cnthctl.el1pcen;
1111 return currEL(tc) ==
EL1 && !scr.ns && !scr.st;
1121 CPSR cpsr, SCR scr, NSACR nsacr,
bool checkSecurity)
1165 int sysM4To3 =
bits(sysM, 4, 3);
1167 if (sysM4To3 == 0) {
1170 }
else if (sysM4To3 == 1) {
1173 }
else if (sysM4To3 == 3) {
1174 if (
bits(sysM, 1) == 0) {
1179 if (
bits(sysM, 0) == 1) {
1187 int sysM2 =
bits(sysM, 2);
1188 int sysM1 =
bits(sysM, 1);
1192 ((sysM2 && !sysM1) << 2) |
1193 ((sysM2 && sysM1) << 3) |
1198 ok &=
mode != cpsr.mode;
1203 if (ok && checkSecurity &&
mode != cpsr.mode) {
1204 switch (cpsr.mode) {
1229 panic(
"unknown Mode 0x%x\n", cpsr.mode);
1243 bool have_nv_ext =
false;
1246 have_nv_ext && hcr.nv == 1 && hcr.nv1 == 1);
1248 HaveExt(tc, ArmExtension::FEAT_VHE) &&
1249 currEL(tc) ==
EL2 && hcr.e2h == 1 && hcr.tge == 1;
1251 return (unpriv_el1 || unpriv_el2) && !cpsr.uao;
1273 panic(
"Invalid exception level");
1297 panic(
"Invalid phys. address range encoding");
1320 panic(
"Invalid phys. address range");
constexpr unsigned NumVecElemPerVecReg
static void mcrMrcIssExtract(uint32_t iss, bool &isRead, uint32_t &crm, RegIndex &rt, uint32_t &crn, uint32_t &opc1, uint32_t &opc2)
Addr maskTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, int topbit)
virtual RegVal readMiscReg(RegIndex misc_reg)=0
constexpr decltype(nullptr) NoFault
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
Affinity getAffinity(ArmSystem *arm_sys, ThreadContext *tc)
Retrieves MPIDR_EL1.
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
bool isGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
virtual RegVal getReg(const RegId ®) const
bool isGenericTimerHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
int decodePhysAddrRange64(uint8_t pa_enc)
Returns the n.
bool isGenericTimerSystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
bool isGenericTimerCommonEL0HypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
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)
bool isGenericTimerSystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool mcrrMrrc15TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
@ 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 ...
bool isAArch64AArch32SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool inAArch64(ThreadContext *tc)
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
Fault AArch64AArch32SystemAccessTrap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm, ExceptionClass ec)
Addr truncPage(Addr addr)
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 condGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool condGenericTimerSystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
bool mcrMrc14TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss)
Fault mcrMrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm)
Addr purifyTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, TCR tcr, bool is_instr)
Removes the tag from tagged addresses if that mode is enabled.
static bool unknownMode32(OperatingMode mode)
bool isGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool has(ArmExtension ext) const
static int regInMode(OperatingMode mode, int reg)
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.
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
virtual uint32_t socketId() const =0
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Fault mcrrMrrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm)
bool condGenericTimerPhysHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc)
std::shared_ptr< FaultBase > Fault
Addr roundPage(Addr addr)
static bool unknownMode(OperatingMode mode)
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
void syncVecElemsToRegs(ThreadContext *tc)
bool EL2Enabled(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)
bool mcrMrc15TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
ExceptionLevel s1TranslationRegime(ThreadContext *tc, ExceptionLevel el)
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)
constexpr RegClass vecRegClass
ExceptionLevel currEL(const ThreadContext *tc)
Returns the current Exception Level (EL) of the provided ThreadContext.
bool has(ArmExtension ext) const
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...
void syncVecRegsToElems(ThreadContext *tc)
constexpr RegClass vecElemClass
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 isGenericTimerSystemAccessTrapEL3(const MiscRegIndex misc_reg, 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 longDescFormatInUse(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 haveAArch32EL(ThreadContext *tc, ExceptionLevel el)
bool isGenericTimerVirtSystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
virtual BaseCPU * getCpuPtr()=0
virtual int threadId() const =0
bool condGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
virtual BaseISA * getIsaPtr() const =0
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
bool condGenericTimerCommonEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int computeAddrTop(ThreadContext *tc, bool selbit, bool is_instr, TCR tcr, ExceptionLevel el)
bool isGenericTimerPhysHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
bool isBigEndian64(const ThreadContext *tc)
bool isAArch64AArch32SystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
const ArmRelease * getRelease() const
bool HaveExt(ThreadContext *tc, ArmExtension ext)
Returns true if the provided ThreadContext supports the ArmExtension passed as a second argument.
bool isGenericTimerPhysEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
RegVal readMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is either returing the value of MPIDR_EL1 (by calling getMPIDR),...
int unflattenMiscReg(int reg)
RegVal getMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is returning the value of MPIDR_EL1.
Register ID: describe an architectural register with its class and index.
#define panic(...)
This implements a cprintf based panic() function.
virtual void setReg(const RegId ®, RegVal val)
Generated on Sun Jul 30 2023 01:56:50 for gem5 by doxygen 1.8.17