[NFC][scudo] Let disableMemoryTagChecksTestOnly to fail
If this happend we can't run corresponding test.
GitOrigin-RevId: 2c212db4ea42fbbc0e83647da4f62261f775388b
Change-Id: I5af0df762e74ae631dd9d33a6e8e9a7ef5b4bf64
diff --git a/standalone/memtag.h b/standalone/memtag.h
index 4bdce16..cf1ec3b 100644
--- a/standalone/memtag.h
+++ b/standalone/memtag.h
@@ -92,12 +92,13 @@
#endif // SCUDO_LINUX
-inline void disableMemoryTagChecksTestOnly() {
+inline bool disableMemoryTagChecksTestOnly() {
__asm__ __volatile__(
R"(
.arch_extension memtag
msr tco, #1
)");
+ return true;
}
inline void enableMemoryTagChecksTestOnly() {
@@ -244,7 +245,7 @@
UNREACHABLE("memory tagging not supported");
}
-inline void disableMemoryTagChecksTestOnly() {
+inline bool disableMemoryTagChecksTestOnly() {
UNREACHABLE("memory tagging not supported");
}
diff --git a/standalone/tests/combined_test.cpp b/standalone/tests/combined_test.cpp
index 50602ef..619a94c 100644
--- a/standalone/tests/combined_test.cpp
+++ b/standalone/tests/combined_test.cpp
@@ -380,21 +380,20 @@
// Check that disabling memory tagging works correctly.
void *P = Allocator->allocate(2048, Origin);
EXPECT_DEATH(reinterpret_cast<char *>(P)[2048] = 0xaa, "");
- scudo::disableMemoryTagChecksTestOnly();
- Allocator->disableMemoryTagging();
- reinterpret_cast<char *>(P)[2048] = 0xaa;
- Allocator->deallocate(P, Origin);
+ if (scudo::disableMemoryTagChecksTestOnly()) {
+ Allocator->disableMemoryTagging();
+ reinterpret_cast<char *>(P)[2048] = 0xaa;
+ Allocator->deallocate(P, Origin);
- P = Allocator->allocate(2048, Origin);
- EXPECT_EQ(scudo::untagPointer(P), P);
- reinterpret_cast<char *>(P)[2048] = 0xaa;
- Allocator->deallocate(P, Origin);
+ P = Allocator->allocate(2048, Origin);
+ EXPECT_EQ(scudo::untagPointer(P), P);
+ reinterpret_cast<char *>(P)[2048] = 0xaa;
+ Allocator->deallocate(P, Origin);
- Allocator->releaseToOS();
-
- // Disabling memory tag checks may interfere with subsequent tests.
- // Re-enable them now.
- scudo::enableMemoryTagChecksTestOnly();
+ // Disabling memory tag checks may interfere with subsequent tests.
+ // Re-enable them now.
+ scudo::enableMemoryTagChecksTestOnly();
+ }
}
}