[compiler-rt] r246330 - [compiler-rt] [tsan] Enable TSan for AArch64/42-bit VMA
Adhemerval Zanella via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 13:40:50 PDT 2015
Author: azanella
Date: Fri Aug 28 15:40:50 2015
New Revision: 246330
URL: http://llvm.org/viewvc/llvm-project?rev=246330&view=rev
Log:
[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).
Modified:
compiler-rt/trunk/cmake/config-ix.cmake
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h
compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
compiler-rt/trunk/test/tsan/ignore_lib0.cc
compiler-rt/trunk/test/tsan/ignore_lib1.cc
compiler-rt/trunk/test/tsan/ignore_lib3.cc
compiler-rt/trunk/test/tsan/lit.cfg
compiler-rt/trunk/test/tsan/test.h
Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Fri Aug 28 15:40:50 2015
@@ -267,7 +267,7 @@ set(ALL_LSAN_SUPPORTED_ARCH ${X86_64} mi
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)
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h Fri Aug 28 15:40:50 2015
@@ -822,6 +822,10 @@ class SizeClassAllocator32 {
void PrintStats() {
}
+ static uptr AdditionalSize() {
+ return 0;
+ }
+
typedef SizeClassMap SizeClassMapT;
static const uptr kNumClasses = SizeClassMap::kNumClasses;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h Fri Aug 28 15:40:50 2015
@@ -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
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h Fri Aug 28 15:40:50 2015
@@ -87,6 +87,7 @@ const uptr kAppMemMsk = 0xfc00000000
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 = 0x7fffffffff
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
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Fri Aug 28 15:40:50 2015
@@ -754,11 +754,7 @@ void ALWAYS_INLINE TraceAddEvent(ThreadS
#ifndef SANITIZER_GO
uptr ALWAYS_INLINE HeapEnd() {
-#if SANITIZER_CAN_USE_ALLOCATOR64
return kHeapMemEnd + PrimaryAllocator::AdditionalSize();
-#else
- return kHeapMemEnd;
-#endif
}
#endif
Modified: compiler-rt/trunk/test/tsan/ignore_lib0.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib0.cc?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib0.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib0.cc Fri Aug 28 15:40:50 2015
@@ -9,7 +9,7 @@
// suppression are ignored.
// Some aarch64 kernels do not support non executable write pages
-// XFAIL: aarch64
+// REQUIRES: stable-runtime
#ifndef LIB
Modified: compiler-rt/trunk/test/tsan/ignore_lib1.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib1.cc?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib1.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib1.cc Fri Aug 28 15:40:50 2015
@@ -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
Modified: compiler-rt/trunk/test/tsan/ignore_lib3.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/ignore_lib3.cc?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/ignore_lib3.cc (original)
+++ compiler-rt/trunk/test/tsan/ignore_lib3.cc Fri Aug 28 15:40:50 2015
@@ -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
Modified: compiler-rt/trunk/test/tsan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/lit.cfg?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/lit.cfg (original)
+++ compiler-rt/trunk/test/tsan/lit.cfg Fri Aug 28 15:40:50 2015
@@ -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')
Modified: compiler-rt/trunk/test/tsan/test.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/test.h?rev=246330&r1=246329&r2=246330&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/test.h (original)
+++ compiler-rt/trunk/test/tsan/test.h Fri Aug 28 15:40:50 2015
@@ -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
}
More information about the llvm-commits
mailing list