lib/cryptodev: avoid implicit conversion to 64 bit number
PATCH 1/2 lib/cryptodev: avoid implicit conversion to 64 bit number
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.
--- lib/cryptodev/rte_cryptodev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/cryptodev/rte_cryptodev.c +1 -1
@@ -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(
Signature · 1 line
2.47.0.vfs.0.3
PATCH 2/2 lib/hash: avoid implicit conversion to 64 bit number
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).
--- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
lib/hash/rte_thash.c +1 -1
@@ -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 ;
lib/hash/rte_thash_gf2_poly_math.c +3 -3
@@ -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
Signature · 1 line
2.47.0.vfs.0.3
Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number
Quoted 13 lines · 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?)
Quoted 5 lines
1ULL should be used as the result of the bit shift gets multiplied by
sizeof(uint32_t).Signed-off-by Andre Muezerie <[email protected]>---
Quoted 9 lines
lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)lib/hash/rte_thash.c +0
-0
lib/hash/rte_thash.c rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, · line 569
Quoted 6 lines
lib/hash/rte_thash.c +1
-1@@ -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?
Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number
Quoted 33 lines · Bruce Richardson
Quoted 13 lines · 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?)Quoted 5 lines
1ULL should be used as the result of the bit shift gets multiplied by
sizeof(uint32_t).Signed-off-by Andre Muezerie <[email protected]>---
Acked-by Bruce Richardson <[email protected]>Quoted 11 lines
lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)lib/hash/rte_thash.c +0
-0@@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, offset;
Quoted 6 lines
lib/hash/rte_thash.c rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, · line 569
Quoted 4 lines
lib/hash/rte_thash.c +1
-1ent =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_BIT64here 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.
RE: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number
Quoted 46 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Wednesday, 22 January 2025 22.37Quoted 26 lines · Bruce Richardson
Quoted 13 lines · 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?)Quoted 5 lines
1ULL should be used as the result of the bit shift gets multiplied by
sizeof(uint32_t).Signed-off-by Andre Muezerie <[email protected]>---
Acked-by Bruce Richardson <[email protected]>Quoted 4 lines
lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)Quoted 5 lines
lib/hash/rte_thash.c rte_thash_add_helper(struct rte_thash_ctx *ctx,
Quoted 5 lines
lib/hash/rte_thash.c +0
-0@@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx,const char *name,
uint32_tlen,Quoted 3 lines
lib/hash/rte_thash.c rte_thash_add_helper(struct rte_thash_ctx *ctx, · line 567
Quoted 3 lines
lib/hash/rte_thash.c +0
-0offset ; ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper)+
Quoted 5 lines
lib/hash/rte_thash.c rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, · line 569
Quoted 3 lines
lib/hash/rte_thash.c +1
-1-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_BIT64here too?
Quoted 4 lines
Here we are calculating the size to be passed to the second argument of
rte_zmalloc, which is of typesize_t.size_tis 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,
Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number
Quoted 51 lines · Morten Brørup
Quoted 46 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Wednesday, 22 January 2025 22.37Quoted 26 lines · Bruce Richardson
Quoted 13 lines · 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?)Quoted 5 lines
1ULL should be used as the result of the bit shift gets multiplied by
sizeof(uint32_t).Signed-off-by Andre Muezerie <[email protected]>---
Acked-by Bruce Richardson <[email protected]>Quoted 4 lines
lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)Quoted 5 lines
lib/hash/rte_thash.c rte_thash_add_helper(struct rte_thash_ctx *ctx,
Quoted 5 lines
lib/hash/rte_thash.c +0
-0@@ -565,7 +565,7 @@ rte_thash_add_helper(struct rte_thash_ctx *ctx,const char *name,
uint32_tlen,Quoted 3 lines
lib/hash/rte_thash.c rte_thash_add_helper(struct rte_thash_ctx *ctx, · line 567
Quoted 3 lines
lib/hash/rte_thash.c +0
-0offset ; ent = rte_zmalloc(NULL, sizeof(struct rte_thash_subtuple_helper)+
Quoted 5 lines
lib/hash/rte_thash.c rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len, · line 569
Quoted 3 lines
lib/hash/rte_thash.c +1
-1-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_BIT64here too?Quoted 4 lines
Here we are calculating the size to be passed to the second argument of
rte_zmalloc, which is of typesize_t.size_tis implementation dependent, typically 4 bytes on 32-bit systems and 8 bytes on 64-bit systems, so using 1ULL seems more appropriate.
Quoted 4 lines
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?
RE: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number
Quoted 8 lines
Quoted 1 line
How about reducing the formula to directly shift the
sizeof()instead, i.e.:
Quoted 1 line
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.
Re: [PATCH 2/2] lib/hash: avoid implicit conversion to 64 bit number
In reply to Andre MuezerieQuoted 22 lines · 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 <[email protected]>--- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
<snip>
Signature · 2 lines
Regards, Vladimir
Quoted 10 lines
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 <[email protected]>
1/2 patch Applied to dpdk-next-crypto
2/2 patch will be taken via main tree.
Thanks.
PATCH v2 1/2 lib/cryptodev: avoid implicit conversion to 64 bit number
In reply to Andre MuezerieMSVC 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.
--- lib/cryptodev/rte_cryptodev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/cryptodev/rte_cryptodev.c +1 -1
@@ -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(
Signature · 1 line
2.47.2.vfs.0.1
PATCH v2 2/2 lib/hash: avoid implicit conversion to 64 bit number
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.
--- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
lib/hash/rte_thash.c +1 -1
@@ -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 ;
lib/hash/rte_thash_gf2_poly_math.c +3 -3
@@ -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
Signature · 1 line
2.47.2.vfs.0.1
RE: [PATCH v2 2/2] lib/hash: avoid implicit conversion to 64 bit number
Quoted 16 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Monday, 27 January 2025 17.04MSVC 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?)
Quoted 7 lines
Instead of multiplying
sizeof(uint32_t)by the result of shifting "1",sizeof(uint32_t)can be shifted directly.Signed-off-by Andre Muezerie <[email protected]>Acked-by Bruce Richardson <[email protected]>---
Quoted 24 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Monday, 27 January 2025 17.04MSVC 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 <[email protected]>Acked-by Akhil Goyal <[email protected]>--- lib/cryptodev/rte_cryptodev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/cryptodev/rte_cryptodev.c +0
-0
lib/cryptodev/rte_cryptodev.c rte_cryptodev_asym_xform_capability_check_hash( · line 624
Quoted 6 lines
lib/cryptodev/rte_cryptodev.c +1
-1@@ -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,
Quoted 34 lines · Morten Brørup
Quoted 24 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Monday, 27 January 2025 17.04MSVC 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 <[email protected]>Acked-by Akhil Goyal <[email protected]>--- lib/cryptodev/rte_cryptodev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/cryptodev/rte_cryptodev.c +0
-0lib/cryptodev/rte_cryptodev.c rte_cryptodev_asym_xform_capability_check_hash( · line 624
Quoted 6 lines
lib/cryptodev/rte_cryptodev.c +1
-1@@ -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_HMAChas 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_HMACalso exists in previous DPDK versions.)
Quoted 8 lines
Furthermore, driver initializations of
hash_algosshould also useRTE_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#L1210With Fixes tag added,
Reviewed-by Morten Brørup <[email protected]>
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.
PATCH v3 1/3 lib/cryptodev: avoid implicit conversion to 64 bit number
In reply to Andre MuezerieMSVC 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.
--- lib/cryptodev/rte_cryptodev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/cryptodev/rte_cryptodev.c +1 -1
@@ -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(
Signature · 1 line
2.47.2.vfs.0.1
PATCH v3 2/3 lib/hash: avoid implicit conversion to 64 bit number
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.
--- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash_gf2_poly_math.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
lib/hash/rte_thash.c +1 -1
@@ -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 ;
lib/hash/rte_thash_gf2_poly_math.c +3 -3
@@ -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
Signature · 1 line
2.47.2.vfs.0.1
PATCH v3 3/3 drivers/crypto: use RTE_BIT64 in initializations of hash_algos
In reply to Andre MuezerieThis was found during code review of similar issues.
--- drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 4 ++-- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +2 -2
@@ -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 )) }
drivers/crypto/openssl/rte_openssl_pmd_ops.c +2 -2
@@ -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)),
Signature · 1 line
2.47.2.vfs.0.1
RE: [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos
Quoted 7 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Monday, 27 January 2025 20.33This was found during code review of similar issues.
Signed-off-by Andre Muezerie <[email protected]>---
CNXK crypto & OpenSSL crypto driver maintainers, please review/ack.
Quoted 44 lines
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 4 ++-- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +1
-2@@ -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)),drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +0
-0.op_types = ((1 << RTE_CRYPTO_ASYM_OP_SIGN) | (1 << RTE_CRYPTO_ASYM_OP_VERIFY)) }drivers/crypto/openssl/rte_openssl_pmd_ops.c +1
-2@@ -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)),drivers/crypto/openssl/rte_openssl_pmd_ops.c +0
-1.op_types = ((1 <<RTE_CRYPTO_ASYM_OP_SIGN ) | (1 << RTE_CRYPTO_ASYM_OP_VERIFY)), --2.47.2.vfs.0.1
Anoob Joseph
Acked-byRE: [PATCH v3 3/3] drivers/crypto: use RTE_BIT64 in initializations of hash_algos
Quoted 11 lines
Quoted 7 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Monday, 27 January 2025 20.33This was found during code review of similar issues.
Signed-off-by Andre Muezerie <mailto:[email protected]>---
Reviewed-by Morten Brørup <mailto:[email protected]>CNXK crypto & OpenSSL crypto driver maintainers, please review/ack.
Quoted 13 lines
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_HMACinrte_crypto_auth_algorithmhas value 32.
Quoted 6 lines
Fixes 6f8ef8b68edb ("cryptodev: add hash algorithms in asymmetric capability")Signed-off-by Andre Muezerie <[email protected]>Acked-by Akhil Goyal <[email protected]>Reviewed-by Morten Brørup <[email protected]>
V2 of this patch was already applied to dpdk-next-crypto.
Now the other patches of the series are also applied. Thanks.