42#ifndef __ARCH_ARM_UTILITY_HH__
43#define __ARCH_ARM_UTILITY_HH__
54#include "enums/ArmExtension.hh"
88 panic(
"Unhandled predicate condition: %d\n", code);
195 it.bottom2 = psr.it1;
210 TCR tcr,
bool isInstr);
235static inline uint32_t
237 uint32_t opc1, uint32_t
opc2)
239 return (isRead << 0) |
249 uint32_t &crn, uint32_t &opc1, uint32_t &
opc2)
251 isRead = (
iss >> 0) & 0x1;
252 crm = (
iss >> 1) & 0xF;
254 crn = (
iss >> 10) & 0xF;
255 opc1 = (
iss >> 14) & 0x7;
259static inline uint32_t
263 return (isRead << 0) |
331 CPSR cpsr, SCR scr, NSACR nsacr,
332 bool checkSecurity=
true);
344 sysM,
r, isIntReg, regIdx, 0, 0, 0,
false);
361 return isBigEndian64(tc) ? ByteOrder::big : ByteOrder::little;
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
ThreadContext is the external interface to all thread state for anything outside of the CPU.
#define panic(...)
This implements a cprintf based panic() function.
bool badMode(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented.
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
ByteOrder byteOrder(const ThreadContext *tc)
static void mcrMrcIssExtract(uint32_t iss, bool &isRead, uint32_t &crm, RegIndex &rt, uint32_t &crn, uint32_t &opc1, uint32_t &opc2)
static bool useVMID(TranslationRegime regime)
bool isAArch64AArch32SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool isGenericTimerVirtSystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
uint8_t encodePhysAddrRange64(int pa_size)
Returns the encoding corresponding to the specified n.
Fault mcrrMrrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm)
void syncVecRegsToElems(ThreadContext *tc)
Fault AArch64AArch32SystemAccessTrap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm, ExceptionClass ec)
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 isGenericTimerSystemAccessTrapEL3(const MiscRegIndex misc_reg, ThreadContext *tc)
ExceptionLevel debugTargetFrom(ThreadContext *tc, bool secure)
ExceptionLevel currEL(const ThreadContext *tc)
Returns the current Exception Level (EL) of the provided ThreadContext.
bool SPAlignmentCheckEnabled(ThreadContext *tc)
bool isSecure(ThreadContext *tc)
static uint32_t mcrrMrrcIssBuild(bool isRead, uint32_t crm, RegIndex rt, RegIndex rt2, uint32_t opc1)
Affinity getAffinity(ArmSystem *arm_sys, ThreadContext *tc)
Retrieves MPIDR_EL1.
Fault mcrMrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm)
ExceptionLevel s1TranslationRegime(ThreadContext *tc, ExceptionLevel el)
Addr maskTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, int topbit)
bool longDescFormatInUse(ThreadContext *tc)
Addr roundPage(Addr addr)
bool isGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool isAArch64AArch32SystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
bool isBigEndian64(const ThreadContext *tc)
bool isGenericTimerSystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool ELStateUsingAArch32(ThreadContext *tc, ExceptionLevel el, bool secure)
void sendEvent(ThreadContext *tc)
Send an event (SEV) to a specific PE if there isn't already a pending event.
bool isGenericTimerCommonEL0HypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
bool isGenericTimerPhysHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
bool isGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
bool isGenericTimerSystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
bool condGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool isGenericTimerHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
static bool inPrivilegedMode(CPSR cpsr)
bool mcrMrc15TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
bool isSecureBelowEL3(ThreadContext *tc)
TranslationRegime translationRegime(ThreadContext *tc, ExceptionLevel el)
bool fgtEnabled(ThreadContext *tc)
bool isUnpriviledgeAccess(ThreadContext *tc)
bool EL2Enabled(ThreadContext *tc)
ExceptionLevel translationEl(TranslationRegime regime)
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 IsSecureEL2Enabled(ThreadContext *tc)
int computeAddrTop(ThreadContext *tc, bool selbit, bool is_instr, TCR tcr, ExceptionLevel el)
static uint32_t mcrMrcIssBuild(bool isRead, uint32_t crm, RegIndex rt, uint32_t crn, uint32_t opc1, uint32_t opc2)
bool mcrMrc14TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss)
bool isHcrxEL2Enabled(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 decodeMrsMsrBankedReg(uint8_t sysM, bool r, bool &isIntReg, int ®Idx, CPSR cpsr, SCR scr, NSACR nsacr, bool checkSecurity)
RegVal getMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is returning the value of MPIDR_EL1.
void syncVecElemsToRegs(ThreadContext *tc)
static bool inUserMode(CPSR cpsr)
bool isGenericTimerPhysEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool testPredicate(uint32_t nz, uint32_t c, uint32_t v, ConditionCode code)
bool isSecureAtEL(ThreadContext *tc, ExceptionLevel el)
std::pair< bool, bool > ELStateUsingAArch32K(ThreadContext *tc, ExceptionLevel el, bool secure)
bool condGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
static int decodeMrsMsrBankedIntRegIndex(uint8_t sysM, bool r)
bool condGenericTimerSystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
int decodePhysAddrRange64(uint8_t pa_enc)
Returns the n.
static ExceptionLevel opModeToEL(OperatingMode mode)
RegVal readMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is either returing the value of MPIDR_EL1 (by calling getMPIDR),...
bool inAArch64(ThreadContext *tc)
static uint8_t itState(CPSR psr)
bool HaveExt(ThreadContext *tc, ArmExtension ext)
Returns true if the provided ThreadContext supports the ArmExtension passed as a second argument.
Addr purifyTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, TCR tcr, bool is_instr)
Removes the tag from tagged addresses if that mode is enabled.
bool condGenericTimerPhysHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc)
Addr truncPage(Addr addr)
bool condGenericTimerCommonEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
bool mcrrMrrc15TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< FaultBase > Fault
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.