summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2015-08-24 13:50:14 +0000
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2015-08-24 13:50:14 +0000
commit2a1e58d0002b8c5306b280350f8848637dcf2fbe (patch)
treecb168ccdcfd46ca5e2d6f0ea786e894d5c4d99c6
parent4754e2d59c20f0ba43336a0e5d20c8ee06949a6a (diff)
downloadbcm5719-llvm-2a1e58d0002b8c5306b280350f8848637dcf2fbe.tar.gz
bcm5719-llvm-2a1e58d0002b8c5306b280350f8848637dcf2fbe.zip
[dfsan] Enable DFSan for AArch64/42-bit VMA
This patch adds support for dfsan 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. llvm-svn: 245841
-rw-r--r--compiler-rt/lib/dfsan/dfsan.cc24
-rw-r--r--compiler-rt/lib/dfsan/dfsan.h4
2 files changed, 28 insertions, 0 deletions
diff --git a/compiler-rt/lib/dfsan/dfsan.cc b/compiler-rt/lib/dfsan/dfsan.cc
index 382c1b5c1a9..3b1e6c43109 100644
--- a/compiler-rt/lib/dfsan/dfsan.cc
+++ b/compiler-rt/lib/dfsan/dfsan.cc
@@ -96,6 +96,22 @@ SANITIZER_INTERFACE_ATTRIBUTE THREADLOCAL dfsan_label __dfsan_arg_tls[64];
// | reserved by kernel |
// +--------------------+ 0x0000000000
+// On Linux/AArch64 (42-bit VMA), memory is laid out as follow:
+//
+// +--------------------+ 0x40000000000 (top of memory)
+// | application memory |
+// +--------------------+ 0x3ff00008000 (kAppAddr)
+// | |
+// | unused |
+// | |
+// +--------------------+ 0x1200000000 (kUnusedAddr)
+// | union table |
+// +--------------------+ 0x8000000000 (kUnionTableAddr)
+// | shadow memory |
+// +--------------------+ 0x0000010000 (kShadowAddr)
+// | reserved by kernel |
+// +--------------------+ 0x0000000000
+
typedef atomic_dfsan_label dfsan_union_table_t[kNumLabels][kNumLabels];
#if defined(__x86_64__)
@@ -110,9 +126,17 @@ static const uptr kUnusedAddr = kUnionTableAddr + sizeof(dfsan_union_table_t);
static const uptr kAppAddr = 0xF000008000;
#elif defined(__aarch64__)
static const uptr kShadowAddr = 0x10000;
+# if SANITIZER_AARCH64_VMA == 39
static const uptr kUnionTableAddr = 0x1000000000;
+# elif SANITIZER_AARCH64_VMA == 42
+static const uptr kUnionTableAddr = 0x8000000000;
+# endif
static const uptr kUnusedAddr = kUnionTableAddr + sizeof(dfsan_union_table_t);
+# if SANITIZER_AARCH64_VMA == 39
static const uptr kAppAddr = 0x7000008000;
+# elif SANITIZER_AARCH64_VMA == 42
+static const uptr kAppAddr = 0x3ff00008000;
+# endif
#else
# error "DFSan not supported for this platform!"
#endif
diff --git a/compiler-rt/lib/dfsan/dfsan.h b/compiler-rt/lib/dfsan/dfsan.h
index 5a512a5cbad..df222e49bb1 100644
--- a/compiler-rt/lib/dfsan/dfsan.h
+++ b/compiler-rt/lib/dfsan/dfsan.h
@@ -49,7 +49,11 @@ inline dfsan_label *shadow_for(void *ptr) {
#elif defined(__mips64)
return (dfsan_label *) ((((uptr) ptr) & ~0xF000000000) << 1);
#elif defined(__aarch64__)
+# if SANITIZER_AARCH64_VMA == 39
return (dfsan_label *) ((((uptr) ptr) & ~0x7800000000) << 1);
+# elif SANITIZER_AARCH64_VMA == 42
+ return (dfsan_label *) ((((uptr) ptr) & ~0x3c000000000) << 1);
+# endif
#endif
}
OpenPOWER on IntegriCloud