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 6D37F4613B; Mon, 27 Jan 2025 20:36:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 371FC402A9; Mon, 27 Jan 2025 20:36:22 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E4597402A9 for ; Mon, 27 Jan 2025 20:36:20 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 2FA572037169; Mon, 27 Jan 2025 11:36:20 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2FA572037169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1738006580; bh=IS5PP/nW4GuoVt4Wdsbgv5xOwgIGwMbiRNMSJdaHgE4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B7cE2LR94phIenprAeBfFMOC+ukyNMZHhXYnOlOWhTRsTQma9ESSCuRaVa3DJKzFp hqn5p+WJD97g4LGmGy0kfQENjEmrKxs2klASlPvD/b6FMtngtGCl0aRIGbrjzpti4B U7Wr/jdyCT489/1r2L/1CXImlsQQj0Uoy7AISVUo= Date: Mon, 27 Jan 2025 11:36:20 -0800 From: Andre Muezerie To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org, fanzhang.oss@gmail.com, gakhil@marvell.com, Kai Ji , Ankur Dwivedi , Anoob Joseph , Tejasree Kondoj Subject: Re: [PATCH v2 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number Message-ID: <20250127193620.GA17281@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1732758837-6350-1-git-send-email-andremue@linux.microsoft.com> <1737993833-22957-1-git-send-email-andremue@linux.microsoft.com> <98CBD80474FA8B44BF855DF32C47DC35E9F9F6@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F9F6@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Mon, Jan 27, 2025 at 06:14:47PM +0100, Morten Brørup wrote: > > From: Andre Muezerie [mailto:andremue@linux.microsoft.com] > > Sent: Monday, 27 January 2025 17.04 > > > > MSVC issues the warning below: > > > > ../lib/cryptodev/rte_cryptodev.c(623): warning C4334: '<<': > > result of 32-bit shift implicitly converted to 64 bits > > (was 64-bit shift intended?) > > > > 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. > > > > Signed-off-by: Andre Muezerie > > Acked-by: Akhil Goyal > > --- > > lib/cryptodev/rte_cryptodev.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > 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 = false; > > > > - if (capability->hash_algos & (1 << hash)) > > + if (capability->hash_algos & RTE_BIT64(hash)) > > ret = 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/rte_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ørup Great observation. I agree that this is indeed fixing a bug. I also fixed the two drivers as suggested and sent out v3 of this series.