Go to the documentation of this file.
61 uint32_t
type, uint32_t cfval)
const
64 ArmShiftType shiftType;
65 shiftType = (ArmShiftType)
type;
78 return (
base >> 31) | -((
base & (1 << 31)) >> 31);
80 return (
base >> shamt) | -((
base & (1 << 31)) >> shamt);
83 return (cfval << 31) | (
base >> 1);
85 return (
base << (32 - shamt)) | (
base >> shamt);
87 ccprintf(std::cerr,
"Unhandled shift type\n");
98 shiftAmt = shiftAmt %
width;
99 ArmShiftType shiftType;
100 shiftType = (ArmShiftType)
type;
105 return base << shiftAmt;
126 ccprintf(std::cerr,
"Unhandled shift type\n");
135 uint64_t shiftAmt, uint8_t
width)
const
137 bool sign_extend =
false;
170 uint64_t tmp = (uint64_t)
bits(
base,
len - 1, 0) << shiftAmt;
172 int sign_bit =
bits(tmp,
len + shiftAmt - 1);
173 tmp = sign_bit ? (tmp | ~
mask(
len + shiftAmt)) : tmp;
181 uint32_t
type, uint32_t cfval)
const
183 enum ArmShiftType shiftType;
184 shiftType = (
enum ArmShiftType)
type;
192 return base << shamt;
197 return base >> shamt;
200 return (
base >> 31) | -((
base & (1 << 31)) >> 31);
202 return (
base >> shamt) | -((
base & (1 << 31)) >> shamt);
204 shamt = shamt & 0x1f;
208 return (
base << (32 - shamt)) | (
base >> shamt);
210 ccprintf(std::cerr,
"Unhandled shift type\n");
221 uint32_t
type, uint32_t cfval)
const
223 enum ArmShiftType shiftType;
224 shiftType = (
enum ArmShiftType)
type;
232 return (
base >> (32 - shamt)) & 1;
237 return (
base >> (shamt - 1)) & 1;
242 return (
base >> (shamt - 1)) & 1;
244 shamt = shamt & 0x1f;
248 return (
base >> (shamt - 1)) & 1;
250 ccprintf(std::cerr,
"Unhandled shift type\n");
261 uint32_t
type, uint32_t cfval)
const
263 enum ArmShiftType shiftType;
264 shiftType = (
enum ArmShiftType)
type;
275 return (
base >> (32 - shamt)) & 1;
280 return (
base >> (shamt - 1)) & 1;
284 return (
base >> (shamt - 1)) & 1;
286 shamt = shamt & 0x1f;
289 return (
base >> (shamt - 1)) & 1;
291 ccprintf(std::cerr,
"Unhandled shift type\n");
300 uint8_t opWidth)
const
307 else if (reg_idx == INTREG_SPX)
308 ccprintf(
os,
"%s%s", (opWidth == 32) ?
"w" :
"",
"sp");
309 else if (reg_idx == INTREG_X31)
310 ccprintf(
os,
"%szr", (opWidth == 32) ?
"w" :
"x");
312 ccprintf(
os,
"%s%d", (opWidth == 32) ?
"w" :
"x", reg_idx);
336 const char *flagtoprfop[]= {
"PLD",
"PLI",
"PST",
"Reserved"};
337 const char *flagtotarget[] = {
"L1",
"L2",
"L3",
"Reserved"};
338 const char *flagtopolicy[] = {
"KEEP",
"STRM"};
340 ccprintf(
os,
"%s%s%s", flagtoprfop[(flag>>3)&3],
341 flagtotarget[(flag>>1)&3], flagtopolicy[flag&1]);
352 bool isSveVecReg)
const
354 ccprintf(
os,
"%s%d", isSveVecReg ?
"z" :
"v", reg_idx);
378 const std::string &suffix,
387 }
else if (withCond64) {
403 if (it != symtab->
end()) {
405 Addr delta = target - it->address;
419 bool noImplicit)
const
475 panic(
"Unrecognized condition code %d.\n", code);
482 const std::string &prefix,
484 const std::string &suffix)
const
488 if (it != symtab->
end()) {
490 if (it->address !=
addr)
503 ArmShiftType
type)
const
505 bool firstOp =
false;
507 if (
rm != INTREG_ZERO) {
513 if ((
type == LSR ||
type == ASR) && immShift && shiftAmt == 0)
518 if (immShift && shiftAmt == 0) {
537 if (immShift && shiftAmt == 0) {
549 panic(
"Tried to disassemble unrecognized shift type.\n");
555 os <<
"#" << shiftAmt;
564 int64_t shiftAmt)
const
595 bool immShift,
bool s, IntRegIndex
rd, IntRegIndex
rn,
596 IntRegIndex
rm, IntRegIndex
rs, uint32_t shiftAmt,
597 ArmShiftType
type, uint64_t
imm)
const
603 if (
rd != INTREG_ZERO) {
609 if (
rn != INTREG_ZERO) {
629 std::stringstream
ss;
637 const auto tc = xc->
tcBase();
641 (hcr.tge || mdcr.tde)) || !
ELIs32(tc,
EL1)) {
643 return std::make_shared<SoftwareBreakpoint>(
machInst,
imm);
646 return std::make_shared<PrefetchAbort>(
readPC(xc),
659 return std::make_shared<SupervisorTrap>(
machInst, 0x1E00000,
662 return std::make_shared<HypervisorTrap>(
machInst, 0x1E00000,
665 return std::make_shared<SecureMonitorTrap>(
machInst, 0x1E00000,
669 panic(
"Illegal EL in advSIMDFPAccessTrap64\n");
678 bool trap_el2 =
false;
682 switch (cptr_en_check.fpen) {
685 trap_el2 = !(
currEL(tc) ==
EL1 && hcr.tge == 1);
688 trap_el2 = (
currEL(tc) ==
EL0 && hcr.tge == 1);
694 }
else if (cptr_en_check.tfp) {
705 if (cptr_en_check.tfp) {
715 CPSR cpsr, CPACR cpacr)
const
718 if ((
el ==
EL0 && cpacr.fpen != 0x3) ||
719 (
el ==
EL1 && !(cpacr.fpen & 0x1)))
727 CPSR cpsr, CPACR cpacr,
728 NSACR nsacr, FPEXC fpexc,
729 bool fpexc_check,
bool advsimd)
const
733 const bool is_secure =
isSecure(tc);
739 uint8_t cpacr_cp10 = cpacr.cp10;
740 bool cpacr_asedis = cpacr.asedis;
742 if (have_security && !
ELIs64(tc,
EL3) && !is_secure) {
753 if ((cur_el ==
EL0 && cpacr_cp10 != 0x3) ||
754 (cur_el !=
EL0 && !(cpacr_cp10 & 0x1)))
758 if (fpexc_check && !fpexc.en)
763 if (have_virtualization && !is_secure &&
ELIs64(tc,
EL2))
766 if (have_virtualization && !is_secure) {
768 bool hcptr_cp10 = hcptr.tcp10;
769 bool hcptr_tase = hcptr.tase;
771 if (have_security && !
ELIs64(tc,
EL3) && !is_secure) {
778 if ((
advsimd && hcptr_tase) || hcptr_cp10) {
779 const uint32_t iss =
advsimd ? (1 << 5) : 0xA;
781 return std::make_shared<UndefinedInstruction>(
785 return std::make_shared<HypervisorTrap>(
795 if (cptr_en_check.tfp)
814 trap = isWfe? !sctlr.ntwe : !sctlr.ntwi;
817 trap = isWfe? hcr.twe : hcr.twi;
820 trap = isWfe? scr.twe : scr.twi;
840 if (
ELIs64(tc, targetEL)) {
848 uint32_t iss = isWfe? 0x1E00001 :
852 return std::make_shared<UndefinedInstruction>(
856 return std::make_shared<HypervisorTrap>(
machInst, iss,
859 return std::make_shared<SecureMonitorTrap>(
machInst, iss,
862 panic(
"Unrecognized Exception Level: %d\n", targetEL);
881 uint32_t iss = isWfe? 0x1E00001 :
885 return std::make_shared<SupervisorTrap>(
machInst, iss,
888 return std::make_shared<HypervisorTrap>(
machInst, iss,
891 return std::make_shared<SecureMonitorTrap>(
machInst, iss,
894 panic(
"Unrecognized Exception Level: %d\n", targetEL);
909 if (curr_el ==
EL0) {
914 ((curr_el ==
EL0) || (curr_el ==
EL1))) {
930 bool setend_disabled(
false);
933 if (pstate_el ==
EL2) {
972 return std::make_shared<UndefinedInstruction>(
991 panic(
"Unrecognized Exception Level: %d\n", pstateEL);
1007 return std::make_shared<SecureMonitorTrap>(
machInst, 0,
1011 panic(
"Illegal EL in sveAccessTrap\n");
1021 if ((
el ==
EL0 && cpacr.zen == 0x1) ||
1022 (!(cpacr.zen & 0x1)))
1025 if ((
el ==
EL0 && cpacr.fpen == 0x1) ||
1026 (!(cpacr.fpen & 0x1)))
1035 if (((cptr_en_check.zen & 0x1) == 0x0) ||
1036 (cptr_en_check.zen == 0x1 &&
el ==
EL0 &&
1040 if (((cptr_en_check.fpen & 0x1) == 0x0) ||
1041 (cptr_en_check.fpen == 0x1 &&
el ==
EL0 &&
1046 if (cptr_en_check.tz == 1)
1048 if (cptr_en_check.tfp == 1)
1056 if (!cptr_en_check.ez)
1058 if (cptr_en_check.tfp)
1071 const uint8_t it =
itState(spsr);
1073 if (!spsr.t || spsr.il)
1078 if (
bits(it, 7, 4) != 0 &&
bits(it, 3, 0) == 0)
1088 if (
itd &&
bits(it, 2, 0) != 0)
1112 }
else if (spsr & 0x2) {
1114 }
else if (target_el ==
EL0 && spsr.sp) {
1128 if (target_el >
currEL(tc))
1131 bool spsr_mode_is_aarch32 = (spsr.width == 1);
1133 assert(known || (target_el ==
EL0 &&
ELIs64(tc,
EL1)));
1135 if (known && (spsr_mode_is_aarch32 != target_el_is_aarch32))
1158 new_cpsr.mode = cpsr.mode;
1160 new_cpsr.width = cpsr.width;
1161 new_cpsr.el = cpsr.el;
1162 new_cpsr.sp = cpsr.sp;
1166 new_cpsr.il = spsr.il;
1169 }
else if (spsr.width) {
1170 new_cpsr.mode = spsr.mode;
1172 new_cpsr.el = spsr.el;
1173 new_cpsr.sp = spsr.sp;
1178 new_cpsr.nz = spsr.nz;
1179 new_cpsr.c = spsr.c;
1180 new_cpsr.v = spsr.v;
1181 new_cpsr.pan = spsr.pan;
1182 if (new_cpsr.width) {
1185 new_cpsr.q = spsr.q;
1186 new_cpsr.ge = spsr.ge;
1187 new_cpsr.e = spsr.e;
1188 new_cpsr.aif = spsr.aif;
1189 new_cpsr.t = spsr.t;
1190 new_cpsr.it2 = it.top6;
1191 new_cpsr.it1 = it.bottom2;
1194 new_cpsr.daif = spsr.daif;
1195 new_cpsr.uao = spsr.uao;
1200 new_cpsr.ss =
ss->debugExceptionReturnSS(tc, spsr, dest);
const int FramePointerReg
void printShiftOperand(std::ostream &os, IntRegIndex rm, bool immShift, uint32_t shiftAmt, IntRegIndex rs, ArmShiftType type) const
void printVecReg(std::ostream &os, RegIndex reg_idx, bool isSveVecReg=false) const
virtual RegVal readMiscReg(RegIndex misc_reg)=0
constexpr decltype(nullptr) NoFault
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
Fault advSIMDFPAccessTrap64(ExceptionLevel el) const
Trap an access to Advanced SIMD or FP registers due to access control bits.
CPSR getPSTATEFromPSR(ThreadContext *tc, CPSR cpsr, CPSR spsr) const
Get the new PSTATE from a SPSR register in preparation for an exception return.
unsigned getCurSveVecLenInBits() const
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
Bitfield< 23, 20 > advsimd
Fault undefinedFault32(ThreadContext *tc, ExceptionLevel el) const
UNDEFINED behaviour in AArch32.
bool shift_carry_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
bool isSecureBelowEL3(ThreadContext *tc)
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const
static bool illegalExceptionReturn(ThreadContext *tc, CPSR cpsr, CPSR spsr)
const char *const ccRegName[NUM_CCREGS]
const_iterator end() const
const char *const miscRegName[]
const int ReturnAddressReg
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 disabledFault() const
static unsigned getCurSveVecLenInBits(ThreadContext *tc)
void printCCReg(std::ostream &os, RegIndex reg_idx) const
Fault trapWFx(ThreadContext *tc, CPSR cpsr, SCR scr, bool isWfe) const
WFE/WFI trapping helper function.
int32_t shift_rm_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
Fault softwareBreakpoint32(ExecContext *xc, uint16_t imm) const
Trigger a Software Breakpoint.
std::pair< bool, bool > ELUsingAArch32K(ThreadContext *tc, ExceptionLevel el)
This function checks whether selected EL provided as an argument is using the AArch32 ISA.
void ccprintf(cp::Print &print)
void printTarget(std::ostream &os, Addr target, const loader::SymbolTable *symtab) const
Fault checkAdvSIMDOrFPEnabled32(ThreadContext *tc, CPSR cpsr, CPACR cpacr, NSACR nsacr, FPEXC fpexc, bool fpexc_check, bool advsimd) const
Check if a VFP/SIMD access from aarch32 should be allowed.
void printCondition(std::ostream &os, unsigned code, bool noImplicit=false) const
static Addr readPC(ExecContext *xc)
static bool unknownMode32(OperatingMode mode)
void printExtendOperand(bool firstOperand, std::ostream &os, IntRegIndex rm, ArmExtendType type, int64_t shiftAmt) const
static uint8_t getRestoredITBits(ThreadContext *tc, CPSR spsr)
Fault checkSETENDEnabled(ThreadContext *tc, CPSR cpsr) const
Check if SETEND instruction execution in aarch32 should be trapped.
virtual BaseISA * getIsaPtr()=0
ThreadContext is the external interface to all thread state for anything outside of the CPU.
std::shared_ptr< FaultBase > Fault
Fault undefinedFault64(ThreadContext *tc, ExceptionLevel el) const
UNDEFINED behaviour in AArch64.
bool HaveVirtHostExt(ThreadContext *tc)
void printMemSymbol(std::ostream &os, const loader::SymbolTable *symtab, const std::string &prefix, const Addr addr, const std::string &suffix) const
int64_t shiftReg64(uint64_t base, uint64_t shiftAmt, ArmShiftType type, uint8_t width) const
static bool unknownMode(OperatingMode mode)
Fault checkForWFxTrap64(ThreadContext *tc, ExceptionLevel tgtEl, bool isWfe) const
Check if WFE/WFI instruction execution in aarch64 should be trapped.
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
bool isWFxTrapping(ThreadContext *tc, ExceptionLevel targetEL, bool isWfe) const
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
const_iterator findNearest(Addr addr, Addr &next_addr) const
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing...
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 shift_carry_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
Fault checkForWFxTrap32(ThreadContext *tc, ExceptionLevel tgtEl, bool isWfe) const
Check if WFE/WFI instruction execution in aarch32 should be trapped.
void printVecPredReg(std::ostream &os, RegIndex reg_idx) const
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Fault checkSveEnabled(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
Check an SVE access against CPACR_EL1, CPTR_EL2, and CPTR_EL3.
bool isSecure(ThreadContext *tc)
bool generalExceptionsToAArch64(ThreadContext *tc, ExceptionLevel pstateEL) const
Return true if exceptions normally routed to EL1 are being handled at an Exception level using AArch6...
const int StackPointerReg
ExceptionLevel currEL(const ThreadContext *tc)
Returns the current Exception Level (EL) of the provided ThreadContext.
int64_t extendReg64(uint64_t base, ArmExtendType type, uint64_t shiftAmt, uint8_t width) const
bool IsSecureEL2Enabled(ThreadContext *tc)
Fault checkFPAdvSIMDEnabled64(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
Check an Advaned SIMD access against CPACR_EL1, CPTR_EL2, and CPTR_EL3.
void printDataInst(std::ostream &os, bool withImm) const
void printFloatReg(std::ostream &os, RegIndex reg_idx) const
int32_t shift_rm_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
SelfDebug * getSelfDebug() const
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
void printMiscReg(std::ostream &os, RegIndex reg_idx) const
int snsBankedIndex(MiscRegIndex reg, ThreadContext *tc)
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
static uint8_t itState(CPSR psr)
void printIntReg(std::ostream &os, RegIndex reg_idx, uint8_t opWidth=0) const
Print a register name for disassembly given the unique dependence tag number (FP or int).
const char * mnemonic
Base mnemonic (e.g., "add").
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Fault sveAccessTrap(ExceptionLevel el) const
Trap an access to SVE registers due to access control bits.
#define panic(...)
This implements a cprintf based panic() function.
void printPFflags(std::ostream &os, int flag) const
Fault checkFPAdvSIMDTrap64(ThreadContext *tc, CPSR cpsr) const
Check an Advaned SIMD access against CPTR_EL2 and CPTR_EL3.
Generated on Wed May 4 2022 12:13:48 for gem5 by doxygen 1.8.17