summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/msan/msan_allocator.cc
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-11-20 12:51:14 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-11-20 12:51:14 +0000
commit584fd96e9eebba95e8335e137c959bae873dbf2b (patch)
tree0c82216898ab26d06f2b61092873a39f70f0a3ac /compiler-rt/lib/msan/msan_allocator.cc
parent115ef14548fb356ba8d99ac04d1451b52d131a31 (diff)
downloadbcm5719-llvm-584fd96e9eebba95e8335e137c959bae873dbf2b.tar.gz
bcm5719-llvm-584fd96e9eebba95e8335e137c959bae873dbf2b.zip
[msan] Unpoison memory that is returned to the OS and flush its shadow.
llvm-svn: 195244
Diffstat (limited to 'compiler-rt/lib/msan/msan_allocator.cc')
-rw-r--r--compiler-rt/lib/msan/msan_allocator.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/compiler-rt/lib/msan/msan_allocator.cc b/compiler-rt/lib/msan/msan_allocator.cc
index 2badf712188..3c74142bcb1 100644
--- a/compiler-rt/lib/msan/msan_allocator.cc
+++ b/compiler-rt/lib/msan/msan_allocator.cc
@@ -22,15 +22,29 @@ struct Metadata {
uptr requested_size;
};
+struct MsanMapUnmapCallback {
+ void OnMap(uptr p, uptr size) const {}
+ void OnUnmap(uptr p, uptr size) const {
+ __msan_unpoison((void *)p, size);
+
+ // We are about to unmap a chunk of user memory.
+ // Mark the corresponding shadow memory as not needed.
+ FlushUnneededShadowMemory(MEM_TO_SHADOW(p), size);
+ if (__msan_get_track_origins())
+ FlushUnneededShadowMemory(MEM_TO_ORIGIN(p), size);
+ }
+};
+
static const uptr kAllocatorSpace = 0x600000000000ULL;
static const uptr kAllocatorSize = 0x80000000000; // 8T.
static const uptr kMetadataSize = sizeof(Metadata);
static const uptr kMaxAllowedMallocSize = 8UL << 30;
typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, kMetadataSize,
- DefaultSizeClassMap> PrimaryAllocator;
+ DefaultSizeClassMap,
+ MsanMapUnmapCallback> PrimaryAllocator;
typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
-typedef LargeMmapAllocator<> SecondaryAllocator;
+typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator;
typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
SecondaryAllocator> Allocator;
OpenPOWER on IntegriCloud