Skip to content

Commit

Permalink
Make exegesis annotator error out when remapping an address (#73)
Browse files Browse the repository at this point in the history
Currently, there is a failure condition seen in some blocks where the
annotator finds a segfault, tells exegesis to map a page there, and then
the block fails again at the same address. This needs some debugging,
but currently it will be helpful if we can just log a warning message
and skip this basic block.
  • Loading branch information
boomanaiden154 authored Mar 18, 2024
1 parent c3c54d3 commit 6827637
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gematria/datasets/find_accessed_addrs_exegesis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ Expected<AccessedAddrs> ExegesisAnnotator::findAccessedAddrs(
uintptr_t MapAddress = (CrashInfo.getAddress() & ~0xfff);
if (MapAddress == 0)
return make_error<Failure>("Segfault at zero address, cannot map.");
// TODO(boomanaiden154): The fault captured below occurs when
// exegesis tries to map an address and the mmap fails. When these
// errors are handled within exegesis, we should remove this check.
for (const auto &MemoryMapping : BenchCode.Key.MemoryMappings) {
if (MemoryMapping.Address == MapAddress)
return make_error<Failure>(
"Segfault at an address already mapped.");
}
MemMap.Address = MapAddress;
MemMap.MemoryValueName = "memdef1";
BenchCode.Key.MemoryMappings.push_back(MemMap);
Expand Down
12 changes: 12 additions & 0 deletions gematria/datasets/find_accessed_addrs_exegesis_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,17 @@ TEST_F(FindAccessedAddrsExegesisTest, ExegesisZeroAddressError) {
ASSERT_FALSE(static_cast<bool>(AddrsOrErr));
}

TEST_F(FindAccessedAddrsExegesisTest, ExegesisMultipleSameAddressError) {
// Try and load memory from an address above the current user space address
// space ceiling (assuming five level page tables are not enabled) as the
// script will currently try and annotate this, but exegesis will fail
// to map the address when it attempts to.
auto AddrsOrErr = FindAccessedAddrsExegesis(R"asm(
movabsq $0x0000800000000000, %rax
movq (%rax), %rax
)asm");
ASSERT_FALSE(static_cast<bool>(AddrsOrErr));
}

} // namespace
} // namespace gematria

0 comments on commit 6827637

Please sign in to comment.