* [PATCH] nvme: map uring_cmd data even if address is 0
@ 2025-02-20 23:51 Xinyu Zhang
2025-02-20 23:58 ` Keith Busch
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Xinyu Zhang @ 2025-02-20 23:51 UTC (permalink / raw)
To: linux-nvme, linux-kernel
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Caleb Sander Mateos, Xinyu Zhang
When using kernel registered bvec fixed buffers, the "address" is
actually the offset into the bvec rather than userspace address.
Therefore it can be 0.
We can skip checking whether the address is NULL before mapping
uring_cmd data. Bad userspace address will be handled properly later when
the user buffer is imported.
With this patch, we will be able to use the kernel registered bvec fixed
buffers in io_uring NVMe passthru with ublk zero-copy support in
https://lore.kernel.org/io-uring/20250218224229.837848-1-kbusch@meta.com/T/#u.
Signed-off-by: Xinyu Zhang <xizhang@purestorage.com>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
---
drivers/nvme/host/ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 60383da86feda..724ab542b4c33 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -500,7 +500,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
return PTR_ERR(req);
req->timeout = d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0;
- if (d.addr && d.data_len) {
+ if (d.data_len) {
ret = nvme_map_user_request(req, d.addr,
d.data_len, nvme_to_user_ptr(d.metadata),
d.metadata_len, 0, ioucmd, vec);
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: map uring_cmd data even if address is 0
2025-02-20 23:51 [PATCH] nvme: map uring_cmd data even if address is 0 Xinyu Zhang
@ 2025-02-20 23:58 ` Keith Busch
2025-02-21 0:55 ` Jens Axboe
2025-02-24 14:33 ` Christoph Hellwig
2 siblings, 0 replies; 6+ messages in thread
From: Keith Busch @ 2025-02-20 23:58 UTC (permalink / raw)
To: Xinyu Zhang
Cc: linux-nvme, linux-kernel, Jens Axboe, Christoph Hellwig,
Sagi Grimberg, Caleb Sander Mateos
On Thu, Feb 20, 2025 at 04:51:01PM -0700, Xinyu Zhang wrote:
> When using kernel registered bvec fixed buffers, the "address" is
> actually the offset into the bvec rather than userspace address.
> Therefore it can be 0.
Nice, thanks for catching this.
I'm prepping a new ublk-zc version based on previous feedback. I'll add
this into the series once its ready, and I'm hoping by tomorrow.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: map uring_cmd data even if address is 0
2025-02-20 23:51 [PATCH] nvme: map uring_cmd data even if address is 0 Xinyu Zhang
2025-02-20 23:58 ` Keith Busch
@ 2025-02-21 0:55 ` Jens Axboe
2025-02-24 14:33 ` Christoph Hellwig
2 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2025-02-21 0:55 UTC (permalink / raw)
To: Xinyu Zhang, linux-nvme, linux-kernel
Cc: Keith Busch, Christoph Hellwig, Sagi Grimberg,
Caleb Sander Mateos
On 2/20/25 4:51 PM, Xinyu Zhang wrote:
> When using kernel registered bvec fixed buffers, the "address" is
> actually the offset into the bvec rather than userspace address.
> Therefore it can be 0.
> We can skip checking whether the address is NULL before mapping
> uring_cmd data. Bad userspace address will be handled properly later when
> the user buffer is imported.
> With this patch, we will be able to use the kernel registered bvec fixed
> buffers in io_uring NVMe passthru with ublk zero-copy support in
> https://lore.kernel.org/io-uring/20250218224229.837848-1-kbusch@meta.com/T/#u.
>
> Signed-off-by: Xinyu Zhang <xizhang@purestorage.com>
> Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
> ---
> drivers/nvme/host/ioctl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
> index 60383da86feda..724ab542b4c33 100644
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -500,7 +500,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
> return PTR_ERR(req);
> req->timeout = d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0;
>
> - if (d.addr && d.data_len) {
> + if (d.data_len) {
> ret = nvme_map_user_request(req, d.addr,
> d.data_len, nvme_to_user_ptr(d.metadata),
> d.metadata_len, 0, ioucmd, vec);
Looks good to me:
Reviewed-by: Jens Axboe <axboe@kernel.dk>
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: map uring_cmd data even if address is 0
2025-02-20 23:51 [PATCH] nvme: map uring_cmd data even if address is 0 Xinyu Zhang
2025-02-20 23:58 ` Keith Busch
2025-02-21 0:55 ` Jens Axboe
@ 2025-02-24 14:33 ` Christoph Hellwig
2025-02-24 14:54 ` Keith Busch
2 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2025-02-24 14:33 UTC (permalink / raw)
To: Xinyu Zhang
Cc: linux-nvme, linux-kernel, Keith Busch, Jens Axboe,
Christoph Hellwig, Sagi Grimberg, Caleb Sander Mateos
On Thu, Feb 20, 2025 at 04:51:01PM -0700, Xinyu Zhang wrote:
> When using kernel registered bvec fixed buffers, the "address" is
> actually the offset into the bvec rather than userspace address.
> Therefore it can be 0.
How is that actually going to work? Who is interpreting that address?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: map uring_cmd data even if address is 0
2025-02-24 14:33 ` Christoph Hellwig
@ 2025-02-24 14:54 ` Keith Busch
2025-02-24 16:04 ` Christoph Hellwig
0 siblings, 1 reply; 6+ messages in thread
From: Keith Busch @ 2025-02-24 14:54 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Xinyu Zhang, linux-nvme, linux-kernel, Jens Axboe, Sagi Grimberg,
Caleb Sander Mateos
On Mon, Feb 24, 2025 at 03:33:51PM +0100, Christoph Hellwig wrote:
> On Thu, Feb 20, 2025 at 04:51:01PM -0700, Xinyu Zhang wrote:
> > When using kernel registered bvec fixed buffers, the "address" is
> > actually the offset into the bvec rather than userspace address.
> > Therefore it can be 0.
>
> How is that actually going to work? Who is interpreting that address?
io_import_fixed() treats the address as an offset into its bio_vec.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: map uring_cmd data even if address is 0
2025-02-24 14:54 ` Keith Busch
@ 2025-02-24 16:04 ` Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2025-02-24 16:04 UTC (permalink / raw)
To: Keith Busch
Cc: Christoph Hellwig, Xinyu Zhang, linux-nvme, linux-kernel,
Jens Axboe, Sagi Grimberg, Caleb Sander Mateos
On Mon, Feb 24, 2025 at 07:54:59AM -0700, Keith Busch wrote:
> On Mon, Feb 24, 2025 at 03:33:51PM +0100, Christoph Hellwig wrote:
> > On Thu, Feb 20, 2025 at 04:51:01PM -0700, Xinyu Zhang wrote:
> > > When using kernel registered bvec fixed buffers, the "address" is
> > > actually the offset into the bvec rather than userspace address.
> > > Therefore it can be 0.
> >
> > How is that actually going to work? Who is interpreting that address?
>
> io_import_fixed() treats the address as an offset into its bio_vec.
Ah, yes. This is in nvme_uring_data and read from the SQE. I thought
we were further down.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-24 16:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 23:51 [PATCH] nvme: map uring_cmd data even if address is 0 Xinyu Zhang
2025-02-20 23:58 ` Keith Busch
2025-02-21 0:55 ` Jens Axboe
2025-02-24 14:33 ` Christoph Hellwig
2025-02-24 14:54 ` Keith Busch
2025-02-24 16:04 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox