[3/3] crypto/qat: compilation fix for GCC-12

Message ID 20220804134055.1816993-3-amitprakashs@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series [1/3] test/test_ipsec: compilation fix for GCC-12 |

Checks

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

Commit Message

Amit Prakash Shukla Aug. 4, 2022, 1:40 p.m. UTC
  GCC 12 raises the following warning:

                 from ../lib/eal/x86/include/rte_vect.h:31,
                 from ../lib/eal/x86/include/rte_memcpy.h:17,
                 from ../drivers/crypto/qat/qat_sym_session.c:10:
In function '_mm_storeu_si128',
    inlined from 'rte_mov16' at
	../lib/eal/x86/include/rte_memcpy.h:508:2,
    inlined from 'rte_mov128' at
	../lib/eal/x86/include/rte_memcpy.h:542:2,
    inlined from 'rte_memcpy_generic' at
	../lib/eal/x86/include/rte_memcpy.h:732:4,
    inlined from 'rte_memcpy' at
	../lib/eal/x86/include/rte_memcpy.h:882:10,
    inlined from 'qat_sym_do_precomputes.constprop' at
	../drivers/crypto/qat/qat_sym_session.c:1434:2:
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/emmintrin.h:739:8: error:
	array subscript 8 is outside array bounds of 'unsigned char[128]'
	[-Werror=array-bounds]
  739 |   *__P = __B;
      |   ~~~~~^~~~~

../drivers/crypto/qat/qat_sym_session.c:
	In function 'qat_sym_do_precomputes.constprop':
../drivers/crypto/qat/qat_sym_session.c:1305:17: note:
	at offset 192 into object 'opad.750' of size 128
 1305 | uint8_t
	  opad[qat_hash_get_block_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)];
      |           ^~~~

../drivers/crypto/qat/qat_sym_session.c:
	In function 'qat_sym_do_precomputes.constprop':
../drivers/crypto/qat/qat_sym_session.c:1304:17: note:
	at offset 128 into object 'ipad.749' of size 128
 1304 | uint8_t
	  ipad[qat_hash_get_block_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)];
      |           ^~~~

Added a check to prevent compiler warnings.

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
 drivers/crypto/qat/qat_sym_session.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Fan Zhang Aug. 5, 2022, 8:12 a.m. UTC | #1
> -----Original Message-----
> From: Amit Prakash Shukla <amitprakashs@marvell.com>
> Sent: Thursday, August 4, 2022 2:41 PM
> To: Zhang, Roy Fan <roy.fan.zhang@intel.com>
> Cc: dev@dpdk.org; jerinj@marvell.com; Amit Prakash Shukla
> <amitprakashs@marvell.com>
> Subject: [PATCH 3/3] crypto/qat: compilation fix for GCC-12
> 
> GCC 12 raises the following warning:
> 
>                  from ../lib/eal/x86/include/rte_vect.h:31,
>                  from ../lib/eal/x86/include/rte_memcpy.h:17,
>                  from ../drivers/crypto/qat/qat_sym_session.c:10:
> In function '_mm_storeu_si128',
>     inlined from 'rte_mov16' at
> 	../lib/eal/x86/include/rte_memcpy.h:508:2,
>     inlined from 'rte_mov128' at
> 	../lib/eal/x86/include/rte_memcpy.h:542:2,
>     inlined from 'rte_memcpy_generic' at
> 	../lib/eal/x86/include/rte_memcpy.h:732:4,
>     inlined from 'rte_memcpy' at
> 	../lib/eal/x86/include/rte_memcpy.h:882:10,
>     inlined from 'qat_sym_do_precomputes.constprop' at
> 	../drivers/crypto/qat/qat_sym_session.c:1434:2:
> /usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/include/emmintrin.h:739:8: error:
> 	array subscript 8 is outside array bounds of 'unsigned char[128]'
> 	[-Werror=array-bounds]
>   739 |   *__P = __B;
>       |   ~~~~~^~~~~
> 
> ../drivers/crypto/qat/qat_sym_session.c:
> 	In function 'qat_sym_do_precomputes.constprop':
> ../drivers/crypto/qat/qat_sym_session.c:1305:17: note:
> 	at offset 192 into object 'opad.750' of size 128
>  1305 | uint8_t
> 
> opad[qat_hash_get_block_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)];
>       |           ^~~~
> 
> ../drivers/crypto/qat/qat_sym_session.c:
> 	In function 'qat_sym_do_precomputes.constprop':
> ../drivers/crypto/qat/qat_sym_session.c:1304:17: note:
> 	at offset 128 into object 'ipad.749' of size 128
>  1304 | uint8_t
> 
> ipad[qat_hash_get_block_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)];
>       |           ^~~~
> 
> Added a check to prevent compiler warnings.
> 
> Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
> ---
Thanks for the help!
The commit log could be shorter. Could you provide a V3 for that?
Apart from that
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
  

Patch

diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c
index 8ca475ca8b..4c513186d4 100644
--- a/drivers/crypto/qat/qat_sym_session.c
+++ b/drivers/crypto/qat/qat_sym_session.c
@@ -1431,6 +1431,10 @@  static int qat_sym_do_precomputes(enum icp_qat_hw_auth_algo hash_alg,
 		QAT_LOG(ERR, "invalid keylen %u", auth_keylen);
 		return -EFAULT;
 	}
+
+	RTE_VERIFY(auth_keylen <= sizeof(ipad));
+	RTE_VERIFY(auth_keylen <= sizeof(opad));
+
 	rte_memcpy(ipad, auth_key, auth_keylen);
 	rte_memcpy(opad, auth_key, auth_keylen);