[compiler-rt] [asan][hwasan] Add config for AArch64 Linux with 39-bit VA. (PR #166881)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 6 18:06:51 PST 2025


https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/166881

This is leveraging work which has already been done for Android, which ships 39-bit VA kernels, and extending it to other embedded Linux targets.

(Marking draft while we complete internal testing.)

>From 4b220d04338bd304b64a00fffd223e98cd488057 Mon Sep 17 00:00:00 2001
From: Eli Friedman <efriedma at qti.qualcomm.com>
Date: Thu, 6 Nov 2025 17:33:06 -0800
Subject: [PATCH] [asan][hwasan] Add config for AArch64 Linux with 39-bit VA.

This is leveraging work which has already been done for Android, which
ships 39-bit VA kernels, and extending it to other embedded Linux
targets.
---
 compiler-rt/CMakeLists.txt                | 7 +++++++
 compiler-rt/lib/asan/asan_allocator.h     | 2 +-
 compiler-rt/lib/hwasan/hwasan_allocator.h | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index a9e8899f8ae0c..1f0f21afbbd6d 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -290,6 +290,9 @@ option(SANITIZER_USE_STATIC_TEST_CXX
   "Use static libc++ for tests." ${DEFAULT_SANITIZER_USE_STATIC_TEST_CXX})
 pythonize_bool(SANITIZER_USE_STATIC_TEST_CXX)
 
+option(SANITIZER_AARCH64_39BIT_VA
+  "Configure sanitizer allocator for 39-bit VA kernel." OFF)
+
 set(COMPILER_RT_SUPPORTED_CXX_LIBRARIES none default libcxx)
 set(COMPILER_RT_CXX_LIBRARY "default" CACHE STRING "Specify C++ library to use. Supported values are ${COMPILER_RT_SUPPORTED_CXX_LIBRARIES}.")
 if (NOT "${COMPILER_RT_CXX_LIBRARY}" IN_LIST COMPILER_RT_SUPPORTED_CXX_LIBRARIES)
@@ -843,6 +846,10 @@ if (SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH)
   add_compile_definitions(SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH)
 endif()
 
+if (SANITIZER_AARCH64_39BIT_VA)
+  add_compile_definitions(SANITIZER_AARCH64_39BIT_VA)
+endif()
+
 add_subdirectory(lib)
 
 if(COMPILER_RT_INCLUDE_TESTS)
diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h
index fdf456473fb02..e2ec877696c0a 100644
--- a/compiler-rt/lib/asan/asan_allocator.h
+++ b/compiler-rt/lib/asan/asan_allocator.h
@@ -200,7 +200,7 @@ const uptr kAllocatorSpace = ~(uptr)0;
 #    if defined(__powerpc64__)
 const uptr kAllocatorSize  =  0x20000000000ULL;  // 2T.
 typedef DefaultSizeClassMap SizeClassMap;
-#    elif defined(__aarch64__) && SANITIZER_ANDROID
+#    elif defined(__aarch64__) && (SANITIZER_ANDROID || defined(SANITIZER_AARCH64_39BIT_VA))
 // Android needs to support 39, 42 and 48 bit VMA.
 const uptr kAllocatorSize  =  0x2000000000ULL;  // 128G.
 typedef VeryCompactSizeClassMap SizeClassMap;
diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h
index 2ada2a0b1851a..94fd7b2f7467b 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.h
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.h
@@ -74,7 +74,7 @@ struct AP64 {
 #if defined(HWASAN_ALIASING_MODE)
   static const uptr kSpaceSize = 1ULL << kAddressTagShift;
   typedef __sanitizer::DefaultSizeClassMap SizeClassMap;
-#elif SANITIZER_LINUX && !SANITIZER_ANDROID
+#elif SANITIZER_LINUX && !SANITIZER_ANDROID && !defined(SANITIZER_AARCH64_39BIT_VA)
   static const uptr kSpaceSize = 0x40000000000ULL;  // 4T.
   typedef __sanitizer::DefaultSizeClassMap SizeClassMap;
 #else



More information about the llvm-commits mailing list