Skip to content

Commit 7d039ef

Browse files
authored
[tsan] Increase size of shadow mappings for C/C++ on linux/x86_64 (#70517)
The current TSan mappings for C/C++ on linux/x86_64 have 0.5TB for low app mem, 1.5TB (1.17TB usable) for mid app mem and 1.5TB for high app mem. This can get a bit cramped if the apps are huge, and/or (in the case of mid/high app mem) with significant ASLR entropy (default ASLR setting of 28-bits = 1TB). This patch increases the mapping sizes to 2TB, 5TB, and 6TB for the low, mid and high app regions respectively. This is compatible with up to 30-bits of ASLR entropy. It is difficult to make the mappings any larger, given the 44-bit pointer compression. It also moves the heap region to avoid HeapEnd() overlapping with the newly enlarged high app region. For convenience, we now use kShadowAdd instead of kShadowXor for this set of mappings. This should be roughly equivalent in runtime performance.
1 parent 3b449bd commit 7d039ef

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

compiler-rt/lib/tsan/rtl/tsan_platform.h

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,16 @@ enum {
4646

4747
/*
4848
C/C++ on linux/x86_64 and freebsd/x86_64
49-
0000 0000 1000 - 0080 0000 0000: main binary and/or MAP_32BIT mappings (512GB)
50-
0040 0000 0000 - 0100 0000 0000: -
51-
0100 0000 0000 - 1000 0000 0000: shadow
52-
1000 0000 0000 - 3000 0000 0000: -
53-
3000 0000 0000 - 3400 0000 0000: metainfo (memory blocks and sync objects)
54-
3400 0000 0000 - 5500 0000 0000: -
55-
5500 0000 0000 - 5680 0000 0000: pie binaries without ASLR or on 4.1+ kernels
56-
5680 0000 0000 - 7d00 0000 0000: -
57-
7b00 0000 0000 - 7c00 0000 0000: heap
58-
7c00 0000 0000 - 7e80 0000 0000: -
59-
7e80 0000 0000 - 8000 0000 0000: modules and main thread stack
49+
0000 0000 1000 - 0200 0000 0000: main binary and/or MAP_32BIT mappings (2TB)
50+
0200 0000 0000 - 1000 0000 0000: -
51+
1000 0000 0000 - 3000 0000 0000: shadow (32TB)
52+
3000 0000 0000 - 3800 0000 0000: metainfo (memory blocks and sync objects; 8TB)
53+
3800 0000 0000 - 5500 0000 0000: -
54+
5500 0000 0000 - 5a00 0000 0000: pie binaries without ASLR or on 4.1+ kernels
55+
5a00 0000 0000 - 7200 0000 0000: -
56+
7200 0000 0000 - 7300 0000 0000: heap (1TB)
57+
7300 0000 0000 - 7a00 0000 0000: -
58+
7a00 0000 0000 - 8000 0000 0000: modules and main thread stack (6TB)
6059
6160
C/C++ on netbsd/amd64 can reuse the same mapping:
6261
* The address space starts from 0x1000 (option with 0x0) and ends with
@@ -72,20 +71,20 @@ C/C++ on netbsd/amd64 can reuse the same mapping:
7271
*/
7372
struct Mapping48AddressSpace {
7473
static const uptr kMetaShadowBeg = 0x300000000000ull;
75-
static const uptr kMetaShadowEnd = 0x340000000000ull;
76-
static const uptr kShadowBeg = 0x010000000000ull;
77-
static const uptr kShadowEnd = 0x100000000000ull;
78-
static const uptr kHeapMemBeg = 0x7b0000000000ull;
79-
static const uptr kHeapMemEnd = 0x7c0000000000ull;
74+
static const uptr kMetaShadowEnd = 0x380000000000ull;
75+
static const uptr kShadowBeg = 0x100000000000ull;
76+
static const uptr kShadowEnd = 0x300000000000ull;
77+
static const uptr kHeapMemBeg = 0x720000000000ull;
78+
static const uptr kHeapMemEnd = 0x730000000000ull;
8079
static const uptr kLoAppMemBeg = 0x000000001000ull;
81-
static const uptr kLoAppMemEnd = 0x008000000000ull;
80+
static const uptr kLoAppMemEnd = 0x020000000000ull;
8281
static const uptr kMidAppMemBeg = 0x550000000000ull;
83-
static const uptr kMidAppMemEnd = 0x568000000000ull;
84-
static const uptr kHiAppMemBeg = 0x7e8000000000ull;
82+
static const uptr kMidAppMemEnd = 0x5a0000000000ull;
83+
static const uptr kHiAppMemBeg = 0x7a0000000000ull;
8584
static const uptr kHiAppMemEnd = 0x800000000000ull;
86-
static const uptr kShadowMsk = 0x780000000000ull;
87-
static const uptr kShadowXor = 0x040000000000ull;
88-
static const uptr kShadowAdd = 0x000000000000ull;
85+
static const uptr kShadowMsk = 0x700000000000ull;
86+
static const uptr kShadowXor = 0x000000000000ull;
87+
static const uptr kShadowAdd = 0x100000000000ull;
8988
static const uptr kVdsoBeg = 0xf000000000000000ull;
9089
};
9190

0 commit comments

Comments
 (0)