* [PATCH 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number @ 2024-11-28 1:53 Andre Muezerie 2024-11-28 1:53 ` [PATCH 2/2] lib/hash: " Andre Muezerie ` (3 more replies) 0 siblings, 4 replies; 19+ messages in thread From: Andre Muezerie @ 2024-11-28 1:53 UTC (permalink / raw) To: Akhil Goyal, Fan Zhang; +Cc: dev, Andre Muezerie 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 <andremue@linux.microsoft.com> --- 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; rte_cryptodev_trace_asym_xform_capability_check_hash( -- 2.47.0.vfs.0.3 ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number 2024-11-28 1:53 [PATCH 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number Andre Muezerie @ 2024-11-28 1:53 ` Andre Muezerie 2025-01-22 16:12 ` Bruce Richardson 2025-01-22 16:15 ` Medvedkin, Vladimir 2025-01-08 10:28 ` [EXTERNAL] [PATCH 1/2] lib/cryptodev: " Akhil Goyal ` (2 subsequent siblings) 3 siblings, 2 replies; 19+ messages in thread From: Andre Muezerie @ 2024-11-28 1:53 UTC (permalink / raw) To: Yipeng Wang, Sameh Gobriel, Bruce Richardson, Vladimir Medvedkin Cc: dev, Andre Muezerie MSVC issues the warnings below: 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 1ULL should be used as the result of the bit shift gets multiplied by sizeof(uint32_t). Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index fa78787143..f076311b57 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, offset; ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) + - sizeof(uint32_t) * (1 << ctx->reta_sz_log), + sizeof(uint32_t) * (1ULL << ctx->reta_sz_log), RTE_CACHE_LINE_SIZE); if (ent == NULL) return -ENOMEM; diff --git a/lib/hash/rte_thash_gf2_poly_math.c b/lib/hash/rte_thash_gf2_poly_math.c index 825da4382f..858884b4d4 100644 --- a/lib/hash/rte_thash_gf2_poly_math.c +++ b/lib/hash/rte_thash_gf2_poly_math.c @@ -119,16 +119,16 @@ static uint32_t gf2_mul(uint32_t a, uint32_t b, uint32_t r, int degree) { uint64_t product = 0; - uint64_t r_poly = r|(1ULL << degree); + uint64_t r_poly = r | RTE_BIT64(degree); for (; b; b &= (b - 1)) product ^= (uint64_t)a << (rte_bsf32(b)); for (int i = degree * 2 - 1; i >= degree; i--) - if (product & (1 << i)) + if (product & RTE_BIT64(i)) product ^= r_poly << (i - degree); - return product; + return (uint32_t)product; } static uint32_t -- 2.47.0.vfs.0.3 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number 2024-11-28 1:53 ` [PATCH 2/2] lib/hash: " Andre Muezerie @ 2025-01-22 16:12 ` Bruce Richardson 2025-01-22 21:36 ` Andre Muezerie 2025-01-22 16:15 ` Medvedkin, Vladimir 1 sibling, 1 reply; 19+ messages in thread From: Bruce Richardson @ 2025-01-22 16:12 UTC (permalink / raw) To: Andre Muezerie; +Cc: Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, dev On Wed, Nov 27, 2024 at 05:53:57PM -0800, Andre Muezerie wrote: > MSVC issues the warnings below: > > 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. > > 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': > result of 32-bit shift implicitly converted to 64 bits > (was 64-bit shift intended?) > > 1ULL should be used as the result of the bit shift gets multiplied > by sizeof(uint32_t). > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > --- Acked-by: Bruce Richardson <bruce.richardson@intel.com> > lib/hash/rte_thash.c | 2 +- > lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c > index fa78787143..f076311b57 100644 > --- a/lib/hash/rte_thash.c > +++ b/lib/hash/rte_thash.c > @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, > offset; > > ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) + > - sizeof(uint32_t) * (1 << ctx->reta_sz_log), > + sizeof(uint32_t) * (1ULL << ctx->reta_sz_log), > RTE_CACHE_LINE_SIZE); Is there a reason not to use RTE_BIT64 here too? ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number 2025-01-22 16:12 ` Bruce Richardson @ 2025-01-22 21:36 ` Andre Muezerie 2025-01-23 7:55 ` Morten Brørup 0 siblings, 1 reply; 19+ messages in thread From: Andre Muezerie @ 2025-01-22 21:36 UTC (permalink / raw) To: Bruce Richardson; +Cc: Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, dev On Wed, Jan 22, 2025 at 04:12:49PM +0000, Bruce Richardson wrote: > On Wed, Nov 27, 2024 at 05:53:57PM -0800, Andre Muezerie wrote: > > MSVC issues the warnings below: > > > > 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. > > > > 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': > > result of 32-bit shift implicitly converted to 64 bits > > (was 64-bit shift intended?) > > > > 1ULL should be used as the result of the bit shift gets multiplied > > by sizeof(uint32_t). > > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > > --- > > Acked-by: Bruce Richardson <bruce.richardson@intel.com> > > > lib/hash/rte_thash.c | 2 +- > > lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c > > index fa78787143..f076311b57 100644 > > --- a/lib/hash/rte_thash.c > > +++ b/lib/hash/rte_thash.c > > @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, > > offset; > > > > ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) + > > - sizeof(uint32_t) * (1 << ctx->reta_sz_log), > > + sizeof(uint32_t) * (1ULL << ctx->reta_sz_log), > > RTE_CACHE_LINE_SIZE); > > Is there a reason not to use RTE_BIT64 here too? Here we are calculating the size to be passed to the second argument of rte_zmalloc, which is of type size_t. size_t is implementation dependent, typically 4 bytes on 32-bit systems and 8 bytes on 64-bit systems, so using 1ULL seems more appropriate. ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number 2025-01-22 21:36 ` Andre Muezerie @ 2025-01-23 7:55 ` Morten Brørup 2025-01-23 17:42 ` Andre Muezerie 0 siblings, 1 reply; 19+ messages in thread From: Morten Brørup @ 2025-01-23 7:55 UTC (permalink / raw) To: Andre Muezerie, Bruce Richardson Cc: Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, dev > From: Andre Muezerie [mailto:andremue@linux.microsoft.com] > Sent: Wednesday, 22 January 2025 22.37 > > On Wed, Jan 22, 2025 at 04:12:49PM +0000, Bruce Richardson wrote: > > On Wed, Nov 27, 2024 at 05:53:57PM -0800, Andre Muezerie wrote: > > > MSVC issues the warnings below: > > > > > > 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. > > > > > > 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': > > > result of 32-bit shift implicitly converted to 64 bits > > > (was 64-bit shift intended?) > > > > > > 1ULL should be used as the result of the bit shift gets multiplied > > > by sizeof(uint32_t). > > > > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > > > --- > > > > Acked-by: Bruce Richardson <bruce.richardson@intel.com> > > > > > lib/hash/rte_thash.c | 2 +- > > > lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- > > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c > > > index fa78787143..f076311b57 100644 > > > --- a/lib/hash/rte_thash.c > > > +++ b/lib/hash/rte_thash.c > > > @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, > const char *name, uint32_t len, > > > offset; > > > > > > ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) > + > > > - sizeof(uint32_t) * (1 << ctx->reta_sz_log), > > > + sizeof(uint32_t) * (1ULL << ctx->reta_sz_log), > > > RTE_CACHE_LINE_SIZE); > > > > Is there a reason not to use RTE_BIT64 here too? > > Here we are calculating the size to be passed to the second argument of > rte_zmalloc, which is of type size_t. size_t is implementation > dependent, typically 4 bytes on 32-bit systems and 8 bytes on 64-bit > systems, so using 1ULL seems more appropriate. 1ULL makes it 8 byte on 32-bit systems too. Did you mean 1UL? How about reducing the formula to directly shift the sizeof() instead, i.e.: sizeof(uint32_t) << ctx->reta_sz_log, ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number 2025-01-23 7:55 ` Morten Brørup @ 2025-01-23 17:42 ` Andre Muezerie 2025-01-25 12:56 ` Morten Brørup 0 siblings, 1 reply; 19+ messages in thread From: Andre Muezerie @ 2025-01-23 17:42 UTC (permalink / raw) To: Morten Brørup Cc: Bruce Richardson, Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, dev On Thu, Jan 23, 2025 at 08:55:29AM +0100, Morten Brørup wrote: > > From: Andre Muezerie [mailto:andremue@linux.microsoft.com] > > Sent: Wednesday, 22 January 2025 22.37 > > > > On Wed, Jan 22, 2025 at 04:12:49PM +0000, Bruce Richardson wrote: > > > On Wed, Nov 27, 2024 at 05:53:57PM -0800, Andre Muezerie wrote: > > > > MSVC issues the warnings below: > > > > > > > > 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. > > > > > > > > 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': > > > > result of 32-bit shift implicitly converted to 64 bits > > > > (was 64-bit shift intended?) > > > > > > > > 1ULL should be used as the result of the bit shift gets multiplied > > > > by sizeof(uint32_t). > > > > > > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > > > > --- > > > > > > Acked-by: Bruce Richardson <bruce.richardson@intel.com> > > > > > > > lib/hash/rte_thash.c | 2 +- > > > > lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- > > > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c > > > > index fa78787143..f076311b57 100644 > > > > --- a/lib/hash/rte_thash.c > > > > +++ b/lib/hash/rte_thash.c > > > > @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, > > const char *name, uint32_t len, > > > > offset; > > > > > > > > ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) > > + > > > > - sizeof(uint32_t) * (1 << ctx->reta_sz_log), > > > > + sizeof(uint32_t) * (1ULL << ctx->reta_sz_log), > > > > RTE_CACHE_LINE_SIZE); > > > > > > Is there a reason not to use RTE_BIT64 here too? > > > > Here we are calculating the size to be passed to the second argument of > > rte_zmalloc, which is of type size_t. size_t is implementation > > dependent, typically 4 bytes on 32-bit systems and 8 bytes on 64-bit > > systems, so using 1ULL seems more appropriate. > > 1ULL makes it 8 byte on 32-bit systems too. Did you mean 1UL? > > How about reducing the formula to directly shift the sizeof() instead, i.e.: > sizeof(uint32_t) << ctx->reta_sz_log, Shifting the sizeof() directly is better indeed. Let me know how we should proceed. Do you want me to send out a new series incorporating this suggestion? ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number 2025-01-23 17:42 ` Andre Muezerie @ 2025-01-25 12:56 ` Morten Brørup 0 siblings, 0 replies; 19+ messages in thread From: Morten Brørup @ 2025-01-25 12:56 UTC (permalink / raw) To: Andre Muezerie Cc: Bruce Richardson, Yipeng Wang, Sameh Gobriel, Vladimir Medvedkin, dev > > How about reducing the formula to directly shift the sizeof() > instead, i.e.: > > sizeof(uint32_t) << ctx->reta_sz_log, > > Shifting the sizeof() directly is better indeed. Let me know how we > should > proceed. Do you want me to send out a new series incorporating this > suggestion? Yes, please. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number 2024-11-28 1:53 ` [PATCH 2/2] lib/hash: " Andre Muezerie 2025-01-22 16:12 ` Bruce Richardson @ 2025-01-22 16:15 ` Medvedkin, Vladimir 1 sibling, 0 replies; 19+ messages in thread From: Medvedkin, Vladimir @ 2025-01-22 16:15 UTC (permalink / raw) To: Andre Muezerie, Yipeng Wang, Sameh Gobriel, Bruce Richardson; +Cc: dev Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> On 28/11/2024 01:53, Andre Muezerie wrote: > MSVC issues the warnings below: > > 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. > > 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': > result of 32-bit shift implicitly converted to 64 bits > (was 64-bit shift intended?) > > 1ULL should be used as the result of the bit shift gets multiplied > by sizeof(uint32_t). > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > --- > lib/hash/rte_thash.c | 2 +- > lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) > <snip> -- Regards, Vladimir ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [EXTERNAL] [PATCH 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number 2024-11-28 1:53 [PATCH 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number Andre Muezerie 2024-11-28 1:53 ` [PATCH 2/2] lib/hash: " Andre Muezerie @ 2025-01-08 10:28 ` Akhil Goyal 2025-01-27 16:03 ` [PATCH v2 " Andre Muezerie 2025-01-27 19:33 ` [PATCH v3 1/3] " Andre Muezerie 3 siblings, 0 replies; 19+ messages in thread From: Akhil Goyal @ 2025-01-08 10:28 UTC (permalink / raw) To: Andre Muezerie, Fan Zhang, thomas; +Cc: dev > 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 <andremue@linux.microsoft.com> Acked-by: Akhil Goyal <gakhil@marvell.com> 1/2 patch Applied to dpdk-next-crypto 2/2 patch will be taken via main tree. Thanks. ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number 2024-11-28 1:53 [PATCH 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number Andre Muezerie 2024-11-28 1:53 ` [PATCH 2/2] lib/hash: " Andre Muezerie 2025-01-08 10:28 ` [EXTERNAL] [PATCH 1/2] lib/cryptodev: " Akhil Goyal @ 2025-01-27 16:03 ` Andre Muezerie 2025-01-27 16:03 ` [PATCH v2 2/2] lib/hash: " Andre Muezerie 2025-01-27 17:14 ` [PATCH v2 1/2] lib/cryptodev: " Morten Brørup 2025-01-27 19:33 ` [PATCH v3 1/3] " Andre Muezerie 3 siblings, 2 replies; 19+ messages in thread From: Andre Muezerie @ 2025-01-27 16:03 UTC (permalink / raw) To: andremue; +Cc: dev, fanzhang.oss, gakhil, mb 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 <andremue@linux.microsoft.com> Acked-by: Akhil Goyal <gakhil@marvell.com> --- 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; rte_cryptodev_trace_asym_xform_capability_check_hash( -- 2.47.2.vfs.0.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 2/2] lib/hash: avoid implicit conversion to 64 bit number 2025-01-27 16:03 ` [PATCH v2 " Andre Muezerie @ 2025-01-27 16:03 ` Andre Muezerie 2025-01-27 17:16 ` Morten Brørup 2025-01-27 17:14 ` [PATCH v2 1/2] lib/cryptodev: " Morten Brørup 1 sibling, 1 reply; 19+ messages in thread From: Andre Muezerie @ 2025-01-27 16:03 UTC (permalink / raw) To: andremue; +Cc: dev, fanzhang.oss, gakhil, mb MSVC issues the warnings below: 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) Instead of multiplying sizeof(uint32_t) by the result of shifting "1", sizeof(uint32_t) can be shifted directly. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 336c228e64..429b895d6c 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, offset; ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) + - sizeof(uint32_t) * (1 << ctx->reta_sz_log), + (sizeof(uint32_t) << ctx->reta_sz_log), RTE_CACHE_LINE_SIZE); if (ent == NULL) return -ENOMEM; diff --git a/lib/hash/rte_thash_gf2_poly_math.c b/lib/hash/rte_thash_gf2_poly_math.c index 1c62974e71..a28f2495a5 100644 --- a/lib/hash/rte_thash_gf2_poly_math.c +++ b/lib/hash/rte_thash_gf2_poly_math.c @@ -118,16 +118,16 @@ static uint32_t gf2_mul(uint32_t a, uint32_t b, uint32_t r, int degree) { uint64_t product = 0; - uint64_t r_poly = r|(1ULL << degree); + uint64_t r_poly = r | RTE_BIT64(degree); for (; b; b &= (b - 1)) product ^= (uint64_t)a << (rte_bsf32(b)); for (int i = degree * 2 - 1; i >= degree; i--) - if (product & (1 << i)) + if (product & RTE_BIT64(i)) product ^= r_poly << (i - degree); - return product; + return (uint32_t)product; } static uint32_t -- 2.47.2.vfs.0.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH v2 2/2] lib/hash: avoid implicit conversion to 64 bit number 2025-01-27 16:03 ` [PATCH v2 2/2] lib/hash: " Andre Muezerie @ 2025-01-27 17:16 ` Morten Brørup 0 siblings, 0 replies; 19+ messages in thread From: Morten Brørup @ 2025-01-27 17:16 UTC (permalink / raw) To: Andre Muezerie; +Cc: dev, fanzhang.oss, gakhil > From: Andre Muezerie [mailto:andremue@linux.microsoft.com] > Sent: Monday, 27 January 2025 17.04 > > MSVC issues the warnings below: > > 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. > > 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': > result of 32-bit shift implicitly converted to 64 bits > (was 64-bit shift intended?) > > Instead of multiplying sizeof(uint32_t) by the result of shifting > "1", sizeof(uint32_t) can be shifted directly. > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> > Acked-by: Bruce Richardson <bruce.richardson@intel.com> > --- Reviewed-by: Morten Brørup <mb@smartsharesystems.com> ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH v2 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number 2025-01-27 16:03 ` [PATCH v2 " Andre Muezerie 2025-01-27 16:03 ` [PATCH v2 2/2] lib/hash: " Andre Muezerie @ 2025-01-27 17:14 ` Morten Brørup 2025-01-27 19:36 ` Andre Muezerie 1 sibling, 1 reply; 19+ messages in thread From: Morten Brørup @ 2025-01-27 17:14 UTC (permalink / raw) To: Andre Muezerie Cc: dev, fanzhang.oss, gakhil, Kai Ji, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj > 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 <andremue@linux.microsoft.com> > Acked-by: Akhil Goyal <gakhil@marvell.com> > --- > 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 <mb@smartsharesystems.com> ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number 2025-01-27 17:14 ` [PATCH v2 1/2] lib/cryptodev: " Morten Brørup @ 2025-01-27 19:36 ` Andre Muezerie 0 siblings, 0 replies; 19+ messages in thread From: Andre Muezerie @ 2025-01-27 19:36 UTC (permalink / raw) To: Morten Brørup Cc: dev, fanzhang.oss, gakhil, Kai Ji, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj 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 <andremue@linux.microsoft.com> > > Acked-by: Akhil Goyal <gakhil@marvell.com> > > --- > > 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 <mb@smartsharesystems.com> 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. ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 1/3] lib/cryptodev: avoid implicit conversion to 64 bit number 2024-11-28 1:53 [PATCH 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number Andre Muezerie ` (2 preceding siblings ...) 2025-01-27 16:03 ` [PATCH v2 " Andre Muezerie @ 2025-01-27 19:33 ` Andre Muezerie 2025-01-27 19:33 ` [PATCH v3 2/3] lib/hash: " Andre Muezerie 2025-01-27 19:33 ` [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos Andre Muezerie 3 siblings, 2 replies; 19+ messages in thread From: Andre Muezerie @ 2025-01-27 19:33 UTC (permalink / raw) To: andremue; +Cc: dev, fanzhang.oss, gakhil, mb, stable 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. This patch actually fixes a bug present in previous DPDK versions because the last of the hash enums RTE_CRYPTO_AUTH_SM3_HMAC in rte_crypto_auth_algorithm has value 32. Fixes: 6f8ef8b68edb ("cryptodev: add hash algorithms in asymmetric capability") Cc: stable@dpdk.org Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> Acked-by: Akhil Goyal <gakhil@marvell.com> Reviewed-by: Morten Brørup <mb@smartsharesystems.com> --- 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; rte_cryptodev_trace_asym_xform_capability_check_hash( -- 2.47.2.vfs.0.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 2/3] lib/hash: avoid implicit conversion to 64 bit number 2025-01-27 19:33 ` [PATCH v3 1/3] " Andre Muezerie @ 2025-01-27 19:33 ` Andre Muezerie 2025-01-27 19:33 ` [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos Andre Muezerie 1 sibling, 0 replies; 19+ messages in thread From: Andre Muezerie @ 2025-01-27 19:33 UTC (permalink / raw) To: andremue; +Cc: dev, fanzhang.oss, gakhil, mb MSVC issues the warnings below: 1) ../lib/hash/rte_thash_gf2_poly_math.c(128): 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. 2) ../lib/hash/rte_thash.c(568): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) Instead of multiplying sizeof(uint32_t) by the result of shifting "1", sizeof(uint32_t) can be shifted directly. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Reviewed-by: Morten Brørup <mb@smartsharesystems.com> --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 336c228e64..429b895d6c 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, offset; ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper) + - sizeof(uint32_t) * (1 << ctx->reta_sz_log), + (sizeof(uint32_t) << ctx->reta_sz_log), RTE_CACHE_LINE_SIZE); if (ent == NULL) return -ENOMEM; diff --git a/lib/hash/rte_thash_gf2_poly_math.c b/lib/hash/rte_thash_gf2_poly_math.c index 1c62974e71..a28f2495a5 100644 --- a/lib/hash/rte_thash_gf2_poly_math.c +++ b/lib/hash/rte_thash_gf2_poly_math.c @@ -118,16 +118,16 @@ static uint32_t gf2_mul(uint32_t a, uint32_t b, uint32_t r, int degree) { uint64_t product = 0; - uint64_t r_poly = r|(1ULL << degree); + uint64_t r_poly = r | RTE_BIT64(degree); for (; b; b &= (b - 1)) product ^= (uint64_t)a << (rte_bsf32(b)); for (int i = degree * 2 - 1; i >= degree; i--) - if (product & (1 << i)) + if (product & RTE_BIT64(i)) product ^= r_poly << (i - degree); - return product; + return (uint32_t)product; } static uint32_t -- 2.47.2.vfs.0.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos 2025-01-27 19:33 ` [PATCH v3 1/3] " Andre Muezerie 2025-01-27 19:33 ` [PATCH v3 2/3] lib/hash: " Andre Muezerie @ 2025-01-27 19:33 ` Andre Muezerie 2025-01-28 7:45 ` Morten Brørup 1 sibling, 1 reply; 19+ messages in thread From: Andre Muezerie @ 2025-01-27 19:33 UTC (permalink / raw) To: andremue; +Cc: dev, fanzhang.oss, gakhil, mb This was found during code review of similar issues. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 4 ++-- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c index 4394513002..e78bc37c37 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c @@ -1207,8 +1207,8 @@ static const struct rte_cryptodev_capabilities caps_eddsa[] = { {.asym = { .xform_capa = { .xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA, - .hash_algos = (1 << RTE_CRYPTO_AUTH_SHA512 | - 1 << RTE_CRYPTO_AUTH_SHAKE_256), + .hash_algos = (RTE_BIT64(RTE_CRYPTO_AUTH_SHA512) | + RTE_BIT64(RTE_CRYPTO_AUTH_SHAKE_256)), .op_types = ((1 << RTE_CRYPTO_ASYM_OP_SIGN) | (1 << RTE_CRYPTO_ASYM_OP_VERIFY)) } diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index 18f096abfd..04e018f3df 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -630,8 +630,8 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = { {.asym = { .xform_capa = { .xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA, - .hash_algos = (1 << RTE_CRYPTO_AUTH_SHA512 | - 1 << RTE_CRYPTO_AUTH_SHAKE_256), + .hash_algos = (RTE_BIT64(RTE_CRYPTO_AUTH_SHA512) | + RTE_BIT64(RTE_CRYPTO_AUTH_SHAKE_256)), .op_types = ((1<<RTE_CRYPTO_ASYM_OP_SIGN) | (1 << RTE_CRYPTO_ASYM_OP_VERIFY)), -- 2.47.2.vfs.0.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos 2025-01-27 19:33 ` [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos Andre Muezerie @ 2025-01-28 7:45 ` Morten Brørup 2025-01-28 7:49 ` Anoob Joseph 0 siblings, 1 reply; 19+ messages in thread From: Morten Brørup @ 2025-01-28 7:45 UTC (permalink / raw) To: Andre Muezerie, Kai Ji, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj Cc: dev, fanzhang.oss, gakhil > From: Andre Muezerie [mailto:andremue@linux.microsoft.com] > Sent: Monday, 27 January 2025 20.33 > > This was found during code review of similar issues. > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > --- Reviewed-by: Morten Brørup <mb@smartsharesystems.com> CNXK crypto & OpenSSL crypto driver maintainers, please review/ack. > drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 4 ++-- > drivers/crypto/openssl/rte_openssl_pmd_ops.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c > b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c > index 4394513002..e78bc37c37 100644 > --- a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c > +++ b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c > @@ -1207,8 +1207,8 @@ static const struct rte_cryptodev_capabilities > caps_eddsa[] = { > {.asym = { > .xform_capa = { > .xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA, > - .hash_algos = (1 << RTE_CRYPTO_AUTH_SHA512 | > - 1 << RTE_CRYPTO_AUTH_SHAKE_256), > + .hash_algos = > (RTE_BIT64(RTE_CRYPTO_AUTH_SHA512) | > + > RTE_BIT64(RTE_CRYPTO_AUTH_SHAKE_256)), > .op_types = ((1 << RTE_CRYPTO_ASYM_OP_SIGN) | > (1 << RTE_CRYPTO_ASYM_OP_VERIFY)) > } > diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c > b/drivers/crypto/openssl/rte_openssl_pmd_ops.c > index 18f096abfd..04e018f3df 100644 > --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c > +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c > @@ -630,8 +630,8 @@ static const struct rte_cryptodev_capabilities > openssl_pmd_capabilities[] = { > {.asym = { > .xform_capa = { > .xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA, > - .hash_algos = (1 << RTE_CRYPTO_AUTH_SHA512 | > - 1 << RTE_CRYPTO_AUTH_SHAKE_256), > + .hash_algos = > (RTE_BIT64(RTE_CRYPTO_AUTH_SHA512) | > + > RTE_BIT64(RTE_CRYPTO_AUTH_SHAKE_256)), > .op_types = > ((1<<RTE_CRYPTO_ASYM_OP_SIGN) | > (1 << RTE_CRYPTO_ASYM_OP_VERIFY)), > -- > 2.47.2.vfs.0.1 ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos 2025-01-28 7:45 ` Morten Brørup @ 2025-01-28 7:49 ` Anoob Joseph 0 siblings, 0 replies; 19+ messages in thread From: Anoob Joseph @ 2025-01-28 7:49 UTC (permalink / raw) To: Morten Brørup, Andre Muezerie, Kai Ji, Ankur Dwivedi, Tejasree Kondoj Cc: dev, fanzhang.oss, Akhil Goyal > > From: Andre Muezerie [mailto:andremue@linux.microsoft.com] > > Sent: Monday, 27 January 2025 20.33 > > > > This was found during code review of similar issues. > > > > Signed-off-by: Andre Muezerie <mailto:andremue@linux.microsoft.com> > > --- > > Reviewed-by: Morten Brørup <mailto:mb@smartsharesystems.com> > > CNXK crypto & OpenSSL crypto driver maintainers, please review/ack. Acked-by: Anoob Joseph <anoobj@marvell.com> ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-01-28 7:50 UTC | newest] Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-11-28 1:53 [PATCH 1/2] lib/cryptodev: avoid implicit conversion to 64 bit number Andre Muezerie 2024-11-28 1:53 ` [PATCH 2/2] lib/hash: " Andre Muezerie 2025-01-22 16:12 ` Bruce Richardson 2025-01-22 21:36 ` Andre Muezerie 2025-01-23 7:55 ` Morten Brørup 2025-01-23 17:42 ` Andre Muezerie 2025-01-25 12:56 ` Morten Brørup 2025-01-22 16:15 ` Medvedkin, Vladimir 2025-01-08 10:28 ` [EXTERNAL] [PATCH 1/2] lib/cryptodev: " Akhil Goyal 2025-01-27 16:03 ` [PATCH v2 " Andre Muezerie 2025-01-27 16:03 ` [PATCH v2 2/2] lib/hash: " Andre Muezerie 2025-01-27 17:16 ` Morten Brørup 2025-01-27 17:14 ` [PATCH v2 1/2] lib/cryptodev: " Morten Brørup 2025-01-27 19:36 ` Andre Muezerie 2025-01-27 19:33 ` [PATCH v3 1/3] " Andre Muezerie 2025-01-27 19:33 ` [PATCH v3 2/3] lib/hash: " Andre Muezerie 2025-01-27 19:33 ` [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos Andre Muezerie 2025-01-28 7:45 ` Morten Brørup 2025-01-28 7:49 ` Anoob Joseph
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).