1 //===-- asan_mapping_sparc64.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 // SPARC64-specific definitions for ASan memory mapping. 11 //===----------------------------------------------------------------------===// 12 #ifndef ASAN_MAPPING_SPARC64_H 13 #define ASAN_MAPPING_SPARC64_H 14 15 // This is tailored to the 52-bit VM layout on SPARC-T4 and later. 16 // The VM space is split into two 51-bit halves at both ends: the low part 17 // has all the bits above the 51st cleared, while the high part has them set. 18 // 0xfff8000000000000 - 0xffffffffffffffff 19 // 0x0000000000000000 - 0x0007ffffffffffff 20 21 #define VMA_BITS 52 22 #define HIGH_BITS (64 - VMA_BITS) 23 24 // The idea is to chop the high bits before doing the scaling, so the two 25 // parts become contiguous again and the usual scheme can be applied. 26 27 #define MEM_TO_SHADOW(mem) \ 28 ((((mem) << HIGH_BITS) >> (HIGH_BITS + (SHADOW_SCALE))) + (SHADOW_OFFSET)) 29 30 #define kLowMemBeg 0 31 #define kLowMemEnd (SHADOW_OFFSET - 1) 32 33 #define kLowShadowBeg SHADOW_OFFSET 34 #define kLowShadowEnd MEM_TO_SHADOW(kLowMemEnd) 35 36 // But of course there is the huge hole between the high shadow memory, 37 // which is in the low part, and the beginning of the high part. 38 39 #define kHighMemBeg (-(1ULL << (VMA_BITS - 1))) 40 41 #define kHighShadowBeg MEM_TO_SHADOW(kHighMemBeg) 42 #define kHighShadowEnd MEM_TO_SHADOW(kHighMemEnd) 43 44 #define kMidShadowBeg 0 45 #define kMidShadowEnd 0 46 47 // With the zero shadow base we can not actually map pages starting from 0. 48 // This constant is somewhat arbitrary. 49 #define kZeroBaseShadowStart 0 50 #define kZeroBaseMaxShadowStart (1 << 18) 51 52 #define kShadowGapBeg (kLowShadowEnd + 1) 53 #define kShadowGapEnd (kHighShadowBeg - 1) 54 55 #define kShadowGap2Beg 0 56 #define kShadowGap2End 0 57 58 #define kShadowGap3Beg 0 59 #define kShadowGap3End 0 60 61 namespace __asan { 62 AddrIsInLowMem(uptr a)63static inline bool AddrIsInLowMem(uptr a) { 64 PROFILE_ASAN_MAPPING(); 65 return a <= kLowMemEnd; 66 } 67 AddrIsInLowShadow(uptr a)68static inline bool AddrIsInLowShadow(uptr a) { 69 PROFILE_ASAN_MAPPING(); 70 return a >= kLowShadowBeg && a <= kLowShadowEnd; 71 } 72 AddrIsInMidMem(uptr a)73static inline bool AddrIsInMidMem(uptr a) { 74 PROFILE_ASAN_MAPPING(); 75 return false; 76 } 77 AddrIsInMidShadow(uptr a)78static inline bool AddrIsInMidShadow(uptr a) { 79 PROFILE_ASAN_MAPPING(); 80 return false; 81 } 82 AddrIsInHighMem(uptr a)83static inline bool AddrIsInHighMem(uptr a) { 84 PROFILE_ASAN_MAPPING(); 85 return kHighMemBeg && a >= kHighMemBeg && a <= kHighMemEnd; 86 } 87 AddrIsInHighShadow(uptr a)88static inline bool AddrIsInHighShadow(uptr a) { 89 PROFILE_ASAN_MAPPING(); 90 return kHighMemBeg && a >= kHighShadowBeg && a <= kHighShadowEnd; 91 } 92 AddrIsInShadowGap(uptr a)93static inline bool AddrIsInShadowGap(uptr a) { 94 PROFILE_ASAN_MAPPING(); 95 return a >= kShadowGapBeg && a <= kShadowGapEnd; 96 } 97 98 } // namespace __asan 99 100 #endif // ASAN_MAPPING_SPARC64_H 101