* [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library
@ 2015-07-15 12:40 Pablo de Lara
2015-07-15 12:40 ` [dpdk-dev] [PATCH] hash: fix compilation for gcc 4.4/4.5 Pablo de Lara
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Pablo de Lara @ 2015-07-15 12:40 UTC (permalink / raw)
To: dev
When encountering a loop while adding a new entry,
element out of bounds of array was being unnecessarily resetted.
Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
lib/librte_hash/rte_cuckoo_hash.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 93f94a5..b753e77 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -446,11 +446,8 @@ make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
break;
/* All entries have been pushed, so entry cannot be added */
- if (i == RTE_HASH_BUCKET_ENTRIES) {
- /* Reset flag */
- bkt->flag[i] = 0;
+ if (i == RTE_HASH_BUCKET_ENTRIES)
return -ENOSPC;
- }
/* Set flag to indicate that this entry is going to be pushed */
bkt->flag[i] = 1;
--
2.4.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH] hash: fix compilation for gcc 4.4/4.5
2015-07-15 12:40 [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library Pablo de Lara
@ 2015-07-15 12:40 ` Pablo de Lara
2015-07-16 14:55 ` Thomas Monjalon
2015-07-15 12:40 ` [dpdk-dev] [PATCH] hash: fix library compilation for CPU with no SSE4.1 Pablo de Lara
2015-07-16 14:55 ` [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library Thomas Monjalon
2 siblings, 1 reply; 5+ messages in thread
From: Pablo de Lara @ 2015-07-15 12:40 UTC (permalink / raw)
To: dev
gcc 4.4 and 4.5 throws following error:
rte_cuckoo_hash.c:145: error: flexible array member in otherwise empty struct.
This is due to empty length in flexible array, which has been changed to use
size 0 in the declaration of the array.
Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
Reported-by: Olga Shern <olgas@mellanox.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
lib/librte_hash/rte_cuckoo_hash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 39cafb7..80cb126 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -142,7 +142,7 @@ struct rte_hash_key {
void *pdata;
};
/* Variable key size */
- char key[];
+ char key[0];
} __attribute__((aligned(KEY_ALIGNMENT)));
/** Bucket structure */
--
2.4.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] hash: fix compilation for gcc 4.4/4.5
2015-07-15 12:40 ` [dpdk-dev] [PATCH] hash: fix compilation for gcc 4.4/4.5 Pablo de Lara
@ 2015-07-16 14:55 ` Thomas Monjalon
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2015-07-16 14:55 UTC (permalink / raw)
To: Pablo de Lara; +Cc: dev
2015-07-15 13:40, Pablo de Lara:
> gcc 4.4 and 4.5 throws following error:
> rte_cuckoo_hash.c:145: error: flexible array member in otherwise empty struct.
>
> This is due to empty length in flexible array, which has been changed to use
> size 0 in the declaration of the array.
>
> Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
>
> Reported-by: Olga Shern <olgas@mellanox.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH] hash: fix library compilation for CPU with no SSE4.1
2015-07-15 12:40 [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library Pablo de Lara
2015-07-15 12:40 ` [dpdk-dev] [PATCH] hash: fix compilation for gcc 4.4/4.5 Pablo de Lara
@ 2015-07-15 12:40 ` Pablo de Lara
2015-07-16 14:55 ` [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library Thomas Monjalon
2 siblings, 0 replies; 5+ messages in thread
From: Pablo de Lara @ 2015-07-15 12:40 UTC (permalink / raw)
To: dev
_mm_test_all_zeros is not available for CPUs with no SSE4.1,
therefore, DPDK would not build.
This patch adds an alternative for this, using _mm_cmpeq_epi32 and
_mm_movemask_epi8.
Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
lib/librte_hash/rte_cuckoo_hash.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 80cb126..0f33376 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -1128,9 +1128,15 @@ rte_hash_k16_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unu
{
const __m128i k1 = _mm_loadu_si128((const __m128i *) key1);
const __m128i k2 = _mm_loadu_si128((const __m128i *) key2);
+#ifndef RTE_MACHINE_CPUFLAG_SSE4_1
const __m128i x = _mm_xor_si128(k1, k2);
return !_mm_test_all_zeros(x, x);
+#else
+ const __m128i x = _mm_cmpeq_epi32(k1, k2);
+
+ return (_mm_movemask_epi8(x) != 0xffff);
+#endif
}
static int
--
2.4.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library
2015-07-15 12:40 [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library Pablo de Lara
2015-07-15 12:40 ` [dpdk-dev] [PATCH] hash: fix compilation for gcc 4.4/4.5 Pablo de Lara
2015-07-15 12:40 ` [dpdk-dev] [PATCH] hash: fix library compilation for CPU with no SSE4.1 Pablo de Lara
@ 2015-07-16 14:55 ` Thomas Monjalon
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2015-07-16 14:55 UTC (permalink / raw)
To: Pablo de Lara; +Cc: dev
2015-07-15 13:40, Pablo de Lara:
> When encountering a loop while adding a new entry,
> element out of bounds of array was being unnecessarily resetted.
>
> Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-07-16 14:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-15 12:40 [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library Pablo de Lara
2015-07-15 12:40 ` [dpdk-dev] [PATCH] hash: fix compilation for gcc 4.4/4.5 Pablo de Lara
2015-07-16 14:55 ` Thomas Monjalon
2015-07-15 12:40 ` [dpdk-dev] [PATCH] hash: fix library compilation for CPU with no SSE4.1 Pablo de Lara
2015-07-16 14:55 ` [dpdk-dev] [PATCH] hash: fix array out of bounds in hash library Thomas Monjalon
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).