1 //===-- asan_mapping_myriad.h -----------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // Myriad-specific definitions for ASan memory mapping.
11 //===----------------------------------------------------------------------===//
12 #ifndef ASAN_MAPPING_MYRIAD_H
13 #define ASAN_MAPPING_MYRIAD_H
14 
15 #define RAW_ADDR(mem) ((mem) & ~kMyriadCacheBitMask32)
16 #define MEM_TO_SHADOW(mem) \
17   (((RAW_ADDR(mem) - kLowMemBeg) >> SHADOW_SCALE) + (SHADOW_OFFSET))
18 
19 #define kLowMemBeg     kMyriadMemoryOffset32
20 #define kLowMemEnd     (SHADOW_OFFSET - 1)
21 
22 #define kLowShadowBeg  SHADOW_OFFSET
23 #define kLowShadowEnd  MEM_TO_SHADOW(kLowMemEnd)
24 
25 #define kHighMemBeg    0
26 
27 #define kHighShadowBeg 0
28 #define kHighShadowEnd 0
29 
30 #define kMidShadowBeg  0
31 #define kMidShadowEnd  0
32 
33 #define kShadowGapBeg  (kLowShadowEnd + 1)
34 #define kShadowGapEnd  kMyriadMemoryEnd32
35 
36 #define kShadowGap2Beg 0
37 #define kShadowGap2End 0
38 
39 #define kShadowGap3Beg 0
40 #define kShadowGap3End 0
41 
42 namespace __asan {
43 
AddrIsInLowMem(uptr a)44 static inline bool AddrIsInLowMem(uptr a) {
45   PROFILE_ASAN_MAPPING();
46   a = RAW_ADDR(a);
47   return a >= kLowMemBeg && a <= kLowMemEnd;
48 }
49 
AddrIsInLowShadow(uptr a)50 static inline bool AddrIsInLowShadow(uptr a) {
51   PROFILE_ASAN_MAPPING();
52   a = RAW_ADDR(a);
53   return a >= kLowShadowBeg && a <= kLowShadowEnd;
54 }
55 
AddrIsInMidMem(uptr a)56 static inline bool AddrIsInMidMem(uptr a) {
57   PROFILE_ASAN_MAPPING();
58   return false;
59 }
60 
AddrIsInMidShadow(uptr a)61 static inline bool AddrIsInMidShadow(uptr a) {
62   PROFILE_ASAN_MAPPING();
63   return false;
64 }
65 
AddrIsInHighMem(uptr a)66 static inline bool AddrIsInHighMem(uptr a) {
67   PROFILE_ASAN_MAPPING();
68   return false;
69 }
70 
AddrIsInHighShadow(uptr a)71 static inline bool AddrIsInHighShadow(uptr a) {
72   PROFILE_ASAN_MAPPING();
73   return false;
74 }
75 
AddrIsInShadowGap(uptr a)76 static inline bool AddrIsInShadowGap(uptr a) {
77   PROFILE_ASAN_MAPPING();
78   a = RAW_ADDR(a);
79   return a >= kShadowGapBeg && a <= kShadowGapEnd;
80 }
81 
82 }  // namespace __asan
83 
84 #endif  // ASAN_MAPPING_MYRIAD_H
85