[v3] eal/arm64: support ASan

Message ID 20211109095952.762109-1-vfialko@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v3] eal/arm64: support ASan |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-spell-check-testing warning Testing issues
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues

Commit Message

Volodymyr Fialko Nov. 9, 2021, 9:59 a.m. UTC
This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
documentation. This offset should cover all arm64 VMAs supported by
ASan.

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
Changes since v2:
- added a comment that describes origin of the ASan shadow offset

Changes since v1:
- changed the subject
- rewrite checks in "elif" manner
---
 config/meson.build             | 2 +-
 doc/guides/prog_guide/asan.rst | 2 +-
 lib/eal/common/malloc_elem.h   | 6 ++++++
 3 files changed, 8 insertions(+), 2 deletions(-)
  

Comments

David Marchand Nov. 12, 2021, 1:34 p.m. UTC | #1
On Tue, Nov 9, 2021 at 11:00 AM Volodymyr Fialko <vfialko@marvell.com> wrote:
>
> This patch defines ASAN_SHADOW_OFFSET for arm64 according to the ASan
> documentation. This offset should cover all arm64 VMAs supported by
> ASan.
>
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> Acked-by: Jerin Jacob <jerinj@marvell.com>
> Acked-by: Ruifeng Wang <ruifeng.wang@arm.com>

Applied, thanks.
  

Patch

diff --git a/config/meson.build b/config/meson.build
index 17b5bec406..7eb710c08d 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -428,7 +428,7 @@  if get_option('b_sanitize') == 'address' or get_option('b_sanitize') == 'address
         dpdk_extra_ldflags += '-lasan'
     endif
 
-    if is_linux and arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_64')
+    if is_linux and arch_subdir in ['x86', 'arm'] and dpdk_conf.get('RTE_ARCH_64')
         dpdk_conf.set10('RTE_MALLOC_ASAN', true)
     endif
 endif
diff --git a/doc/guides/prog_guide/asan.rst b/doc/guides/prog_guide/asan.rst
index 6d1b871c93..28b2382fc7 100644
--- a/doc/guides/prog_guide/asan.rst
+++ b/doc/guides/prog_guide/asan.rst
@@ -33,7 +33,7 @@  Example::
     "stty echo" command when an error occurs.
 
 ASan is aware of DPDK memory allocations, thanks to added instrumentation.
-This is only enabled on x86_64 at the moment.
+This is enabled on x86_64 and arm64 at the moment.
 Other architectures may have to define ASAN_SHADOW_OFFSET.
 
 Example heap-buffer-overflow error
diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h
index 262d69bb3e..de14d22a62 100644
--- a/lib/eal/common/malloc_elem.h
+++ b/lib/eal/common/malloc_elem.h
@@ -104,8 +104,14 @@  malloc_elem_cookies_ok(const struct malloc_elem *elem)
 
 #ifdef RTE_MALLOC_ASAN
 
+/*
+ * ASAN_SHADOW_OFFSET should match to the corresponding
+ * value defined in gcc/libsanitizer/asan/asan_mapping.h
+ */
 #ifdef RTE_ARCH_X86_64
 #define ASAN_SHADOW_OFFSET    0x00007fff8000
+#elif defined(RTE_ARCH_ARM64)
+#define ASAN_SHADOW_OFFSET    0x001000000000
 #endif
 
 #define ASAN_SHADOW_GRAIN_SIZE	8