[compiler-rt] 2c212db - [NFC][scudo] Let disableMemoryTagChecksTestOnly to fail
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu May 20 19:26:55 PDT 2021
Author: Vitaly Buka
Date: 2021-05-20T19:25:20-07:00
New Revision: 2c212db4ea42fbbc0e83647da4f62261f775388b
URL: https://github.com/llvm/llvm-project/commit/2c212db4ea42fbbc0e83647da4f62261f775388b
DIFF: https://github.com/llvm/llvm-project/commit/2c212db4ea42fbbc0e83647da4f62261f775388b.diff
LOG: [NFC][scudo] Let disableMemoryTagChecksTestOnly to fail
If this happend we can't run corresponding test.
Added:
Modified:
compiler-rt/lib/scudo/standalone/memtag.h
compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/memtag.h b/compiler-rt/lib/scudo/standalone/memtag.h
index 4bdce16faea8..cf1ec3bcc124 100644
--- a/compiler-rt/lib/scudo/standalone/memtag.h
+++ b/compiler-rt/lib/scudo/standalone/memtag.h
@@ -92,12 +92,13 @@ inline bool systemDetectsMemoryTagFaultsTestOnly() { return false; }
#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 @@ inline bool systemDetectsMemoryTagFaultsTestOnly() {
UNREACHABLE("memory tagging not supported");
}
-inline void disableMemoryTagChecksTestOnly() {
+inline bool disableMemoryTagChecksTestOnly() {
UNREACHABLE("memory tagging not supported");
}
diff --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
index 50602efcf642..619a94c24eb8 100644
--- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
@@ -380,21 +380,20 @@ SCUDO_TYPED_TEST(ScudoCombinedTest, DisableMemoryTagging) {
// 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);
-
- P = Allocator->allocate(2048, Origin);
- EXPECT_EQ(scudo::untagPointer(P), P);
- 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);
- Allocator->releaseToOS();
+ P = Allocator->allocate(2048, Origin);
+ EXPECT_EQ(scudo::untagPointer(P), P);
+ reinterpret_cast<char *>(P)[2048] = 0xaa;
+ Allocator->deallocate(P, Origin);
- // 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();
+ }
}
}
More information about the llvm-commits
mailing list