summaryrefslogtreecommitdiff
path: root/lib/msan/msan.h
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2015-06-25 06:22:31 +0000
committerJay Foad <jay.foad@gmail.com>2015-06-25 06:22:31 +0000
commit12a1093f3429816b0f2c4f0aab8fd4842c1d73d3 (patch)
treeb25e8fab6c0c22b099401605d319d6d89006763d /lib/msan/msan.h
parent5d83e5e9184611514c7b038f99b74506515aec52 (diff)
Enable memory sanitizer for PPC64
Summary: This patch adds basic memory sanitizer support for PPC64. PR23219. I have further patches ready to enable it in LLVM and Clang, and to fix most of the many failing tests in check-msan. Reviewers: kcc, willschm, samsonov, wschmidt, eugenis Reviewed By: eugenis Subscribers: wschmidt, llvm-commits Differential Revision: http://reviews.llvm.org/D10648 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan/msan.h')
-rw-r--r--lib/msan/msan.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/msan/msan.h b/lib/msan/msan.h
index 0adbeb68f..cd8bc19f5 100644
--- a/lib/msan/msan.h
+++ b/lib/msan/msan.h
@@ -52,6 +52,25 @@ const MappingDesc kMemoryLayout[] = {
#define MEM_TO_SHADOW(mem) (((uptr)(mem)) & ~0x4000000000ULL)
#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x002000000000)
+#elif SANITIZER_LINUX && defined(__powerpc64__)
+
+const MappingDesc kMemoryLayout[] = {
+ {0x000000000000ULL, 0x000100000000ULL, MappingDesc::APP, "low memory"},
+ {0x000100000000ULL, 0x080000000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x080000000000ULL, 0x180100000000ULL, MappingDesc::SHADOW, "shadow"},
+ {0x180100000000ULL, 0x1C0000000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x1C0000000000ULL, 0x2C0100000000ULL, MappingDesc::ORIGIN, "origin"},
+ {0x2C0100000000ULL, 0x300000000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x300000000000ULL, 0x400000000000ULL, MappingDesc::APP, "high memory"}};
+
+// Maps low and high app ranges to contiguous space with zero base:
+// Low: 0000 0000 0000 - 0000 ffff ffff -> 1000 0000 0000 - 1000 ffff ffff
+// High: 3000 0000 0000 - 3fff ffff ffff -> 0000 0000 0000 - 0fff ffff ffff
+#define LINEARIZE_MEM(mem) \
+ (((uptr)(mem) & ~0x200000000000ULL) ^ 0x100000000000ULL)
+#define MEM_TO_SHADOW(mem) (LINEARIZE_MEM((mem)) + 0x080000000000ULL)
+#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x140000000000ULL)
+
#elif SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 64
// Low memory: main binary, MAP_32BIT mappings and modules