summaryrefslogtreecommitdiff
path: root/lib/asan/asan_poisoning.cc
diff options
context:
space:
mode:
authorWalter Lee <waltl@google.com>2018-05-18 04:09:45 +0000
committerWalter Lee <waltl@google.com>2018-05-18 04:09:45 +0000
commit1394070245396b7bb503ee5c55d176f677ceb71b (patch)
tree31c7ebdb21314ba62c09b45c1c64f13dde7b702f /lib/asan/asan_poisoning.cc
parent4f5c2afbfe552f2db91dbcdf88100219842b1a7f (diff)
[asan] Add support for Myriad RTEMS memory map
The Myriad RTEMS memory system has a few unique aspects that require support in the ASan run-time. - A limited amount of memory (currently 512M). - No virtual memory, no memory protection. - DRAM starts at address 0x80000000. Other parts of memory may be used for MMIO, etc. - The second highest address bit is the "cache" bit, and 0x80000000 and 0x84000000 alias to the same memory. To support the above, we make the following changes: - Use a ShadowScale of 5, to reduce shadow memory overhead. - Adjust some existing macros to remove assumption that the lowest memory address is 0. - add a RawAddr macro that on Myriad strips the cache bit from the input address, before using the address for shadow memory (for other archs this does nothing). - We must check that an address is in DRAM range before using it to index into shadow memory. Differential Revision: https://reviews.llvm.org/D46456 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@332690 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_poisoning.cc')
-rw-r--r--lib/asan/asan_poisoning.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/asan/asan_poisoning.cc b/lib/asan/asan_poisoning.cc
index 62cbfe6f0..1e9c37a13 100644
--- a/lib/asan/asan_poisoning.cc
+++ b/lib/asan/asan_poisoning.cc
@@ -182,8 +182,15 @@ int __asan_address_is_poisoned(void const volatile *addr) {
uptr __asan_region_is_poisoned(uptr beg, uptr size) {
if (!size) return 0;
uptr end = beg + size;
- if (!AddrIsInMem(beg)) return beg;
- if (!AddrIsInMem(end)) return end;
+ if (SANITIZER_MYRIAD2) {
+ // On Myriad, address not in DRAM range need to be treated as
+ // unpoisoned.
+ if (!AddrIsInMem(beg) && !AddrIsInShadow(beg)) return 0;
+ if (!AddrIsInMem(end) && !AddrIsInShadow(end)) return 0;
+ } else {
+ if (!AddrIsInMem(beg)) return beg;
+ if (!AddrIsInMem(end)) return end;
+ }
CHECK_LT(beg, end);
uptr aligned_b = RoundUpTo(beg, SHADOW_GRANULARITY);
uptr aligned_e = RoundDownTo(end, SHADOW_GRANULARITY);
@@ -452,4 +459,3 @@ bool WordIsPoisoned(uptr addr) {
return (__asan_region_is_poisoned(addr, sizeof(uptr)) != 0);
}
}
-