48using namespace ArmISA;
61 }
else if (!req->isCacheMaintenance() ||
62 (req->isCacheInvalidate() && !req->isCacheClean())) {
67 req->isCacheMaintenance());
90 if (pcst.itstate() != 0x0)
92 if (
p.enable &&
p.isActive(
pc) &&(!
to32 || !
p.onUse)) {
93 const DBGBCR ctr =
p.getControlReg(tc);
94 if (
p.isEnabled(tc,
el, ctr.hmc, ctr.ssc, ctr.pmc)) {
95 if (
p.test(tc,
pc,
el, ctr,
false)) {
111 return std::make_shared<PrefetchAbort>(
vaddr,
116 return std::make_shared<HardwareBreakpoint>(
vaddr, 0x22);
122 bool atomic,
unsigned size,
bool cm)
147 return std::make_shared<DataAbort>(
vaddr,
152 return std::make_shared<Watchpoint>(0,
vaddr, write,
cm);
158 bool secure,
bool mask)
161 (!secure ||
HaveExt(tc, ArmExtension::FEAT_SEL2)) &&
169 if (
el == target_el) {
172 return target_el >
el;
178 bool secure,
bool mask)
289 if (
HaveExt(tc, ArmExtension::FEAT_VHE) &&
295 if (
HaveExt(tc, ArmExtension::FEAT_VHE) && from_link &&
332 for (
int i = 0;
i <= dfr.brps;
i++) {
333 const bool isctxaw =
i >= (dfr.brps - dfr.ctx_cmps);
337 this, isctxaw, (
bool)mm_fr2.varange,
345 for (
int i = 0;
i <= dfr.wrps;
i++) {
348 this, (
bool)mm_fr2.varange,
aarch32);
381 prs =
bits(in_pc, 1, 0) == 0x2;
383 prs =
bits(in_pc, 1, 0) == 0x0;
385 return (
pc == pc_tocmp) && prs;
401 prs =
bits(in_pc, 1, 0) == 0x2;
403 prs =
bits(in_pc, 1, 0) == 0x0;
405 return (
pc != pc_tocmp) && !prs;
429 if (
el ==
EL2 && a32)
443 uint32_t vmid_index = 55;
466 if (no_el3 && !no_el2 && (
ssc == 0x1 ||
ssc == 0x2) &&
469 }
else if (no_el3 && no_el2 && (
hmc != 0x0 ||
ssc != 0x0) &&
470 !(!aarch32 && ((
hmc &&
ssc == 0x1 &&
pmc == 0x0) ||
ssc == 0x3))) {
472 }
else if (no_el2 &&
hmc &&
ssc == 0x3 &&
pmc == 0x0) {
474 }
else if (
ssc == 0x11 &&
pmc == 0x1 &&
475 !(!aarch32 &&
hmc &&
ssc == 0x3 &&
pmc == 0x0)) {
478 }
else if (
hmc &&
ssc == 0x1 &&
pmc == 0x0) {
484 v = (
pmc == 0x3) || (
pmc == 0x2 &&
hmc == 0x0);
488 panic(
"Unexpected EL in SelfDebug::isDebugEnabled.\n");
491 v = (
pmc == 0x3) || (
pmc == 0x1);
497 ((
hmc == 0x1) && !((
ssc == 0x2) && (
pmc == 0x0)));
499 panic(
"Unexpected EL in SelfDebug::isDebugEnabled.\n");
503 panic(
"Unexpected EL in SelfDebug::isDebugEnabled.\n");
504 v = (
hmc == 0x1) & (
ssc != 0x3);
507 panic(
"Unexpected EL %d in BrkPoint::isEnabled.\n",
el);
515 uint32_t vmid_index = 39;
538 if (
ssc == 0x01 ||
ssc == 0x02 ){
545 if (no_el2 &&
hmc &&
ssc == 0x03 &&
pac == 0)
553 v = (
pac == 0x1 ||
pac == 0x3);
560 (
ssc == 0x1 && (
pac == 0x1 ||
pac == 0x3))));
563 panic(
"Unexpected EL in WatchPoint::isEnabled.\n");
570 bool atomic,
unsigned size)
575 if (
isEnabled(tc,
el, ctr.hmc, ctr.ssc, ctr.pac) &&
576 ((wrt && (ctr.lsv & 0x2)) || (!wrt && (ctr.lsv & 0x1)) ||
atomic)) {
582 if (
atomic && (ctr.lsv & 0x1)) {
590 uint8_t
mask,
unsigned size)
601 for (
int i = 0;
i < maxbits;
i++) {
602 uint8_t bas_m = 0x1 <<
i;
603 uint8_t masked_bas =
bas & bas_m;
604 if (masked_bas == bas_m) {
605 uint8_t off = log2(masked_bas);
606 Addr cmpaddr = addr_tocmp | off;
607 for (
int j = 0; j < size; j++) {
608 if ((
addr + j) == cmpaddr) {
617 for (
int j = 0; j < size; j++) {
626 v =
v || (
addr == compaddr);
637 bool enabled_src =
false;
641 bool enabled_dst =
false;
652 if (!
ELIs32(tc, ELd) && !enabled_src && enabled_dst) {
void updateControl(DBGBCR val)
bool test(ThreadContext *tc, Addr pc, ExceptionLevel el, DBGBCR ctr, bool from_link)
bool testLinkedBk(ThreadContext *tc, Addr vaddr, ExceptionLevel el)
const DBGBCR getControlReg(ThreadContext *tc)
bool isEnabled(ThreadContext *tc, ExceptionLevel el, uint8_t hmc, uint8_t ssc, uint8_t pmc)
vmid_t getVMIDfromReg(ThreadContext *tc, bool vs)
bool testContextMatch(ThreadContext *tc, bool ctx1, bool low_ctx)
bool testAddrMissMatch(ThreadContext *tc, Addr pc, uint8_t bas)
bool testVMIDMatch(ThreadContext *tc)
RegVal getContextfromReg(ThreadContext *tc, bool ctxid1) const
bool testAddrMatch(ThreadContext *tc, Addr pc, uint8_t bas)
Addr getAddrfromReg(ThreadContext *tc) const
Fault triggerException(ThreadContext *tc, Addr vaddr)
bool targetAArch32(ThreadContext *tc)
void setenableTDETGE(HCR hcr, HDCR mdcr)
Fault triggerWatchpointException(ThreadContext *tc, Addr vaddr, bool write, bool cm)
BrkPoint * getBrkPoint(uint8_t index)
static bool securityStateMatch(ThreadContext *tc, uint8_t ssc, bool hmc)
void init(ThreadContext *tc)
void updateOSLock(RegVal val)
void setMDSCRvals(RegVal val)
Fault testBreakPoints(ThreadContext *tc, Addr vaddr)
Fault testDebug(ThreadContext *tc, const RequestPtr &req, BaseMMU::Mode mode)
bool isDebugEnabled(ThreadContext *tc)
std::vector< BrkPoint > arBrkPoints
void setAArch32(ThreadContext *tc)
bool isDebugEnabledForEL64(ThreadContext *tc, ExceptionLevel el, bool secure, bool mask)
Fault testWatchPoints(ThreadContext *tc, Addr vaddr, bool write, bool atomic, unsigned size, bool cm)
bool isDebugEnabledForEL32(ThreadContext *tc, ExceptionLevel el, bool secure, bool mask)
std::vector< WatchPoint > arWatchPoints
bool advanceSS(ThreadContext *tc)
bool debugExceptionReturnSS(ThreadContext *tc, CPSR spsr, ExceptionLevel dest)
static const uint8_t ACTIVE_NOT_PENDING_STATE
static const uint8_t INACTIVE_STATE
static const uint8_t ACTIVE_PENDING_STATE
void updateControl(DBGWCR val)
MiscRegIndex ctrlRegIndex
bool compareAddress(ThreadContext *tc, Addr in_addr, uint8_t bas, uint8_t mask, unsigned size)
bool isEnabled(ThreadContext *tc, ExceptionLevel el, bool hmc, uint8_t ssc, uint8_t pac)
Addr getAddrfromReg(ThreadContext *tc)
bool isDoubleAligned(Addr addr)
bool test(ThreadContext *tc, Addr addr, ExceptionLevel el, bool &wrt, bool atomic, unsigned size)
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual const PCStateBase & pcState() const =0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define panic(...)
This implements a cprintf based panic() function.
Bitfield< 23, 20 > atomic
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
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 ...
ExceptionLevel debugTargetFrom(ThreadContext *tc, bool secure)
ExceptionLevel currEL(const ThreadContext *tc)
Returns the current Exception Level (EL) of the provided ThreadContext.
bool isSecure(ThreadContext *tc)
bool ELStateUsingAArch32(ThreadContext *tc, ExceptionLevel el, bool secure)
bool isSecureBelowEL3(ThreadContext *tc)
bool EL2Enabled(ThreadContext *tc)
@ MISCREG_ID_AA64DFR0_EL1
@ MISCREG_ID_AA64MMFR1_EL1
@ MISCREG_ID_AA64MMFR2_EL1
bool HaveExt(ThreadContext *tc, ArmExtension ext)
Returns true if the provided ThreadContext supports the ArmExtension passed as a second argument.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< FaultBase > Fault
std::shared_ptr< Request > RequestPtr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
constexpr decltype(nullptr) NoFault