* [for-next v1 0/2] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes
@ 2026-11-18 15:23 Abhijit Gangurde
2026-11-18 15:23 ` [for-next v1 1/2] RDMA/ionic: Accept CQ ring buffers as ioctl " Abhijit Gangurde
2026-11-18 15:23 ` [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
0 siblings, 2 replies; 5+ messages in thread
From: Abhijit Gangurde @ 2026-11-18 15:23 UTC (permalink / raw)
To: jgg, leon
Cc: allen.hubbe, nikhil.agarwal, linux-rdma, linux-kernel,
Abhijit Gangurde
Let userspace hand ionic queue rings to create_cq and create_qp as
struct ib_uverbs_buffer_desc, instead of only as a raw address in the
driver request. A ring may be a virtual address or a page-aligned
slice of a dma-buf, so several rings can share one dma-buf.
The get_context bit IONIC_CTX_CMASK_CQ_QP_BUF_UMEM tells userspace it
may send the descriptors. ionic_cq_req and ionic_qp_req are unchanged,
so a provider that does not send them still uses the existing write
path and ib_umem_get_va.
Userspace: https://github.com/linux-rdma/rdma-core/pull/1862
Abhijit Gangurde (2):
RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes
RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
drivers/infiniband/hw/ionic/ionic_admin.c | 2 +-
.../infiniband/hw/ionic/ionic_controlpath.c | 183 +++++++++++++++---
drivers/infiniband/hw/ionic/ionic_ibdev.c | 17 ++
drivers/infiniband/hw/ionic/ionic_ibdev.h | 2 +
include/uapi/rdma/ionic-abi.h | 1 +
include/uapi/rdma/ionic_user_ioctl_cmds.h | 15 ++
6 files changed, 187 insertions(+), 33 deletions(-)
create mode 100644 include/uapi/rdma/ionic_user_ioctl_cmds.h
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [for-next v1 1/2] RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes
2026-11-18 15:23 [for-next v1 0/2] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes Abhijit Gangurde
@ 2026-11-18 15:23 ` Abhijit Gangurde
2026-11-18 15:54 ` sashiko-bot
2026-11-18 15:23 ` [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
1 sibling, 1 reply; 5+ messages in thread
From: Abhijit Gangurde @ 2026-11-18 15:23 UTC (permalink / raw)
To: jgg, leon
Cc: allen.hubbe, nikhil.agarwal, linux-rdma, linux-kernel,
Abhijit Gangurde
Userspace can now pass each enabled CQ ring to create_cq as a
struct ib_uverbs_buffer_desc in a per-UDMA driver attribute, instead
of only as a raw address in ionic_cq_req.
Advertise support with IONIC_CTX_CMASK_CQ_QP_BUF_UMEM in the get_context
response. Register two optional UVERBS_ATTR_UMEM attributes,
IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0 and _1, on UVERBS_METHOD_CQ_CREATE
through ibdev->driver_def.
For each UDMA index in udma_mask, ionic_cq_get_user_umem() resolves the
ring buffer:
- No attribute: pin req_cq->addr as before, with DMA_FROM_DEVICE.
- VA descriptor: desc.addr must equal req_cq->addr; pin as before.
- DMABUF descriptor: desc.addr is a page-aligned dma-buf offset; pin
req_cq->size bytes from desc.fd at that offset.
An attribute for a UDMA index that is not in udma_mask, or any other
buffer type, is rejected with -EINVAL. The kernel admin CQ path passes
no attribute bundle and is unchanged.
ionic_cq_req and ionic_cq_resp are not changed, so older providers
continue to use the write command path.
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
drivers/infiniband/hw/ionic/ionic_admin.c | 2 +-
.../infiniband/hw/ionic/ionic_controlpath.c | 89 ++++++++++++++++---
drivers/infiniband/hw/ionic/ionic_ibdev.c | 17 ++++
drivers/infiniband/hw/ionic/ionic_ibdev.h | 2 +
include/uapi/rdma/ionic-abi.h | 1 +
include/uapi/rdma/ionic_user_ioctl_cmds.h | 15 ++++
6 files changed, 114 insertions(+), 12 deletions(-)
create mode 100644 include/uapi/rdma/ionic_user_ioctl_cmds.h
diff --git a/drivers/infiniband/hw/ionic/ionic_admin.c b/drivers/infiniband/hw/ionic/ionic_admin.c
index 0ccd869ad8e6..67ce56acb4dc 100644
--- a/drivers/infiniband/hw/ionic/ionic_admin.c
+++ b/drivers/infiniband/hw/ionic/ionic_admin.c
@@ -575,7 +575,7 @@ static struct ionic_vcq *ionic_create_rdma_admincq(struct ionic_ibdev *dev,
vcq->udma_mask = 1;
cq = &vcq->cq[0];
- rc = ionic_create_cq_common(vcq, &buf, &attr, NULL, NULL,
+ rc = ionic_create_cq_common(vcq, &buf, &attr, NULL, NULL, NULL,
NULL, 0);
if (rc)
goto err_init;
diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 8a0a1575a339..11458262f280 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -73,11 +73,70 @@ static void ionic_put_cqid(struct ionic_ibdev *dev, u32 cqid)
ionic_resid_put(&dev->inuse_cqid, bitid);
}
+static const u16 ionic_cq_buf_attrs[] = {
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0,
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1,
+};
+
+static int ionic_cq_get_user_umem(struct ionic_ibdev *dev, struct ionic_cq *cq,
+ const struct ionic_qdesc *req_cq,
+ const struct uverbs_attr_bundle *attrs,
+ int udma_idx)
+{
+ struct ib_umem_dmabuf *umem_dmabuf;
+ struct ib_uverbs_buffer_desc desc;
+ struct ib_umem *umem;
+ u16 attr_id;
+ int rc;
+
+ if (udma_idx < 0 || udma_idx >= ARRAY_SIZE(ionic_cq_buf_attrs))
+ return -EINVAL;
+
+ attr_id = ionic_cq_buf_attrs[udma_idx];
+ if (attrs && uverbs_attr_is_valid(attrs, attr_id)) {
+ rc = uverbs_get_buffer_desc(attrs, attr_id, &desc);
+ if (rc)
+ return rc;
+
+ if (desc.length < req_cq->size)
+ return -EINVAL;
+
+ if (desc.type == IB_UVERBS_BUFFER_TYPE_DMABUF) {
+ if (desc.addr & (PAGE_SIZE - 1))
+ return -EINVAL;
+
+ umem_dmabuf = ib_umem_dmabuf_get_pinned(&dev->ibdev,
+ desc.addr,
+ req_cq->size,
+ desc.fd,
+ IB_ACCESS_LOCAL_WRITE);
+ if (IS_ERR(umem_dmabuf))
+ return PTR_ERR(umem_dmabuf);
+
+ cq->umem = &umem_dmabuf->umem;
+ return 0;
+ }
+
+ if (desc.type != IB_UVERBS_BUFFER_TYPE_VA ||
+ desc.addr != req_cq->addr)
+ return -EINVAL;
+ }
+
+ umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, req_cq->addr,
+ req_cq->size, IB_ACCESS_LOCAL_WRITE);
+ if (IS_ERR(umem))
+ return PTR_ERR(umem);
+
+ cq->umem = umem;
+ return 0;
+}
+
int ionic_create_cq_common(struct ionic_vcq *vcq,
struct ionic_tbl_buf *buf,
const struct ib_cq_init_attr *attr,
struct ionic_ctx *ctx,
struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs,
struct ionic_qdesc *req_cq,
int udma_idx)
{
@@ -110,13 +169,9 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
if (rc)
goto err_qdesc;
- cq->umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL,
- req_cq->addr, req_cq->size,
- IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(cq->umem)) {
- rc = PTR_ERR(cq->umem);
+ rc = ionic_cq_get_user_umem(dev, cq, req_cq, attrs, udma_idx);
+ if (rc)
goto err_qdesc;
- }
cq->q.ptr = NULL;
cq->q.size = req_cq->size;
@@ -428,7 +483,8 @@ int ionic_alloc_ucontext(struct ib_ucontext *ibctx, struct ib_udata *udata)
resp.udma_count = dev->lif_cfg.udma_count;
resp.expdb_mask = dev->lif_cfg.expdb_mask;
resp.rcq_sign_bit = dev->lif_cfg.rcq_sign_bit;
- resp.comp_mask |= IONIC_CTX_CMASK_IONIC_FLAGS;
+ resp.comp_mask |= IONIC_CTX_CMASK_IONIC_FLAGS |
+ IONIC_CTX_CMASK_CQ_QP_BUF_UMEM;
if (dev->lif_cfg.sq_expdb)
resp.expdb_qtypes |= IONIC_EXPDB_SQ;
@@ -1362,13 +1418,24 @@ int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
goto err_init;
}
- for (; udma_idx < dev->lif_cfg.udma_count; ++udma_idx) {
+ for (udma_idx = 0; udma_idx < ARRAY_SIZE(ionic_cq_buf_attrs);
+ udma_idx++) {
+ if (vcq->udma_mask & BIT(udma_idx))
+ continue;
+
+ if (uverbs_attr_is_valid(attrs, ionic_cq_buf_attrs[udma_idx])) {
+ rc = -EINVAL;
+ udma_idx = 0;
+ goto err_init;
+ }
+ }
+
+ for (udma_idx = 0; udma_idx < dev->lif_cfg.udma_count; ++udma_idx) {
if (!(vcq->udma_mask & BIT(udma_idx)))
continue;
- rc = ionic_create_cq_common(vcq, &buf, attr, ctx, udata,
- &req.cq[udma_idx],
- udma_idx);
+ rc = ionic_create_cq_common(vcq, &buf, attr, ctx, udata, attrs,
+ &req.cq[udma_idx], udma_idx);
if (rc)
goto err_init;
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.c b/drivers/infiniband/hw/ionic/ionic_ibdev.c
index b4d4544bb7ac..e64c8e891f30 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.c
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.c
@@ -11,6 +11,9 @@
#include "ionic_ibdev.h"
+#define UVERBS_MODULE_NAME ionic_rdma
+#include <rdma/uverbs_named_ioctl.h>
+
#define DRIVER_DESCRIPTION "AMD Pensando RoCE HCA driver"
#define DEVICE_DESCRIPTION "AMD Pensando RoCE HCA"
@@ -217,6 +220,18 @@ static void ionic_disassociate_ucontext(struct ib_ucontext *ibcontext)
*/
}
+ADD_UVERBS_ATTRIBUTES_SIMPLE(
+ ionic_cq_create,
+ UVERBS_OBJECT_CQ,
+ UVERBS_METHOD_CQ_CREATE,
+ UVERBS_ATTR_UMEM(IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0, UA_OPTIONAL),
+ UVERBS_ATTR_UMEM(IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1, UA_OPTIONAL));
+
+static const struct uapi_definition ionic_uapi_defs[] = {
+ UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_CQ, &ionic_cq_create),
+ {},
+};
+
static const struct ib_device_ops ionic_dev_ops = {
.owner = THIS_MODULE,
.driver_id = RDMA_DRIVER_IONIC,
@@ -376,6 +391,8 @@ static struct ionic_ibdev *ionic_create_ibdev(struct ionic_aux_dev *ionic_adev)
ionic_stats_init(dev);
+ ibdev->driver_def = ionic_uapi_defs;
+
rc = ib_register_device(ibdev, "ionic_%d", ibdev->dev.parent);
if (rc)
goto err_register;
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
index 127b79cdfc45..b25fe2f6c4b1 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.h
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
@@ -10,6 +10,7 @@
#include <rdma/uverbs_ioctl.h>
#include <rdma/ionic-abi.h>
+#include <rdma/ionic_user_ioctl_cmds.h>
#include <ionic_api.h>
#include <ionic_regs.h>
@@ -491,6 +492,7 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
const struct ib_cq_init_attr *attr,
struct ionic_ctx *ctx,
struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs,
struct ionic_qdesc *req_cq,
int udma_idx);
int ionic_post_create_cq_cmd(struct ionic_cq *cq,
diff --git a/include/uapi/rdma/ionic-abi.h b/include/uapi/rdma/ionic-abi.h
index ac48fcd19a4f..f503552bf23a 100644
--- a/include/uapi/rdma/ionic-abi.h
+++ b/include/uapi/rdma/ionic-abi.h
@@ -24,6 +24,7 @@
enum ionic_ctx_resp_comp_mask {
IONIC_CTX_CMASK_IONIC_FLAGS = 1 << 0,
+ IONIC_CTX_CMASK_CQ_QP_BUF_UMEM = 1 << 1,
};
struct ionic_ctx_req {
diff --git a/include/uapi/rdma/ionic_user_ioctl_cmds.h b/include/uapi/rdma/ionic_user_ioctl_cmds.h
new file mode 100644
index 000000000000..98bb8d7238e6
--- /dev/null
+++ b/include/uapi/rdma/ionic_user_ioctl_cmds.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* Copyright (C) 2026, Advanced Micro Devices, Inc */
+
+#ifndef IONIC_USER_IOCTL_CMDS_H
+#define IONIC_USER_IOCTL_CMDS_H
+
+#include <linux/types.h>
+#include <rdma/ib_user_ioctl_cmds.h>
+
+enum ionic_ib_create_cq_attrs {
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0 = UVERBS_ID_DRIVER_NS_WITH_UHW,
+ IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_1,
+};
+
+#endif
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
2026-11-18 15:23 [for-next v1 0/2] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes Abhijit Gangurde
2026-11-18 15:23 ` [for-next v1 1/2] RDMA/ionic: Accept CQ ring buffers as ioctl " Abhijit Gangurde
@ 2026-11-18 15:23 ` Abhijit Gangurde
2026-11-18 15:51 ` sashiko-bot
1 sibling, 1 reply; 5+ messages in thread
From: Abhijit Gangurde @ 2026-11-18 15:23 UTC (permalink / raw)
To: jgg, leon
Cc: allen.hubbe, nikhil.agarwal, linux-rdma, linux-kernel,
Abhijit Gangurde
Userspace passes each QP ring to create_qp as a
struct ib_uverbs_buffer_desc on the core attributes
UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM and
UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM. Those attributes are already
optional on UVERBS_METHOD_QP_CREATE. The get_context bit
IONIC_CTX_CMASK_CQ_QP_BUF_UMEM tells userspace it may send them.
ionic_get_user_q_umem() resolves one ring:
- No attribute: validate the qdesc address and pin it with
ib_umem_get_va, as before.
- VA descriptor: length equals the qdesc size and the address matches
the qdesc; pin through ib_umem_get_attr_or_va.
- DMABUF descriptor: qdesc.addr is zero. Check queue geometry only,
require a page-aligned dma-buf offset, and pin through
ib_umem_get_attr_or_va.
Any other descriptor is -EINVAL. Access is 0, so the VA mapping
direction stays DMA_TO_DEVICE. SRQ creation passes no attribute
bundle and keeps ib_umem_get_va. An SRQ QP still only checks that
the RQ qdesc is zero.
ionic_qp_req is not changed, so a provider that does not send the
attributes still creates a QP on the write path.
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
.../infiniband/hw/ionic/ionic_controlpath.c | 94 ++++++++++++++-----
1 file changed, 73 insertions(+), 21 deletions(-)
diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 11458262f280..02f1972126ed 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -14,13 +14,9 @@
#define ionic_set_ecn(tos) (((tos) | 2u) & ~1u)
#define ionic_clear_ecn(tos) ((tos) & ~3u)
-static int ionic_validate_qdesc(struct ionic_qdesc *q)
+static int ionic_validate_qdesc_geom(struct ionic_qdesc *q)
{
- if (!q->addr || !q->size || !q->mask ||
- !q->depth_log2 || !q->stride_log2)
- return -EINVAL;
-
- if (q->addr & (PAGE_SIZE - 1))
+ if (!q->size || !q->mask || !q->depth_log2 || !q->stride_log2)
return -EINVAL;
if (q->mask != BIT(q->depth_log2) - 1)
@@ -32,6 +28,14 @@ static int ionic_validate_qdesc(struct ionic_qdesc *q)
return 0;
}
+static int ionic_validate_qdesc(struct ionic_qdesc *q)
+{
+ if (!q->addr || (q->addr & (PAGE_SIZE - 1)))
+ return -EINVAL;
+
+ return ionic_validate_qdesc_geom(q);
+}
+
static u32 ionic_get_eqid(struct ionic_ibdev *dev, u32 comp_vector, u8 udma_idx)
{
/* EQ per vector per udma, and the first eqs reserved for async events.
@@ -1993,10 +1997,57 @@ static void ionic_qp_sq_destroy_cmb(struct ionic_ibdev *dev,
ionic_put_cmb(dev->lif_cfg.lif, qp->sq_cmb_pgid, qp->sq_cmb_order);
}
+static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q,
+ const struct uverbs_attr_bundle *attrs,
+ u16 attr_id, struct ib_umem **umem_out)
+{
+ struct ib_uverbs_buffer_desc desc;
+ struct ib_umem *umem;
+ int rc;
+
+ if (attrs && uverbs_attr_is_valid(attrs, attr_id)) {
+ rc = uverbs_get_buffer_desc(attrs, attr_id, &desc);
+ if (rc)
+ return rc;
+
+ if (desc.length != q->size)
+ return -EINVAL;
+
+ if (desc.type == IB_UVERBS_BUFFER_TYPE_DMABUF) {
+ if (desc.addr & (PAGE_SIZE - 1))
+ return -EINVAL;
+
+ rc = ionic_validate_qdesc_geom(q);
+ } else if (desc.type == IB_UVERBS_BUFFER_TYPE_VA &&
+ desc.addr == q->addr) {
+ rc = ionic_validate_qdesc(q);
+ } else {
+ rc = -EINVAL;
+ }
+ if (rc)
+ return rc;
+
+ umem = ib_umem_get_attr_or_va(&dev->ibdev, attrs, attr_id,
+ q->addr, q->size, 0);
+ } else {
+ rc = ionic_validate_qdesc(q);
+ if (rc)
+ return rc;
+
+ umem = ib_umem_get_va(&dev->ibdev, q->addr, q->size, 0);
+ }
+ if (IS_ERR(umem))
+ return PTR_ERR(umem);
+
+ *umem_out = umem;
+ return 0;
+}
+
static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
struct ionic_qp *qp, struct ionic_qdesc *sq,
struct ionic_tbl_buf *buf, int max_wr, int max_sge,
- int max_data, int sq_spec, struct ib_udata *udata)
+ int max_data, int sq_spec, struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs)
{
u32 wqe_size;
int rc = 0;
@@ -2040,7 +2091,9 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
return rc;
if (udata) {
- rc = ionic_validate_qdesc(sq);
+ rc = ionic_get_user_q_umem(dev, sq, attrs,
+ UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM,
+ &qp->sq_umem);
if (rc)
return rc;
@@ -2054,10 +2107,6 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
qp->sq_meta = NULL;
qp->sq_msn_idx = NULL;
-
- qp->sq_umem = ib_umem_get_va(&dev->ibdev, sq->addr, sq->size, 0);
- if (IS_ERR(qp->sq_umem))
- return PTR_ERR(qp->sq_umem);
} else {
qp->sq_umem = NULL;
@@ -2260,7 +2309,8 @@ static void ionic_rq_destroy_cmb(struct ionic_ibdev *dev,
static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
struct ionic_rq *rq, struct ionic_qdesc *qdesc,
struct ionic_tbl_buf *buf, int max_wr, int max_sge,
- int rq_spec, struct ib_udata *udata)
+ int rq_spec, struct ib_udata *udata,
+ const struct uverbs_attr_bundle *attrs)
{
u32 wqe_size;
int rc = 0;
@@ -2278,7 +2328,9 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
return rc;
if (udata) {
- rc = ionic_validate_qdesc(qdesc);
+ rc = ionic_get_user_q_umem(dev, qdesc, attrs,
+ UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM,
+ &rq->umem);
if (rc)
return rc;
@@ -2291,10 +2343,6 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,
rq->q.stride_log2 = qdesc->stride_log2;
rq->meta = NULL;
-
- rq->umem = ib_umem_get_va(&dev->ibdev, qdesc->addr, qdesc->size, 0);
- if (IS_ERR(rq->umem))
- return PTR_ERR(rq->umem);
} else {
rq->umem = NULL;
@@ -2380,6 +2428,7 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
struct ionic_qp *qp = to_ionic_qp(ibqp);
struct ionic_ctx *ctx =
rdma_udata_to_drv_context(udata, struct ionic_ctx, ibctx);
+ const struct uverbs_attr_bundle *attrs = NULL;
struct ionic_qp_resp resp = {};
struct ionic_qp_req req = {};
struct ionic_cq *cq;
@@ -2388,6 +2437,8 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
int rc;
if (udata) {
+ attrs = rdma_udata_to_uverbs_attr_bundle(udata);
+
rc = ib_copy_validate_udata_in(udata, req, rsvd);
if (rc)
return rc;
@@ -2466,7 +2517,8 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
rc = ionic_qp_sq_init(dev, ctx, qp, &req.sq, &sq_buf,
attr->cap.max_send_wr, attr->cap.max_send_sge,
- attr->cap.max_inline_data, req.sq_spec, udata);
+ attr->cap.max_inline_data, req.sq_spec, udata,
+ attrs);
if (rc)
goto err_sq;
@@ -2485,7 +2537,7 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
qp->rq.qid = qp->qpid;
rc = ionic_rq_init(dev, ctx, &qp->rq, &req.rq, &rq_buf,
attr->cap.max_recv_wr, attr->cap.max_recv_sge,
- req.rq_spec, udata);
+ req.rq_spec, udata, attrs);
}
if (rc)
goto err_rq;
@@ -3092,7 +3144,7 @@ int ionic_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *attr,
rc = ionic_rq_init(dev, ctx, &srq->rq, &req.rq, &buf,
attr->attr.max_wr, attr->attr.max_sge,
- req.rq_spec, udata);
+ req.rq_spec, udata, NULL);
if (rc)
return rc;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
2026-11-18 15:23 ` [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
@ 2026-11-18 15:51 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-18 15:51 UTC (permalink / raw)
To: Abhijit Gangurde; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] RDMA/ionic: double-fetch of buffer descriptor in
ionic_get_user_q_umem()
- [Medium] RDMA/ionic: missing DMABUF addr==0 handling in CQ and QP
qdesc validation
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] RDMA/ionic: validation bypass via undefined behavior in
ionic_validate_qdesc() [1]
--
commit 2a0ba584011ea872720029ef7dae9322c2160a45
Author: Abhijit Gangurde <abhijit.gangurde@amd.com>
RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem attributes
This commit adds support for pinning QP SQ and RQ rings from the
UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM and UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM
ioctl buffer descriptor attributes, splitting queue geometry validation into
ionic_validate_qdesc_geom() for dma-buf descriptors.
> diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
> index 11458262f280d..02f1972126ed0 100644
> --- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
> +++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
> @@ -14,13 +14,9 @@
> #define ionic_set_ecn(tos) (((tos) | 2u) & ~1u)
> #define ionic_clear_ecn(tos) ((tos) & ~3u)
>
> -static int ionic_validate_qdesc(struct ionic_qdesc *q)
> +static int ionic_validate_qdesc_geom(struct ionic_qdesc *q)
> {
> - if (!q->addr || !q->size || !q->mask ||
> - !q->depth_log2 || !q->stride_log2)
> - return -EINVAL;
> -
> - if (q->addr & (PAGE_SIZE - 1))
> + if (!q->size || !q->mask || !q->depth_log2 || !q->stride_log2)
> return -EINVAL;
>
> if (q->mask != BIT(q->depth_log2) - 1)
> @@ -32,6 +28,14 @@ static int ionic_validate_qdesc(struct ionic_qdesc *q)
> return 0;
> }
>
> +static int ionic_validate_qdesc(struct ionic_qdesc *q)
> +{
> + if (!q->addr || (q->addr & (PAGE_SIZE - 1)))
> + return -EINVAL;
> +
> + return ionic_validate_qdesc_geom(q);
> +}
[Severity: Critical]
This problem wasn't introduced by this patch, but can a user bypass the queue
size check in ionic_validate_qdesc_geom() [1] when q->depth_log2 +
q->stride_log2 is 64 or greater?
drivers/infiniband/hw/ionic/ionic_controlpath.c:ionic_validate_qdesc_geom() {
...
if (q->size < BIT_ULL(q->depth_log2 + q->stride_log2))
return -EINVAL;
return 0;
}
Neither q->depth_log2 nor q->stride_log2 is bounded before the shift, so a
sum of 64 or more triggers shift undefined behavior (wrapping the shift count
modulo 64 on x86_64) and lets a small q->size pass validation before the
out-of-bounds queue parameters are sent to firmware.
> @@ -1993,10 +1997,57 @@ static void ionic_qp_sq_destroy_cmb(struct ionic_ibdev *dev,
> ionic_put_cmb(dev->lif_cfg.lif, qp->sq_cmb_pgid, qp->sq_cmb_order);
> }
>
> +static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q,
> + const struct uverbs_attr_bundle *attrs,
> + u16 attr_id, struct ib_umem **umem_out)
> +{
> + struct ib_uverbs_buffer_desc desc;
> + struct ib_umem *umem;
> + int rc;
> +
> + if (attrs && uverbs_attr_is_valid(attrs, attr_id)) {
> + rc = uverbs_get_buffer_desc(attrs, attr_id, &desc);
> + if (rc)
> + return rc;
> +
> + if (desc.length != q->size)
> + return -EINVAL;
> +
> + if (desc.type == IB_UVERBS_BUFFER_TYPE_DMABUF) {
> + if (desc.addr & (PAGE_SIZE - 1))
> + return -EINVAL;
> +
> + rc = ionic_validate_qdesc_geom(q);
[Severity: Medium]
Should the IB_UVERBS_BUFFER_TYPE_DMABUF branch also reject non-zero q->addr,
and does CQ creation need the same qdesc handling when req_cq->addr is zero?
The commit message notes that qdesc.addr is zero for a dma-buf descriptor,
which is why ionic_validate_qdesc_geom() is split out here, but this branch
does not check that q->addr is zero. Meanwhile, ionic_create_cq_common() in
commit "RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes" still
calls ionic_validate_qdesc(req_cq) unconditionally before
ionic_cq_get_user_umem():
drivers/infiniband/hw/ionic/ionic_controlpath.c:ionic_create_cq_common() {
...
if (udata) {
rc = ionic_validate_qdesc(req_cq);
if (rc)
goto err_qdesc;
rc = ionic_cq_get_user_umem(dev, cq, req_cq, attrs, udma_idx);
...
}
Because ionic_validate_qdesc() rejects !q->addr, creating a dma-buf CQ with
req_cq->addr set to 0 always fails with -EINVAL.
> + } else if (desc.type == IB_UVERBS_BUFFER_TYPE_VA &&
> + desc.addr == q->addr) {
> + rc = ionic_validate_qdesc(q);
> + } else {
> + rc = -EINVAL;
> + }
> + if (rc)
> + return rc;
> +
> + umem = ib_umem_get_attr_or_va(&dev->ibdev, attrs, attr_id,
> + q->addr, q->size, 0);
[Severity: Medium]
Does calling ib_umem_get_attr_or_va() here re-fetch struct
ib_uverbs_buffer_desc from user memory after desc has already been validated?
UVERBS_ATTR_UMEM is defined without UA_ALLOC_AND_COPY and struct
ib_uverbs_buffer_desc is 32 bytes (not inline), so ib_umem_get_attr_or_va()
-> ib_umem_resolve_desc() -> uverbs_get_buffer_desc() performs a second
copy_from_user() of the descriptor and only checks that umem->length >=
q->size. A concurrent userspace thread modifying the descriptor between the
two reads can bypass the checks on desc.addr page alignment, desc.length ==
q->size, and desc.type, programming firmware with a mismatched or unaligned
ring mapping. Pinning the validated local descriptor via
ib_umem_get_desc(&dev->ibdev, &desc, 0) would avoid the second copy.
[1] https://sashiko.dev/#/bug/linux-f6f7b3eb-a66a-4c37-9e7c-001f6bd900bf
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118152313.113714-1-abhijit.gangurde@amd.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [for-next v1 1/2] RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes
2026-11-18 15:23 ` [for-next v1 1/2] RDMA/ionic: Accept CQ ring buffers as ioctl " Abhijit Gangurde
@ 2026-11-18 15:54 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-18 15:54 UTC (permalink / raw)
To: Abhijit Gangurde; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] RDMA/ionic: DMABUF CQ creation fails when req_cq->addr is 0
--
commit d9049031ddccb7cfb004f9f8562a0180d2a52483
Author: Abhijit Gangurde <abhijit.gangurde@amd.com>
RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes
This commit adds optional per-UDMA UVERBS_ATTR_UMEM attributes to
UVERBS_METHOD_CQ_CREATE so userspace can pass CQ ring buffers as VA or
DMABUF descriptors.
> diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
> index 8a0a1575a339c..11458262f280d 100644
> --- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
> +++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
[ ... ]
> @@ -110,13 +169,9 @@ int ionic_create_cq_common(struct ionic_vcq *vcq,
> if (rc)
> goto err_qdesc;
>
> - cq->umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL,
> - req_cq->addr, req_cq->size,
> - IB_ACCESS_LOCAL_WRITE);
> - if (IS_ERR(cq->umem)) {
> - rc = PTR_ERR(cq->umem);
> + rc = ionic_cq_get_user_umem(dev, cq, req_cq, attrs, udma_idx);
> + if (rc)
> goto err_qdesc;
> - }
[Severity: High]
Does DMABUF CQ creation fail with -EINVAL when userspace passes
req_cq->addr == 0?
ionic_create_cq_common() calls ionic_validate_qdesc(req_cq) before
ionic_cq_get_user_umem():
drivers/infiniband/hw/ionic/ionic_controlpath.c:ionic_validate_qdesc() {
if (!q->addr || !q->size || !q->mask ||
!q->depth_log2 || !q->stride_log2)
return -EINVAL;
...
}
For IB_UVERBS_BUFFER_TYPE_DMABUF, the ring buffer is specified by desc.fd
and desc.addr while req_cq->addr is unused and expected to be zero (as in
the follow-up commit "RDMA/ionic: Accept QP SQ and RQ rings as ioctl umem
attributes", which validates only queue geometry for DMABUF descriptors),
so ionic_validate_qdesc() rejects the request before reaching
ionic_cq_get_user_umem().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118152313.113714-1-abhijit.gangurde@amd.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-18 15:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 15:23 [for-next v1 0/2] RDMA/ionic: Accept CQ, SQ, and RQ rings as umem attributes Abhijit Gangurde
2026-11-18 15:23 ` [for-next v1 1/2] RDMA/ionic: Accept CQ ring buffers as ioctl " Abhijit Gangurde
2026-11-18 15:54 ` sashiko-bot
2026-11-18 15:23 ` [for-next v1 2/2] RDMA/ionic: Accept QP SQ and RQ rings " Abhijit Gangurde
2026-11-18 15:51 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox