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 E6C074613A; Mon, 27 Jan 2025 18:14:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88F5640698; Mon, 27 Jan 2025 18:14:52 +0100 (CET) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id DC92640275 for ; Mon, 27 Jan 2025 18:14:50 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id A5F8E2091E; Mon, 27 Jan 2025 18:14:48 +0100 (CET) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v2 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number Date: Mon, 27 Jan 2025 18:14:47 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F9F6@smartserver.smartshare.dk> X-MimeOLE: Produced By Microsoft Exchange V6.5 In-Reply-To: <1737993833-22957-1-git-send-email-andremue@linux.microsoft.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v2 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number Thread-Index: Adtw1RUzQPOf//1mQ7W6o6LpukotZQAB5+Ag References: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> <1737993833-22957-1-git-send-email-andremue@linux.microsoft.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Andre Muezerie" Cc: , , , "Kai Ji" , "Ankur Dwivedi" , "Anoob Joseph" , "Tejasree Kondoj" 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 > From: Andre Muezerie [mailto:andremue@linux.microsoft.com] > Sent: Monday, 27 January 2025 17.04 >=20 > MSVC issues the warning below: >=20 > ../lib/cryptodev/rte_cryptodev.c(623): warning C4334: '<<': > result of 32-bit shift implicitly converted to 64 bits > (was 64-bit shift intended?) >=20 > The code would be better off by using 64 bit numbers to begin with. > That eliminates the need for a conversion to 64 bits later. >=20 > Signed-off-by: Andre Muezerie > Acked-by: Akhil Goyal > --- > lib/cryptodev/rte_cryptodev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/lib/cryptodev/rte_cryptodev.c > b/lib/cryptodev/rte_cryptodev.c > index 85a4b46ac9..a49b0662f3 100644 > --- a/lib/cryptodev/rte_cryptodev.c > +++ b/lib/cryptodev/rte_cryptodev.c > @@ -620,7 +620,7 @@ rte_cryptodev_asym_xform_capability_check_hash( > { > bool ret =3D false; >=20 > - if (capability->hash_algos & (1 << hash)) > + if (capability->hash_algos & RTE_BIT64(hash)) > ret =3D true; If I'm not mistaken, the last of the hash enums RTE_CRYPTO_AUTH_SM3_HMAC = has the value 32, so this patch actually fixes a bug. If you agree with my analysis, a Fixes tag should be added, so the patch = can be backported. (RTE_CRYPTO_AUTH_SM3_HMAC also exists in previous = DPDK versions.) Furthermore, driver initializations of hash_algos should also use = RTE_BIT64(): https://elixir.bootlin.com/dpdk/v24.11.1/C/ident/hash_algos Specifically, OpenSSL and CNXK crypto drivers have the same bug, and = need to be fixed too: https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/crypto/openssl/rt= e_openssl_pmd_ops.c#L633 https://elixir.bootlin.com/dpdk/v24.11.1/source/drivers/crypto/cnxk/cnxk_= cryptodev_capabilities.c#L1210 With Fixes tag added, Reviewed-by: Morten Br=F8rup