54 const bool d_step = softStep->advanceSS(tc);
56 fault = testVectorCatch(tc, req->getVaddr(),
nullptr);
58 fault = testBreakPoints(tc, req->getVaddr());
60 }
else if (!req->isCacheMaintenance() ||
61 (req->isCacheInvalidate() && !req->isCacheClean())) {
63 fault = testWatchPoints(tc, req->getVaddr(),
md,
66 req->isCacheMaintenance());
80 to32 = targetAArch32(tc);
84 if (!isDebugEnabled(tc))
88 for (
auto &
p: arBrkPoints){
91 if (pcst.itstate() != 0x0)
93 if (
p.enable &&
p.isActive(
pc) &&(!to32 || !
p.onUse)) {
94 const DBGBCR ctr =
p.getControlReg(tc);
95 if (
p.isEnabled(tc,
el, ctr.hmc, ctr.ssc, ctr.pmc)) {
96 bool debug =
p.test(tc,
pc,
el, ctr,
false);
100 return triggerException(tc,
pc);
113 return std::make_shared<PrefetchAbort>(
vaddr,
118 return std::make_shared<HardwareBreakpoint>(
vaddr, 0x22);
124 bool atomic,
unsigned size,
bool cm)
127 to32 = targetAArch32(tc);
130 if (!isDebugEnabled(tc) || !mde)
135 for (
auto &
p: arWatchPoints){
140 return triggerWatchpointException(tc,
vaddr, write,
cm);
154 return std::make_shared<DataAbort>(
vaddr,
159 return std::make_shared<Watchpoint>(0,
vaddr, write,
cm);
165 bool secure,
bool mask)
175 if (
el == target_el) {
178 return target_el >
el;
184 bool secure,
bool mask)
187 return isDebugEnabledForEL64(tc,
el, secure,
mask);
213 const DBGBCR ctr = getControlReg(tc);
214 if ((ctr.bt & 0x1) &&
enable) {
227 v = testAddrMatch(tc,
pc, ctr.bas);
231 v = testAddrMatch(tc,
pc, ctr.bas);
233 v = (conf->getBrkPoint(ctr.lbn))->testLinkedBk(tc,
pc,
el);
240 v = testContextMatch(tc, !host,
true);
247 v = testContextMatch(tc, !host,
true);
252 v = testAddrMissMatch(tc,
pc, ctr.bas);
256 v = testAddrMissMatch(tc,
pc, ctr.bas);
258 v =
v && (conf->getBrkPoint(ctr.lbn))->testLinkedBk(tc,
pc,
el);
263 v = testContextMatch(tc,
true);
268 v = testContextMatch(tc,
true);
273 v = testVMIDMatch(tc);
279 v = testVMIDMatch(tc);
285 v = testContextMatch(tc,
true);
287 v =
v && testVMIDMatch(tc);
292 v = testContextMatch(tc,
true);
293 v =
v && testVMIDMatch(tc);
299 v = testContextMatch(tc,
false);
305 v = testContextMatch(tc,
false);
312 v = testContextMatch(tc,
true);
313 v =
v && testContextMatch(tc,
false);
319 v = testContextMatch(tc,
true);
320 v =
v && testContextMatch(tc,
false);
335 aarch32 = cpsr.width == 1;
341 for (
int i = 0;
i <= dfr.brps;
i++) {
342 const bool isctxaw =
i >= (dfr.brps - dfr.ctx_cmps);
346 this, isctxaw, (
bool)mm_fr2.varange,
347 mm_fr1.vmidbits, aarch32);
351 arBrkPoints.push_back(bkp);
354 for (
int i = 0;
i <= dfr.wrps;
i++) {
357 this, (
bool)mm_fr2.varange, aarch32);
361 arWatchPoints.push_back(wtp);
367 updateOSLock(oslar_el1);
370 setMDSCRvals(mdscr_el1);
377 setenableTDETGE(hcr, mdcr);
381 vcExcpt =
new VectorCatch(dvid.vectorcatch==0x0,
this);
387 Addr pc_tocmp = getAddrfromReg(tc);
396 prs =
bits(in_pc, 1, 0) == 0x2;
398 prs =
bits(in_pc, 1, 0) == 0x0;
400 return (
pc == pc_tocmp) && prs;
408 Addr pc_tocmp = getAddrfromReg(tc);
416 prs =
bits(in_pc, 1, 0) == 0x2;
418 prs =
bits(in_pc, 1, 0) == 0x0;
420 return (
pc != pc_tocmp) && !prs;
426 return testContextMatch(tc, ctx1, ctx1);
436 bool a32 = conf->isAArch32();
444 if (
el ==
EL2 && a32)
449 RegVal v = getContextfromReg(tc, low_ctx);
456 uint32_t vmid_index = 55;
464 uint32_t
v = getVMIDfromReg(tc);
474 bool aarch32 = conf->isAArch32();
478 if (no_el3 && !no_el2 && (
ssc == 0x1 ||
ssc == 0x2) &&
481 }
else if (no_el3 && no_el2 && (
hmc != 0x0 ||
ssc != 0x0) &&
482 !(!aarch32 && ((
hmc &&
ssc == 0x1 &&
pmc == 0x0) ||
ssc == 0x3))) {
484 }
else if (no_el2 &&
hmc &&
ssc == 0x3 &&
pmc == 0x0) {
486 }
else if (
ssc == 0x11 &&
pmc == 0x1 &&
487 !(!aarch32 &&
hmc &&
ssc == 0x3 &&
pmc == 0x0)) {
490 }
else if (
hmc &&
ssc == 0x1 &&
pmc == 0x0) {
496 v = (
pmc == 0x3) || (
pmc == 0x2 &&
hmc == 0x0);
500 panic(
"Unexpected EL in SelfDebug::isDebugEnabled.\n");
503 v = (
pmc == 0x3) || (
pmc == 0x1);
509 ((
hmc == 0x1) && !((
ssc == 0x2) && (
pmc == 0x0)));
511 panic(
"Unexpected EL in SelfDebug::isDebugEnabled.\n");
515 panic(
"Unexpected EL in SelfDebug::isDebugEnabled.\n");
516 v = (
hmc == 0x1) & (
ssc != 0x3);
519 panic(
"Unexpected EL %d in BrkPoint::isEnabled.\n",
el);
527 uint32_t vmid_index = 39;
540 bool aarch32 = conf->isAArch32();
550 if (
ssc == 0x01 ||
ssc == 0x02 ){
557 if (no_el2 &&
hmc &&
ssc == 0x03 &&
pac == 0)
565 v = (
pac == 0x1 ||
pac == 0x3);
572 (
ssc == 0x1 && (
pac == 0x1 ||
pac == 0x3))));
575 panic(
"Unexpected EL in WatchPoint::isEnabled.\n");
582 bool atomic,
unsigned size)
587 if (isEnabled(tc,
el, ctr.hmc, ctr.ssc, ctr.pac) &&
588 ((wrt && (ctr.lsv & 0x2)) || (!wrt && (ctr.lsv & 0x1)) ||
atomic)) {
589 v = compareAddress(tc,
addr, ctr.bas, ctr.mask, size);
591 v =
v && (conf->getBrkPoint(ctr.lbn))->testLinkedBk(tc,
addr,
el);
594 if (
atomic && (ctr.lsv & 0x1)) {
602 uint8_t
mask,
unsigned size)
604 Addr addr_tocmp = getAddrfromReg(tc);
605 int maxbits = isDoubleAligned(addr_tocmp) ? 4: 8;
606 int bottom = isDoubleAligned(addr_tocmp) ? 2: 3;
613 for (
int i = 0;
i < maxbits;
i++) {
614 uint8_t bas_m = 0x1 <<
i;
615 uint8_t masked_bas =
bas & bas_m;
616 if (masked_bas == bas_m) {
617 uint8_t off = log2(masked_bas);
618 Addr cmpaddr = addr_tocmp | off;
619 for (
int j = 0;
j < size;
j++) {
620 if ((
addr +
j) == cmpaddr) {
629 for (
int j = 0;
j < size;
j++) {
633 compaddr =
bits(addr_tocmp, maxAddrSize,
mask);
635 addr =
bits((in_addr+
j), maxAddrSize, bottom);
636 compaddr =
bits(addr_tocmp, maxAddrSize, bottom);
638 v =
v || (
addr == compaddr);
649 bool enabled_src =
false;
651 enabled_src = conf->isDebugEnabled(tc);
653 bool enabled_dst =
false;
656 enabled_dst = conf->isDebugEnabledForEL32(tc, dest, secure,
659 enabled_dst = conf->isDebugEnabledForEL64(tc, dest, secure,
664 if (!
ELIs32(tc, ELd) && !enabled_src && enabled_dst) {
667 stateSS = ACTIVE_PENDING_STATE;
669 stateSS = ACTIVE_NOT_PENDING_STATE;
687 case ACTIVE_NOT_PENDING_STATE:
689 if (cpsrD == 1 || !bSS) {
690 stateSS = INACTIVE_STATE;
693 stateSS = ACTIVE_PENDING_STATE;
698 case ACTIVE_PENDING_STATE:
704 stateSS = INACTIVE_STATE;
720 to32 = targetAArch32(tc);
723 if (!isDebugEnabled(tc) || !mde || !aarch32)
728 if (fault ==
nullptr)
729 debug = vcExcpt->addressMatching(tc,
addr,
el);
731 debug = vcExcpt->exceptionTrapping(tc,
el, fault);
734 return std::make_shared<HypervisorTrap>(0, 0x22,
737 return std::make_shared<PrefetchAbort>(
addr,
753 if (conf->isAArch32() &&
ELIs32(tc,
EL1) &&
756 DBGVCR match_word = 0x0;
758 Addr vbase = getVectorBase(tc,
false);
761 if (vaddress == vbase) {
763 uint32_t bmask = 1UL << (low_addr + 24);
764 match_word = match_word | (DBGVCR) bmask;
767 uint32_t bmask = 1UL << (low_addr);
768 match_word = match_word | (DBGVCR) bmask;
772 uint32_t mvbase = getVectorBase(tc,
true);
774 isSecure(tc) && (vaddress == mvbase)) {
775 uint32_t bmask = 1UL << (low_addr + 8);
776 match_word = match_word | (DBGVCR) bmask;
784 mask = (DBGVCR) 0xDE;
786 mask = (DBGVCR) 0xDE0000DE;
788 mask = (DBGVCR) 0xDE00DEDE;
791 match_word = match_word & dbgvcr &
mask;
796 if (((match_word & 0x18001818) != 0x0) && ELd ==
el) {
816 mask = (DBGVCR) 0xDE;
818 mask = (DBGVCR) 0x0000DE00;
821 mask = (DBGVCR) 0x000000DE;
823 mask = (DBGVCR) 0xDE000000;
825 match_type = match_type &
mask & dbgvcr;
827 if (match_type != 0x0) {