From 3ab0271a03e49392018be33a06b3078559250a1c Mon Sep 17 00:00:00 2001 From: Juan Zhou Date: Tue, 25 Jul 2023 16:03:02 +0800 Subject: [PATCH] Two patchs are uploaded from rdma-core mainline 1.Remove unnecessary QP checks 2.Fix reference to uninitialized cq pointer Signed-off-by: Juan Zhou --- ...-libhns-Remove-unnecessary-QP-checks.patch | 64 +++++++++++++++++++ ...eference-to-uninitialized-cq-pointer.patch | 56 ++++++++++++++++ rdma-core.spec | 10 ++- 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 0051-libhns-Remove-unnecessary-QP-checks.patch create mode 100644 0052-libhns-Fix-reference-to-uninitialized-cq-pointer.patch diff --git a/0051-libhns-Remove-unnecessary-QP-checks.patch b/0051-libhns-Remove-unnecessary-QP-checks.patch new file mode 100644 index 0000000..e14b679 --- /dev/null +++ b/0051-libhns-Remove-unnecessary-QP-checks.patch @@ -0,0 +1,64 @@ +From 14e8bd8f4e30abdaabbe7ffc3a19e4381b4130fe Mon Sep 17 00:00:00 2001 +From: Chengchang Tang +Date: Wed, 24 May 2023 10:34:07 +0800 +Subject: [PATCH 1/2] libhns: Remove unnecessary QP checks + +mainline inclusion +from mainline-v47.0 +commit 4ea9a4f77ac8c174d1ae4cf551a2e5abea13516f +category: cleanup +bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I7NT3M +CVE: NA + +Reference: https://github.com/linux-rdma/rdma-core/commit/4ea9a4f77ac8c174d1ae4cf551a2e5abea13516f + +---------------------------------------------------------------------- + +It is not necessary to check the type of the queue on post_send and +post_recv since the QP type that cannot be supported will be rejected +when it is created. + +Check for srq in post_recv has also been removed, because the RQ of +QP bound to srq is empty and will return immediate error in post_recv. + +Besides, remove the unused parameter ctx. + +Signed-off-by: Chengchang Tang +Signed-off-by: Junxian Huang +Signed-off-by: Juan Zhou +--- + providers/hns/hns_roce_u_hw_v2.c | 11 +---------- + 1 file changed, 1 insertion(+), 10 deletions(-) + +diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c +index ee2fffe..688eff8 100644 +--- a/providers/hns/hns_roce_u_hw_v2.c ++++ b/providers/hns/hns_roce_u_hw_v2.c +@@ -908,11 +908,6 @@ static int check_qp_send(struct hns_roce_qp *qp, struct hns_roce_context *ctx) + struct ibv_qp *ibvqp = &qp->verbs_qp.qp; + int ret = 0; + +- if (unlikely(ibvqp->qp_type != IBV_QPT_RC && +- ibvqp->qp_type != IBV_QPT_UD) && +- ibvqp->qp_type != IBV_QPT_XRC_SEND) +- return -EINVAL; +- + if (unlikely(ibvqp->state == IBV_QPS_RESET || + ibvqp->state == IBV_QPS_INIT || + ibvqp->state == IBV_QPS_RTR)) +@@ -1516,11 +1511,7 @@ static int check_qp_recv(struct hns_roce_qp *qp, struct hns_roce_context *ctx) + struct ibv_qp *ibvqp = &qp->verbs_qp.qp; + int ret = 0; + +- if (unlikely(ibvqp->qp_type != IBV_QPT_RC && +- ibvqp->qp_type != IBV_QPT_UD)) +- return -EINVAL; +- +- if (ibvqp->state == IBV_QPS_RESET || ibvqp->srq) ++ if (ibvqp->state == IBV_QPS_RESET) + return -EINVAL; + + if (check_dca_attach_enable(qp)) { +-- +2.25.1 + diff --git a/0052-libhns-Fix-reference-to-uninitialized-cq-pointer.patch b/0052-libhns-Fix-reference-to-uninitialized-cq-pointer.patch new file mode 100644 index 0000000..94dd58c --- /dev/null +++ b/0052-libhns-Fix-reference-to-uninitialized-cq-pointer.patch @@ -0,0 +1,56 @@ +From e20de83892bcba8e8944cbf83e8acc9192d514bb Mon Sep 17 00:00:00 2001 +From: Chengchang Tang +Date: Mon, 3 Jul 2023 15:22:57 +0800 +Subject: [PATCH 2/2] libhns: Fix reference to uninitialized cq pointer + +mainline inclusion +from mainline-v47.0 +commit e850ebe1570c06990cc60e96d0085d5d2a1cfcaa +category: bugfix +bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I7NTLE +CVE: NA + +Reference: https://github.com/linux-rdma/rdma-core/commit/e850ebe1570c06990cc60e96d0085d5d2a1cfcaa + +---------------------------------------------------------------------- + +In cases such as using XRC and SRQ where RQs are not created, the recv_cq +pointer will not be initailized, and thus the unsupported post recv +function should return before referencing the recv_cq pointer. + +Fixes: 4ea9a4f77ac8 ("libhns: Remove unnecessary QP checks") +Signed-off-by: Chengchang Tang +Signed-off-by: Junxian Huang +Signed-off-by: Juan Zhou +--- + providers/hns/hns_roce_u_hw_v2.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c +index 688eff8..9238fe5 100644 +--- a/providers/hns/hns_roce_u_hw_v2.c ++++ b/providers/hns/hns_roce_u_hw_v2.c +@@ -1599,15 +1599,15 @@ static int hns_roce_u_v2_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, + + max_sge = qp->rq.max_gs - qp->rq.rsv_sge; + for (nreq = 0; wr; ++nreq, wr = wr->next) { +- if (hns_roce_v2_wq_overflow(&qp->rq, nreq, +- to_hr_cq(qp->verbs_qp.qp.recv_cq))) { +- ret = ENOMEM; ++ if (wr->num_sge > max_sge) { ++ ret = max_sge > 0 ? EINVAL : EOPNOTSUPP; + *bad_wr = wr; + goto out; + } + +- if (wr->num_sge > max_sge) { +- ret = EINVAL; ++ if (hns_roce_v2_wq_overflow(&qp->rq, nreq, ++ to_hr_cq(qp->verbs_qp.qp.recv_cq))) { ++ ret = ENOMEM; + *bad_wr = wr; + goto out; + } +-- +2.25.1 + diff --git a/rdma-core.spec b/rdma-core.spec index 07b220a..96355f3 100644 --- a/rdma-core.spec +++ b/rdma-core.spec @@ -1,6 +1,6 @@ Name: rdma-core Version: 41.0 -Release: 13 +Release: 14 Summary: RDMA core userspace libraries and daemons License: GPLv2 or BSD Url: https://github.com/linux-rdma/rdma-core @@ -56,6 +56,8 @@ Patch46: 0047-libhns-Fix-the-owner-bit-error-of-sq-in-new-io.patch Patch47: 0048-libhns-Fix-incorrect-post-send-with-direct-wqe-of-wr.patch Patch48: 0049-libhns-Add-a-judgment-to-the-congestion-control-algo.patch Patch49: 0050-libhns-Support-user-to-choose-using-UD-sl-or-pktype-.patch +Patch50: 0051-libhns-Remove-unnecessary-QP-checks.patch +Patch51: 0052-libhns-Fix-reference-to-uninitialized-cq-pointer.patch BuildRequires: binutils cmake >= 2.8.11 gcc libudev-devel pkgconfig pkgconfig(libnl-3.0) BuildRequires: pkgconfig(libnl-route-3.0) valgrind-devel systemd systemd-devel @@ -303,6 +305,12 @@ fi %{_mandir}/* %changelog +* Tue Jul 25 2023 Juan Zhou - 41.0-14 +- Type: bugfix +- ID: NA +- SUG: NA +- DESC: Two patchs are uploaded from rdma-core mainline + * Fri Jun 9 2023 Juan Zhou - 41.0-13 - Type: bugfix - ID: NA -- Gitee