Avoid infinite exception loop
PiperOrigin-RevId: 696199044
Change-Id: I13d544bb2fe4a5f782a5e52565ac7df6f0ac2aff
diff --git a/cheriot/cheriot_top.cc b/cheriot/cheriot_top.cc
index 798ccfe..f74fc76 100644
--- a/cheriot/cheriot_top.cc
+++ b/cheriot/cheriot_top.cc
@@ -210,8 +210,16 @@
bool CheriotTop::ExecuteInstruction(Instruction *inst) {
// Check that pcc has tag set.
if (!pcc_->tag()) {
- state_->HandleCheriRegException(inst, inst->address(),
- EC::kCapExTagViolation, pcc_);
+ if (state_->mtcc()->tag()) {
+ state_->HandleCheriRegException(inst, inst->address(),
+ EC::kCapExTagViolation, pcc_);
+ return true;
+ }
+ // If the mtcc tag is not set, then we would get an infinite loop of
+ // exceptions. Better to exit.
+ LOG(ERROR) << absl::StrCat("Infinite exception loop detected at ",
+ absl::Hex(inst->address()), " - halting");
+ RequestHalt(HaltReason::kSimulatorError, inst);
return true;
}
// Check that pcc has execute permission.
diff --git a/cheriot/riscv_cheriot_instructions.cc b/cheriot/riscv_cheriot_instructions.cc
index cdd30ee..1bf26e0 100644
--- a/cheriot/riscv_cheriot_instructions.cc
+++ b/cheriot/riscv_cheriot_instructions.cc
@@ -79,7 +79,6 @@
// Instruction semantic function bodies.
void CheriotAuicap(const Instruction *instruction) {
- // TODO(torerik): fix bug here.
auto *cap_src = GetCapSource(instruction, 0);
auto offset = generic::GetInstructionSource<uint32_t>(instruction, 1);
auto *cap_dest = GetCapDest(instruction, 0);
diff --git a/repos.bzl b/repos.bzl
index a563a21..ded86d7 100644
--- a/repos.bzl
+++ b/repos.bzl
@@ -22,7 +22,7 @@
if not native.existing_rule("com_google_mpact-riscv"):
http_archive(
name = "com_google_mpact-riscv",
- sha256 = "b708de08f8371ad38d30eafb71951199d96de0901753398b2f923303e2938990",
- strip_prefix = "mpact-riscv-39ca15d0f1265758fdfbef4b6cfd5d321988aeac",
- url = "https://github.com/google/mpact-riscv/archive/39ca15d0f1265758fdfbef4b6cfd5d321988aeac.tar.gz",
+ sha256 = "7490948dac93eaa6d97f9f834d5831f9e46eae32e67cbb4b95c71be919e59487",
+ strip_prefix = "mpact-riscv-280f56fa6f91cda69d3e1198249db706024c1acb",
+ url = "https://github.com/google/mpact-riscv/archive/280f56fa6f91cda69d3e1198249db706024c1acb.tar.gz",
)