Go to the documentation of this file.
58 uint32_t
type, uint32_t cfval)
const
75 return (
base >> 31) | -((
base & (1 << 31)) >> 31);
77 return (
base >> shamt) | -((
base & (1 << 31)) >> shamt);
80 return (cfval << 31) | (
base >> 1);
82 return (
base << (32 - shamt)) | (
base >> shamt);
84 ccprintf(std::cerr,
"Unhandled shift type\n");
95 shiftAmt = shiftAmt %
width;
102 return base << shiftAmt;
123 ccprintf(std::cerr,
"Unhandled shift type\n");
132 uint64_t shiftAmt, uint8_t
width)
const
134 bool sign_extend =
false;
167 uint64_t tmp = (uint64_t)
bits(
base,
len - 1, 0) << shiftAmt;
169 int sign_bit =
bits(tmp,
len + shiftAmt - 1);
170 tmp = sign_bit ? (tmp | ~
mask(
len + shiftAmt)) : tmp;
178 uint32_t
type, uint32_t cfval)
const
189 return base << shamt;
194 return base >> shamt;
197 return (
base >> 31) | -((
base & (1 << 31)) >> 31);
199 return (
base >> shamt) | -((
base & (1 << 31)) >> shamt);
201 shamt = shamt & 0x1f;
205 return (
base << (32 - shamt)) | (
base >> shamt);
207 ccprintf(std::cerr,
"Unhandled shift type\n");
218 uint32_t
type, uint32_t cfval)
const
229 return (
base >> (32 - shamt)) & 1;
234 return (
base >> (shamt - 1)) & 1;
239 return (
base >> (shamt - 1)) & 1;
241 shamt = shamt & 0x1f;
245 return (
base >> (shamt - 1)) & 1;
247 ccprintf(std::cerr,
"Unhandled shift type\n");
258 uint32_t
type, uint32_t cfval)
const
272 return (
base >> (32 - shamt)) & 1;
277 return (
base >> (shamt - 1)) & 1;
281 return (
base >> (shamt - 1)) & 1;
283 shamt = shamt & 0x1f;
286 return (
base >> (shamt - 1)) & 1;
288 ccprintf(std::cerr,
"Unhandled shift type\n");
297 uint8_t opWidth)
const
305 ccprintf(
os,
"%s%s", (opWidth == 32) ?
"w" :
"",
"sp");
307 ccprintf(
os,
"%szr", (opWidth == 32) ?
"w" :
"x");
309 ccprintf(
os,
"%s%d", (opWidth == 32) ?
"w" :
"x", reg_idx);
333 const char *flagtoprfop[]= {
"PLD",
"PLI",
"PST",
"Reserved"};
334 const char *flagtotarget[] = {
"L1",
"L2",
"L3",
"Reserved"};
335 const char *flagtopolicy[] = {
"KEEP",
"STRM"};
337 ccprintf(
os,
"%s%s%s", flagtoprfop[(flag>>3)&3],
338 flagtotarget[(flag>>1)&3], flagtopolicy[flag&1]);
349 bool isSveVecReg)
const
351 ccprintf(
os,
"%s%d", isSveVecReg ?
"z" :
"v", reg_idx);
375 const std::string &suffix,
384 }
else if (withCond64) {
400 if (it != symtab->
end()) {
402 Addr delta = target - it->address;
416 bool noImplicit)
const
472 panic(
"Unrecognized condition code %d.\n", code);
479 const std::string &prefix,
481 const std::string &suffix)
const
485 if (it != symtab->
end()) {
487 if (it->address !=
addr)
502 bool firstOp =
false;
515 if (immShift && shiftAmt == 0) {
534 if (immShift && shiftAmt == 0) {
546 panic(
"Tried to disassemble unrecognized shift type.\n");
552 os <<
"#" << shiftAmt;
561 int64_t shiftAmt)
const
626 std::stringstream
ss;
634 const auto tc = xc->
tcBase();
638 (hcr.tge || mdcr.tde)) || !
ELIs32(tc,
EL1)) {
640 return std::make_shared<SoftwareBreakpoint>(
machInst,
imm);
643 return std::make_shared<PrefetchAbort>(
readPC(xc),
656 return std::make_shared<SupervisorTrap>(
machInst, 0x1E00000,
659 return std::make_shared<HypervisorTrap>(
machInst, 0x1E00000,
662 return std::make_shared<SecureMonitorTrap>(
machInst, 0x1E00000,
666 panic(
"Illegal EL in advSIMDFPAccessTrap64\n");
675 bool trap_el2 =
false;
679 switch (cptr_en_check.fpen) {
682 trap_el2 = !(
currEL(tc) ==
EL1 && hcr.tge == 1);
685 trap_el2 = (
currEL(tc) ==
EL0 && hcr.tge == 1);
691 }
else if (cptr_en_check.tfp) {
702 if (cptr_en_check.tfp) {
712 CPSR cpsr, CPACR cpacr)
const
715 if ((
el ==
EL0 && cpacr.fpen != 0x3) ||
716 (
el ==
EL1 && !(cpacr.fpen & 0x1)))
724 CPSR cpsr, CPACR cpacr,
725 NSACR nsacr, FPEXC fpexc,
726 bool fpexc_check,
bool advsimd)
const
730 const bool is_secure =
isSecure(tc);
736 uint8_t cpacr_cp10 = cpacr.cp10;
737 bool cpacr_asedis = cpacr.asedis;
739 if (have_security && !
ELIs64(tc,
EL3) && !is_secure) {
750 if ((cur_el ==
EL0 && cpacr_cp10 != 0x3) ||
751 (cur_el !=
EL0 && !(cpacr_cp10 & 0x1)))
755 if (fpexc_check && !fpexc.en)
760 if (have_virtualization && !is_secure &&
ELIs64(tc,
EL2))
763 if (have_virtualization && !is_secure) {
765 bool hcptr_cp10 = hcptr.tcp10;
766 bool hcptr_tase = hcptr.tase;
768 if (have_security && !
ELIs64(tc,
EL3) && !is_secure) {
775 if ((
advsimd && hcptr_tase) || hcptr_cp10) {
776 const uint32_t iss =
advsimd ? (1 << 5) : 0xA;
778 return std::make_shared<UndefinedInstruction>(
782 return std::make_shared<HypervisorTrap>(
792 if (cptr_en_check.tfp)
811 trap = isWfe? !sctlr.ntwe : !sctlr.ntwi;
814 trap = isWfe? hcr.twe : hcr.twi;
817 trap = isWfe? scr.twe : scr.twi;
837 if (
ELIs64(tc, targetEL)) {
845 uint32_t iss = isWfe? 0x1E00001 :
849 return std::make_shared<UndefinedInstruction>(
853 return std::make_shared<HypervisorTrap>(
machInst, iss,
856 return std::make_shared<SecureMonitorTrap>(
machInst, iss,
859 panic(
"Unrecognized Exception Level: %d\n", targetEL);
878 uint32_t iss = isWfe? 0x1E00001 :
882 return std::make_shared<SupervisorTrap>(
machInst, iss,
885 return std::make_shared<HypervisorTrap>(
machInst, iss,
888 return std::make_shared<SecureMonitorTrap>(
machInst, iss,
891 panic(
"Unrecognized Exception Level: %d\n", targetEL);
906 if (curr_el ==
EL0) {
911 ((curr_el ==
EL0) || (curr_el ==
EL1))) {
927 bool setend_disabled(
false);
930 if (pstate_el ==
EL2) {
969 return std::make_shared<UndefinedInstruction>(
988 panic(
"Unrecognized Exception Level: %d\n", pstateEL);
1004 return std::make_shared<SecureMonitorTrap>(
machInst, 0,
1008 panic(
"Illegal EL in sveAccessTrap\n");
1018 if ((
el ==
EL0 && cpacr.zen == 0x1) ||
1019 (!(cpacr.zen & 0x1)))
1022 if ((
el ==
EL0 && cpacr.fpen == 0x1) ||
1023 (!(cpacr.fpen & 0x1)))
1032 if (((cptr_en_check.zen & 0x1) == 0x0) ||
1033 (cptr_en_check.zen == 0x1 &&
el ==
EL0 &&
1037 if (((cptr_en_check.fpen & 0x1) == 0x0) ||
1038 (cptr_en_check.fpen == 0x1 &&
el ==
EL0 &&
1043 if (cptr_en_check.tz == 1)
1045 if (cptr_en_check.tfp == 1)
1053 if (!cptr_en_check.ez)
1055 if (cptr_en_check.tfp)
1068 const uint8_t it =
itState(spsr);
1070 if (!spsr.t || spsr.il)
1075 if (
bits(it, 7, 4) != 0 &&
bits(it, 3, 0) == 0)
1085 if (
itd &&
bits(it, 2, 0) != 0)
1109 }
else if (spsr & 0x2) {
1111 }
else if (target_el ==
EL0 && spsr.sp) {
1125 if (target_el >
currEL(tc))
1128 bool spsr_mode_is_aarch32 = (spsr.width == 1);
1129 bool known, target_el_is_aarch32;
1130 std::tie(known, target_el_is_aarch32) =
ELUsingAArch32K(tc, target_el);
1131 assert(known || (target_el ==
EL0 &&
ELIs64(tc,
EL1)));
1133 if (known && (spsr_mode_is_aarch32 != target_el_is_aarch32))
1156 new_cpsr.mode = cpsr.mode;
1158 new_cpsr.width = cpsr.width;
1159 new_cpsr.el = cpsr.el;
1160 new_cpsr.sp = cpsr.sp;
1164 new_cpsr.il = spsr.il;
1167 }
else if (spsr.width) {
1168 new_cpsr.mode = spsr.mode;
1170 new_cpsr.el = spsr.el;
1171 new_cpsr.sp = spsr.sp;
1176 new_cpsr.nz = spsr.nz;
1177 new_cpsr.c = spsr.c;
1178 new_cpsr.v = spsr.v;
1179 new_cpsr.pan = spsr.pan;
1180 if (new_cpsr.width) {
1183 new_cpsr.q = spsr.q;
1184 new_cpsr.ge = spsr.ge;
1185 new_cpsr.e = spsr.e;
1186 new_cpsr.aif = spsr.aif;
1187 new_cpsr.t = spsr.t;
1188 new_cpsr.it2 = it.top6;
1189 new_cpsr.it1 = it.bottom2;
1192 new_cpsr.daif = spsr.daif;
1197 new_cpsr.ss =
ss->debugExceptionReturnSS(tc, spsr, dest);
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
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 ...
static Addr readPC(ExecContext *xc)
bool EL2Enabled(ThreadContext *tc)
const_iterator findNearest(Addr addr, Addr &nextaddr) const
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing...
Bitfield< 23, 20 > advsimd
bool HaveVirtHostExt(ThreadContext *tc)
void printCCReg(std::ostream &os, RegIndex reg_idx) const
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
bool isWFxTrapping(ThreadContext *tc, ExceptionLevel targetEL, bool isWfe) const
int snsBankedIndex(MiscRegIndex reg, ThreadContext *tc)
Fault checkForWFxTrap64(ThreadContext *tc, ExceptionLevel tgtEl, bool isWfe) const
Check if WFE/WFI instruction execution in aarch64 should be trapped.
static ExceptionLevel currEL(const ThreadContext *tc)
Fault sveAccessTrap(ExceptionLevel el) const
Trap an access to SVE registers due to access control bits.
Fault checkFPAdvSIMDEnabled64(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
Check an Advaned SIMD access against CPACR_EL1, CPTR_EL2, and CPTR_EL3.
static uint8_t itState(CPSR psr)
Fault advSIMDFPAccessTrap64(ExceptionLevel el) const
Trap an access to Advanced SIMD or FP registers due to access control bits.
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).
int64_t shiftReg64(uint64_t base, uint64_t shiftAmt, ArmShiftType type, uint8_t width) const
int32_t shift_rm_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
void printShiftOperand(std::ostream &os, IntRegIndex rm, bool immShift, uint32_t shiftAmt, IntRegIndex rs, ArmShiftType type) const
const char *const miscRegName[]
static bool illegalExceptionReturn(ThreadContext *tc, CPSR cpsr, CPSR spsr)
void printMemSymbol(std::ostream &os, const Loader::SymbolTable *symtab, const std::string &prefix, const Addr addr, const std::string &suffix) const
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
virtual BaseISA * getIsaPtr()=0
bool IsSecureEL2Enabled(ThreadContext *tc)
bool shift_carry_imm(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.
Fault checkForWFxTrap32(ThreadContext *tc, ExceptionLevel tgtEl, bool isWfe) const
Check if WFE/WFI instruction execution in aarch32 should be trapped.
void printExtendOperand(bool firstOperand, std::ostream &os, IntRegIndex rm, ArmExtendType type, int64_t shiftAmt) const
Fault checkSETENDEnabled(ThreadContext *tc, CPSR cpsr) const
Check if SETEND instruction execution in aarch32 should be trapped.
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
int64_t extendReg64(uint64_t base, ArmExtendType type, uint64_t shiftAmt, uint8_t width) const
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
static unsigned getCurSveVecLenInBits(ThreadContext *tc)
std::shared_ptr< FaultBase > Fault
Fault undefinedFault32(ThreadContext *tc, ExceptionLevel el) const
UNDEFINED behaviour in AArch32.
const char *const ccRegName[NUM_CCREGS]
void printMiscReg(std::ostream &os, RegIndex reg_idx) const
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
const int FramePointerReg
bool shift_carry_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
static ExceptionLevel opModeToEL(OperatingMode mode)
const char * mnemonic
Base mnemonic (e.g., "add").
Fault checkFPAdvSIMDTrap64(ThreadContext *tc, CPSR cpsr) const
Check an Advaned SIMD access against CPTR_EL2 and CPTR_EL3.
std::pair< bool, bool > ELUsingAArch32K(ThreadContext *tc, ExceptionLevel el)
This function checks whether selected EL provided as an argument is using the AArch32 ISA.
constexpr decltype(nullptr) NoFault
static uint8_t getRestoredITBits(ThreadContext *tc, CPSR spsr)
void printCondition(std::ostream &os, unsigned code, bool noImplicit=false) const
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void printVecPredReg(std::ostream &os, RegIndex reg_idx) const
void printVecReg(std::ostream &os, RegIndex reg_idx, bool isSveVecReg=false) const
SelfDebug * getSelfDebug() 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 printFloatReg(std::ostream &os, RegIndex reg_idx) const
static bool unknownMode32(OperatingMode mode)
const_iterator end() const
bool generalExceptionsToAArch64(ThreadContext *tc, ExceptionLevel pstateEL) const
Return true if exceptions normally routed to EL1 are being handled at an Exception level using AArch6...
void printDataInst(std::ostream &os, bool withImm) const
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
bool isSecureBelowEL3(ThreadContext *tc)
const ExtMachInst machInst
The binary machine instruction.
const int StackPointerReg
virtual RegVal readMiscReg(RegIndex misc_reg)=0
Fault trapWFx(ThreadContext *tc, CPSR cpsr, SCR scr, bool isWfe) const
WFE/WFI trapping helper function.
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
static bool unknownMode(OperatingMode mode)
void ccprintf(cp::Print &print)
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
const int ReturnAddressReg
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
Fault checkSveEnabled(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
Check an SVE access against CPACR_EL1, CPTR_EL2, and CPTR_EL3.
void printTarget(std::ostream &os, Addr target, const Loader::SymbolTable *symtab) const
int32_t shift_rm_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
void printPFflags(std::ostream &os, int flag) const
Fault undefinedFault64(ThreadContext *tc, ExceptionLevel el) const
UNDEFINED behaviour in AArch64.
bool isSecure(ThreadContext *tc)
#define panic(...)
This implements a cprintf based panic() function.
Fault disabledFault() const
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Generated on Wed Sep 30 2020 14:02:00 for gem5 by doxygen 1.8.17