HWASan fixes for ART tests
Bug: 156593692
Test: SANITIZE_TARGET=hwaddress art/tools/run-gtests.sh
Test: SANITIZE_TARGET=hwaddress art/test.py -r --target --64
Change-Id: I24c5afdb4fed5ac94ce3a7b54a10c592f529191f
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 6b4dbed..4b6a557 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -107,7 +107,9 @@
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)));