summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBill Seurer <seurer@linux.vnet.ibm.com>2017-11-09 16:14:57 +0000
committerBill Seurer <seurer@linux.vnet.ibm.com>2017-11-09 16:14:57 +0000
commit57c7865216d50a1b4fd85fefcd5d8a731f3eed0e (patch)
tree3290f73fb8addefb29205b7b1cfc3494e791826c /lib
parenta27bbe7200e0f282ac1db1a3567cca19b8ceca44 (diff)
[PowerPC][msan] Update msan to handle changed memory layouts in newer kernels
In more recent Linux kernels (including those with 47 bit VMAs) the layout of virtual memory for powerpc64 changed causing the memory sanitizer to not work properly. This patch adjusts the memory ranges in the tables for the memory sanitizer to work on the newer kernels while continuing to work on the older ones as well. Tested on several 4.x and 3.x kernel releases. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/msan/msan.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/msan/msan.h b/lib/msan/msan.h
index b81b7ea80..e58dfe061 100644
--- a/lib/msan/msan.h
+++ b/lib/msan/msan.h
@@ -160,21 +160,25 @@ const MappingDesc kMemoryLayout[] = {
# define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x1000000000ULL)
#elif SANITIZER_LINUX && SANITIZER_PPC64
-
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"}};
-
+ {0x000000000000ULL, 0x000200000000ULL, MappingDesc::APP, "low memory"},
+ {0x000200000000ULL, 0x080000000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x080000000000ULL, 0x180200000000ULL, MappingDesc::SHADOW, "shadow"},
+ {0x180200000000ULL, 0x1C0000000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x1C0000000000ULL, 0x2C0200000000ULL, MappingDesc::ORIGIN, "origin"},
+ {0x2C0200000000ULL, 0x300000000000ULL, MappingDesc::INVALID, "invalid"},
+ {0x300000000000ULL, 0x800000000000ULL, MappingDesc::APP, "high memory"}};
+
+// Various kernels use different low end ranges but we can combine them into one
+// big range. They also use different high end ranges but we can map them all to
+// one range.
// 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
+// Low: 0000 0000 0000 - 0001 ffff ffff -> 1000 0000 0000 - 1001 ffff ffff
// High: 3000 0000 0000 - 3fff ffff ffff -> 0000 0000 0000 - 0fff ffff ffff
+// High: 4000 0000 0000 - 4fff ffff ffff -> 0000 0000 0000 - 0fff ffff ffff
+// High: 7000 0000 0000 - 7fff ffff ffff -> 0000 0000 0000 - 0fff ffff ffff
#define LINEARIZE_MEM(mem) \
- (((uptr)(mem) & ~0x200000000000ULL) ^ 0x100000000000ULL)
+ (((uptr)(mem) & ~0xE00000000000ULL) ^ 0x100000000000ULL)
#define MEM_TO_SHADOW(mem) (LINEARIZE_MEM((mem)) + 0x080000000000ULL)
#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x140000000000ULL)