Skip to content

Commit 22c91ae

Browse files
authored
Revert "[scudo] Small cleanup of memory tagging code. (#166860)"
This reverts commit 046ae85.
1 parent 222f4e4 commit 22c91ae

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

compiler-rt/lib/scudo/standalone/combined.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ class Allocator {
171171
Primary.Options.set(OptionBit::DeallocTypeMismatch);
172172
if (getFlags()->delete_size_mismatch)
173173
Primary.Options.set(OptionBit::DeleteSizeMismatch);
174-
if (systemSupportsMemoryTagging())
174+
if (allocatorSupportsMemoryTagging<AllocatorConfig>() &&
175+
systemSupportsMemoryTagging())
175176
Primary.Options.set(OptionBit::UseMemoryTagging);
176177

177178
QuarantineMaxChunkSize =

compiler-rt/lib/scudo/standalone/memtag.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ inline bool systemSupportsMemoryTagging() {
6666
#ifndef HWCAP2_MTE
6767
#define HWCAP2_MTE (1 << 18)
6868
#endif
69-
static bool SupportsMemoryTagging = getauxval(AT_HWCAP2) & HWCAP2_MTE;
70-
return SupportsMemoryTagging;
69+
return getauxval(AT_HWCAP2) & HWCAP2_MTE;
7170
}
7271

7372
inline bool systemDetectsMemoryTagFaultsTestOnly() {
@@ -262,7 +261,9 @@ inline uptr loadTag(uptr Ptr) {
262261

263262
#else
264263

265-
inline bool systemSupportsMemoryTagging() { return false; }
264+
inline NORETURN bool systemSupportsMemoryTagging() {
265+
UNREACHABLE("memory tagging not supported");
266+
}
266267

267268
inline NORETURN bool systemDetectsMemoryTagFaultsTestOnly() {
268269
UNREACHABLE("memory tagging not supported");

compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ TEST(MemtagBasicDeathTest, Unsupported) {
2828
EXPECT_DEATH(untagPointer((uptr)0), "not supported");
2929
EXPECT_DEATH(extractTag((uptr)0), "not supported");
3030

31+
EXPECT_DEATH(systemSupportsMemoryTagging(), "not supported");
3132
EXPECT_DEATH(systemDetectsMemoryTagFaultsTestOnly(), "not supported");
3233
EXPECT_DEATH(enableSystemMemoryTaggingTestOnly(), "not supported");
3334

compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
const scudo::uptr PageSize = scudo::getPageSizeCached();
2828

2929
template <typename Config> static scudo::Options getOptionsForConfig() {
30-
if (!scudo::systemSupportsMemoryTagging())
30+
if (!Config::getMaySupportMemoryTagging() ||
31+
!scudo::archSupportsMemoryTagging() ||
32+
!scudo::systemSupportsMemoryTagging())
3133
return {};
3234
scudo::AtomicOptions AO;
3335
AO.set(scudo::OptionBit::UseMemoryTagging);

compiler-rt/lib/scudo/standalone/tests/wrappers_cpp_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ TEST_F(ScudoWrappersCppTest, ThreadedNew) {
187187
// TODO: Investigate why libc sometimes crashes with tag missmatch in
188188
// __pthread_clockjoin_ex.
189189
std::unique_ptr<scudo::ScopedDisableMemoryTagChecks> NoTags;
190-
if (!SCUDO_ANDROID && scudo::systemSupportsMemoryTagging())
190+
if (!SCUDO_ANDROID && scudo::archSupportsMemoryTagging() &&
191+
scudo::systemSupportsMemoryTagging())
191192
NoTags = std::make_unique<scudo::ScopedDisableMemoryTagChecks>();
192193

193194
Ready = false;

0 commit comments

Comments
 (0)