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