Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler-rt/lib/scudo/standalone/combined.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ class Allocator {
Primary.Options.set(OptionBit::DeallocTypeMismatch);
if (getFlags()->delete_size_mismatch)
Primary.Options.set(OptionBit::DeleteSizeMismatch);
if (systemSupportsMemoryTagging())
if (allocatorSupportsMemoryTagging<AllocatorConfig>() &&
systemSupportsMemoryTagging())
Primary.Options.set(OptionBit::UseMemoryTagging);

QuarantineMaxChunkSize =
Expand Down
7 changes: 4 additions & 3 deletions compiler-rt/lib/scudo/standalone/memtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ inline bool systemSupportsMemoryTagging() {
#ifndef HWCAP2_MTE
#define HWCAP2_MTE (1 << 18)
#endif
static bool SupportsMemoryTagging = getauxval(AT_HWCAP2) & HWCAP2_MTE;
return SupportsMemoryTagging;
return getauxval(AT_HWCAP2) & HWCAP2_MTE;
}

inline bool systemDetectsMemoryTagFaultsTestOnly() {
Expand Down Expand Up @@ -262,7 +261,9 @@ inline uptr loadTag(uptr Ptr) {

#else

inline bool systemSupportsMemoryTagging() { return false; }
inline NORETURN bool systemSupportsMemoryTagging() {
UNREACHABLE("memory tagging not supported");
}

inline NORETURN bool systemDetectsMemoryTagFaultsTestOnly() {
UNREACHABLE("memory tagging not supported");
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TEST(MemtagBasicDeathTest, Unsupported) {
EXPECT_DEATH(untagPointer((uptr)0), "not supported");
EXPECT_DEATH(extractTag((uptr)0), "not supported");

EXPECT_DEATH(systemSupportsMemoryTagging(), "not supported");
EXPECT_DEATH(systemDetectsMemoryTagFaultsTestOnly(), "not supported");
EXPECT_DEATH(enableSystemMemoryTaggingTestOnly(), "not supported");

Expand Down
4 changes: 3 additions & 1 deletion compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
const scudo::uptr PageSize = scudo::getPageSizeCached();

template <typename Config> static scudo::Options getOptionsForConfig() {
if (!scudo::systemSupportsMemoryTagging())
if (!Config::getMaySupportMemoryTagging() ||
!scudo::archSupportsMemoryTagging() ||
!scudo::systemSupportsMemoryTagging())
return {};
scudo::AtomicOptions AO;
AO.set(scudo::OptionBit::UseMemoryTagging);
Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ TEST_F(ScudoWrappersCppTest, ThreadedNew) {
// TODO: Investigate why libc sometimes crashes with tag missmatch in
// __pthread_clockjoin_ex.
std::unique_ptr<scudo::ScopedDisableMemoryTagChecks> NoTags;
if (!SCUDO_ANDROID && scudo::systemSupportsMemoryTagging())
if (!SCUDO_ANDROID && scudo::archSupportsMemoryTagging() &&
scudo::systemSupportsMemoryTagging())
NoTags = std::make_unique<scudo::ScopedDisableMemoryTagChecks>();

Ready = false;
Expand Down
Loading