Skip to content

Conversation

@thurstond
Copy link
Contributor

@thurstond thurstond commented Aug 6, 2025

This adds commentary to explain why ASan does not work for AArch64 non-Android Linux with 39-bit and 42-bit VMAs (e.g., #145259).

Additionally, it updates the 42-bit VMA shadow map comment, which has been outdated for the last 10 years
(18b2258 changed 39-bit and 42-bit to use the same offset), and adds a comment for the 48-bit VMA shadow map.

This adds commentary to explain why the AArch64 non-Android Linux (*) shadow mappings do
not work for 39-bit and 42-bit VMAs (e.g.,
llvm#145259).

Additionally, it updates the 42-bit VMA shadow map comment, which has
been outdated for the last 10 years
(18b2258 changed 39-bit and 42-bit to
use the same offset).

(*) AArch64 Android still works with 39-bit and 42-bit VMAs. Maybe one
day they will move from ASan to something more robust, like MTE.
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Thurston Dang (thurstond)

Changes

This adds commentary to explain why ASan does not work for AArch64 non-Android Linux (*) with 39-bit and 42-bit VMAs (e.g., #145259).

Additionally, it updates the 42-bit VMA shadow map comment, which has been outdated for the last 10 years
(18b2258 changed 39-bit and 42-bit to use the same offset).

(*) Thankfully, ASan on AArch64 Android still works with 39-bit and 42-bit VMAs, in the absence of something more robust such as MTE.


Full diff: https://github.com/llvm/llvm-project/pull/152412.diff

1 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_mapping.h (+21-10)
diff --git a/compiler-rt/lib/asan/asan_mapping.h b/compiler-rt/lib/asan/asan_mapping.h
index 91fe60db6329a..bddae9a074056 100644
--- a/compiler-rt/lib/asan/asan_mapping.h
+++ b/compiler-rt/lib/asan/asan_mapping.h
@@ -83,18 +83,29 @@
 // || `[0x0000000000, 0x0d5554ffff]` || LowMem     ||
 //
 // Default Linux/AArch64 (39-bit VMA) mapping:
-// || `[0x2000000000, 0x7fffffffff]` || highmem    ||
-// || `[0x1400000000, 0x1fffffffff]` || highshadow ||
-// || `[0x1200000000, 0x13ffffffff]` || shadowgap  ||
-// || `[0x1000000000, 0x11ffffffff]` || lowshadow  ||
-// || `[0x0000000000, 0x0fffffffff]` || lowmem     ||
+// TODO: this mapping is ok, but the allocator size is too large on non-Android
+//       AArch64 platforms (see asan_allocator.h)
+// || `[0x2000000000, 0x7fffffffff]` || highmem    || 384GB
+// || `[0x1400000000, 0x1fffffffff]` || highshadow || 48GB
+// || `[0x1200000000, 0x13ffffffff]` || shadowgap  || 8GB
+// || `[0x1000000000, 0x11ffffffff]` || lowshadow  || 8GB
+// || `[0x0000000000, 0x0fffffffff]` || lowmem     || 64GB
 //
 // Default Linux/AArch64 (42-bit VMA) mapping:
-// || `[0x10000000000, 0x3ffffffffff]` || highmem    ||
-// || `[0x0a000000000, 0x0ffffffffff]` || highshadow ||
-// || `[0x09000000000, 0x09fffffffff]` || shadowgap  ||
-// || `[0x08000000000, 0x08fffffffff]` || lowshadow  ||
-// || `[0x00000000000, 0x07fffffffff]` || lowmem     ||
+// TODO: this mapping is ok, but the allocator size is too large on non-Android
+//       AArch64 platforms (see asan_allocator.h)
+// || `[0x09000000000, 0x03ffffffffff]` || highmem    || 3520GB
+// || `[0x02200000000, 0x008fffffffff]` || highshadow || 440GB
+// || `[0x01200000000, 0x0021ffffffff]` || shadowgap  || 64GB
+// || `[0x01000000000, 0x0011ffffffff]` || lowshadow  || 8GB
+// || `[0x00000000000, 0x000fffffffff]` || lowmem     || 64GB
+//
+// Default Linux/AArch64 (48-bit VMA) mapping:
+// || `[0x201000000000, 0xffffffffffff]` || HighMem    || 229312GB
+// || `[0x041200000000, 0x200fffffffff]` || HighShadow || 28664GB
+// || `[0x001200000000, 0x0411ffffffff]` || ShadowGap  || 4096GB
+// || `[0x001000000000, 0x0011ffffffff]` || LowShadow  || 8GB
+// || `[0x000000000000, 0x000fffffffff]` || LowMem     || 64GB
 //
 // Default Linux/S390 mapping:
 // || `[0x30000000, 0x7fffffff]` || HighMem    ||

Copy link
Contributor

@fmayer fmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(*) Thankfully, ASan on AArch64 Android still works with 39-bit and 42-bit VMAs, in the absence of something more robust such as MTE.

Remove this. ASan is deprecated on AArch64 Android in favor of HWASan 1.

@thurstond
Copy link
Contributor Author

(*) Thankfully, ASan on AArch64 Android still works with 39-bit and 42-bit VMAs, in the absence of something more robust such as MTE.

Remove this. ASan is deprecated on AArch64 Android in favor of HWASan 1.

Big Byte Ignore is masking the truth

@thurstond thurstond merged commit 01472d8 into llvm:main Aug 7, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants