summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/common_compiler_test.cc4
-rw-r--r--libartbase/base/memory_tool.h12
-rw-r--r--runtime/interpreter/interpreter_switch_impl-inl.h2
-rw-r--r--runtime/oat_quick_method_header.h3
-rw-r--r--test/common/gtest_main.cc2
-rw-r--r--test/knownfailures.json17
6 files changed, 36 insertions, 4 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 6b4dbed03b..4b6a557455 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -107,7 +107,9 @@ void CommonCompilerTest::MakeExecutable(const void* code_start, size_t code_leng
uintptr_t base = RoundDown(data, kPageSize);
uintptr_t limit = RoundUp(data + code_length, kPageSize);
uintptr_t len = limit - base;
- int result = mprotect(reinterpret_cast<void*>(base), len, PROT_READ | PROT_WRITE | PROT_EXEC);
+ // Remove hwasan tag. This is done in kernel in newer versions. This supports older kernels.
+ void* base_ptr = HWASanUntag(reinterpret_cast<void*>(base));
+ int result = mprotect(base_ptr, len, PROT_READ | PROT_WRITE | PROT_EXEC);
CHECK_EQ(result, 0);
CHECK(FlushCpuCaches(reinterpret_cast<void*>(base), reinterpret_cast<void*>(base + len)));
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_
diff --git a/runtime/interpreter/interpreter_switch_impl-inl.h b/runtime/interpreter/interpreter_switch_impl-inl.h
index 863612fae2..0f15adffb8 100644
--- a/runtime/interpreter/interpreter_switch_impl-inl.h
+++ b/runtime/interpreter/interpreter_switch_impl-inl.h
@@ -1909,7 +1909,7 @@ class InstructionHandler {
};
// Don't inline in ASAN. It would create massive stack frame.
-#ifdef ADDRESS_SANITIZER
+#if defined(ADDRESS_SANITIZER) || defined(HWADDRESS_SANITIZER)
#define ASAN_NO_INLINE NO_INLINE
#else
#define ASAN_NO_INLINE ALWAYS_INLINE
diff --git a/runtime/oat_quick_method_header.h b/runtime/oat_quick_method_header.h
index c8ee9b4e91..9a1133e0ac 100644
--- a/runtime/oat_quick_method_header.h
+++ b/runtime/oat_quick_method_header.h
@@ -114,7 +114,8 @@ class PACKED(4) OatQuickMethodHeader {
}
bool Contains(uintptr_t pc) const {
- uintptr_t code_start = reinterpret_cast<uintptr_t>(code_);
+ // Remove hwasan tag to make comparison below valid. The PC from the stack does not have it.
+ uintptr_t code_start = reinterpret_cast<uintptr_t>(HWASanUntag(code_));
static_assert(kRuntimeISA != InstructionSet::kThumb2, "kThumb2 cannot be a runtime ISA");
if (kRuntimeISA == InstructionSet::kArm) {
// On Thumb-2, the pc is offset by one.
diff --git a/test/common/gtest_main.cc b/test/common/gtest_main.cc
index 2fb67019f5..917600100f 100644
--- a/test/common/gtest_main.cc
+++ b/test/common/gtest_main.cc
@@ -25,7 +25,7 @@
#include "runtime.h"
extern "C" bool GetInitialArgs(const char*** args, size_t* num_args) {
- static const char* initial_args[] = {"--deadline_threshold_ms=600000",
+ static const char* initial_args[] = {"--deadline_threshold_ms=1200000", // hwasan takes ~10min.
"--slow_threshold_ms=300000"};
*args = initial_args;
*num_args = 2;
diff --git a/test/knownfailures.json b/test/knownfailures.json
index ced572317b..070df351ad 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -652,6 +652,12 @@
"env_vars": {"SANITIZE_HOST": "address"}
},
{
+ "tests": "175-alloc-big-bignums",
+ "description": "ASAN runs out of memory due to huge allocations.",
+ "variant": "target",
+ "env_vars": {"SANITIZE_TARGET": "hwaddress"}
+ },
+ {
"tests": "202-thread-oome",
"description": "ASAN aborts when large thread stacks are requested.",
"variant": "host",
@@ -718,6 +724,17 @@
"env_vars": {"SANITIZE_TARGET": "address"}
},
{
+ "tests": [
+ "074-gc-thrash"
+ ],
+ "description": [
+ "Interpreter with access checks stack frames are too large and result in",
+ "StackOverFlow errors being thrown."
+ ],
+ "variant": "interp-ac & target",
+ "env_vars": {"SANITIZE_TARGET": "hwaddress"}
+ },
+ {
"tests": "071-dexfile-map-clean",
"description": [ "We use prebuilt zipalign on master-art-host to avoid pulling in a lot",
"of the framework. But a non-sanitized zipalign binary does not work with",