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 CEA64A0A0C for ; Thu, 20 May 2021 10:09:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C34D541100; Thu, 20 May 2021 10:09:00 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 3385C40041; Thu, 20 May 2021 10:08:57 +0200 (CEST) IronPort-SDR: EA9Dy93gAKxR+YBnYPbPOtQNQfggjjEsPS8QN9Q5sieMlBbfkZfsx4HJCU2TiKINHUvXQ4E1+Q ijiB/LUFLF+g== X-IronPort-AV: E=McAfee;i="6200,9189,9989"; a="188577132" X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="188577132" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2021 01:08:55 -0700 IronPort-SDR: eNUWheVgAxvwRtUkF4AnVPUDLGm1flR9D+OVC9sDlWoTVlVgbPVsr63k5/WVwgNpVQHmghkLdU yRrdLe/mVX0g== X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="412090767" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.241.8]) ([10.213.241.8]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2021 01:08:53 -0700 To: Feifei Wang , John Griffin , Fiona Trahe , Deepak Kumar Jain , Jerin Jacob , Herbert Guan Cc: "dev@dpdk.org" , "david.marchand@redhat.com" , nd , "stable@dpdk.org" , Ruifeng Wang References: <20210514074113.2666225-1-feifei.wang2@arm.com> <20210517090709.4078-1-feifei.wang2@arm.com> From: Ferruh Yigit X-User: ferruhy Message-ID: Date: Thu, 20 May 2021 09:08:48 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-stable] =?utf-8?b?5Zue5aSNOiAgW1BBVENIIHYzXSBjcnlwdG8vcWF0?= =?utf-8?q?=3A_fix_uninitilized_compiler_warning?= X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On 5/20/2021 6:44 AM, Feifei Wang wrote: > Hi, Ferruh > > Thanks for your comments. > Please see below. > >> -----邮件原件----- >> 发件人: Ferruh Yigit >> 发送时间: 2021年5月19日 16:12 >> 收件人: Feifei Wang ; John Griffin >> ; Fiona Trahe ; Deepak >> Kumar Jain ; Jerin Jacob >> ; Herbert Guan >> >> 抄送: dev@dpdk.org; david.marchand@redhat.com; nd ; >> stable@dpdk.org; Ruifeng Wang >> 主题: Re: [dpdk-stable] [PATCH v3] crypto/qat: fix uninitilized compiler >> warning >> >> On 5/17/2021 10:07 AM, Feifei Wang wrote: >>> In Arm platform, when "RTE_ARCH_ARM64_MEMCPY" is set as true, >> compiler >>> will report variable uninitilized warning: >>> >>> ../drivers/crypto/qat/qat_sym_session.c: >>> In function ‘partial_hash_compute’: >>> ../lib/eal/include/generic/rte_byteorder.h:241:24: warning: >>> ‘’ may be used uninitialized in this function >>> [-Wmaybe-uninitialized] >>> 241 | #define rte_bswap32(x) __builtin_bswap32(x) >>> ... >>> >>> This is because "digest" will be initialized by "rte_memcpy" function >>> rather than "memcpy" if "RTE_ARCH_ARM64_MEMCPY" is set as true. >>> However, >> >> How 'digest' is initialized by 'rte_memcpy'? > > Firstly, 'digest' is initialized by rte_memcpy in partial_hash_sha_x function : > 'partial_hash_compute' -> 'partial_hash_sha_x' -> 'rte_memcpy'. > > If "RTE_ARCH_ARM64_MEMCPY = false", rte_memcpy will be defined as > 'memcpy' to initialize 'digest' in lib\eal\arm\include\rte_memcpy_64.h: 364, > and compiler can identify this. > > However, if "RTE_ARCH_ARM64_MEMCPY = true", rte_memcpy will be a inline > function, and finally it will initialize 'digest' with two steps by invoking rte_mov16: > rte_memcpy -> rte_memcpy_ge16_lt_128 -> > step 1: rte_mov16(dst,src ) > step 2: rte_mov16(dst - 16 + n, src - 16 + n) > And the compiler cannot identify this multi-step initialization, then it will report warning. > OK, I got what you mean, thanks for clarification. >> >>> compiler cannot know it is initialized by the function. >>> >>> To fix this, use "calloc" to initialize "digest". >>> >>> Fixes: cd7fc8a84b48 ("eal/arm64: optimize memcpy") >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Feifei Wang >>> Reviewed-by: Ruifeng Wang >>> --- >>> v2: add check and free for memory dynamic allocation (David Marchand) >>> v3: fix compiler error >>> >>> drivers/crypto/qat/qat_sym_session.c | 27 ++++++++++++++++++--------- >>> 1 file changed, 18 insertions(+), 9 deletions(-) >>> >>> diff --git a/drivers/crypto/qat/qat_sym_session.c >>> b/drivers/crypto/qat/qat_sym_session.c >>> index 231b1640da..105a10957a 100644 >>> --- a/drivers/crypto/qat/qat_sym_session.c >>> +++ b/drivers/crypto/qat/qat_sym_session.c >>> @@ -1190,8 +1190,7 @@ static int partial_hash_compute(enum >> icp_qat_hw_auth_algo hash_alg, >>> uint8_t *data_out) >>> { >>> int digest_size; >>> - uint8_t digest[qat_hash_get_digest_size( >>> - ICP_QAT_HW_AUTH_ALGO_DELIMITER)]; >>> + uint8_t *digest; >> >> Will a memset 'digest' work too? Although not sure which one is better. > Thanks for your meaningful comments, I try to use memset and it is ok to solve this warning. > I will update this in the next version. >