From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D33C8A0C43; Fri, 17 Sep 2021 22:50:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A856406B4; Fri, 17 Sep 2021 22:50:59 +0200 (CEST) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by mails.dpdk.org (Postfix) with ESMTP id 7FB2140689 for ; Fri, 17 Sep 2021 22:50:58 +0200 (CEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18HJbG0X029103; Fri, 17 Sep 2021 16:50:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : subject : to : cc : references : message-id : date : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=CeSYyLK+ih0K0k2mIl4j5aXe0D0XbU7Opf5N68iGkYw=; b=Q0O5XkjQ56vEWqs8VE2tfD7VZ8HnaajSlHfwnFWMdTDvE+DHvZK5Dd0UbcNF1zEKjmKL 3Y/sekseLDDZkUajYxePqvukAJp0B1PPKxigJmNEQS/mQXHg8tvO8i7GSFb1tRoXmRl2 +r51rMAcJ832TWVkm18i9ZmukiknmRnRC28+YcQB95IEawLCPrz6Pr3uAlHNAUaTq/q+ QvS3VR+UKFL8McZccT7mJUR0Nw7c0kO8g0L0FGjhLwR0q5SENtOtkZHy1taTA3TnB1lN FRni2dGmaTht3H+4T7vaM0hu97Ujlqp4Z47fdj8mBikzq8qLea13tgxK7CnTfttTmkI9 gA== Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 3b4uxx97hx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Sep 2021 16:50:57 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18HKgGNj012864; Fri, 17 Sep 2021 20:50:56 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma04dal.us.ibm.com with ESMTP id 3b0m3dvawn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Sep 2021 20:50:56 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18HKot8w44433846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Sep 2021 20:50:55 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A82A02805A; Fri, 17 Sep 2021 20:50:55 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00FD228058; Fri, 17 Sep 2021 20:50:54 +0000 (GMT) Received: from Davids-MBP.randomparity.org (unknown [9.211.49.26]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 17 Sep 2021 20:50:54 +0000 (GMT) From: David Christensen To: "Peng, ZhihongX" , "Burakov, Anatoly" , "Ananyev, Konstantin" , "stephen@networkplumber.org" Cc: "dev@dpdk.org" , "Lin, Xueqin" References: <20210910020147.148019-1-zhihongx.peng@intel.com> Message-ID: <61dd38ed-b570-d7d5-e839-1f845e28e932@linux.vnet.ibm.com> Date: Fri, 17 Sep 2021 13:50:54 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-GUID: e9avNhJCILbiwFfTPEwe5aMyCwNmshg8 X-Proofpoint-ORIG-GUID: e9avNhJCILbiwFfTPEwe5aMyCwNmshg8 Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-17_08,2021-09-17_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109170123 Subject: Re: [dpdk-dev] [PATCH] Enable AddressSanitizer feature on DPDK X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" >>> If you want to use this feature, >>> you need to add below compilation options when compiling code: >>> -Dbuildtype=debug -Db_lundef=false -Db_sanitize=address >>> "-Dbuildtype=debug": Display code information when coredump occurs in >>> the program. >>> "-Db_lundef=false": It is enabled by default, and needs to be disabled >>> when using asan. >> >> On initial inspection, it appears ASAN functionality doesn't work with DPDK >> on PPC architecture. I tested the patch with several compiler versions (gcc >> 8.3.1 from RHEL 8.3 through gcc 11.2.1 from the IBM Advanced Toolchain 15.0) >> and observed the following error when running testpmd with ASAN enabled: >> >> AddressSanitizer:DEADLYSIGNAL >> ========================================================== >> ======= >> ==49246==ERROR: AddressSanitizer: SEGV on unknown address >> 0x0000a0077bd0 (pc 0x000010b4eca4 bp 0x7fffffffe150 sp 0x7fffffffe150 T0) >> ==49246==The signal is caused by a UNKNOWN memory access. >> #0 0x10b4eca4 in asan_set_shadow ../lib/eal/common/malloc_elem.h:120 >> #1 0x10b4ed68 in asan_set_zone ../lib/eal/common/malloc_elem.h:135 >> #2 0x10b4ee90 in asan_clear_split_alloczone >> ../lib/eal/common/malloc_elem.h:162 >> #3 0x10b51f84 in malloc_elem_alloc ../lib/eal/common/malloc_elem.c:477 >> ... >> >> Can you incorporate an exception for PPC architecture with this patch while I >> look into the problem further? >> >> Dave > > We do not have a ppc platform, so there is no adaptation. doc/guides/prog_guide/asan.rst > has stated that we currently only support Linux x86_64. You can adapt according to the > following documents, the main work is to modify the base address according to the platform. > Documents: > https://github.com/google/sanitizers/wiki/AddressSanitizer > https://github.com/llvm/llvm-project/tree/main/compiler-rt Understand you don't have such a platform. I looked into it and suggest the following change in lib/eal/common/malloc_elem.h: #define ASAN_SHADOW_GRAIN_SIZE 8 #define ASAN_SHADOW_SCALE 3 #ifdef RTE_ARCH_PPC_64 #define ASAN_SHADOW_OFFSET 0x020000000000 #else #define ASAN_SHADOW_OFFSET 0x00007fff8000 #endif #define ASAN_MEM_FREE_FLAG 0xfd #define ASAN_MEM_REDZONE_FLAG 0xfa #define ASAN_MEM_TO_SHADOW(mem) (((mem) >> ASAN_SHADOW_SCALE) + ASAN_SHADOW_OFFSET) This resolves the segmentation error I receive. Dave P.S. FYI, here's the ASAN mapping I observe on x86 vs. POWER: x86 results: ----------------------------------------------------------------------------------- ASAN_OPTIONS=verbosity=1 ./a.out ==141271==AddressSanitizer: libc interceptors initialized || `[0x1000_7fff_8000, 0x7fff_ffff_ffff]` || HighMem || || `[0x0200_8fff_7000, 0x1000_7fff_7fff]` || HighShadow || || `[0x0000_8fff_7000, 0x0200_8fff_6fff]` || ShadowGap || || `[0x0000_7fff_8000, 0x0000_8fff_6fff]` || LowShadow || || `[0x0000_0000_0000, 0x0000_7fff_7fff]` || LowMem || MemToShadow(shadow): 0x0000_8fff_7000 0x0000_91ff_6dff 0x0040_91ff_6e00 0x0200_8fff_6fff redzone=16 max_redzone=2048 quarantine_size_mb=256M thread_local_quarantine_size_kb=1024K malloc_context_size=30 SHADOW_SCALE: 3 SHADOW_GRANULARITY: 8 SHADOW_OFFSET: 0x7fff_8000 POWER results: ----------------------------------------------------------------------------------- ASAN_OPTIONS=verbosity=1 ./a.out ... ==93284==AddressSanitizer: libc interceptors initialized || `[0x1200_0000_0000, 0x7fff_ffff_ffff]` || HighMem || || `[0x0440_0000_0000, 0x11ff_ffff_ffff]` || HighShadow || || `[0x0240_0000_0000, 0x043f_ffff_ffff]` || ShadowGap || || `[0x0200_0000_0000, 0x023f_ffff_ffff]` || LowShadow || || `[0x0000_0000_0000, 0x01ff_ffff_ffff]` || LowMem || MemToShadow(shadow): 0x0240_0000_0000 0x0247_ffff_ffff 0x0288_0000_0000 0x043f_ffff_ffff redzone=16 max_redzone=2048 quarantine_size_mb=256M thread_local_quarantine_size_kb=1024K malloc_context_size=30 SHADOW_SCALE: 3 SHADOW_GRANULARITY: 8 SHADOW_OFFSET: 0x200_0000_0000