[compiler-rt] f020acf - [tsan] Add 47-bit VMA mapping for linux/aarch64 (#205949)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 18:02:18 PDT 2026


Author: Fei Peng
Date: 2026-07-15T18:02:13-07:00
New Revision: f020acfd395d9094303e78c807bc168a46a783fa

URL: https://github.com/llvm/llvm-project/commit/f020acfd395d9094303e78c807bc168a46a783fa
DIFF: https://github.com/llvm/llvm-project/commit/f020acfd395d9094303e78c807bc168a46a783fa.diff

LOG: [tsan] Add 47-bit VMA mapping for linux/aarch64 (#205949)

Add 47-bit VMA mapping to support TSan on the latest Android
emulator(16kb page size and 47 va bits).

Fixes https://github.com/llvm/llvm-project/issues/151931

Android kernel config:
https://android.googlesource.com/kernel/build/+/refs/heads/main-kernel-2026/kleaf/impl/defconfig/arm64_16k_defconfig#6

Added: 
    

Modified: 
    compiler-rt/lib/tsan/rtl/tsan_platform.h
    compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h b/compiler-rt/lib/tsan/rtl/tsan_platform.h
index 5edec59d5af52..e833095c46c61 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 - 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 - 5c00 0000 0000: main binary (PIE)               (6828 GB)
+5c00 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 = 0x0040000000000ull;
+  static const uptr kShadowBeg = 0x00aaa00000000ull;
+  static const uptr kShadowEnd = 0x0280000000000ull;
+  static const uptr kMetaShadowBeg = 0x0400000000000ull;
+  static const uptr kMetaShadowEnd = 0x0500000000000ull;
+  static const uptr kMidAppMemBeg = 0x0555500000000ull;
+  static const uptr kMidAppMemEnd = 0x05c0000000000ull;
+  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;


        


More information about the llvm-commits mailing list