[compiler-rt] r245596 - [asan] Enable ASan for AArch64/42-bit VMA
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 13:00:51 PDT 2015
Hi Adhemerval
This is breaking our internal Darwin based bots. I believe the reason is that this code has no else case, so we never set the variable. There’s code elsewhere that checks for linux. I wonder if there needs to be ‘elif not linux’ on the end here to support Darwin and other architectures?
> +# if SANITIZER_AARCH64_VMA == 39
> +# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 39)
> +# elif SANITIZER_AARCH64_VMA == 42
> +# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 42)
> +# endif
Could you please take a look.
Thanks,
Pete
> On Aug 20, 2015, at 11:49 AM, Adhemerval Zanella via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
> Author: azanella
> Date: Thu Aug 20 13:49:40 2015
> New Revision: 245596
>
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D245596-26view-3Drev&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=03tkj3107244TlY4t3_hEgkDY-UG6gKwwK0wOUS3qjM&m=U-R26yIkN5hBsJZ9vRqk2zyr33b80Gb2UZn--6GRzVQ&s=g8xtnutUzMEH9Wp5wO3VG8fNl7T8d2RhntxZHo9o7j4&e=
> Log:
> [asan] Enable ASan for AArch64/42-bit VMA
>
> This patch adds support for asan on aarch64-linux with 42-bit VMA
> (current default config for 64K pagesize kernels). The support is
> enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time
> for both clang/llvm and compiler-rt. The default VMA is 39 bits.
>
> For 42-bit VMA aarch64 uses SANITIZIER_CAN_USER_ALLOCATOR64.
>
> Modified:
> compiler-rt/trunk/lib/asan/asan_allocator.h
> compiler-rt/trunk/lib/asan/asan_mapping.h
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h
>
> Modified: compiler-rt/trunk/lib/asan/asan_allocator.h
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_compiler-2Drt_trunk_lib_asan_asan-5Fallocator.h-3Frev-3D245596-26r1-3D245595-26r2-3D245596-26view-3Ddiff&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=03tkj3107244TlY4t3_hEgkDY-UG6gKwwK0wOUS3qjM&m=U-R26yIkN5hBsJZ9vRqk2zyr33b80Gb2UZn--6GRzVQ&s=Qx2CNrB3Ys8PUxiPD_1z2nqeEtC85YpAJGnrFjgJm-g&e=
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_allocator.h (original)
> +++ compiler-rt/trunk/lib/asan/asan_allocator.h Thu Aug 20 13:49:40 2015
> @@ -114,6 +114,11 @@ struct AsanMapUnmapCallback {
> # if defined(__powerpc64__)
> const uptr kAllocatorSpace = 0xa0000000000ULL;
> const uptr kAllocatorSize = 0x20000000000ULL; // 2T.
> +# elif defined(__aarch64__)
> +// AArch64/SANITIZIER_CAN_USER_ALLOCATOR64 is only for 42-bit VMA
> +// so no need to different values for different VMA.
> +const uptr kAllocatorSpace = 0x10000000000ULL;
> +const uptr kAllocatorSize = 0x10000000000ULL; // 3T.
> # else
> const uptr kAllocatorSpace = 0x600000000000ULL;
> const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
>
> Modified: compiler-rt/trunk/lib/asan/asan_mapping.h
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_compiler-2Drt_trunk_lib_asan_asan-5Fmapping.h-3Frev-3D245596-26r1-3D245595-26r2-3D245596-26view-3Ddiff&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=03tkj3107244TlY4t3_hEgkDY-UG6gKwwK0wOUS3qjM&m=U-R26yIkN5hBsJZ9vRqk2zyr33b80Gb2UZn--6GRzVQ&s=K8ztCmHXS4eOUpHVXr8erRVLCycd9F9uPxn-eeooMGw&e=
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_mapping.h (original)
> +++ compiler-rt/trunk/lib/asan/asan_mapping.h Thu Aug 20 13:49:40 2015
> @@ -80,6 +80,13 @@
> // || `[0x1000000000, 0x11ffffffff]` || lowshadow ||
> // || `[0x0000000000, 0x0fffffffff]` || lowmem ||
> //
> +// Default Linux/AArch64 (42-bit VMA) mapping:
> +// || `[0x10000000000, 0x3ffffffffff]` || highmem ||
> +// || `[0x0a000000000, 0x0ffffffffff]` || highshadow ||
> +// || `[0x09000000000, 0x09fffffffff]` || shadowgap ||
> +// || `[0x08000000000, 0x08fffffffff]` || lowshadow ||
> +// || `[0x00000000000, 0x07fffffffff]` || lowmem ||
> +//
> // Shadow mapping on FreeBSD/x86-64 with SHADOW_OFFSET == 0x400000000000:
> // || `[0x500000000000, 0x7fffffffffff]` || HighMem ||
> // || `[0x4a0000000000, 0x4fffffffffff]` || HighShadow ||
> @@ -111,7 +118,11 @@ static const u64 kIosShadowOffset32 = 1U
> static const u64 kIosShadowOffset64 = 0x130000000;
> static const u64 kIosSimShadowOffset32 = 1ULL << 30;
> static const u64 kIosSimShadowOffset64 = kDefaultShadowOffset64;
> +#if SANITIZER_AARCH64_VMA == 39
> static const u64 kAArch64_ShadowOffset64 = 1ULL << 36;
> +#elif SANITIZER_AARCH64_VMA == 42
> +static const u64 kAArch64_ShadowOffset64 = 1ULL << 39;
> +#endif
> static const u64 kMIPS32_ShadowOffset32 = 0x0aaa0000;
> static const u64 kMIPS64_ShadowOffset64 = 1ULL << 37;
> static const u64 kPPC64_ShadowOffset64 = 1ULL << 41;
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_compiler-2Drt_trunk_lib_sanitizer-5Fcommon_sanitizer-5Fplatform.h-3Frev-3D245596-26r1-3D245595-26r2-3D245596-26view-3Ddiff&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=03tkj3107244TlY4t3_hEgkDY-UG6gKwwK0wOUS3qjM&m=U-R26yIkN5hBsJZ9vRqk2zyr33b80Gb2UZn--6GRzVQ&s=F21vMdVabqE2g-CXCwpcE9Z3jTogjnEM_fnYI_x1rtE&e=
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h Thu Aug 20 13:49:40 2015
> @@ -81,13 +81,24 @@
> # define SANITIZER_X32 0
> #endif
>
> +// VMA size definition for architecture that support multiple sizes.
> +// AArch64 has 3 VMA sizes: 39, 42 and 48.
> +#if SANITIZER_LINUX && defined(__aarch64__)
> +# if SANITIZER_AARCH64_VMA != 39 && SANITIZER_AARCH64_VMA != 42
> +# error "invalid SANITIZER_AARCH64_VMA size"
> +# endif
> +# ifndef SANITIZER_AARCH64_VMA
> +# define SANITIZER_AARCH64_VMA 39
> +# endif
> +#endif
> +
> // By default we allow to use SizeClassAllocator64 on 64-bit platform.
> // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
> // does not work well and we need to fallback to SizeClassAllocator32.
> // For such platforms build this code with -DSANITIZER_CAN_USE_ALLOCATOR64=0 or
> // change the definition of SANITIZER_CAN_USE_ALLOCATOR64 here.
> #ifndef SANITIZER_CAN_USE_ALLOCATOR64
> -# if defined(__aarch64__) || defined(__mips64)
> +# if defined(__mips64) || (defined(__aarch64__) && SANITIZER_AARCH64_VMA == 39)
> # define SANITIZER_CAN_USE_ALLOCATOR64 0
> # else
> # define SANITIZER_CAN_USE_ALLOCATOR64 (SANITIZER_WORDSIZE == 64)
> @@ -99,7 +110,11 @@
> // e.g. on AArch64 it is most likely (1ULL << 39). Larger values will still work
> // but will consume more memory for TwoLevelByteMap.
> #if defined(__aarch64__)
> -# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 39)
> +# if SANITIZER_AARCH64_VMA == 39
> +# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 39)
> +# elif SANITIZER_AARCH64_VMA == 42
> +# define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 42)
> +# endif
> #elif defined(__mips__)
> # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 40)
> #else
> @@ -130,7 +145,7 @@
> #define SANITIZER_USES_UID16_SYSCALLS 0
> #endif
>
> -#if defined(__mips__) || defined(__aarch64__)
> +#if defined(__mips__) || (defined(__aarch64__) && SANITIZER_AARCH64_VMA == 39)
> # define SANITIZER_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 10)
> #else
> # define SANITIZER_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 12)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=03tkj3107244TlY4t3_hEgkDY-UG6gKwwK0wOUS3qjM&m=U-R26yIkN5hBsJZ9vRqk2zyr33b80Gb2UZn--6GRzVQ&s=SbxBNRLXpWfoRt2H9gGy7vzUpDbOtR8FLPBDrBiEY54&e=
More information about the llvm-commits
mailing list