summaryrefslogtreecommitdiff
path: root/libartbase/base/memory_tool.h
diff options
context:
space:
mode:
Diffstat (limited to 'libartbase/base/memory_tool.h')
-rw-r--r--libartbase/base/memory_tool.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/libartbase/base/memory_tool.h b/libartbase/base/memory_tool.h
index aca12015c3..5ed9cda44c 100644
--- a/libartbase/base/memory_tool.h
+++ b/libartbase/base/memory_tool.h
@@ -67,11 +67,23 @@ constexpr size_t kMemoryToolStackGuardSizeScale = 1;
#endif
#if __has_feature(hwaddress_sanitizer)
+# define HWADDRESS_SANITIZER
# define ATTRIBUTE_NO_SANITIZE_HWADDRESS __attribute__((no_sanitize("hwaddress")))
#else
# define ATTRIBUTE_NO_SANITIZE_HWADDRESS
#endif
+// Removes the hwasan tag from the pointer (the top eight bits).
+// Those bits are used for verification by hwasan and they are ignored by normal ARM memory ops.
+template<typename PtrType>
+static inline PtrType* HWASanUntag(PtrType* p) {
+#if __has_feature(hwaddress_sanitizer) && defined(__aarch64__)
+ return reinterpret_cast<PtrType*>(reinterpret_cast<uintptr_t>(p) & ((1ULL << 56) - 1));
+#else
+ return p;
+#endif
+}
+
} // namespace art
#endif // ART_LIBARTBASE_BASE_MEMORY_TOOL_H_