[PATCH] D11647: [dfsan] Enable dfsan for aarch64

Adhemerval Zanella adhemerval.zanella at linaro.org
Thu Jul 30 07:47:20 PDT 2015


zatrazz created this revision.
zatrazz added reviewers: kcc, rengolin, dvyukov, eugenis.
zatrazz added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.

This patch enable DFSan for AArch64 (39-bit VMA).  All tests are passing
but:

 * test/dfsan/custom.cc

Due an invalid access in dl_iterate_phdr instrumentation (commenting out
this function make the testcase to pass). I plan to continue investigate this
issue.

lllvm related patch: http://reviews.llvm.org/D11646
clang related patch: http://reviews.llvm.org/D11645

http://reviews.llvm.org/D11647

Files:
  cmake/config-ix.cmake
  lib/dfsan/dfsan.cc
  lib/dfsan/dfsan.h

Index: lib/dfsan/dfsan.h
===================================================================
--- lib/dfsan/dfsan.h
+++ lib/dfsan/dfsan.h
@@ -48,6 +48,8 @@
   return (dfsan_label *) ((((uptr) ptr) & ~0x700000000000) << 1);
 #elif defined(__mips64)
   return (dfsan_label *) ((((uptr) ptr) & ~0xF000000000) << 1);
+#elif defined(__aarch64__)
+  return (dfsan_label *) ((((uptr) ptr) & ~0x7800000000) << 1);
 #endif
 }
 
Index: lib/dfsan/dfsan.cc
===================================================================
--- lib/dfsan/dfsan.cc
+++ lib/dfsan/dfsan.cc
@@ -80,6 +80,22 @@
 // | reserved by kernel |
 // +--------------------+ 0x0000000000
 
+// On Linux/AArch64 (39-bit VMA), memory is laid out as follow:
+//
+// +--------------------+ 0x8000000000 (top of memory)
+// | application memory |
+// +--------------------+ 0x7000008000 (kAppAddr)
+// |                    |
+// |       unused       |
+// |                    |
+// +--------------------+ 0x1200000000 (kUnusedAddr)
+// |    union table     |
+// +--------------------+ 0x1000000000 (kUnionTableAddr)
+// |   shadow memory    |
+// +--------------------+ 0x0000010000 (kShadowAddr)
+// | reserved by kernel |
+// +--------------------+ 0x0000000000
+
 typedef atomic_dfsan_label dfsan_union_table_t[kNumLabels][kNumLabels];
 
 #if defined(__x86_64__)
@@ -92,6 +108,11 @@
 static const uptr kUnionTableAddr = 0x2000000000;
 static const uptr kUnusedAddr = kUnionTableAddr + sizeof(dfsan_union_table_t);
 static const uptr kAppAddr = 0xF000008000;
+#elif defined(__aarch64__)
+static const uptr kShadowAddr = 0x10000;
+static const uptr kUnionTableAddr = 0x1000000000;
+static const uptr kUnusedAddr = kUnionTableAddr + sizeof(dfsan_union_table_t);
+static const uptr kAppAddr = 0x7000008000;
 #else
 # error "DFSan not supported for this platform!"
 #endif
Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -255,7 +255,7 @@
   ${SANITIZER_COMMON_SUPPORTED_ARCH})
 filter_available_targets(ASAN_SUPPORTED_ARCH
   x86_64 i386 i686 powerpc64 powerpc64le arm mips mipsel mips64 mips64el aarch64)
-filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
+filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64 mips64 mips64el aarch64)
 filter_available_targets(LSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
 filter_available_targets(MSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
 filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 i686 arm mips mips64


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11647.31026.patch
Type: text/x-patch
Size: 2533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150730/30a846cf/attachment.bin>


More information about the llvm-commits mailing list