DPDK: mlx5 driver: fix memory region cache lookup

This commit backports commit 95086c6 from upstream DPDK, as well
as adds a similar check for a valid memory region.

https://github.com/DPDK/dpdk/commit/95086c6

Since the latest mellanox driver has had a lot of refactoring in
the latest upstream, this patch, as well as the associated bug
should be re-evaluated on the next openvswitch/DPDK upversion.

The original commit states:

The Memory Region (MR) cache contains pointers to mlx5_mr.
The MR cache indexes are filled when a new MR is created. As it is
possible for MR to be created on the flight, an extra validation must be
added to avoid segmentation fault.

Change-Id: Ia54267a7fab30dbde96f4601ca33f0ca117a0650
Closes-Bug: #1792418
Signed-off-by: Steven Webster <steven.webster@windriver.com>
This commit is contained in:
Steven Webster 2018-10-17 10:12:51 -04:00
parent f6a30cfb93
commit d9645e5a8b
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,25 @@
From 5cabd4876e772f59a18a71a15f8fdfac0b0cf0ea Mon Sep 17 00:00:00 2001
From: Steven Webster <steven.webster@windriver.com>
Date: Wed, 17 Oct 2018 09:54:53 -0400
Subject: [PATCH] net-mlx5-fix-memory-region-cache-lookup
---
SPECS/openvswitch.spec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/SPECS/openvswitch.spec b/SPECS/openvswitch.spec
index f286a13..6d95f35 100644
--- a/SPECS/openvswitch.spec
+++ b/SPECS/openvswitch.spec
@@ -127,7 +127,7 @@ Patch422: 0003-vhost-extract-virtqueue-cleaning-and-freeing-functio.patch
Patch423: 0004-vhost-destroy-unused-virtqueues-when-multiqueue-not-.patch
Patch424: 0005-vhost-add-flag-for-built-in-virtio-driver.patch
Patch425: 0006-vhost-drop-virtqueues-only-with-built-in-virtio-driv.patch
-
+Patch426: net-mlx5-fix-memory-region-cache-lookup.patch
BuildRequires: gcc
BuildRequires: python2-sphinx
--
1.8.3.1

View File

@ -6,3 +6,4 @@
0006-rpm-check-with-condition.patch
0007-enable-mlx-pmds.patch
0008-iommu-width-fix.patch
0009-net-mlx5-fix-memory-region-cache-lookup.patch

View File

@ -0,0 +1,31 @@
From de2067b4419323eb9cefdb2faed3245b28e7d4b2 Mon Sep 17 00:00:00 2001
From: Steven Webster <steven.webster@windriver.com>
Date: Wed, 17 Oct 2018 09:50:07 -0400
Subject: [PATCH] net-mlx5-fix-memory-region-cache-lookup
---
dpdk-17.11/drivers/net/mlx5/mlx5_rxtx.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dpdk-17.11/drivers/net/mlx5/mlx5_rxtx.h b/dpdk-17.11/drivers/net/mlx5/mlx5_rxtx.h
index d34f3cc..70db913 100644
--- a/dpdk-17.11/drivers/net/mlx5/mlx5_rxtx.h
+++ b/dpdk-17.11/drivers/net/mlx5/mlx5_rxtx.h
@@ -548,10 +548,12 @@ struct mlx5_mr *mlx5_txq_mp2mr_reg(struct mlx5_txq_data *, struct rte_mempool *,
struct mlx5_mr *mr;
assert(i < RTE_DIM(txq->mp2mr));
- if (likely(txq->mp2mr[i]->start <= addr && txq->mp2mr[i]->end >= addr))
+ if (likely(txq->mp2mr[i] != NULL &&
+ txq->mp2mr[i]->start <= addr && txq->mp2mr[i]->end >= addr))
return txq->mp2mr[i]->lkey;
for (i = 0; (i != RTE_DIM(txq->mp2mr)); ++i) {
- if (unlikely(txq->mp2mr[i]->mr == NULL)) {
+ if (unlikely(txq->mp2mr[i] == NULL ||
+ txq->mp2mr[i]->mr == NULL)) {
/* Unknown MP, add a new MR for it. */
break;
}
--
1.8.3.1