@@ -136,6 +136,8 @@ struct MappingAppleAarch64 {
136
136
static const uptr kAppMemMsk = 0x0ull ;
137
137
static const uptr kAppMemXor = 0x0ull ;
138
138
static const uptr kVdsoBeg = 0x7000000000000000ull ;
139
+ static const uptr kMidAppMemBeg = 0 ;
140
+ static const uptr kMidAppMemEnd = 0 ;
139
141
};
140
142
141
143
/*
@@ -258,6 +260,8 @@ struct MappingPPC64_44 {
258
260
static const uptr kAppMemMsk = 0x0f0000000000ull ;
259
261
static const uptr kAppMemXor = 0x002100000000ull ;
260
262
static const uptr kVdsoBeg = 0x3c0000000000000ull ;
263
+ static const uptr kMidAppMemBeg = 0 ;
264
+ static const uptr kMidAppMemEnd = 0 ;
261
265
};
262
266
263
267
/*
@@ -290,6 +294,8 @@ struct MappingPPC64_46 {
290
294
static const uptr kAppMemMsk = 0x3c0000000000ull ;
291
295
static const uptr kAppMemXor = 0x020000000000ull ;
292
296
static const uptr kVdsoBeg = 0x7800000000000000ull ;
297
+ static const uptr kMidAppMemBeg = 0 ;
298
+ static const uptr kMidAppMemEnd = 0 ;
293
299
};
294
300
295
301
/*
@@ -322,6 +328,8 @@ struct MappingPPC64_47 {
322
328
static const uptr kAppMemMsk = 0x7c0000000000ull ;
323
329
static const uptr kAppMemXor = 0x020000000000ull ;
324
330
static const uptr kVdsoBeg = 0x7800000000000000ull ;
331
+ static const uptr kMidAppMemBeg = 0 ;
332
+ static const uptr kMidAppMemEnd = 0 ;
325
333
};
326
334
327
335
/*
@@ -354,6 +362,8 @@ struct MappingS390x {
354
362
static const uptr kAppMemMsk = 0xb00000000000ull ;
355
363
static const uptr kAppMemXor = 0x100000000000ull ;
356
364
static const uptr kVdsoBeg = 0xfffffffff000ull ;
365
+ static const uptr kMidAppMemBeg = 0 ;
366
+ static const uptr kMidAppMemEnd = 0 ;
357
367
};
358
368
359
369
/* Go on linux, darwin and freebsd on x86_64
@@ -535,10 +545,8 @@ struct MappingGoS390x {
535
545
536
546
# if HAS_48_BIT_ADDRESS_SPACE
537
547
typedef Mapping48AddressSpace Mapping;
538
- # define TSAN_MID_APP_RANGE 1
539
548
# elif defined(__mips64)
540
549
typedef MappingMips64_40 Mapping40;
541
- # define TSAN_MID_APP_RANGE 1
542
550
# define TSAN_RUNTIME_VMA 1
543
551
# elif defined(__aarch64__) && defined(__APPLE__)
544
552
typedef MappingAppleAarch64 Mapping;
@@ -554,7 +562,6 @@ typedef MappingAarch64_48 Mapping48;
554
562
// Indicates the runtime will define the memory regions at runtime.
555
563
# define TSAN_RUNTIME_VMA 1
556
564
// Indicates that mapping defines a mid range memory segment.
557
- # define TSAN_MID_APP_RANGE 1
558
565
# elif defined(__powerpc64__)
559
566
// PPC64 supports multiple VMA which leads to multiple address transformation
560
567
// functions. To support these multiple VMAS transformations and mappings TSAN
@@ -643,10 +650,8 @@ enum MappingType {
643
650
MAPPING_LO_APP_END,
644
651
MAPPING_HI_APP_BEG,
645
652
MAPPING_HI_APP_END,
646
- #ifdef TSAN_MID_APP_RANGE
647
653
MAPPING_MID_APP_BEG,
648
654
MAPPING_MID_APP_END,
649
- #endif
650
655
MAPPING_HEAP_BEG,
651
656
MAPPING_HEAP_END,
652
657
MAPPING_APP_BEG,
@@ -667,10 +672,8 @@ struct MappingField {
667
672
#if !SANITIZER_GO
668
673
case MAPPING_LO_APP_BEG: return Mapping::kLoAppMemBeg ;
669
674
case MAPPING_LO_APP_END: return Mapping::kLoAppMemEnd ;
670
- # ifdef TSAN_MID_APP_RANGE
671
675
case MAPPING_MID_APP_BEG: return Mapping::kMidAppMemBeg ;
672
676
case MAPPING_MID_APP_END: return Mapping::kMidAppMemEnd ;
673
- # endif
674
677
case MAPPING_HI_APP_BEG: return Mapping::kHiAppMemBeg ;
675
678
case MAPPING_HI_APP_END: return Mapping::kHiAppMemEnd ;
676
679
case MAPPING_HEAP_BEG: return Mapping::kHeapMemBeg ;
@@ -703,7 +706,6 @@ uptr LoAppMemEnd(void) {
703
706
return SelectMapping<MappingField>(MAPPING_LO_APP_END);
704
707
}
705
708
706
- #ifdef TSAN_MID_APP_RANGE
707
709
ALWAYS_INLINE
708
710
uptr MidAppMemBeg (void ) {
709
711
return SelectMapping<MappingField>(MAPPING_MID_APP_BEG);
@@ -712,7 +714,6 @@ ALWAYS_INLINE
712
714
uptr MidAppMemEnd (void ) {
713
715
return SelectMapping<MappingField>(MAPPING_MID_APP_END);
714
716
}
715
- #endif
716
717
717
718
ALWAYS_INLINE
718
719
uptr HeapMemBeg (void ) { return SelectMapping<MappingField>(MAPPING_HEAP_BEG); }
@@ -743,8 +744,6 @@ uptr AppMemEnd(void) { return SelectMapping<MappingField>(MAPPING_APP_END); }
743
744
static inline
744
745
bool GetUserRegion (int i, uptr *start, uptr *end) {
745
746
switch (i) {
746
- default :
747
- return false ;
748
747
#if !SANITIZER_GO
749
748
case 0 :
750
749
*start = LoAppMemBeg ();
@@ -758,18 +757,21 @@ bool GetUserRegion(int i, uptr *start, uptr *end) {
758
757
*start = HeapMemBeg ();
759
758
*end = HeapMemEnd ();
760
759
return true ;
761
- # ifdef TSAN_MID_APP_RANGE
762
760
case 3 :
763
- *start = MidAppMemBeg ();
764
- *end = MidAppMemEnd ();
765
- return true ;
766
- # endif
761
+ if (MidAppMemBeg ()) {
762
+ *start = MidAppMemBeg ();
763
+ *end = MidAppMemEnd ();
764
+ return true ;
765
+ }
766
+ FALLTHROUGH;
767
767
#else
768
768
case 0 :
769
769
*start = AppMemBeg ();
770
770
*end = AppMemEnd ();
771
771
return true ;
772
772
#endif
773
+ default :
774
+ return false ;
773
775
}
774
776
}
775
777
@@ -801,9 +803,7 @@ struct IsAppMemImpl {
801
803
static bool Apply (uptr mem) {
802
804
#if !SANITIZER_GO
803
805
return (mem >= Mapping::kHeapMemBeg && mem < Mapping::kHeapMemEnd ) ||
804
- # ifdef TSAN_MID_APP_RANGE
805
806
(mem >= Mapping::kMidAppMemBeg && mem < Mapping::kMidAppMemEnd ) ||
806
- # endif
807
807
(mem >= Mapping::kLoAppMemBeg && mem < Mapping::kLoAppMemEnd ) ||
808
808
(mem >= Mapping::kHiAppMemBeg && mem < Mapping::kHiAppMemEnd );
809
809
#else
@@ -898,13 +898,13 @@ struct ShadowToMemImpl {
898
898
if (p >= Mapping::kLoAppMemBeg && p < Mapping::kLoAppMemEnd &&
899
899
MemToShadowImpl::Apply<Mapping>(p) == sp)
900
900
return p;
901
- # ifdef TSAN_MID_APP_RANGE
902
- p = ((sp / kShadowCnt ) ^ Mapping::kAppMemXor ) +
903
- (Mapping::kMidAppMemBeg & Mapping::kAppMemMsk );
904
- if (p >= Mapping::kMidAppMemBeg && p < Mapping::kMidAppMemEnd &&
905
- MemToShadowImpl::Apply<Mapping>(p) == sp)
906
- return p;
907
- # endif
901
+ if (Mapping:: kMidAppMemBeg ) {
902
+ p = ((sp / kShadowCnt ) ^ Mapping::kAppMemXor ) +
903
+ (Mapping::kMidAppMemBeg & Mapping::kAppMemMsk );
904
+ if (p >= Mapping::kMidAppMemBeg && p < Mapping::kMidAppMemEnd &&
905
+ MemToShadowImpl::Apply<Mapping>(p) == sp)
906
+ return p;
907
+ }
908
908
return ((sp / kShadowCnt ) ^ Mapping::kAppMemXor ) | Mapping::kAppMemMsk ;
909
909
#else // #if !SANITIZER_GO
910
910
# ifndef SANITIZER_WINDOWS
0 commit comments