crypto/qat: fix uninitilized compiler warning
PATCH 1/1 crypto/qat: fix uninitilized compiler warning
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, compiler cannot know it is initialized by the function.
To fix this, use "calloc" to initialize "digest".
--- drivers/crypto/qat/qat_sym_session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_sym_session.c +2 -2
@@ -1190,8 +1190,8 @@ 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 = (uint8_t *)calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ),sizeof (uint8_t ));uint32_t *hash_state_out_be32;uint64_t *hash_state_out_be64;int i;
Signature · 1 line
2.25.1
Quoted 31 lines · Feifei Wang
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, compiler cannot know it is initialized by the function.To fix this, use "calloc" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- drivers/crypto/qat/qat_sym_session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/crypto/qat/qat_sym_session.c +0
-0
drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, · line 1194
Quoted 7 lines
drivers/crypto/qat/qat_sym_session.c +2
-2@@ -1190,8 +1190,8 @@ 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 = (uint8_t *)calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ),sizeof (uint8_t ));
calloc can fail.
cast is unneded.
A simple uint8_t digest[...] = { 0 } would do the job.
Quoted 6 lines
drivers/crypto/qat/qat_sym_session.c +0
-1uint32_t *hash_state_out_be32;uint64_t *hash_state_out_be64;int i; --2.25.1
Signature · 1 line
David Marchand
Hi, David
Quoted 56 lines
-----邮件原件-----
发件人: David Marchand <[email protected]>
发送时间: 2021年5月14日 15:50
收件人: Feifei Wang <[email protected]>
抄送: John Griffin <[email protected]>; Fiona Trahe <[email protected]>; Deepak Kumar Jain <[email protected]>; Herbert Guan <[email protected]>; Jerin Jacob <[email protected]>; dev <[email protected]>; nd <[email protected]>; dpdk stable <[email protected]>; Ruifeng Wang <[email protected]>
主题: Re: [dpdk-stable] [PATCH]crypto/qat: fix uninitilized compiler warningQuoted 2 lines · Feifei Wang
In Arm platform, when "
RTE_ARCH_ARM64_MEMCPY" is set as true,compiler
Quoted 3 lines
will report variable uninitilized warning:
../drivers/crypto/qat/qat_sym_session.c: In function‘partial_hash_compute’:
drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum
Quoted 27 lines
../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, compiler cannot know it is initialized by the function.To fix this, use "calloc" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- drivers/crypto/qat/qat_sym_session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/crypto/qat/qat_sym_session.c +0
-0@@ -1190,8 +1190,8 @@ static int partial_hash_compute(enum
icp_qat_hw_auth_algohash_alg,drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg,
Quoted 7 lines
drivers/crypto/qat/qat_sym_session.c +3
-2uint8_t *data_out) {int digest_size; -uint8_t digest[qat_hash_get_digest_size ( -ICP_QAT_HW_AUTH_ALGO_DELIMITER )]; +uint8_t *digest = (uint8_t *)calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ), +sizeof (uint8_t ));
Quoted 4 lines
calloc can fail.
cast is unneded.A simple
uint8_tdigest[...] = { 0 } would do the job.
Thanks for your comment. Actually, we have tried to use this simple method:
uint8_t digest[qat_hash_get_digest_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0};
And it will report compile error:../drivers/crypto/qat/qat_sym_session.c:1194:4: error: variable-sized object may not be initialized
1194 | ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0};
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~../drivers/crypto/qat/qat_sym_session.c:1194:40: warning: excess elements in array initializer
1194 | ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0};
| ^../drivers/crypto/qat/qat_sym_session.c:1194:40: note: (near initialization for ‘digest’)
ninja: build stopped: subcommand failed.
I think this is because compiler cannot know the size of digest due to function 'qat_hash_get_digest_size' during compiling time.
Best Regards
Feifei
Quoted 13 lines
Quoted 8 lines
drivers/crypto/qat/qat_sym_session.c +0
-1uint32_t *hash_state_out_be32;uint64_t *hash_state_out_be64;int i; --2.25.1
--
David Marchand
Quoted 22 lines · Feifei Wang
Quoted 10 lines
Review static int partial_hash_compute(enum
Quoted 1 line
(quoted diff) +0
-0@@ -1190,8 +1190,8 @@ static int partial_hash_compute(enum
icp_qat_hw_auth_algohash_alg,drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg,
Quoted 7 lines
drivers/crypto/qat/qat_sym_session.c +3
-2uint8_t *data_out) {int digest_size; -uint8_t digest[qat_hash_get_digest_size ( -ICP_QAT_HW_AUTH_ALGO_DELIMITER )]; +uint8_t *digest = (uint8_t *)calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ), +sizeof (uint8_t ));Quoted 4 lines
calloc can fail.
cast is unneded.A simple
uint8_tdigest[...] = { 0 } would do the job.Thanks for your comment. Actually, we have tried to use this simple method:
uint8_tdigest[qat_hash_get_digest_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0};And it will report compile error:
../drivers/crypto/qat/qat_sym_session.c:1194:4: error: variable-sized object may not be initialized1194 | ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 8 lines
../drivers/crypto/qat/qat_sym_session.c:1194:40: warning: excess elements in array initializer
1194 |ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0};
| ^../drivers/crypto/qat/qat_sym_session.c:1194:40: note: (near initialization for ‘digest’)
ninja: build stopped: subcommand failed.I think this is because compiler cannot know the size of digest due to function '
qat_hash_get_digest_size' during compiling time.
Ok, I had not noticed the function call.
Please check dynamic allocation succeeds.
+ free this temp buffer before leaving this helper function.
Signature · 1 line
David marchand
Quoted 49 lines
-----邮件原件-----
发件人: David Marchand <[email protected]>
发送时间: 2021年5月14日 16:14
收件人: Feifei Wang <[email protected]>
抄送: John Griffin <[email protected]>; Fiona Trahe <[email protected]>; Deepak Kumar Jain <[email protected]>; Herbert Guan <[email protected]>; Jerin Jacob <[email protected]>; dev <[email protected]>; nd <[email protected]>; dpdk stable <[email protected]>; Ruifeng Wang <[email protected]>
主题: Re: [dpdk-stable] [PATCH]crypto/qat: fix uninitilized compiler warningQuoted 10 lines · Feifei Wang
Quoted 10 lines
Review static int partial_hash_compute(enum
Quoted 1 line
(quoted diff) +0
-0@@ -1190,8 +1190,8 @@ static int partial_hash_compute(enum
icp_qat_hw_auth_algohash_alg,Quoted 7 lines
drivers/crypto/qat/qat_sym_session.c +3
-2uint8_t *data_out) {int digest_size; -uint8_t digest[qat_hash_get_digest_size ( -ICP_QAT_HW_AUTH_ALGO_DELIMITER )]; +uint8_t *digest = (uint8_t *)calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ), +sizeof (uint8_t ));Quoted 6 lines
Quoted 4 lines
calloc can fail.
cast is unneded.A simple
uint8_tdigest[...] = { 0 } would do the job.Thanks for your comment. Actually, we have tried to use this simple
method:
Quoted 2 lines
uint8_t
digest[qat_hash_get_digest_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)]=
Quoted 4 lines
{0};
And it will report compile error:
../drivers/crypto/qat/qat_sym_session.c:1194:4: error: variable-sizedobject may not be initialized
Quoted 3 lines
1194 | ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/crypto/qat/qat_sym_session.c:1194:40: warning: excesselements in array initializer
Quoted 6 lines
1194 |
ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0};
| ^../drivers/crypto/qat/qat_sym_session.c:1194:40: note: (near initialization for ‘digest’)
ninja: build stopped: subcommand failed.
Quoted 7 lines
Quoted 2 lines
I think this is because compiler cannot know the size of digest due to function '
qat_hash_get_digest_size' during compiling time.Ok, I had not noticed the function call.
Please check dynamic allocation succeeds.
+ free this temp buffer before leaving this helper function.
Thanks for this comments, I will add check and free operations for this dynamic allocation in the next version
Best Regards
Feifei
Quoted 4 lines
--
David marchand
PATCH v3 1/1 crypto/qat: fix uninitilized compiler warning
In reply to Feifei WangIn 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, compiler cannot know it is initialized by the function.
To fix this, use "calloc" to initialize "digest".
---
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(-)
drivers/crypto/qat/qat_sym_session.c +18 -9
@@ -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;uint32_t *hash_state_out_be32;uint64_t *hash_state_out_be64;int i;
@@ -1200,55 +1199,65 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg,if (digest_size <=0 )return -EFAULT ; + digest =calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ),sizeof (uint8_t )); +if (!digest) +return -ENOMEM ; + hash_state_out_be32 = (uint32_t *)data_out; hash_state_out_be64 = (uint64_t *)data_out;switch (hash_alg) {case ICP_QAT_HW_AUTH_ALGO_SHA1 :if (partial_hash_sha1 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA224 :if (partial_hash_sha224 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA256 :if (partial_hash_sha256 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA384 :if (partial_hash_sha384 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>3 ; i++, hash_state_out_be64++) *hash_state_out_be64 =rte_bswap64 (*(((uint64_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA512 :if (partial_hash_sha512 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>3 ; i++, hash_state_out_be64++) *hash_state_out_be64 =rte_bswap64 (*(((uint64_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_MD5 :if (partial_hash_md5 (data_in, data_out)) -return -EFAULT ; + goto fail;break ;default :QAT_LOG (ERR ,"invalid hash alg %u" , hash_alg); -return -EFAULT ; + goto fail; } +free (digest);return 0 ; + +fail: +free (digest); +return -EFAULT ; }#define HMAC_IPAD_VALUE 0x36#define HMAC_OPAD_VALUE 0x5c
Signature · 1 line
2.25.1
17/05/2021 11:07, Feifei Wang:
Quoted 17 lines
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, compiler cannot know it is initialized by the function.To fix this, use "calloc" to initialize "digest".
Quoted 8 lines
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler error
I am not confortable applying this patch without PMD maintainers ack.
Quoted 7 lines · Feifei Wang
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
Quoted 6 lines
[-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'?
Quoted 21 lines
compiler cannot know it is initialized by the function.
To fix this, use "calloc" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler errordrivers/crypto/qat/qat_sym_session.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/crypto/qat/qat_sym_session.c +0
-0
drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, · line 1193
Quoted 6 lines
drivers/crypto/qat/qat_sym_session.c +1
-2@@ -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.
Hi, Ferruh
Thanks for your comments.
Please see below.
Quoted 26 lines
-----邮件原件-----
发件人: Ferruh Yigit <[email protected]>
发送时间: 2021年5月19日 16:12
收件人: Feifei Wang <[email protected]>; John Griffin <[email protected]>; Fiona Trahe <[email protected]>; Deepak Kumar Jain <[email protected]>; Jerin Jacob <[email protected]>; Herbert Guan <[email protected]>
抄送: [email protected]; [email protected]; nd <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>
主题: Re: [dpdk-stable] [PATCH v3]crypto/qat: fix uninitilized compiler warningQuoted 1 line · Feifei Wang
In Arm platform, when "
RTE_ARCH_ARM64_MEMCPY" is set as true,compiler
Quoted 10 lines
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) ...
Quoted 5 lines
Quoted 3 lines
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.
Quoted 24 lines
drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum
Quoted 23 lines
compiler cannot know it is initialized by the function.
To fix this, use "calloc" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler errordrivers/crypto/qat/qat_sym_session.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/crypto/qat/qat_sym_session.c +0
-0@@ -1190,8 +1190,7 @@ static int partial_hash_compute(enum
icp_qat_hw_auth_algohash_alg,
Quoted 8 lines
drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, · line 1193
Quoted 6 lines
drivers/crypto/qat/qat_sym_session.c +1
-2uint8_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.
Quoted 44 lines · Feifei Wang
Hi, Ferruh
Thanks for your comments.
Please see below.Quoted 26 lines
-----邮件原件-----
发件人: Ferruh Yigit <[email protected]>
发送时间: 2021年5月19日 16:12
收件人: Feifei Wang <[email protected]>; John Griffin <[email protected]>; Fiona Trahe <[email protected]>; Deepak Kumar Jain <[email protected]>; Jerin Jacob <[email protected]>; Herbert Guan <[email protected]>
抄送: [email protected]; [email protected]; nd <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>
主题: Re: [dpdk-stable] [PATCH v3]crypto/qat: fix uninitilized compiler warningQuoted 1 line · Feifei Wang
In Arm platform, when "
RTE_ARCH_ARM64_MEMCPY" is set as true,compiler
Quoted 10 lines
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) ...Quoted 5 lines
Quoted 3 lines
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_memcpyinpartial_hash_sha_xfunction :
'partial_hash_compute' -> 'partial_hash_sha_x' -> 'rte_memcpy'.If "
RTE_ARCH_ARM64_MEMCPY= false",rte_memcpywill be defined as 'memcpy' to initialize 'digest' in lib\eal\arm\include\rte_memcpy_64.h: 364, and compiler can identify this.
Quoted 7 lines
However, if "
RTE_ARCH_ARM64_MEMCPY= true",rte_memcpywill be a inline function, and finally it will initialize 'digest' with two steps by invokingrte_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.
Quoted 35 lines
Quoted 24 lines
drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum
Quoted 23 lines
compiler cannot know it is initialized by the function.
To fix this, use "calloc" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler errordrivers/crypto/qat/qat_sym_session.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/crypto/qat/qat_sym_session.c +0
-0@@ -1190,8 +1190,7 @@ static int partial_hash_compute(enum
icp_qat_hw_auth_algohash_alg,Quoted 8 lines
drivers/crypto/qat/qat_sym_session.c static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, · line 1193
Quoted 6 lines
drivers/crypto/qat/qat_sym_session.c +1
-2uint8_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.
Hi.
I checked how it works on QAT hardware, and it does no harm. All unit tests still pass. Verified on two QAT-enabled machines.
The question is: should this patch be simplified to just add a call to memset (to zero the digest variable while still keeping it on the stack) at the function begin? And that will be a faster solution in run-time (using the variable on the stack instead of calloc that uses the heap).
Adam
Quoted 134 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Feifei Wang
Sent: Monday, 17 May, 2021 11:07
To: Griffin, John <[email protected]>; Trahe, Fiona <[email protected]>; Jain, Deepak K <[email protected]>; Jerin Jacob <[email protected]>; Herbert Guan <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Feifei Wang <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>
Subject: [dpdk-dev] [PATCH v3]crypto/qat: fix uninitilized compiler warningIn 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, compiler cannot know it is initialized by the function.To fix this, use "calloc" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler errordrivers/crypto/qat/qat_sym_session.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/crypto/qat/qat_sym_session.c +1
-2@@ -1190,8 +1190,7 @@ static int partial_hash_compute(enumicp_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;uint32_t *hash_state_out_be32;uint64_t *hash_state_out_be64;drivers/crypto/qat/qat_sym_session.c +17
-7int i;@@ -1200,55 +1199,65 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, if (digest_size <= 0) return -EFAULT; + digest =calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ),sizeof (uint8_t )); +if (!digest) +return -ENOMEM ; + hash_state_out_be32 = (uint32_t *)data_out; hash_state_out_be64 = (uint64_t *)data_out;switch (hash_alg) {case ICP_QAT_HW_AUTH_ALGO_SHA1 :if (partial_hash_sha1 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA224 :if (partial_hash_sha224 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA256 :if (partial_hash_sha256 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA384 :if (partial_hash_sha384 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>3 ; i++, hash_state_out_be64++) *hash_state_out_be64 =rte_bswap64 (*(((uint64_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA512 :if (partial_hash_sha512 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>3 ; i++, hash_state_out_be64++) *hash_state_out_be64 =rte_bswap64 (*(((uint64_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_MD5 :if (partial_hash_md5 (data_in, data_out)) -return -EFAULT ; + goto fail;break ;default :QAT_LOG (ERR ,"invalid hash alg %u" , hash_alg); -return -EFAULT ; + goto fail; } +free (digest);return 0 ; + +fail: +free (digest); +return -EFAULT ; }#define
HMAC_IPAD_VALUE0x36
#defineHMAC_OPAD_VALUE0x5c
--
2.25.1
Hi.
I checked how it works on QAT hardware, and it does no harm. All unit tests still pass. Verified on two QAT-enabled machines.
The question is: should this patch be simplified to just add a call to memset (to zero the digest variable while still keeping it on the stack) at the function begin? And that will be a faster solution in run-time (using the variable on the stack instead of calloc that uses the heap).
Adam
Quoted 134 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Feifei Wang
Sent: Monday, 17 May, 2021 11:07
To: Griffin, John <[email protected]>; Trahe, Fiona <[email protected]>; Jain, Deepak K <[email protected]>; Jerin Jacob <[email protected]>; Herbert Guan <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Feifei Wang <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>
Subject: [dpdk-dev] [PATCH v3]crypto/qat: fix uninitilized compiler warningIn 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, compiler cannot know it is initialized by the function.To fix this, use "calloc" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler errordrivers/crypto/qat/qat_sym_session.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/crypto/qat/qat_sym_session.c +1
-2@@ -1190,8 +1190,7 @@ static int partial_hash_compute(enumicp_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;uint32_t *hash_state_out_be32;uint64_t *hash_state_out_be64;drivers/crypto/qat/qat_sym_session.c +17
-7int i;@@ -1200,55 +1199,65 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, if (digest_size <= 0) return -EFAULT; + digest =calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ),sizeof (uint8_t )); +if (!digest) +return -ENOMEM ; + hash_state_out_be32 = (uint32_t *)data_out; hash_state_out_be64 = (uint64_t *)data_out;switch (hash_alg) {case ICP_QAT_HW_AUTH_ALGO_SHA1 :if (partial_hash_sha1 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA224 :if (partial_hash_sha224 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA256 :if (partial_hash_sha256 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA384 :if (partial_hash_sha384 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>3 ; i++, hash_state_out_be64++) *hash_state_out_be64 =rte_bswap64 (*(((uint64_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA512 :if (partial_hash_sha512 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>3 ; i++, hash_state_out_be64++) *hash_state_out_be64 =rte_bswap64 (*(((uint64_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_MD5 :if (partial_hash_md5 (data_in, data_out)) -return -EFAULT ; + goto fail;break ;default :QAT_LOG (ERR ,"invalid hash alg %u" , hash_alg); -return -EFAULT ; + goto fail; } +free (digest);return 0 ; + +fail: +free (digest); +return -EFAULT ; }#define
HMAC_IPAD_VALUE0x36
#defineHMAC_OPAD_VALUE0x5c
--
2.25.1
Hi,
Quoted 12 lines
-----邮件原件-----
发件人: Dybkowski, AdamX <[email protected]>
发送时间: 2021年5月19日 21:17
收件人: Feifei Wang <[email protected]>; Griffin, John <[email protected]>; Trahe, Fiona <[email protected]>; Jain, Deepak K <[email protected]>; Jerin Jacob <[email protected]>; Herbert Guan <[email protected]>
抄送: [email protected]; [email protected]; nd <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>
主题: RE: [dpdk-dev] [PATCH v3]crypto/qat: fix uninitilized compiler warning
Quoted 5 lines
Hi.
I checked how it works on QAT hardware, and it does no harm. All unit tests still pass.
Verified on two QAT-enabled machines.
Thanks very much for your testing.
Quoted 6 lines
The question is: should this patch be simplified to just add a call to memset (to zero the digest variable while still keeping it on the stack) at the function begin? And that will be a faster solution in run-time (using the variable on the stack instead of calloc that uses the heap).
A good comment for this. I try to apply it and it also can solve the warning. And actually maybe memset is more faster.
I will update this in the next version.
Best Regards
Feifei
Quoted 139 lines
Adam
Quoted 8 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Feifei Wang
Sent: Monday, 17 May, 2021 11:07
To: Griffin, John <[email protected]>; Trahe, Fiona <[email protected]>; Jain, Deepak K <[email protected]>; Jerin Jacob <[email protected]>; Herbert Guan <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; FeifeiWang
Quoted 6 lines
<[email protected]>; [email protected]; Ruifeng Wang <[email protected]>
Subject: [dpdk-dev] [PATCH v3]crypto/qat: fix uninitilized compiler warningIn Arm platform, when "
RTE_ARCH_ARM64_MEMCPY" is set as true,compiler
Quoted 121 lines
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, compiler cannot know it is initialized by the function.To fix this, use "calloc" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler errordrivers/crypto/qat/qat_sym_session.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/crypto/qat/qat_sym_session.c +1
-2@@ -1190,8 +1190,7 @@ static int partial_hash_compute(enumicp_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;uint32_t *hash_state_out_be32;uint64_t *hash_state_out_be64;drivers/crypto/qat/qat_sym_session.c +17
-7int i;@@ -1200,55 +1199,65 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg, if (digest_size <= 0) return -EFAULT; + digest =calloc (qat_hash_get_digest_size ( +ICP_QAT_HW_AUTH_ALGO_DELIMITER ),sizeof (uint8_t )); +if (!digest) +return -ENOMEM ; + hash_state_out_be32 = (uint32_t *)data_out; hash_state_out_be64 = (uint64_t *)data_out;switch (hash_alg) {case ICP_QAT_HW_AUTH_ALGO_SHA1 :if (partial_hash_sha1 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA224 :if (partial_hash_sha224 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA256 :if (partial_hash_sha256 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>2 ; i++, hash_state_out_be32++) *hash_state_out_be32 =rte_bswap32 (*(((uint32_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA384 :if (partial_hash_sha384 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>3 ; i++, hash_state_out_be64++) *hash_state_out_be64 =rte_bswap64 (*(((uint64_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_SHA512 :if (partial_hash_sha512 (data_in, digest)) -return -EFAULT ; + goto fail;for (i =0 ; i < digest_size >>3 ; i++, hash_state_out_be64++) *hash_state_out_be64 =rte_bswap64 (*(((uint64_t *)digest)+i));break ;case ICP_QAT_HW_AUTH_ALGO_MD5 :if (partial_hash_md5 (data_in, data_out)) -return -EFAULT ; + goto fail;break ;default :QAT_LOG (ERR ,"invalid hash alg %u" , hash_alg); -return -EFAULT ; + goto fail; } +free (digest);return 0 ; + +fail: +free (digest); +return -EFAULT ; }#define
HMAC_IPAD_VALUE0x36
#defineHMAC_OPAD_VALUE0x5c
--
2.25.1
PATCH v4 1/1 crypto/qat: fix uninitilized gcc compiler warning
In reply to Feifei WangIn Arm platform, when "RTE_ARCH_ARM64_MEMCPY" is set as true, gcc 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. Furthermore, 'rte_memcpy' will initialize 'digest' with two steps by invoking rte_mov_x functions. For example:
partial_hash_sha1 -> rte_memcpy -> rte_memcpy_ge16_lt_128 -> step 1: rte_mov16(dst,src )
step 2: rte_mov16(dst - 16 + n, src - 16 + n)
However, gcc compiler cannot identify this multi-step initialization, then it will report warning.
To fix this, use "memset" to initialize "digest".
---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler error
v4: use 'memset' to initialize digest (Ferruh, Adam)
drivers/crypto/qat/qat_sym_session.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/qat/qat_sym_session.c +3 -0
@@ -1196,6 +1196,9 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg,uint64_t *hash_state_out_be64;int i; +/* Initialize to avoid gcc warning */ +memset (digest,0 ,sizeof (digest)); + digest_size =qat_hash_get_digest_size (hash_alg);if (digest_size <=0 )return -EFAULT ;
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v4] crypto/qat: fix uninitilized gcc compiler warning
Quoted 35 lines
-----Original Message-----
From: Feifei Wang <[email protected]>
Sent: Thursday, 20 May, 2021 10:44
To: Griffin, John <[email protected]>; Trahe, Fiona <[email protected]>; Jain, Deepak K <[email protected]>; Herbert Guan <[email protected]>; Jerin Jacob <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Dybkowski, AdamX <[email protected]>; [email protected]; Feifei Wang <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>
Subject: [PATCH v4]crypto/qat: fix uninitilized gcc compiler warningIn Arm platform, when "
RTE_ARCH_ARM64_MEMCPY" is set as true, gcc 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. Furthermore, 'rte_memcpy' will initialize 'digest' with two steps by invokingrte_mov_xfunctions. For example:
partial_hash_sha1->rte_memcpy->rte_memcpy_ge16_lt_128-> step 1:rte_mov16(dst,src )step 2:rte_mov16(dst - 16 + n, src - 16 + n)However, gcc compiler cannot identify this multi-step initialization, then it will report warning.
Quoted 8 lines
To fix this, use "memset" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
PATCH v5 1/1 crypto/qat: fix uninitialized gcc compiler warning
In reply to Feifei WangIn Arm platform, when "RTE_ARCH_ARM64_MEMCPY" is set as true, gcc will report variable uninitialized 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. Furthermore, 'rte_memcpy' will initialize 'digest' with two steps by invoking rte_mov_x functions. For example:
partial_hash_sha1 -> rte_memcpy -> rte_memcpy_ge16_lt_128 -> step 1: rte_mov16(dst,src )
step 2: rte_mov16(dst - 16 + n, src - 16 + n)
However, gcc compiler cannot identify this multi-step initialization, then it will report warning.
To fix this, use "memset" to initialize "digest".
---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler error
v4: use 'memset' to initialize digest (Ferruh, Adam)
v5: fixed spelling errors in commit message (Honnappa)
drivers/crypto/qat/qat_sym_session.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/qat/qat_sym_session.c +3 -0
@@ -1196,6 +1196,9 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg,uint64_t *hash_state_out_be64;int i; +/* Initialize to avoid gcc warning */ +memset (digest,0 ,sizeof (digest)); + digest_size =qat_hash_get_digest_size (hash_alg);if (digest_size <=0 )return -EFAULT ;
Signature · 1 line
2.25.1
Akhil Goyal
AppliedRe: [dpdk-dev] [EXT] [PATCH v5] crypto/qat: fix uninitialized gcc compiler warning
Quoted 32 lines
In Arm platform, when "
RTE_ARCH_ARM64_MEMCPY" is set as true, gcc will report variable uninitialized 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. Furthermore, 'rte_memcpy' will initialize 'digest' with two steps by invokingrte_mov_xfunctions. For example:
partial_hash_sha1->rte_memcpy->rte_memcpy_ge16_lt_128-> step 1:rte_mov16(dst,src )
step 2:rte_mov16(dst - 16 + n, src - 16 + n)However, gcc compiler cannot identify this multi-step initialization, then it will report warning.
To fix this, use "memset" to initialize "digest".
Fixes cd7fc8a84b48 ("eal/arm64: optimize memcpy")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>Acked-by Adam Dybkowski <[email protected]>
Quoted 6 lines
---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler error
v4: use 'memset' to initialize digest (Ferruh, Adam)
v5: fixed spelling errors in commit message (Honnappa)
Applied to dpdk-next-crypto
Thanks.