summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2015-08-28 20:40:50 +0000
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2015-08-28 20:40:50 +0000
commit3bd0141232dc951e418a170dbc29fc76b37f1742 (patch)
tree4d6100199be70b64e38b4ea297c82a508c45858e
parent7eedde663ebef4e9d1d287efd568c9cd7094811f (diff)
downloadcompiler-rt-3bd0141232dc951e418a170dbc29fc76b37f1742.tar.gz
[compiler-rt] [tsan] Enable TSan for AArch64/42-bit VMA
This patch adds support for tsan on aarch64-linux with 42-bit VMA (current default config for 64K pagesize kernels). The support is enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time for both clang/llvm and compiler-rt. The default VMA is 39 bits. It also enabled tsan for previous supported VMA (39). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@246330 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--cmake/config-ix.cmake2
-rw-r--r--lib/sanitizer_common/sanitizer_allocator.h4
-rw-r--r--lib/sanitizer_common/sanitizer_platform.h2
-rw-r--r--lib/tsan/rtl/tsan_platform.h32
-rw-r--r--lib/tsan/rtl/tsan_rtl.h4
-rw-r--r--test/tsan/ignore_lib0.cc2
-rw-r--r--test/tsan/ignore_lib1.cc2
-rw-r--r--test/tsan/ignore_lib3.cc2
-rw-r--r--test/tsan/lit.cfg5
-rw-r--r--test/tsan/test.h18
10 files changed, 64 insertions, 9 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index ccae57b01..3b22813b8 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -267,7 +267,7 @@ set(ALL_LSAN_SUPPORTED_ARCH ${X86_64} mips64 mips64el)
set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} mips64 mips64el)
set(ALL_PROFILE_SUPPORTED_ARCH ${X86_64} i386 i686 ${ARM32} mips mips64
mipsel mips64el ${ARM64} powerpc64 powerpc64le)
-set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} mips64 mips64el)
+set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} mips64 mips64el ${ARM64})
set(ALL_UBSAN_SUPPORTED_ARCH ${X86_64} i386 i686 ${ARM32} ${ARM64} mips
mipsel mips64 mips64el powerpc64 powerpc64le)
set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86_64} i386 i686)
diff --git a/lib/sanitizer_common/sanitizer_allocator.h b/lib/sanitizer_common/sanitizer_allocator.h
index deaffef71..e53068259 100644
--- a/lib/sanitizer_common/sanitizer_allocator.h
+++ b/lib/sanitizer_common/sanitizer_allocator.h
@@ -822,6 +822,10 @@ class SizeClassAllocator32 {
void PrintStats() {
}
+ static uptr AdditionalSize() {
+ return 0;
+ }
+
typedef SizeClassMap SizeClassMapT;
static const uptr kNumClasses = SizeClassMap::kNumClasses;
diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
index bfd65382f..a1da6150f 100644
--- a/lib/sanitizer_common/sanitizer_platform.h
+++ b/lib/sanitizer_common/sanitizer_platform.h
@@ -146,6 +146,8 @@
#if defined(__mips__) || (defined(__aarch64__) && SANITIZER_AARCH64_VMA == 39)
# define SANITIZER_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 10)
+#elif defined(__aarch64__) && SANITIZER_AARCH64_VMA == 42
+# define SANITIZER_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 11)
#else
# define SANITIZER_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 12)
#endif
diff --git a/lib/tsan/rtl/tsan_platform.h b/lib/tsan/rtl/tsan_platform.h
index d50301035..dcf9d64c3 100644
--- a/lib/tsan/rtl/tsan_platform.h
+++ b/lib/tsan/rtl/tsan_platform.h
@@ -87,6 +87,7 @@ const uptr kAppMemMsk = 0xfc00000000ull;
const uptr kAppMemXor = 0x0400000000ull;
const uptr kVdsoBeg = 0xfffff00000ull;
#elif defined(__aarch64__)
+# if SANITIZER_AARCH64_VMA == 39
/*
C/C++ on linux/aarch64 (39-bit VMA)
0000 4000 00 - 0200 0000 00: main binary
@@ -113,6 +114,37 @@ const uptr kHiAppMemEnd = 0x7fffffffffull;
const uptr kAppMemMsk = 0x7800000000ull;
const uptr kAppMemXor = 0x0800000000ull;
const uptr kVdsoBeg = 0x7f00000000ull;
+# elif SANITIZER_AARCH64_VMA == 42
+/*
+C/C++ on linux/aarch64 (42-bit VMA)
+00000 4000 00 - 01000 0000 00: main binary
+01000 0000 00 - 10000 0000 00: -
+10000 0000 00 - 20000 0000 00: shadow memory
+20000 0000 00 - 26000 0000 00: -
+26000 0000 00 - 28000 0000 00: metainfo
+28000 0000 00 - 36200 0000 00: -
+36200 0000 00 - 36240 0000 00: traces
+36240 0000 00 - 3e000 0000 00: -
+3e000 0000 00 - 3f000 0000 00: heap
+3c000 0000 00 - 3ff00 0000 00: -
+3ff00 0000 00 - 3ffff f000 00: modules and main thread stack
+*/
+const uptr kLoAppMemBeg = 0x00000400000ull;
+const uptr kLoAppMemEnd = 0x01000000000ull;
+const uptr kShadowBeg = 0x10000000000ull;
+const uptr kShadowEnd = 0x20000000000ull;
+const uptr kMetaShadowBeg = 0x26000000000ull;
+const uptr kMetaShadowEnd = 0x28000000000ull;
+const uptr kTraceMemBeg = 0x36200000000ull;
+const uptr kTraceMemEnd = 0x36400000000ull;
+const uptr kHeapMemBeg = 0x3e000000000ull;
+const uptr kHeapMemEnd = 0x3f000000000ull;
+const uptr kHiAppMemBeg = 0x3ff00000000ull;
+const uptr kHiAppMemEnd = 0x3fffff00000ull;
+const uptr kAppMemMsk = 0x3c000000000ull;
+const uptr kAppMemXor = 0x04000000000ull;
+const uptr kVdsoBeg = 0x37f00000000ull;
+# endif
#endif
ALWAYS_INLINE
diff --git a/lib/tsan/rtl/tsan_rtl.h b/lib/tsan/rtl/tsan_rtl.h
index d37f2d495..e51e46680 100644
--- a/lib/tsan/rtl/tsan_rtl.h
+++ b/lib/tsan/rtl/tsan_rtl.h
@@ -754,11 +754,7 @@ void ALWAYS_INLINE TraceAddEvent(ThreadState *thr, FastState fs,
#ifndef SANITIZER_GO
uptr ALWAYS_INLINE HeapEnd() {
-#if SANITIZER_CAN_USE_ALLOCATOR64
return kHeapMemEnd + PrimaryAllocator::AdditionalSize();
-#else
- return kHeapMemEnd;
-#endif
}
#endif
diff --git a/test/tsan/ignore_lib0.cc b/test/tsan/ignore_lib0.cc
index 13d0fb92f..122ec1f45 100644
--- a/test/tsan/ignore_lib0.cc
+++ b/test/tsan/ignore_lib0.cc
@@ -9,7 +9,7 @@
// suppression are ignored.
// Some aarch64 kernels do not support non executable write pages
-// XFAIL: aarch64
+// REQUIRES: stable-runtime
#ifndef LIB
diff --git a/test/tsan/ignore_lib1.cc b/test/tsan/ignore_lib1.cc
index cd4c023dc..1283cfdb4 100644
--- a/test/tsan/ignore_lib1.cc
+++ b/test/tsan/ignore_lib1.cc
@@ -8,7 +8,7 @@
// Tests that interceptors coming from a dynamically loaded library specified
// in called_from_lib suppression are ignored.
-// XFAIL: aarch64
+// REQUIRES: stable-runtime
#ifndef LIB
diff --git a/test/tsan/ignore_lib3.cc b/test/tsan/ignore_lib3.cc
index 69e0f893d..79e4ba181 100644
--- a/test/tsan/ignore_lib3.cc
+++ b/test/tsan/ignore_lib3.cc
@@ -6,7 +6,7 @@
// causes program crash (this is not supported).
// Some aarch64 kernels do not support non executable write pages
-// XFAIL: aarch64
+// REQUIRES: stable-runtime
#ifndef LIB
diff --git a/test/tsan/lit.cfg b/test/tsan/lit.cfg
index d27500f8e..092fa43be 100644
--- a/test/tsan/lit.cfg
+++ b/test/tsan/lit.cfg
@@ -63,3 +63,8 @@ config.suffixes = ['.c', '.cc', '.cpp']
# ThreadSanitizer tests are currently supported on FreeBSD and Linux only.
if config.host_os not in ['FreeBSD', 'Linux']:
config.unsupported = True
+
+# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL
+# because the test hangs.
+if config.target_arch != 'aarch64':
+ config.available_features.add('stable-runtime')
diff --git a/test/tsan/test.h b/test/tsan/test.h
index b441ba13d..6af33a139 100644
--- a/test/tsan/test.h
+++ b/test/tsan/test.h
@@ -40,7 +40,23 @@ void print_address(void *address) {
// to the format used in the diagnotic message.
#ifdef __x86_64__
fprintf(stderr, "0x%012lx", (unsigned long) address);
-#elif defined(__mips64) || defined(__aarch64__)
+#elif defined(__mips64)
fprintf(stderr, "0x%010lx", (unsigned long) address);
+#elif defined(__aarch64__)
+ // AArch64 currently has 3 different VMA (39, 42, and 48 bits) and it requires
+ // different pointer size to match the diagnostic message.
+ const char *format = 0;
+ unsigned long vma = (unsigned long)__builtin_frame_address(0);
+ vma = 64 - __builtin_clzll(vma);
+ if (vma == 39)
+ format = "0x%010lx";
+ else if (vma == 42)
+ format = "0x%011lx";
+ else {
+ fprintf(stderr, "unsupported vma: %ul\n", vma);
+ exit(1);
+ }
+
+ fprintf(stderr, format, (unsigned long) address);
#endif
}