@@ -393,6 +393,8 @@ enum {
#define IORING_OFF_PBUF_RING 0x80000000ULL
#define IORING_OFF_PBUF_SHIFT 16
#define IORING_OFF_MMAP_MASK 0xf8000000ULL
+#define IORING_OFF_RBUF_RING 0x20000000ULL
+#define IORING_OFF_RBUF_SHIFT 16
/*
* Filled with the offset for mmap(2)
@@ -3368,6 +3368,11 @@ static void *io_uring_validate_mmap_request(struct file *file,
return ERR_PTR(-EINVAL);
break;
}
+ case IORING_OFF_RBUF_RING:
+ if (!ctx->ifq)
+ return ERR_PTR(-EINVAL);
+ ptr = ctx->ifq->ring;
+ break;
default:
return ERR_PTR(-EINVAL);
}
@@ -34,6 +34,7 @@ int io_register_zc_rx_ifq(struct io_ring_ctx *ctx,
{
struct io_uring_zc_rx_ifq_reg reg;
struct io_zc_rx_ifq *ifq;
+ size_t ring_sz, rqes_sz, cqes_sz;
int ret;
if (copy_from_user(®, arg, sizeof(reg)))
@@ -58,6 +59,22 @@ int io_register_zc_rx_ifq(struct io_ring_ctx *ctx,
ifq->if_rxq_id = reg.if_rxq_id;
ctx->ifq = ifq;
+ ring_sz = sizeof(struct io_rbuf_ring);
+ rqes_sz = sizeof(struct io_uring_rbuf_rqe) * ifq->rq_entries;
+ cqes_sz = sizeof(struct io_uring_rbuf_cqe) * ifq->cq_entries;
+ reg.mmap_sz = ring_sz + rqes_sz + cqes_sz;
+ reg.rq_off.rqes = ring_sz;
+ reg.cq_off.cqes = ring_sz + rqes_sz;
+ reg.rq_off.head = offsetof(struct io_rbuf_ring, rq.head);
+ reg.rq_off.tail = offsetof(struct io_rbuf_ring, rq.tail);
+ reg.cq_off.head = offsetof(struct io_rbuf_ring, cq.head);
+ reg.cq_off.tail = offsetof(struct io_rbuf_ring, cq.tail);
+
+ if (copy_to_user(arg, ®, sizeof(reg))) {
+ ret = -EFAULT;
+ goto err;
+ }
+
return 0;
err:
io_zc_rx_ifq_free(ifq);