[compiler-rt] [tsan] Add 47-bit VMA mapping for linux/aarch64 (PR #205949)
Fei Peng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 25 20:09:29 PDT 2026
https://github.com/airpfei updated https://github.com/llvm/llvm-project/pull/205949
>From 57078f9d15a57f6db9940d292b05544fa15f96a8 Mon Sep 17 00:00:00 2001
From: Fei Peng <pengfei.02 at bytedance.com>
Date: Thu, 25 Jun 2026 15:41:15 -0700
Subject: [PATCH 1/2] [tsan] Add 47-bit VMA mapping for linux/aarch64
---
compiler-rt/lib/tsan/rtl/tsan_platform.h | 34 +++++++++++++++++++
.../lib/tsan/rtl/tsan_platform_linux.cpp | 28 +++++++--------
2 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h b/compiler-rt/lib/tsan/rtl/tsan_platform.h
index 5edec59d5af52..101ad76897a3c 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform.h
@@ -214,6 +214,37 @@ struct MappingAarch64_42 {
static const uptr kVdsoBeg = 0x37f00000000ull;
};
+/*
+C/C++ on linux/aarch64 (47-bit VMA)
+0000 0000 1000 - 0500 0000 0000: main binary (5120 GB)
+0500 0000 0000 - 0aaa 0000 0000: -
+0aaa 0000 0000 - 2a00 0000 0000: shadow memory (32088 GB)
+2a00 0000 0000 - 4000 0000 0000: -
+4000 0000 0000 - 5000 0000 0000: metainfo (16384 GB)
+5000 0000 0000 - 5555 0000 0000: -
+5555 0000 0000 - 5600 0000 0000: main binary (PIE) (684 GB)
+5600 0000 0000 - 7c00 0000 0000: -
+7c00 0000 0000 - 7fff ffff ffff: modules and main thread stack (4096 GB)
+*/
+struct MappingAarch64_47 {
+ static const uptr kLoAppMemBeg = 0x0000000001000ull;
+ static const uptr kLoAppMemEnd = 0x0050000000000ull;
+ static const uptr kShadowBeg = 0x00aaa00000000ull;
+ static const uptr kShadowEnd = 0x02a0000000000ull;
+ static const uptr kMetaShadowBeg = 0x0400000000000ull;
+ static const uptr kMetaShadowEnd = 0x0500000000000ull;
+ static const uptr kMidAppMemBeg = 0x0555500000000ull;
+ static const uptr kMidAppMemEnd = 0x0560000000000ull;
+ static const uptr kHiAppMemBeg = 0x07c0000000000ull;
+ static const uptr kHiAppMemEnd = 0x0800000000000ull;
+ static const uptr kHeapMemBeg = 0x07c0000000000ull;
+ static const uptr kHeapMemEnd = 0x07c0000000000ull;
+ static const uptr kShadowMsk = 0x0600000000000ull;
+ static const uptr kShadowXor = 0x0100000000000ull;
+ static const uptr kShadowAdd = 0x0000000000000ull;
+ static const uptr kVdsoBeg = 0x07fff00000000ull;
+};
+
/*
C/C++ on linux/aarch64 (48-bit VMA)
0000 0000 1000 - 0a00 0000 0000: main binary (10240 GB)
@@ -807,6 +838,8 @@ ALWAYS_INLINE auto SelectMapping(Arg arg) {
return Func::template Apply<MappingAarch64_39>(arg);
case 42:
return Func::template Apply<MappingAarch64_42>(arg);
+ case 47:
+ return Func::template Apply<MappingAarch64_47>(arg);
case 48:
return Func::template Apply<MappingAarch64_48>(arg);
}
@@ -846,6 +879,7 @@ void ForEachMapping() {
Func::template Apply<MappingAppleAarch64>();
Func::template Apply<MappingAarch64_39>();
Func::template Apply<MappingAarch64_42>();
+ Func::template Apply<MappingAarch64_47>();
Func::template Apply<MappingAarch64_48>();
Func::template Apply<MappingLoongArch64_47>();
Func::template Apply<MappingPPC64_44>();
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
index c974f549acbcb..f800353d72bbe 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
@@ -329,20 +329,20 @@ void InitializePlatformEarly() {
(MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1);
#if defined(__aarch64__)
# if !SANITIZER_GO
- if (vmaSize != 39 && vmaSize != 42 && vmaSize != 48) {
+ if (vmaSize != 39 && vmaSize != 42 && vmaSize != 47 && vmaSize != 48) {
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
- Printf("FATAL: Found %zd - Supported 39, 42 and 48\n", vmaSize);
+ Printf("FATAL: Found %zd - Supported 39, 42, 47 and 48\n", vmaSize);
Die();
}
-#else
+# else
if (vmaSize != 48) {
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
Printf("FATAL: Found %zd - Supported 48\n", vmaSize);
Die();
}
-#endif
-#elif SANITIZER_LOONGARCH64
-# if !SANITIZER_GO
+# endif
+# elif SANITIZER_LOONGARCH64
+# if !SANITIZER_GO
if (vmaSize != 47) {
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
@@ -355,34 +355,34 @@ void InitializePlatformEarly() {
Die();
}
# endif
-#elif defined(__powerpc64__)
-# if !SANITIZER_GO
+# elif defined(__powerpc64__)
+# if !SANITIZER_GO
if (vmaSize != 44 && vmaSize != 46 && vmaSize != 47) {
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
Printf("FATAL: Found %zd - Supported 44, 46, and 47\n", vmaSize);
Die();
}
-# else
+# else
if (vmaSize != 46 && vmaSize != 47) {
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
Printf("FATAL: Found %zd - Supported 46, and 47\n", vmaSize);
Die();
}
-# endif
-#elif defined(__mips64)
-# if !SANITIZER_GO
+# endif
+# elif defined(__mips64)
+# if !SANITIZER_GO
if (vmaSize != 40) {
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
Printf("FATAL: Found %zd - Supported 40\n", vmaSize);
Die();
}
-# else
+# else
if (vmaSize != 47) {
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
Die();
}
-# endif
+# endif
# elif SANITIZER_RISCV64
// the bottom half of vma is allocated for userspace
vmaSize = vmaSize + 1;
>From a21376d4ec230bae5beca42c70b7d98dd873fe7d Mon Sep 17 00:00:00 2001
From: pengfei <pengfei.02 at bytedance.com>
Date: Fri, 26 Jun 2026 02:59:17 +0000
Subject: [PATCH 2/2] fix CompressedAddr error
---
compiler-rt/lib/tsan/rtl/tsan_platform.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h b/compiler-rt/lib/tsan/rtl/tsan_platform.h
index 101ad76897a3c..0486df16dc892 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform.h
@@ -216,10 +216,10 @@ struct MappingAarch64_42 {
/*
C/C++ on linux/aarch64 (47-bit VMA)
-0000 0000 1000 - 0500 0000 0000: main binary (5120 GB)
-0500 0000 0000 - 0aaa 0000 0000: -
-0aaa 0000 0000 - 2a00 0000 0000: shadow memory (32088 GB)
-2a00 0000 0000 - 4000 0000 0000: -
+0000 0000 1000 - 0400 0000 0000: main binary (4096 GB)
+0400 0000 0000 - 0aaa 0000 0000: -
+0aaa 0000 0000 - 2800 0000 0000: shadow memory (30040 GB)
+2800 0000 0000 - 4000 0000 0000: -
4000 0000 0000 - 5000 0000 0000: metainfo (16384 GB)
5000 0000 0000 - 5555 0000 0000: -
5555 0000 0000 - 5600 0000 0000: main binary (PIE) (684 GB)
@@ -228,9 +228,9 @@ C/C++ on linux/aarch64 (47-bit VMA)
*/
struct MappingAarch64_47 {
static const uptr kLoAppMemBeg = 0x0000000001000ull;
- static const uptr kLoAppMemEnd = 0x0050000000000ull;
+ static const uptr kLoAppMemEnd = 0x0040000000000ull;
static const uptr kShadowBeg = 0x00aaa00000000ull;
- static const uptr kShadowEnd = 0x02a0000000000ull;
+ static const uptr kShadowEnd = 0x0280000000000ull;
static const uptr kMetaShadowBeg = 0x0400000000000ull;
static const uptr kMetaShadowEnd = 0x0500000000000ull;
static const uptr kMidAppMemBeg = 0x0555500000000ull;
More information about the llvm-commits
mailing list