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