patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Feifei Wang <Feifei.Wang2@arm.com>,
	John Griffin <john.griffin@intel.com>,
	Fiona Trahe <fiona.trahe@intel.com>,
	Deepak Kumar Jain <deepak.k.jain@intel.com>,
	Jerin Jacob <jerin.jacob@caviumnetworks.com>,
	Herbert Guan <Herbert.Guan@arm.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>,
	nd <nd@arm.com>, "stable@dpdk.org" <stable@dpdk.org>,
	Ruifeng Wang <Ruifeng.Wang@arm.com>
Subject: Re: [dpdk-stable]  回复:  [PATCH v3] crypto/qat: fix uninitilized compiler warning
Date: Thu, 20 May 2021 09:08:48 +0100	[thread overview]
Message-ID: <aaf635f8-062c-3e4f-ae98-7bd135628472@intel.com> (raw)
In-Reply-To: <DB9PR08MB692398F05DE01FD707DEAF78C82A9@DB9PR08MB6923.eurprd08.prod.outlook.com>

On 5/20/2021 6:44 AM, Feifei Wang wrote:
> Hi, Ferruh
> 
> Thanks for your comments.
> Please see below.
> 
>> -----邮件原件-----
>> 发件人: Ferruh Yigit <ferruh.yigit@intel.com>
>> 发送时间: 2021年5月19日 16:12
>> 收件人: Feifei Wang <Feifei.Wang2@arm.com>; John Griffin
>> <john.griffin@intel.com>; Fiona Trahe <fiona.trahe@intel.com>; Deepak
>> Kumar Jain <deepak.k.jain@intel.com>; Jerin Jacob
>> <jerin.jacob@caviumnetworks.com>; Herbert Guan
>> <Herbert.Guan@arm.com>
>> 抄送: dev@dpdk.org; david.marchand@redhat.com; nd <nd@arm.com>;
>> stable@dpdk.org; Ruifeng Wang <Ruifeng.Wang@arm.com>
>> 主题: 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:
>>> ‘<U35a0>’ 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 <feifei.wang2@arm.com>
>>> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
>>> ---
>>> 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. 
> 


  reply	other threads:[~2021-05-20  8:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  7:41 [dpdk-stable] [PATCH] " Feifei Wang
2021-05-14  7:49 ` David Marchand
2021-05-14  8:01   ` [dpdk-stable] 回复: " Feifei Wang
2021-05-14  8:13     ` [dpdk-stable] " David Marchand
2021-05-14  8:30       ` [dpdk-stable] 回复: " Feifei Wang
2021-05-17  9:07 ` [dpdk-stable] [PATCH v3] " Feifei Wang
2021-05-19  7:56   ` Thomas Monjalon
2021-05-19  8:11   ` Ferruh Yigit
2021-05-20  5:44     ` [dpdk-stable] 回复: " Feifei Wang
2021-05-20  8:08       ` Ferruh Yigit [this message]
2021-05-19 13:13   ` [dpdk-stable] [dpdk-dev] " Dybkowski, AdamX
2021-05-19 13:16   ` Dybkowski, AdamX
2021-05-20  5:47     ` [dpdk-stable] 回复: " Feifei Wang
2021-05-20  8:43 ` [dpdk-stable] [PATCH v4] crypto/qat: fix uninitilized gcc " Feifei Wang
2021-05-20  9:06   ` Dybkowski, AdamX
2021-05-21  2:00 ` [dpdk-stable] [PATCH v5] crypto/qat: fix uninitialized " Feifei Wang
2021-06-29 20:04   ` [dpdk-stable] [EXT] [dpdk-dev] " Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aaf635f8-062c-3e4f-ae98-7bd135628472@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=Feifei.Wang2@arm.com \
    --cc=Herbert.Guan@arm.com \
    --cc=Ruifeng.Wang@arm.com \
    --cc=david.marchand@redhat.com \
    --cc=deepak.k.jain@intel.com \
    --cc=dev@dpdk.org \
    --cc=fiona.trahe@intel.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=john.griffin@intel.com \
    --cc=nd@arm.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).