[llvm-dev] Dynamic VMA in Sanitizers for AArch64

Jakub Jelinek via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 25 12:11:43 PDT 2015


On Fri, Sep 25, 2015 at 10:38:59AM -0700, Evgenii Stepanov wrote:
> Jakub makes a good point, are you sure that there is no single shadow
> offset value that works for all VMA variants? What exactly breaks when
> 1<<36 is used on 42-bit VMA?

Note, in our distros we are shipping 42-bit VMA and are using patch on
top of vanilla libsanitizer (with the 1UL << 36 shadow offset) and I don't
remember any bugs reported against this not working (and the testsuite works
too).  So, assuming 39-bit VMA works too, that would show that at least
those two settings work, the question is if 48-bit VMA (or how many) works
too, and if it does, the next thing is tweaking the library so that it can
perhaps with some small but still acceptable performance hit decide between
those at runtime (e.g. kAllocatorSpace/kAllocatorSize could be turned into
non-const variables for aarch64, harder would be to add some allocator that
at runtime picks if it uses 32-bit or 64-bit allocator.

--- libsanitizer/asan/asan_allocator.h	(revision 219833)
+++ libsanitizer/asan/asan_allocator.h	(working copy)
@@ -100,6 +100,10 @@
 # if defined(__powerpc64__)
 const uptr kAllocatorSpace =  0xa0000000000ULL;
 const uptr kAllocatorSize  =  0x20000000000ULL;  // 2T.
+# elif defined(__aarch64__)
+// Valid only for 42-bit VA
+const uptr kAllocatorSpace =  0x10000000000ULL;
+const uptr kAllocatorSize  =  0x10000000000ULL;  // 1T.
 # else
 const uptr kAllocatorSpace = 0x600000000000ULL;
 const uptr kAllocatorSize  =  0x40000000000ULL;  // 4T.
--- libsanitizer/sanitizer_common/sanitizer_platform.h	(revision 219833)
+++ libsanitizer/sanitizer_common/sanitizer_platform.h	(working copy)
@@ -79,7 +79,7 @@
 // For such platforms build this code with -DSANITIZER_CAN_USE_ALLOCATOR64=0 or
 // change the definition of SANITIZER_CAN_USE_ALLOCATOR64 here.
 #ifndef SANITIZER_CAN_USE_ALLOCATOR64
-# if defined(__aarch64__) || defined(__mips64)
+# if defined(__mips64)
 #  define SANITIZER_CAN_USE_ALLOCATOR64 0
 # else
 #  define SANITIZER_CAN_USE_ALLOCATOR64 (SANITIZER_WORDSIZE == 64)
@@ -88,10 +88,10 @@
 
 // The range of addresses which can be returned my mmap.
 // FIXME: this value should be different on different platforms,
-// e.g. on AArch64 it is most likely (1ULL << 39). Larger values will still work
+// e.g. on AArch64 it is most likely (1ULL << 42). Larger values will still work
 // but will consume more memory for TwoLevelByteMap.
 #if defined(__aarch64__)
-# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 39)
+# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 42)
 #else
 # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47)
 #endif

	Jakub


More information about the llvm-dev mailing list