From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Jared Holzman <jholzman@nvidia.com>,
linux-rdma@vger.kernel.org,
"yanjun.zhu@linux.dev" <yanjun.zhu@linux.dev>
Subject: Re: [PATCH] rxe: Fix dma.length computation in wr_set_sge_list
Date: Sun, 31 May 2026 11:11:36 -0700 [thread overview]
Message-ID: <b3f1f416-5de4-4160-b6b2-2d5d3c2f690e@linux.dev> (raw)
In-Reply-To: <20260531120721.1347977-1-jholzman@nvidia.com>
在 2026/5/31 5:07, Jared Holzman 写道:
> wr_set_sge_list() summed the SGE lengths with a loop that never
> advanced sg_list:
Good catch! This is a clean and straightforward fix for a subtle but
high-impact bug in the Soft-RoCE (rxe) user-space provider.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
>
> while (num_sge--)
> tot_length += sg_list->length;
>
> so tot_length ended up as num_sge * sg_list[0].length instead of the
> true sum, and wqe->dma.length / wqe->dma.resid were written with that
> wrong value. The per-SGE entries themselves were unaffected because
> they are populated by the preceding memcpy().
>
> The kernel rxe driver requires dma.length == sum(sge[i].length) and
> enforces it in rxe_mr.c:copy_data(), so a multi-SGE WR posted through
> the ibv_qp_ex builder API (ibv_wr_set_sge_list) on rxe completes with
> IB_WC_LOC_PROT_ERR once finish_packet()/copy_data() runs off the end
> of the SGE list.
>
> The legacy ibv_post_send path (init_send_wqe) is unaffected; it sums
> the lengths with an indexed for loop.
>
> Fix by computing the total with an indexed loop, matching the style
> already used in rxe_post_one_recv() and init_send_wqe() in this file.
>
> Fixes: 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb")
> Signed-off-by: Jared Holzman <jholzman@nvidia.com>
> PR: https://github.com/linux-rdma/rdma-core/pull/1744
> ---
> providers/rxe/rxe.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c
> index 423f834b1..6d7be1493 100644
> --- a/providers/rxe/rxe.c
> +++ b/providers/rxe/rxe.c
> @@ -1138,6 +1138,7 @@ static void wr_set_sge_list(struct ibv_qp_ex *ibqp, size_t num_sge,
> struct rxe_send_wqe *wqe = addr_from_index(qp->sq.queue,
> qp->cur_index - 1);
> size_t tot_length = 0;
> + size_t i;
>
> if (qp->err)
> return;
> @@ -1150,8 +1151,8 @@ static void wr_set_sge_list(struct ibv_qp_ex *ibqp, size_t num_sge,
> wqe->dma.num_sge = num_sge;
> memcpy(wqe->dma.sge, sg_list, num_sge*sizeof(*sg_list));
>
> - while (num_sge--)
> - tot_length += sg_list->length;
> + for (i = 0; i < num_sge; i++)
> + tot_length += sg_list[i].length;
>
> wqe->dma.length = tot_length;
> wqe->dma.resid = tot_length;
next prev parent reply other threads:[~2026-05-31 18:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-31 12:07 [PATCH] rxe: Fix dma.length computation in wr_set_sge_list Jared Holzman
2026-05-31 18:11 ` Zhu Yanjun [this message]
2026-06-03 18:11 ` Jason Gunthorpe
2026-06-08 8:33 ` Jared Holzman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b3f1f416-5de4-4160-b6b2-2d5d3c2f690e@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=jholzman@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.