| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/07 01:56 | flow | patch-triage |
31mArgs:null Results: {
"EnableConfigs": [
"IO_URING",
"DMA_SHARED_BUFFER",
"BLK_DEV_NVME",
"DMABUF_HEAPS",
"DMABUF_HEAPS_SYSTEM",
"UDMABUF",
"BLK_DEV_DM"
],
"FocusSymbols": [
"io_register_dmabuf",
"io_register_rsrc_update",
"io_sqe_buffers_register",
"__io_import_reg_buf",
"io_read_fixed",
"io_write_fixed",
"bio_iov_iter_set",
"bio_split_io_at",
"nvme_rq_setup_dmabuf",
"__nvme_init_dma_buf_io_ctx",
"__nvme_pci_remove_dmabuf"
],
"KMSANReasoning": "The patch series adds support for direct I/O to/from DMA-BUF memory in io_uring, the block layer, and the NVMe PCIe driver.\n\nEvaluating KMSAN applicability:\n1. Kernel-to-user info-leaks: No kernel structures are copied or leaked to user space (no copy_to_user, put_user, netlink skbs, etc.). The new UAPI structs (such as struct io_uring_regbuf_desc and io_uring_rsrc_update2) are only copied from user space to kernel space.\n2. Uninitialized memory reads/branches: All newly introduced or modified kernel structures on the stack and heap are fully initialized or zeroed:\n - io_files_update zeroes `up2` via memset(\u0026up2, 0, sizeof(up2)).\n - io_iov_to_regbuf_desc zeroes unspecified fields via C99 compound literal initialization.\n - io_register_dmabuf allocates `bd` via kzalloc.\n - io_register_dmabuf_desc zeroes `imu` via memset(imu, 0, sizeof(*imu)).\n - nvme_init_io_ctx_locked allocates `nvme_ctx` via kzalloc_obj.\n - In nvme_dma_buf_io_map, struct nvme_dmabuf_map has all struct fields initialized before use.\n - No conditional branches or control flow rely on uninitialized memory.\n\nEvaluating KASAN / LOCKDEP applicability:\nThe primary failure modes introduced by this patch series involve DMA buffer lifetime management (dma_buf attachment/detachment, refcounts, use-after-free), scatterlist and segment index calculations (potential out-of-bounds accesses in map-\u003edma_list or sg_list descriptors), and lock ordering (buf_list-\u003elock and dma-resv locks). These issues are thoroughly covered by standard KASAN, LOCKDEP, and standard bug detectors.\n\nTherefore, there is no risk of uninitialized memory use that would justify spawning an expensive dedicated KMSAN fuzzing session.",
"NeedsKMSAN": false,
"Reasoning": "The patch introduces support for dma-buf backed fixed buffers in io_uring, the block layer, and NVMe PCI host driver. It adds new registration logic (IORING_RSRC_UPDATE_EXTENDED, IO_REGBUF_TYPE_DMABUF), bio cloning/splitting adjustments for dma-buf bios, and NVMe request PRP/SGL construction from dma-buf scatterlists. These changes modify core reachable subsystems (io_uring, block layer) and QEMU-emulated hardware drivers (NVMe PCI). Fuzzing is warranted to uncover boundary issues, lifecycle bugs, and regressions in fixed buffer and bio iter handling.",
"WorthFuzzing": true
} |
| 1/1 | 2026/10/07 01:56 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 94b94c945655f70393579916fdfa996691884372\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Wed Oct 7 01:56:37 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/block/bio.c b/block/bio.c\nindex b48091c7663fa..1e0d9714c5413 100644\n--- a/block/bio.c\n+++ b/block/bio.c\n@@ -881,7 +881,11 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)\n \tbio-\u003ebi_write_stream = bio_src-\u003ebi_write_stream;\n \tbio-\u003ebi_bvec_gap_bit = bio_src-\u003ebi_bvec_gap_bit;\n \tbio-\u003ebi_iter = bio_src-\u003ebi_iter;\n-\tbio-\u003ebi_io_vec = bio_src-\u003ebi_io_vec;\n+\n+\tif (op_is_dmabuf(bio-\u003ebi_opf))\n+\t\tbio-\u003ebi_dmabuf_map = bio_src-\u003ebi_dmabuf_map;\n+\telse\n+\t\tbio-\u003ebi_io_vec = bio_src-\u003ebi_io_vec;\n \n \tif (bio-\u003ebi_bdev) {\n \t\tif (bio-\u003ebi_bdev == bio_src-\u003ebi_bdev \u0026\u0026\n@@ -1204,16 +1208,23 @@ EXPORT_SYMBOL_GPL(__bio_release_pages);\n \n bool bio_iov_iter_set(struct bio *bio, const struct iov_iter *iter)\n {\n-\tif (!iov_iter_is_bvec(iter))\n+\tif (!iov_iter_is_bvec(iter) \u0026\u0026 !iov_iter_is_dmabuf_map(iter))\n \t\treturn false;\n \n \tWARN_ON_ONCE(bio-\u003ebi_max_vecs);\n \n+\tstatic_assert(offsetof(struct bio, bi_io_vec) ==\n+\t\t offsetof(struct bio, bi_dmabuf_map));\n+\tstatic_assert(offsetof(struct iov_iter, bvec) ==\n+\t\t offsetof(struct iov_iter, dmabuf_map));\n+\n \tbio-\u003ebi_io_vec = (struct bio_vec *)iter-\u003ebvec;\n \tbio-\u003ebi_iter.bi_idx = 0;\n \tbio-\u003ebi_iter.bi_offset = iter-\u003eiov_offset;\n \tbio-\u003ebi_iter.bi_size = iov_iter_count(iter);\n \tbio_set_flag(bio, BIO_CLONED);\n+\tif (iov_iter_is_dmabuf_map(iter))\n+\t\tbio-\u003ebi_opf |= REQ_NOMERGE | REQ_DMABUF;\n \treturn true;\n }\n \ndiff --git a/block/blk-merge.c b/block/blk-merge.c\nindex 258a726071d12..18f014ff3314b 100644\n--- a/block/blk-merge.c\n+++ b/block/blk-merge.c\n@@ -9,6 +9,7 @@\n #include \u003clinux/blk-integrity.h\u003e\n #include \u003clinux/part_stat.h\u003e\n #include \u003clinux/blk-cgroup.h\u003e\n+#include \u003clinux/dma-buf-io.h\u003e\n \n #include \u003ctrace/events/block.h\u003e\n \n@@ -319,6 +320,41 @@ static inline unsigned int bvec_seg_gap(struct bio_vec *bvprv,\n \treturn bv-\u003ebv_offset | (bvprv-\u003ebv_offset + bvprv-\u003ebv_len);\n }\n \n+static inline int bio_split_io_at_dmabuf(struct bio *bio,\n+\t\tconst struct queue_limits *lim, unsigned *segs,\n+\t\tunsigned max_bytes, unsigned len_align_mask,\n+\t\tunsigned start_align_mask)\n+{\n+\tunsigned bytes = min(bio-\u003ebi_iter.bi_size, max_bytes);\n+\tunsigned seg_shift = bio-\u003ebi_dmabuf_map-\u003emin_seg_shift;\n+\tunsigned offset = bio-\u003ebi_iter.bi_offset \u0026 ((1U \u003c\u003c seg_shift) - 1);\n+\tu64 max_segs_bytes;\n+\n+\t/*\n+\t * dma-buf maps don't expose the underlying segmentation, but they're\n+\t * guaranteed to not have alignment gaps, we only need to check the\n+\t * start and length alignment.\n+\t */\n+\tif ((bio-\u003ebi_iter.bi_offset \u0026 start_align_mask) ||\n+\t (bio-\u003ebi_iter.bi_size \u0026 len_align_mask))\n+\t\treturn -EINVAL;\n+\n+\t/* Presented as a single contiguous range into the dma-buf */\n+\t*segs = 1;\n+\n+\t/*\n+\t * Limit by the number of segments by using the minimal segment size.\n+\t * Any I/O consisting of N full segments should be able to cover at\n+\t * least N multiplied by the segment size. It's stricter than walking\n+\t * the segments and might cause extra splitting.\n+\t */\n+\tmax_segs_bytes = (u64)lim-\u003emax_segments \u003c\u003c seg_shift;\n+\tbytes = min_t(u64, bytes, max_segs_bytes - offset);\n+\tif (bytes != bio-\u003ebi_iter.bi_size)\n+\t\treturn bytes;\n+\treturn 0;\n+}\n+\n /**\n * bio_split_io_at - check if and where to split a bio\n * @bio: [in] bio to be split\n@@ -346,6 +382,19 @@ int bio_split_io_at(struct bio *bio, const struct queue_limits *lim,\n \t\tlen_align_mask |= (bc-\u003ebc_key-\u003ecrypto_cfg.data_unit_size - 1);\n \t}\n \n+\tif (op_is_dmabuf(bio-\u003ebi_opf)) {\n+\t\tint ret;\n+\n+\t\tret = bio_split_io_at_dmabuf(bio, lim, \u0026nsegs, max_bytes,\n+\t\t\t\t\t len_align_mask, start_align_mask);\n+\t\tif (ret \u003c 0)\n+\t\t\treturn ret;\n+\t\tif (!ret)\n+\t\t\tgoto out;\n+\t\tbytes = ret;\n+\t\tgoto split;\n+\t}\n+\n \tbio_for_each_bvec(bv, bio, iter) {\n \t\tif (bv.bv_offset \u0026 start_align_mask ||\n \t\t bv.bv_len \u0026 len_align_mask)\n@@ -376,6 +425,7 @@ int bio_split_io_at(struct bio *bio, const struct queue_limits *lim,\n \t\tbvprvp = \u0026bvprv;\n \t}\n \n+out:\n \t*segs = nsegs;\n \tbio-\u003ebi_bvec_gap_bit = ffs(gaps);\n \treturn 0;\ndiff --git a/block/fops.c b/block/fops.c\nindex 9905ed24a1578..e9da48ab73be6 100644\n--- a/block/fops.c\n+++ b/block/fops.c\n@@ -362,7 +362,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,\n \t * Users don't rely on the iterator being in any particular\n \t * state for async I/O returning -EIOCBQUEUED, hence we can\n \t * avoid expensive iov_iter_advance(). Bypass\n-\t * bio_iov_iter_get_pages() and set the bvec directly.\n+\t * bio_iov_iter_get_pages() and set the bvec/dmabuf directly.\n \t */\n \tif (!bio_iov_iter_set(bio, iter)) {\n \t\tret = blkdev_iov_iter_get_pages(bio, iter, bdev);\n@@ -730,6 +730,9 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from)\n \n static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from)\n {\n+\tif (unlikely(iov_iter_is_dmabuf_map(from)))\n+\t\treturn -EOPNOTSUPP;\n+\n \treturn iomap_file_buffered_write(iocb, from, \u0026blkdev_iomap_ops, NULL,\n \t\t\tNULL);\n }\n@@ -855,6 +858,11 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)\n \t\tif (ret \u003c 0 || !count)\n \t\t\tgoto reexpand;\n \t}\n+\tif (unlikely(iov_iter_is_dmabuf_map(to))) {\n+\t\tif (!ret)\n+\t\t\tret = -EOPNOTSUPP;\n+\t\tgoto reexpand;\n+\t}\n \n \t/*\n \t * Take i_rwsem and invalidate_lock to avoid racing with set_blocksize\n@@ -958,6 +966,19 @@ static int blkdev_mmap_prepare(struct vm_area_desc *desc)\n \treturn generic_file_mmap_prepare(desc);\n }\n \n+static int blkdev_init_dma_buf_io_ctx(struct file *file,\n+\t\t\t\t struct dma_buf_io_ctx *ctx)\n+{\n+\tstruct block_device *bdev = file_bdev(file);\n+\tstruct gendisk *disk = bdev-\u003ebd_disk;\n+\n+\tif (!(file-\u003ef_flags \u0026 O_DIRECT))\n+\t\treturn -EINVAL;\n+\tif (!disk-\u003efops-\u003einit_dma_buf_io_ctx)\n+\t\treturn -EOPNOTSUPP;\n+\treturn disk-\u003efops-\u003einit_dma_buf_io_ctx(bdev, ctx);\n+}\n+\n const struct file_operations def_blk_fops = {\n \t.open\t\t= blkdev_open,\n \t.release\t= blkdev_release,\n@@ -976,6 +997,7 @@ const struct file_operations def_blk_fops = {\n \t.fallocate\t= blkdev_fallocate,\n \t.uring_cmd\t= blkdev_uring_cmd,\n \t.fop_flags\t= FOP_BUFFER_RASYNC | FOP_DONTCACHE,\n+\t.init_dma_buf_io_ctx = blkdev_init_dma_buf_io_ctx,\n };\n \n static __init int blkdev_init(void)\ndiff --git a/drivers/md/dm-io-rewind.c b/drivers/md/dm-io-rewind.c\nindex 04f3fc8aeb6f9..b22719c6411cf 100644\n--- a/drivers/md/dm-io-rewind.c\n+++ b/drivers/md/dm-io-rewind.c\n@@ -113,10 +113,12 @@ static inline void dm_bio_rewind_iter(const struct bio *bio,\n \titer-\u003ebi_sector -= bytes \u003e\u003e 9;\n \n \t/* No advance means no rewind */\n-\tif (bio_no_advance_iter(bio))\n+\tif (bio_no_advance_iter(bio)) {\n \t\titer-\u003ebi_size += bytes;\n-\telse\n+\t\titer-\u003ebi_offset -= bytes;\n+\t} else {\n \t\tdm_bvec_iter_rewind(bio-\u003ebi_io_vec, iter, bytes);\n+\t}\n }\n \n /**\ndiff --git a/drivers/nvme/host/Makefile b/drivers/nvme/host/Makefile\nindex 67563a69f7dcc..8288b986d7131 100644\n--- a/drivers/nvme/host/Makefile\n+++ b/drivers/nvme/host/Makefile\n@@ -21,6 +21,7 @@ nvme-core-$(CONFIG_NVME_HWMON)\t\t+= hwmon.o\n nvme-core-$(CONFIG_NVME_HOST_AUTH)\t+= auth.o\n \n nvme-y\t\t\t\t\t+= pci.o\n+nvme-$(CONFIG_DMA_SHARED_BUFFER)\t+= pci-dmabuf.o\n \n nvme-fabrics-y\t\t\t\t+= fabrics.o\n \ndiff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c\nindex 7eb0f9fe6b18d..2f9b2262f77cd 100644\n--- a/drivers/nvme/host/core.c\n+++ b/drivers/nvme/host/core.c\n@@ -2708,6 +2708,17 @@ static int nvme_report_zones(struct gendisk *disk, sector_t sector,\n #define nvme_report_zones\tNULL\n #endif /* CONFIG_BLK_DEV_ZONED */\n \n+static int nvme_init_dma_buf_io_ctx(struct block_device *bdev,\n+\t\tstruct dma_buf_io_ctx *ctx)\n+{\n+\tstruct nvme_ns *ns = bdev-\u003ebd_disk-\u003eprivate_data;\n+\tstruct nvme_ctrl *ctrl = ns-\u003ectrl;\n+\n+\tif (!ctrl-\u003eops-\u003einit_dma_buf_io_ctx)\n+\t\treturn -EINVAL;\n+\treturn ctrl-\u003eops-\u003einit_dma_buf_io_ctx(ctrl, ctx);\n+}\n+\n const struct block_device_operations nvme_bdev_ops = {\n \t.owner\t\t= THIS_MODULE,\n \t.ioctl\t\t= nvme_ioctl,\n@@ -2718,6 +2729,7 @@ const struct block_device_operations nvme_bdev_ops = {\n \t.get_unique_id\t= nvme_get_unique_id,\n \t.report_zones\t= nvme_report_zones,\n \t.pr_ops\t\t= \u0026nvme_pr_ops,\n+\t.init_dma_buf_io_ctx = nvme_init_dma_buf_io_ctx,\n };\n \n static int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,\ndiff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h\nindex a643c4723a69b..be32e9a5ca5a1 100644\n--- a/drivers/nvme/host/nvme.h\n+++ b/drivers/nvme/host/nvme.h\n@@ -668,6 +668,8 @@ struct nvme_ctrl_ops {\n \tint (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);\n \tvoid (*print_device_info)(struct nvme_ctrl *ctrl);\n \tbool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);\n+\tint (*init_dma_buf_io_ctx)(struct nvme_ctrl *ctrl,\n+\t\t\t\t struct dma_buf_io_ctx *ctx);\n \tunsigned long (*get_virt_boundary)(struct nvme_ctrl *ctrl, bool is_admin);\n };\n \ndiff --git a/drivers/nvme/host/pci-dmabuf.c b/drivers/nvme/host/pci-dmabuf.c\nnew file mode 100644\nindex 0000000000000..d58a38a75d673\n--- /dev/null\n+++ b/drivers/nvme/host/pci-dmabuf.c\n@@ -0,0 +1,164 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/*\n+ * Copyright (C) 2026 Pavel Begunkov \u003casml.silence@gmail.com\u003e\n+ */\n+\n+#include \u003clinux/dma-resv.h\u003e\n+\n+#include \"pci-dmabuf.h\"\n+\n+static void nvme_dmabuf_invalidate_mappings(struct dma_buf_attachment *attach)\n+{\n+\tstruct dma_buf_io_ctx *ctx = attach-\u003eimporter_priv;\n+\n+\tdma_buf_io_invalidate_mappings(ctx);\n+}\n+\n+static const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {\n+\t.invalidate_mappings\t= nvme_dmabuf_invalidate_mappings,\n+\t.allow_peer2peer\t= true,\n+};\n+\n+static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\n+{\n+\tunsigned nr_entries = ctx-\u003edmabuf-\u003esize / NVME_CTRL_PAGE_SIZE;\n+\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\n+\tstruct dma_buf_attachment *attach = nvme_ctx-\u003eattach;\n+\tunsigned long tmp, i = 0;\n+\tstruct nvme_dmabuf_map *map;\n+\tstruct scatterlist *sg;\n+\tstruct sg_table *sgt;\n+\tint ret;\n+\n+\tdma_resv_assert_held(ctx-\u003edmabuf-\u003eresv);\n+\n+\tif (ctx-\u003edmabuf-\u003esize % NVME_CTRL_PAGE_SIZE)\n+\t\treturn ERR_PTR(-EINVAL);\n+\n+\tmap = kvmalloc_flex(*map, dma_list, nr_entries);\n+\tif (!map)\n+\t\treturn ERR_PTR(-ENOMEM);\n+\tmap-\u003enr_entries = nr_entries;\n+\n+\tsgt = dma_buf_map_attachment(attach, ctx-\u003edir);\n+\tif (IS_ERR(sgt)) {\n+\t\tret = PTR_ERR(sgt);\n+\t\tsgt = NULL;\n+\t\tgoto err;\n+\t}\n+\n+\tfor_each_sgtable_dma_sg(sgt, sg, tmp) {\n+\t\tdma_addr_t dma_addr = sg_dma_address(sg);\n+\t\tunsigned long sg_len = sg_dma_len(sg);\n+\n+\t\tif ((sg_len % NVME_CTRL_PAGE_SIZE) ||\n+\t\t (dma_addr % NVME_CTRL_PAGE_SIZE)) {\n+\t\t\tret = -EINVAL;\n+\t\t\tgoto err;\n+\t\t}\n+\t\twhile (sg_len) {\n+\t\t\tmap-\u003edma_list[i++] = dma_addr;\n+\t\t\tdma_addr += NVME_CTRL_PAGE_SIZE;\n+\t\t\tsg_len -= NVME_CTRL_PAGE_SIZE;\n+\t\t}\n+\t}\n+\n+\tret = dma_buf_io_init_map(ctx, \u0026map-\u003ebase, sgt);\n+\tif (ret)\n+\t\tgoto err;\n+\tmap-\u003esgt = sgt;\n+\treturn \u0026map-\u003ebase;\n+err:\n+\tif (sgt)\n+\t\tdma_buf_unmap_attachment(attach, sgt, ctx-\u003edir);\n+\tkvfree(map);\n+\treturn ERR_PTR(ret);\n+}\n+\n+static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,\n+\t\tstruct dma_buf_io_map *map_base)\n+{\n+\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\n+\tstruct nvme_dmabuf_map *map = to_nvme_dmabuf_map(map_base);\n+\n+\tdma_resv_assert_held(ctx-\u003edmabuf-\u003eresv);\n+\n+\tdma_buf_unmap_attachment(nvme_ctx-\u003eattach, map-\u003esgt, ctx-\u003edir);\n+\tkvfree(map);\n+}\n+\n+static void nvme_dma_buf_io_release(struct dma_buf_io_ctx *base_ctx)\n+{\n+\tstruct nvme_dma_buf_io_ctx *ctx = base_ctx-\u003edev_priv;\n+\tstruct nvme_dma_buf_list *buf_list = ctx-\u003ebuf_list;\n+\n+\tmutex_lock(\u0026buf_list-\u003elock);\n+\tif (!list_empty(\u0026ctx-\u003elist)) {\n+\t\tdma_buf_detach(ctx-\u003ebase-\u003edmabuf, ctx-\u003eattach);\n+\t\tlist_del_init(\u0026ctx-\u003elist);\n+\t}\n+\tmutex_unlock(\u0026buf_list-\u003elock);\n+\n+\tnvme_put_ctrl(ctx-\u003ectrl);\n+\tkfree(ctx);\n+}\n+\n+void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\n+{\n+\tstruct nvme_dma_buf_io_ctx *ctx, *tmp;\n+\n+\tmutex_lock(\u0026list-\u003elock);\n+\tlist_for_each_entry_safe(ctx, tmp, \u0026list-\u003ectxs, list) {\n+\t\tdma_buf_io_detach(ctx-\u003ebase);\n+\t\tdma_buf_detach(ctx-\u003ebase-\u003edmabuf, ctx-\u003eattach);\n+\t\tlist_del_init(\u0026ctx-\u003elist);\n+\t}\n+\tmutex_unlock(\u0026list-\u003elock);\n+}\n+\n+const struct dma_buf_io_ops nvme_dma_buf_io_ops = {\n+\t.map\t\t= nvme_dma_buf_io_map,\n+\t.unmap\t\t= nvme_dma_buf_io_unmap,\n+\t.release\t= nvme_dma_buf_io_release,\n+};\n+\n+static int nvme_init_io_ctx_locked(struct nvme_ctrl *ctrl,\n+\t\tstruct nvme_dma_buf_list *buf_list,\n+\t\tstruct dma_buf_io_ctx *ctx)\n+{\n+\tstruct nvme_dma_buf_io_ctx *nvme_ctx;\n+\tstruct dma_buf_attachment *attach;\n+\n+\tnvme_ctx = kzalloc_obj(*nvme_ctx);\n+\tif (!nvme_ctx)\n+\t\treturn -ENOMEM;\n+\n+\tattach = dma_buf_dynamic_attach(ctx-\u003edmabuf, ctrl-\u003edev,\n+\t\t\t\t\t\u0026nvme_dmabuf_importer_ops, ctx);\n+\tif (IS_ERR(attach)) {\n+\t\tkfree(nvme_ctx);\n+\t\treturn PTR_ERR(attach);\n+\t}\n+\n+\tnvme_get_ctrl(ctrl);\n+\tlist_add(\u0026nvme_ctx-\u003elist, \u0026buf_list-\u003ectxs);\n+\tnvme_ctx-\u003eattach = attach;\n+\tnvme_ctx-\u003ebase = ctx;\n+\tnvme_ctx-\u003ectrl = ctrl;\n+\tnvme_ctx-\u003ebuf_list = buf_list;\n+\tctx-\u003edev_priv = nvme_ctx;\n+\tctx-\u003edev_ops = \u0026nvme_dma_buf_io_ops;\n+\treturn 0;\n+}\n+\n+int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\n+\t\tstruct nvme_dma_buf_list *buf_list,\n+\t\tstruct dma_buf_io_ctx *ctx)\n+{\n+\tint ret;\n+\n+\tmutex_lock(\u0026buf_list-\u003elock);\n+\tret = nvme_init_io_ctx_locked(ctrl, buf_list, ctx);\n+\tmutex_unlock(\u0026buf_list-\u003elock);\n+\treturn ret;\n+}\ndiff --git a/drivers/nvme/host/pci-dmabuf.h b/drivers/nvme/host/pci-dmabuf.h\nnew file mode 100644\nindex 0000000000000..8e91f7f4ece5a\n--- /dev/null\n+++ b/drivers/nvme/host/pci-dmabuf.h\n@@ -0,0 +1,73 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/*\n+ * Copyright (C) 2026 Pavel Begunkov \u003casml.silence@gmail.com\u003e\n+ */\n+\n+#ifndef _NVME_PCI_DMABUF_H\n+#define _NVME_PCI_DMABUF_H\n+\n+#include \u003clinux/dma-buf-io.h\u003e\n+\n+#include \"nvme.h\"\n+\n+struct nvme_dma_buf_list {\n+\tstruct list_head ctxs;\n+\tstruct mutex lock;\n+};\n+\n+struct nvme_dma_buf_io_ctx {\n+\tstruct dma_buf_attachment *attach;\n+\tstruct nvme_dma_buf_list *buf_list;\n+\tstruct dma_buf_io_ctx *base;\n+\tstruct nvme_ctrl *ctrl;\n+\tstruct list_head list;\n+};\n+\n+struct nvme_dmabuf_map {\n+\tstruct dma_buf_io_map base;\n+\tstruct sg_table *sgt;\n+\tunsigned nr_entries;\n+\tdma_addr_t dma_list[] __counted_by(nr_entries);\n+};\n+\n+static inline struct nvme_dmabuf_map *to_nvme_dmabuf_map(\n+\tstruct dma_buf_io_map *map)\n+{\n+\treturn container_of(map, struct nvme_dmabuf_map, base);\n+}\n+\n+static inline struct nvme_dmabuf_map *nvme_req_to_map(struct request *req)\n+{\n+\tstruct dma_buf_io_map *map = req-\u003ebio-\u003ebi_dmabuf_map;\n+\n+\treturn to_nvme_dmabuf_map(map);\n+}\n+\n+void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list);\n+int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\n+\t\tstruct nvme_dma_buf_list *buf_list,\n+\t\tstruct dma_buf_io_ctx *ctx);\n+\n+static inline void nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\n+{\n+\tif (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\n+\t\t__nvme_pci_remove_dmabuf(list);\n+}\n+\n+static inline int nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\n+\t\tstruct nvme_dma_buf_list *buf_list,\n+\t\tstruct dma_buf_io_ctx *ctx)\n+{\n+\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\n+\t\treturn -EOPNOTSUPP;\n+\treturn __nvme_init_dma_buf_io_ctx(ctrl, buf_list, ctx);\n+}\n+\n+static inline void nvme_init_buf_list(struct nvme_dma_buf_list *buf_list)\n+{\n+\tINIT_LIST_HEAD(\u0026buf_list-\u003ectxs);\n+\tmutex_init(\u0026buf_list-\u003elock);\n+}\n+\n+\n+#endif /* _NVME_PCI_DMABUF_H */\n\\ No newline at end of file\ndiff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c\nindex 77317e5d00f9f..79b3c1092e4d1 100644\n--- a/drivers/nvme/host/pci.c\n+++ b/drivers/nvme/host/pci.c\n@@ -30,6 +30,7 @@\n \n #include \"trace.h\"\n #include \"nvme.h\"\n+#include \"pci-dmabuf.h\"\n \n #define SQ_SIZE(q)\t((q)-\u003eq_depth \u003c\u003c (q)-\u003esqes)\n #define CQ_SIZE(q)\t((q)-\u003eq_depth * sizeof(struct nvme_completion))\n@@ -318,6 +319,7 @@ struct nvme_dev {\n \tbool hmb;\n \tstruct sg_table *hmb_sgt;\n \tmempool_t *dmavec_mempool;\n+\tstruct nvme_dma_buf_list dmabufs;\n \n \t/* shadow doorbell buffer support: */\n \t__le32 *dbbuf_dbs;\n@@ -865,6 +867,76 @@ static void nvme_free_descriptors(struct request *req)\n \t}\n }\n \n+static blk_status_t nvme_rq_setup_dmabuf_map(struct request *req,\n+\t\tstruct nvme_queue *nvmeq)\n+{\n+\tstruct nvme_iod *iod = blk_mq_rq_to_pdu(req);\n+\tstruct nvme_dmabuf_map *map = nvme_req_to_map(req);\n+\tunsigned bvec_done = req-\u003ebio-\u003ebi_iter.bi_offset;\n+\tunsigned map_idx = bvec_done / NVME_CTRL_PAGE_SIZE;\n+\tunsigned offset = bvec_done \u0026 (NVME_CTRL_PAGE_SIZE - 1);\n+\tint length = blk_rq_payload_bytes(req) - (NVME_CTRL_PAGE_SIZE - offset);\n+\tdma_addr_t *dma_list = map-\u003edma_list;\n+\tu64 prp1_dma = dma_list[map_idx++] + offset;\n+\tu64 dma_addr, prp2_dma;\n+\tdma_addr_t prp_dma;\n+\t__le64 *prp_list;\n+\tunsigned i;\n+\n+\tif (length \u003c= 0) {\n+\t\tprp2_dma = 0;\n+\t\tgoto done;\n+\t}\n+\n+\tif (length \u003c= NVME_CTRL_PAGE_SIZE) {\n+\t\tprp2_dma = dma_list[map_idx];\n+\t\tgoto done;\n+\t}\n+\n+\tif (DIV_ROUND_UP(length, NVME_CTRL_PAGE_SIZE) \u003c=\n+\t NVME_SMALL_POOL_SIZE / sizeof(__le64))\n+\t\tiod-\u003eflags |= IOD_SMALL_DESCRIPTOR;\n+\n+\tprp_list = dma_pool_alloc(nvme_dma_pool(nvmeq, iod), GFP_ATOMIC,\n+\t\t\t\u0026prp_dma);\n+\tif (!prp_list)\n+\t\treturn BLK_STS_RESOURCE;\n+\n+\tiod-\u003edescriptors[iod-\u003enr_descriptors++] = prp_list;\n+\tprp2_dma = prp_dma;\n+\ti = 0;\n+\tfor (;;) {\n+\t\tif (i == NVME_CTRL_PAGE_SIZE \u003e\u003e 3) {\n+\t\t\t__le64 *old_prp_list = prp_list;\n+\n+\t\t\tprp_list = dma_pool_alloc(nvmeq-\u003edescriptor_pools.large,\n+\t\t\t\t\tGFP_ATOMIC, \u0026prp_dma);\n+\t\t\tif (!prp_list)\n+\t\t\t\tgoto free_prps;\n+\t\t\tiod-\u003edescriptors[iod-\u003enr_descriptors++] = prp_list;\n+\t\t\tprp_list[0] = old_prp_list[i - 1];\n+\t\t\told_prp_list[i - 1] = cpu_to_le64(prp_dma);\n+\t\t\ti = 1;\n+\t\t}\n+\n+\t\tdma_addr = dma_list[map_idx++];\n+\t\tprp_list[i++] = cpu_to_le64(dma_addr);\n+\n+\t\tlength -= NVME_CTRL_PAGE_SIZE;\n+\t\tif (length \u003c= 0)\n+\t\t\tbreak;\n+\t}\n+done:\n+\tiod-\u003ecmd.common.dptr.prp1 = cpu_to_le64(prp1_dma);\n+\tiod-\u003ecmd.common.dptr.prp2 = cpu_to_le64(prp2_dma);\n+\treturn BLK_STS_OK;\n+free_prps:\n+\tiod-\u003ecmd.common.dptr.prp1 = cpu_to_le64(prp1_dma);\n+\tiod-\u003ecmd.common.dptr.prp2 = cpu_to_le64(prp2_dma);\n+\tnvme_free_descriptors(req);\n+\treturn BLK_STS_RESOURCE;\n+}\n+\n static void nvme_free_prps(struct request *req, unsigned int attrs)\n {\n \tstruct nvme_iod *iod = blk_mq_rq_to_pdu(req);\n@@ -943,6 +1015,9 @@ static void nvme_unmap_data(struct request *req)\n \tstruct device *dma_dev = nvmeq-\u003edev-\u003edev;\n \tunsigned int attrs = 0;\n \n+\tif (blk_mq_rq_is_dmabuf(req))\n+\t\tgoto out_free_desc;\n+\n \tif (iod-\u003eflags \u0026 IOD_SINGLE_SEGMENT) {\n \t\tstatic_assert(offsetof(union nvme_data_ptr, prp1) ==\n \t\t\t\toffsetof(union nvme_data_ptr, sgl.addr));\n@@ -967,6 +1042,7 @@ static void nvme_unmap_data(struct request *req)\n \t\t\tnvme_free_prps(req, attrs);\n \t}\n \n+out_free_desc:\n \tif (iod-\u003enr_descriptors)\n \t\tnvme_free_descriptors(req);\n }\n@@ -1148,13 +1224,19 @@ static blk_status_t nvme_pci_setup_data_prp(struct request *req,\n }\n \n static void nvme_pci_sgl_set_data(struct nvme_sgl_desc *sge,\n-\t\tstruct blk_dma_iter *iter)\n+\t\tdma_addr_t addr, u32 len)\n {\n-\tsge-\u003eaddr = cpu_to_le64(iter-\u003eaddr);\n-\tsge-\u003elength = cpu_to_le32(iter-\u003elen);\n+\tsge-\u003eaddr = cpu_to_le64(addr);\n+\tsge-\u003elength = cpu_to_le32(len);\n \tsge-\u003etype = NVME_SGL_FMT_DATA_DESC \u003c\u003c 4;\n }\n \n+static void nvme_pci_dma_iter_set_sgl(struct nvme_sgl_desc *sge,\n+\t\tstruct blk_dma_iter *iter)\n+{\n+\tnvme_pci_sgl_set_data(sge, iter-\u003eaddr, iter-\u003elen);\n+}\n+\n static void nvme_pci_sgl_set_seg(struct nvme_sgl_desc *sge,\n \t\tdma_addr_t dma_addr, int entries)\n {\n@@ -1163,6 +1245,142 @@ static void nvme_pci_sgl_set_seg(struct nvme_sgl_desc *sge,\n \tsge-\u003etype = NVME_SGL_FMT_LAST_SEG_DESC \u003c\u003c 4;\n }\n \n+static unsigned int nvme_pci_dmabuf_sgl_nents(struct request *req)\n+{\n+\tstruct bio *bio = req-\u003ebio;\n+\tstruct nvme_dmabuf_map *map = to_nvme_dmabuf_map(bio-\u003ebi_dmabuf_map);\n+\tstruct scatterlist *sg;\n+\tunsigned long tmp;\n+\tsize_t offset = bio-\u003ebi_iter.bi_offset;\n+\tsize_t remaining = blk_rq_payload_bytes(req);\n+\tunsigned int nents = 0;\n+\n+\tfor_each_sgtable_dma_sg(map-\u003esgt, sg, tmp) {\n+\t\tsize_t sg_len = sg_dma_len(sg);\n+\n+\t\tif (!remaining)\n+\t\t\tbreak;\n+\t\tif (offset \u003e= sg_len) {\n+\t\t\toffset -= sg_len;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tsg_len -= offset;\n+\t\toffset = 0;\n+\n+\t\tdo {\n+\t\t\tsize_t chunk = min(remaining, sg_len);\n+\n+\t\t\tnents++;\n+\t\t\tsg_len -= chunk;\n+\t\t\tremaining -= chunk;\n+\t\t} while (sg_len \u0026\u0026 remaining);\n+\t}\n+\n+\tif (unlikely(remaining))\n+\t\treturn 0;\n+\n+\treturn nents;\n+}\n+\n+static blk_status_t nvme_rq_setup_dmabuf_sgl(struct request *req,\n+\t\tstruct nvme_queue *nvmeq, unsigned int entries)\n+{\n+\tstruct nvme_iod *iod = blk_mq_rq_to_pdu(req);\n+\tstruct nvme_dmabuf_map *map = nvme_req_to_map(req);\n+\tsize_t length = blk_rq_payload_bytes(req);\n+\tstruct nvme_sgl_desc *sg_list = \u0026iod-\u003ecmd.common.dptr.sgl;\n+\tsize_t offset = req-\u003ebio-\u003ebi_iter.bi_offset;\n+\tbool pooled = entries \u003e 1;\n+\tdma_addr_t sgl_dma = 0;\n+\tunsigned int mapped = 0;\n+\tunsigned long tmp;\n+\tstruct scatterlist *sg;\n+\tsize_t remaining = length;\n+\n+\tif (!entries)\n+\t\treturn BLK_STS_IOERR;\n+\n+\tiod-\u003ecmd.common.flags = NVME_CMD_SGL_METABUF;\n+\tiod-\u003etotal_len = length;\n+\n+\t/* entries == 1 fits in the inline descriptor; more needs a pool. */\n+\tif (pooled) {\n+\t\tif (entries \u003c= NVME_SMALL_POOL_SIZE / sizeof(*sg_list))\n+\t\t\tiod-\u003eflags |= IOD_SMALL_DESCRIPTOR;\n+\n+\t\tsg_list = dma_pool_alloc(nvme_dma_pool(nvmeq, iod), GFP_ATOMIC,\n+\t\t\t\t\t \u0026sgl_dma);\n+\t\tif (!sg_list)\n+\t\t\treturn BLK_STS_RESOURCE;\n+\t\tiod-\u003edescriptors[iod-\u003enr_descriptors++] = sg_list;\n+\t}\n+\n+\tfor_each_sgtable_dma_sg(map-\u003esgt, sg, tmp) {\n+\t\tsize_t sg_len = sg_dma_len(sg);\n+\t\tdma_addr_t addr = sg_dma_address(sg);\n+\n+\t\tif (!remaining)\n+\t\t\tbreak;\n+\t\tif (offset \u003e= sg_len) {\n+\t\t\toffset -= sg_len;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\taddr += offset;\n+\t\tsg_len -= offset;\n+\t\toffset = 0;\n+\n+\t\tdo {\n+\t\t\tu32 chunk = min_t(size_t, remaining, sg_len);\n+\n+\t\t\tif (WARN_ON_ONCE(mapped == entries))\n+\t\t\t\tgoto err_free;\n+\t\t\tnvme_pci_sgl_set_data(\u0026sg_list[mapped++], addr, chunk);\n+\n+\t\t\taddr += chunk;\n+\t\t\tsg_len -= chunk;\n+\t\t\tremaining -= chunk;\n+\t\t} while (sg_len \u0026\u0026 remaining);\n+\t}\n+\n+\tif (unlikely(remaining))\n+\t\tgoto err_free;\n+\n+\tif (pooled)\n+\t\tnvme_pci_sgl_set_seg(\u0026iod-\u003ecmd.common.dptr.sgl, sgl_dma,\n+\t\t\t\t mapped);\n+\treturn BLK_STS_OK;\n+err_free:\n+\tif (pooled) {\n+\t\tiod-\u003enr_descriptors--;\n+\t\tdma_pool_free(nvme_dma_pool(nvmeq, iod), sg_list, sgl_dma);\n+\t}\n+\treturn BLK_STS_IOERR;\n+}\n+\n+static blk_status_t nvme_rq_setup_dmabuf(struct request *req,\n+\t\tstruct nvme_queue *nvmeq, enum nvme_use_sgl use_sgl)\n+{\n+\tunsigned int entries;\n+\tsize_t avg_seg;\n+\n+\tif (use_sgl == SGL_UNSUPPORTED)\n+\t\treturn nvme_rq_setup_dmabuf_map(req, nvmeq);\n+\n+\tentries = nvme_pci_dmabuf_sgl_nents(req);\n+\n+\tif (use_sgl == SGL_FORCED)\n+\t\treturn nvme_rq_setup_dmabuf_sgl(req, nvmeq, entries);\n+\n+\tavg_seg = entries ?\n+\t\tDIV_ROUND_UP(blk_rq_payload_bytes(req), entries) : 0;\n+\tif (sgl_threshold \u0026\u0026 avg_seg \u003e= sgl_threshold)\n+\t\treturn nvme_rq_setup_dmabuf_sgl(req, nvmeq, entries);\n+\n+\treturn nvme_rq_setup_dmabuf_map(req, nvmeq);\n+}\n+\n static blk_status_t nvme_pci_setup_data_sgl(struct request *req,\n \t\tstruct blk_dma_iter *iter)\n {\n@@ -1177,7 +1395,7 @@ static blk_status_t nvme_pci_setup_data_sgl(struct request *req,\n \tiod-\u003ecmd.common.flags = NVME_CMD_SGL_METABUF;\n \n \tif (entries == 1 || blk_rq_dma_map_coalesce(\u0026iod-\u003edma_state)) {\n-\t\tnvme_pci_sgl_set_data(\u0026iod-\u003ecmd.common.dptr.sgl, iter);\n+\t\tnvme_pci_dma_iter_set_sgl(\u0026iod-\u003ecmd.common.dptr.sgl, iter);\n \t\tiod-\u003etotal_len += iter-\u003elen;\n \t\treturn BLK_STS_OK;\n \t}\n@@ -1199,7 +1417,7 @@ static blk_status_t nvme_pci_setup_data_sgl(struct request *req,\n \t\t\titer-\u003estatus = BLK_STS_IOERR;\n \t\t\tbreak;\n \t\t}\n-\t\tnvme_pci_sgl_set_data(\u0026sg_list[mapped++], iter);\n+\t\tnvme_pci_dma_iter_set_sgl(\u0026sg_list[mapped++], iter);\n \t\tiod-\u003etotal_len += iter-\u003elen;\n \t} while (blk_rq_dma_map_iter_next(req, nvmeq-\u003edev-\u003edev, iter));\n \n@@ -1257,6 +1475,9 @@ static blk_status_t nvme_map_data(struct request *req)\n \tstruct blk_dma_iter iter;\n \tblk_status_t ret;\n \n+\tif (blk_mq_rq_is_dmabuf(req))\n+\t\treturn nvme_rq_setup_dmabuf(req, nvmeq, use_sgl);\n+\n \t/*\n \t * Try to skip the DMA iterator for single segment requests, as that\n \t * significantly improves performances for small I/O sizes.\n@@ -1359,13 +1580,13 @@ static blk_status_t nvme_pci_setup_meta_iter(struct request *req)\n \tiod-\u003ecmd.common.metadata = cpu_to_le64(sgl_dma);\n \tif (entries == 1) {\n \t\tiod-\u003emeta_total_len = iter.len;\n-\t\tnvme_pci_sgl_set_data(sg_list, \u0026iter);\n+\t\tnvme_pci_dma_iter_set_sgl(sg_list, \u0026iter);\n \t\treturn BLK_STS_OK;\n \t}\n \n \tsgl_dma += sizeof(*sg_list);\n \tdo {\n-\t\tnvme_pci_sgl_set_data(\u0026sg_list[++i], \u0026iter);\n+\t\tnvme_pci_dma_iter_set_sgl(\u0026sg_list[++i], \u0026iter);\n \t\tiod-\u003emeta_total_len += iter.len;\n \t} while (blk_rq_integrity_dma_map_iter_next(req, dev-\u003edev, \u0026iter));\n \n@@ -3357,6 +3578,9 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)\n \t\t\tnvme_unquiesce_admin_queue(\u0026dev-\u003ectrl);\n \t}\n \tmutex_unlock(\u0026dev-\u003eshutdown_lock);\n+\n+\tif (shutdown)\n+\t\tnvme_pci_remove_dmabuf(\u0026dev-\u003edmabufs);\n }\n \n static int nvme_disable_prepare_reset(struct nvme_dev *dev, bool shutdown)\n@@ -3564,6 +3788,14 @@ static unsigned long nvme_pci_get_virt_boundary(struct nvme_ctrl *ctrl,\n \treturn 0;\n }\n \n+static int nvme_pci_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\n+\t\tstruct dma_buf_io_ctx *ctx)\n+{\n+\tstruct nvme_dev *dev = to_nvme_dev(ctrl);\n+\n+\treturn nvme_init_dma_buf_io_ctx(ctrl, \u0026dev-\u003edmabufs, ctx);\n+}\n+\n static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {\n \t.name\t\t\t= \"pcie\",\n \t.module\t\t\t= THIS_MODULE,\n@@ -3579,6 +3811,7 @@ static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {\n \t.print_device_info\t= nvme_pci_print_device_info,\n \t.supports_pci_p2pdma\t= nvme_pci_supports_pci_p2pdma,\n \t.get_virt_boundary\t= nvme_pci_get_virt_boundary,\n+\t.init_dma_buf_io_ctx\t= nvme_pci_init_dma_buf_io_ctx,\n };\n \n static int nvme_dev_map(struct nvme_dev *dev)\n@@ -3701,6 +3934,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev,\n \t\treturn ERR_PTR(-ENOMEM);\n \tINIT_WORK(\u0026dev-\u003ectrl.reset_work, nvme_reset_work);\n \tmutex_init(\u0026dev-\u003eshutdown_lock);\n+\tnvme_init_buf_list(\u0026dev-\u003edmabufs);\n \n \tdev-\u003enr_write_queues = write_queues;\n \tdev-\u003enr_poll_queues = poll_queues;\n@@ -4346,5 +4580,6 @@ MODULE_AUTHOR(\"Matthew Wilcox \u003cwilly@linux.intel.com\u003e\");\n MODULE_LICENSE(\"GPL\");\n MODULE_VERSION(\"1.0\");\n MODULE_DESCRIPTION(\"NVMe host PCIe transport driver\");\n+MODULE_IMPORT_NS(\"DMA_BUF\");\n module_init(nvme_init);\n module_exit(nvme_exit);\ndiff --git a/include/linux/bio.h b/include/linux/bio.h\nindex 17944e44b5849..7a794ce723b84 100644\n--- a/include/linux/bio.h\n+++ b/include/linux/bio.h\n@@ -80,7 +80,8 @@ static inline bool bio_no_advance_iter(const struct bio *bio)\n {\n \treturn bio_op(bio) == REQ_OP_DISCARD ||\n \t bio_op(bio) == REQ_OP_SECURE_ERASE ||\n-\t bio_op(bio) == REQ_OP_WRITE_ZEROES;\n+\t bio_op(bio) == REQ_OP_WRITE_ZEROES ||\n+\t op_is_dmabuf(bio-\u003ebi_opf);\n }\n \n static inline void *bio_data(struct bio *bio)\n@@ -113,11 +114,13 @@ static inline void bio_advance_iter(const struct bio *bio,\n {\n \titer-\u003ebi_sector += bytes \u003e\u003e 9;\n \n-\tif (bio_no_advance_iter(bio))\n+\tif (bio_no_advance_iter(bio)) {\n \t\titer-\u003ebi_size -= bytes;\n-\telse\n+\t\titer-\u003ebi_offset += bytes;\n+\t} else {\n \t\tbvec_iter_advance(bio-\u003ebi_io_vec, iter, bytes);\n \t\t/* TODO: It is reasonable to complete bio with error here. */\n+\t}\n }\n \n /* @bytes should be less or equal to bvec[i-\u003ebi_idx].bv_len */\n@@ -127,10 +130,12 @@ static inline void bio_advance_iter_single(const struct bio *bio,\n {\n \titer-\u003ebi_sector += bytes \u003e\u003e 9;\n \n-\tif (bio_no_advance_iter(bio))\n+\tif (bio_no_advance_iter(bio)) {\n \t\titer-\u003ebi_size -= bytes;\n-\telse\n+\t\titer-\u003ebi_offset += bytes;\n+\t} else {\n \t\tbvec_iter_advance_single(bio-\u003ebi_io_vec, iter, bytes);\n+\t}\n }\n \n void __bio_advance(struct bio *, unsigned bytes);\n@@ -434,12 +439,12 @@ static inline void bio_wouldblock_error(struct bio *bio)\n \n /*\n * Calculate number of bvec segments that should be allocated to fit data\n- * pointed by @iter. If @iter is backed by bvec it's going to be reused\n- * instead of allocating a new one.\n+ * pointed by @iter. If @iter is backed by a bvec or a dmabuf, the bvec array /\n+ * the dma map are going to be reused, and so no extra allocation is required.\n */\n static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)\n {\n-\tif (iov_iter_is_bvec(iter))\n+\tif (iov_iter_is_bvec(iter) || iov_iter_is_dmabuf_map(iter))\n \t\treturn 0;\n \treturn iov_iter_npages(iter, max_segs);\n }\ndiff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h\nindex af878597afb8c..7c7504c84e090 100644\n--- a/include/linux/blk-mq.h\n+++ b/include/linux/blk-mq.h\n@@ -1017,6 +1017,13 @@ static inline void *blk_mq_rq_to_pdu(struct request *rq)\n \treturn rq + 1;\n }\n \n+static inline bool blk_mq_rq_is_dmabuf(struct request *rq)\n+{\n+\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\n+\t\treturn false;\n+\treturn rq-\u003ebio \u0026\u0026 op_is_dmabuf(rq-\u003ebio-\u003ebi_opf);\n+}\n+\n static inline struct blk_mq_hw_ctx *queue_hctx(struct request_queue *q, int id)\n {\n \tstruct blk_mq_hw_ctx *hctx;\ndiff --git a/include/linux/blk_types.h b/include/linux/blk_types.h\nindex 98e21b4cbf328..0cc09b975d8ff 100644\n--- a/include/linux/blk_types.h\n+++ b/include/linux/blk_types.h\n@@ -233,7 +233,12 @@ struct bio {\n \tatomic_t\t\t__bi_remaining;\n \n \t/* The actual vec list, preserved by bio_reset() */\n-\tstruct bio_vec\t\t*bi_io_vec;\n+\tunion {\n+\t\tstruct bio_vec\t\t*bi_io_vec;\n+\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\n+\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\n+\t};\n+\n \tstruct bvec_iter\tbi_iter;\n \n \tunion {\n@@ -402,6 +407,7 @@ enum req_flag_bits {\n \t__REQ_DRV,\t\t/* for driver use */\n \t__REQ_FS_PRIVATE,\t/* for file system (submitter) use */\n \t__REQ_ATOMIC,\t\t/* for atomic write operations */\n+\t__REQ_DMABUF,\t\t/* Using premmaped dma buffers */\n \t/*\n \t * Command specific flags, keep last:\n \t */\n@@ -434,6 +440,7 @@ enum req_flag_bits {\n #define REQ_DRV\t\t(__force blk_opf_t)(1ULL \u003c\u003c __REQ_DRV)\n #define REQ_FS_PRIVATE\t(__force blk_opf_t)(1ULL \u003c\u003c __REQ_FS_PRIVATE)\n #define REQ_ATOMIC\t(__force blk_opf_t)(1ULL \u003c\u003c __REQ_ATOMIC)\n+#define REQ_DMABUF\t(__force blk_opf_t)(1ULL \u003c\u003c __REQ_DMABUF)\n \n #define REQ_NOUNMAP\t(__force blk_opf_t)(1ULL \u003c\u003c __REQ_NOUNMAP)\n \n@@ -487,6 +494,11 @@ static inline bool op_is_discard(blk_opf_t op)\n \treturn (op \u0026 REQ_OP_MASK) == REQ_OP_DISCARD;\n }\n \n+static inline bool op_is_dmabuf(blk_opf_t op)\n+{\n+\treturn op \u0026 REQ_DMABUF;\n+}\n+\n /*\n * Check if a bio or request operation is a zone management operation.\n */\ndiff --git a/include/linux/blkdev.h b/include/linux/blkdev.h\nindex d003a9d2d1f6c..2d5c30823aab9 100644\n--- a/include/linux/blkdev.h\n+++ b/include/linux/blkdev.h\n@@ -1599,6 +1599,8 @@ struct block_device_operations {\n \t/* returns the length of the identifier or a negative errno: */\n \tint (*get_unique_id)(struct gendisk *disk, u8 id[16],\n \t\t\tenum blk_unique_id id_type);\n+\tint (*init_dma_buf_io_ctx)(struct block_device *,\n+\t\t\t\t struct dma_buf_io_ctx *);\n \tstruct module *owner;\n \tconst struct pr_ops *pr_ops;\n \ndiff --git a/include/linux/bvec.h b/include/linux/bvec.h\nindex fc566ee1c1ff1..b63914ff56e33 100644\n--- a/include/linux/bvec.h\n+++ b/include/linux/bvec.h\n@@ -108,7 +108,8 @@ struct bvec_iter {\n \tunsigned int\t\tbi_idx;\n \n \t/*\n-\t * Current offset in the bvec entry pointed to by `bi_idx`.\n+\t * Current offset in the bvec entry pointed to by `bi_idx` or into\n+\t * a dma-buf map.\n \t */\n \tunsigned int\t\tbi_offset;\n } __packed __aligned(4);\ndiff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h\nindex 90fea94ad2029..73cd11d173df0 100644\n--- a/include/linux/io_uring_types.h\n+++ b/include/linux/io_uring_types.h\n@@ -11,6 +11,7 @@\n \n struct iou_loop_params;\n struct io_uring_bpf_ops;\n+struct dma_buf_io_map;\n \n enum {\n \t/*\n@@ -610,6 +611,7 @@ enum {\n \tREQ_F_IMPORT_BUFFER_BIT,\n \tREQ_F_SQE_COPIED_BIT,\n \tREQ_F_IOPOLL_BIT,\n+\tREQ_F_DMABUF_BIT,\n \n \t/* not a real bit, just to check we're not overflowing the space */\n \t__REQ_F_LAST_BIT,\n@@ -705,6 +707,8 @@ enum {\n \tREQ_F_SQE_COPIED\t= IO_REQ_FLAG(REQ_F_SQE_COPIED_BIT),\n \t/* request must be iopolled to completion (set in -\u003eissue()) */\n \tREQ_F_IOPOLL\t\t= IO_REQ_FLAG(REQ_F_IOPOLL_BIT),\n+\t/* there is a dma map attached to request that needs to be dropped */\n+\tREQ_F_DMABUF\t\t= IO_REQ_FLAG(REQ_F_DMABUF_BIT),\n };\n \n struct io_tw_req {\n@@ -827,6 +831,7 @@ struct io_kiocb {\n \t/* custom credentials, valid IFF REQ_F_CREDS is set */\n \tconst struct cred\t\t*creds;\n \tstruct io_wq_work\t\twork;\n+\tstruct dma_buf_io_map\t\t*dmabuf_map;\n \n \tstruct io_big_cqe {\n \t\tu64\t\t\textra1;\ndiff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h\nindex b42b66b424a76..b456f45fa8de7 100644\n--- a/include/uapi/linux/io_uring.h\n+++ b/include/uapi/linux/io_uring.h\n@@ -791,13 +791,42 @@ struct io_uring_rsrc_update {\n \n struct io_uring_rsrc_update2 {\n \t__u32 offset;\n-\t__u32 resv;\n+\t__u32 flags;\n \t__aligned_u64 data;\n \t__aligned_u64 tags;\n \t__u32 nr;\n \t__u32 resv2;\n };\n \n+/* struct io_uring_rsrc_update2::flags */\n+enum io_uring_rsrc_reg_flags {\n+\t/*\n+\t * Use the extended descriptor format for buffer updates,\n+\t * see struct io_uring_regbuf_desc\n+\t */\n+\tIORING_RSRC_UPDATE_EXTENDED\t\t= 1U \u003c\u003c 1,\n+};\n+\n+/* Buffer registration type, passed in struct io_uring_regbuf_desc::type */\n+enum io_uring_regbuf_type {\n+\tIO_REGBUF_TYPE_EMPTY,\n+\tIO_REGBUF_TYPE_UADDR,\n+\tIO_REGBUF_TYPE_DMABUF,\n+\n+\t__IO_REGBUF_TYPE_MAX,\n+};\n+\n+struct io_uring_regbuf_desc {\n+\t__u32 type; /* enum io_uring_regbuf_type */\n+\t__u32 flags;\n+\t__u64 size;\n+\t__u64 uaddr;\n+\n+\t__s32 dmabuf_fd;\n+\t__s32 target_fd;\n+\t__u64 __resv[6];\n+};\n+\n /* Skip updating fd indexes set to this value in the fd table */\n #define IORING_REGISTER_FILES_SKIP\t(-2)\n \ndiff --git a/io_uring/Makefile b/io_uring/Makefile\nindex c54e328d14104..965bb60e9f7b1 100644\n--- a/io_uring/Makefile\n+++ b/io_uring/Makefile\n@@ -26,3 +26,4 @@ obj-$(CONFIG_PROC_FS) += fdinfo.o\n obj-$(CONFIG_IO_URING_MOCK_FILE) += mock_file.o\n obj-$(CONFIG_IO_URING_BPF) += bpf_filter.o\n obj-$(CONFIG_IO_URING_BPF_OPS) += bpf-ops.o\n+obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o\ndiff --git a/io_uring/dma-buf.c b/io_uring/dma-buf.c\nnew file mode 100644\nindex 0000000000000..f40c9d87ed8aa\n--- /dev/null\n+++ b/io_uring/dma-buf.c\n@@ -0,0 +1,68 @@\n+#include \"dma-buf.h\"\n+\n+static inline void io_release_dmabuf(void *priv)\n+{\n+\tstruct io_buf_dma *bd = priv;\n+\n+\tfput(bd-\u003etarget_file);\n+\tdma_buf_io_ctx_release(bd-\u003ectx);\n+\tkfree(bd);\n+}\n+\n+int io_register_dmabuf(struct io_ring_ctx *ctx,\n+\t\t\tstruct io_uring_regbuf_desc *desc,\n+\t\t\tstruct io_mapped_ubuf *imu)\n+{\n+\tstruct io_buf_dma *bd = NULL;\n+\tstruct file *target_file = NULL;\n+\tstruct dma_buf *dmabuf = NULL;\n+\tint ret;\n+\n+\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\n+\t\treturn -EOPNOTSUPP;\n+\tif (ctx-\u003eflags \u0026 IORING_SETUP_IOPOLL)\n+\t\treturn -EOPNOTSUPP;\n+\tif (desc-\u003euaddr || desc-\u003esize)\n+\t\treturn -EINVAL;\n+\n+\tbd = kzalloc(sizeof(*bd), GFP_KERNEL);\n+\tif (!bd)\n+\t\treturn -ENOMEM;\n+\n+\ttarget_file = fget(desc-\u003etarget_fd);\n+\tif (!target_file) {\n+\t\tret = -EBADF;\n+\t\tgoto err;\n+\t}\n+\tdmabuf = dma_buf_get(desc-\u003edmabuf_fd);\n+\tif (IS_ERR(dmabuf)) {\n+\t\tret = PTR_ERR(dmabuf);\n+\t\tdmabuf = NULL;\n+\t\tgoto err;\n+\t}\n+\tret = io_validate_user_buf_range(0, dmabuf-\u003esize);\n+\tif (ret)\n+\t\tgoto err;\n+\n+\tret = dma_buf_io_ctx_create(target_file, dmabuf, DMA_BIDIRECTIONAL,\n+\t\t\t\t \u0026bd-\u003ectx);\n+\tif (ret)\n+\t\tgoto err;\n+\n+\tbd-\u003etarget_file = target_file;\n+\timu-\u003elen = dmabuf-\u003esize;\n+\timu-\u003erelease = io_release_dmabuf;\n+\timu-\u003epriv = bd;\n+\timu-\u003eflags = IO_REGBUF_F_DMABUF;\n+\timu-\u003edir = IO_BUF_DEST | IO_BUF_SOURCE;\n+\tdma_buf_put(dmabuf);\n+\treturn 0;\n+err:\n+\tkfree(bd);\n+\tif (target_file)\n+\t\tfput(target_file);\n+\tif (dmabuf)\n+\t\tdma_buf_put(dmabuf);\n+\treturn ret;\n+}\n+\ndiff --git a/io_uring/dma-buf.h b/io_uring/dma-buf.h\nnew file mode 100644\nindex 0000000000000..10d2efdd8c9f1\n--- /dev/null\n+++ b/io_uring/dma-buf.h\n@@ -0,0 +1,67 @@\n+// SPDX-License-Identifier: GPL-2.0\n+#ifndef IOU_DMA_BUF_H\n+#define IOU_DMA_BUF_H\n+\n+#include \u003clinux/dma-buf-io.h\u003e\n+#include \u003clinux/io_uring_types.h\u003e\n+\n+#include \"rsrc.h\"\n+\n+struct io_buf_dma {\n+\tstruct dma_buf_io_ctx\t\t*ctx;\n+\tstruct file\t\t\t*target_file;\n+};\n+\n+static inline void io_detach_dmabuf_map(struct io_kiocb *req)\n+{\n+\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\n+\t\treturn;\n+\tif (!(req-\u003eflags \u0026 REQ_F_DMABUF) || !req-\u003edmabuf_map)\n+\t\treturn;\n+\tdma_buf_io_map_drop(req-\u003edmabuf_map);\n+\treq-\u003edmabuf_map = NULL;\n+}\n+\n+static inline int io_attach_dmabuf_map(struct io_kiocb *req,\n+\t\t\t\t\tstruct iov_iter *iter,\n+\t\t\t\t\tunsigned issue_flags)\n+{\n+\tbool nowait = issue_flags \u0026 IO_URING_F_NONBLOCK;\n+\tstruct dma_buf_io_map *map;\n+\tstruct io_buf_dma *bd;\n+\n+\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\n+\t\treturn -EOPNOTSUPP;\n+\tif (!(req-\u003eflags \u0026 REQ_F_DMABUF))\n+\t\treturn 0;\n+\n+\tbd = req-\u003ebuf_node-\u003ebuf-\u003epriv;\n+\tmap = dma_buf_io_get_map(bd-\u003ectx, nowait);\n+\tif (unlikely(IS_ERR(map)))\n+\t\treturn PTR_ERR(map);\n+\treq-\u003edmabuf_map = map;\n+\titer-\u003edmabuf_map = map;\n+\treturn 0;\n+}\n+\n+static inline int io_import_dmabuf_map(struct io_kiocb *req,\n+\t\t\t\tint ddir, struct iov_iter *iter,\n+\t\t\t\tstruct io_mapped_ubuf *imu,\n+\t\t\t\tsize_t len, size_t offset)\n+{\n+\tstruct io_buf_dma *bd = imu-\u003epriv;\n+\n+\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\n+\t\treturn -EOPNOTSUPP;\n+\tif (req-\u003efile != bd-\u003etarget_file)\n+\t\treturn -EBADF;\n+\treq-\u003eflags |= REQ_F_DMABUF;\n+\tiov_iter_dmabuf_map(iter, ddir, NULL, offset, len);\n+\treturn 0;\n+}\n+\n+int io_register_dmabuf(struct io_ring_ctx *ctx,\n+\t\t\tstruct io_uring_regbuf_desc *desc,\n+\t\t\tstruct io_mapped_ubuf *imu);\n+\n+#endif /* IOU_DMA_BUF_H */\ndiff --git a/io_uring/rsrc.c b/io_uring/rsrc.c\nindex 1efaf29514e8d..d6f7cbf731eb2 100644\n--- a/io_uring/rsrc.c\n+++ b/io_uring/rsrc.c\n@@ -10,6 +10,7 @@\n #include \u003clinux/compat.h\u003e\n #include \u003clinux/io_uring.h\u003e\n #include \u003clinux/io_uring/cmd.h\u003e\n+#include \u003clinux/dma-buf-io.h\u003e\n \n #include \u003cuapi/linux/io_uring.h\u003e\n \n@@ -19,6 +20,7 @@\n #include \"rsrc.h\"\n #include \"memmap.h\"\n #include \"register.h\"\n+#include \"dma-buf.h\"\n \n struct io_rsrc_update {\n \tstruct file\t\t\t*file;\n@@ -28,7 +30,7 @@ struct io_rsrc_update {\n };\n \n static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,\n-\t\t\t\t\t\t struct iovec *iov);\n+\t\t\t\t\t\t struct io_uring_regbuf_desc *desc);\n \n static int hpage_acct_ref(struct io_ring_ctx *ctx, struct page *hpage,\n \t\t\t bool *acct_new)\n@@ -81,6 +83,18 @@ static bool hpage_acct_unref(struct io_ring_ctx *ctx, struct page *hpage)\n \n #define IO_CACHED_BVECS_SEGS\t32\n \n+static void io_iov_to_regbuf_desc(const struct iovec *iov,\n+\t\t\t\t struct io_uring_regbuf_desc *desc)\n+{\n+\t*desc = (struct io_uring_regbuf_desc) {\n+\t\t.type = IO_REGBUF_TYPE_UADDR,\n+\t\t.uaddr = (u64)(uintptr_t)iov-\u003eiov_base,\n+\t\t.size = iov-\u003eiov_len,\n+\t};\n+\tif (!desc-\u003euaddr)\n+\t\tdesc-\u003etype = IO_REGBUF_TYPE_EMPTY;\n+}\n+\n int __io_account_mem(struct user_struct *user, unsigned long nr_pages)\n {\n \tunsigned long page_limit, cur_pages, new_pages;\n@@ -326,6 +340,8 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,\n \t\treturn -ENXIO;\n \tif (up-\u003eoffset + nr_args \u003e ctx-\u003efile_table.data.nr)\n \t\treturn -EINVAL;\n+\tif (up-\u003eflags)\n+\t\treturn -EINVAL;\n \n \tfor (done = 0; done \u003c nr_args; done++) {\n \t\tu64 tag = 0;\n@@ -385,9 +401,8 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,\n \t\t\t\t struct io_uring_rsrc_update2 *up,\n \t\t\t\t unsigned int nr_args)\n {\n+\tbool extended = up-\u003eflags \u0026 IORING_RSRC_UPDATE_EXTENDED;\n \tu64 __user *tags = u64_to_user_ptr(up-\u003etags);\n-\tstruct iovec fast_iov, *iov;\n-\tstruct iovec __user *uvec;\n \tu64 user_data = up-\u003edata;\n \t__u32 done;\n \tint i, err;\n@@ -396,26 +411,49 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,\n \t\treturn -ENXIO;\n \tif (up-\u003eoffset + nr_args \u003e ctx-\u003ebuf_table.nr)\n \t\treturn -EINVAL;\n+\tif (up-\u003eflags \u0026 ~IORING_RSRC_UPDATE_EXTENDED)\n+\t\treturn -EINVAL;\n \n \tfor (done = 0; done \u003c nr_args; done++) {\n+\t\tstruct io_uring_regbuf_desc desc;\n \t\tstruct io_rsrc_node *node;\n \t\tu64 tag = 0;\n \n-\t\tuvec = u64_to_user_ptr(user_data);\n-\t\tiov = iovec_from_user(uvec, 1, 1, \u0026fast_iov, io_is_compat(ctx));\n-\t\tif (IS_ERR(iov)) {\n-\t\t\terr = PTR_ERR(iov);\n-\t\t\tbreak;\n-\t\t}\n \t\tif (tags \u0026\u0026 copy_from_user(\u0026tag, \u0026tags[done], sizeof(tag))) {\n \t\t\terr = -EFAULT;\n \t\t\tbreak;\n \t\t}\n-\t\tnode = io_sqe_buffer_register(ctx, iov);\n+\n+\t\tif (extended) {\n+\t\t\tif (copy_from_user(\u0026desc, u64_to_user_ptr(user_data),\n+\t\t\t\t\t sizeof(desc))) {\n+\t\t\t\terr = -EFAULT;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tuser_data += sizeof(desc);\n+\t\t} else {\n+\t\t\tstruct iovec __user *uvec = u64_to_user_ptr(user_data);\n+\t\t\tstruct iovec fast_iov, *iov;\n+\n+\t\t\tif (io_is_compat(ctx))\n+\t\t\t\tuser_data += sizeof(struct compat_iovec);\n+\t\t\telse\n+\t\t\t\tuser_data += sizeof(struct iovec);\n+\n+\t\t\tiov = iovec_from_user(uvec, 1, 1, \u0026fast_iov, io_is_compat(ctx));\n+\t\t\tif (IS_ERR(iov)) {\n+\t\t\t\terr = PTR_ERR(iov);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tio_iov_to_regbuf_desc(iov, \u0026desc);\n+\t\t}\n+\n+\t\tnode = io_sqe_buffer_register(ctx, \u0026desc);\n \t\tif (IS_ERR(node)) {\n \t\t\terr = PTR_ERR(node);\n \t\t\tbreak;\n \t\t}\n+\n \t\tif (tag) {\n \t\t\tif (!node) {\n \t\t\t\terr = -EINVAL;\n@@ -426,10 +464,6 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,\n \t\ti = array_index_nospec(up-\u003eoffset + done, ctx-\u003ebuf_table.nr);\n \t\tio_reset_rsrc_node(ctx, \u0026ctx-\u003ebuf_table, i);\n \t\tctx-\u003ebuf_table.nodes[i] = node;\n-\t\tif (io_is_compat(ctx))\n-\t\t\tuser_data += sizeof(struct compat_iovec);\n-\t\telse\n-\t\t\tuser_data += sizeof(struct iovec);\n \t}\n \treturn done ? done : err;\n }\n@@ -464,7 +498,7 @@ int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,\n \tmemset(\u0026up, 0, sizeof(up));\n \tif (copy_from_user(\u0026up, arg, sizeof(struct io_uring_rsrc_update)))\n \t\treturn -EFAULT;\n-\tif (up.resv || up.resv2)\n+\tif (up.resv2)\n \t\treturn -EINVAL;\n \treturn __io_register_rsrc_update(ctx, IORING_RSRC_FILE, \u0026up, nr_args);\n }\n@@ -478,7 +512,7 @@ int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg,\n \t\treturn -EINVAL;\n \tif (copy_from_user(\u0026up, arg, sizeof(up)))\n \t\treturn -EFAULT;\n-\tif (!up.nr || up.resv || up.resv2)\n+\tif (!up.nr || up.resv2)\n \t\treturn -EINVAL;\n \treturn __io_register_rsrc_update(ctx, type, \u0026up, up.nr);\n }\n@@ -578,12 +612,9 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)\n \tstruct io_uring_rsrc_update2 up2;\n \tint ret;\n \n+\tmemset(\u0026up2, 0, sizeof(up2));\n \tup2.offset = up-\u003eoffset;\n \tup2.data = up-\u003earg;\n-\tup2.nr = 0;\n-\tup2.tags = 0;\n-\tup2.resv = 0;\n-\tup2.resv2 = 0;\n \n \tif (up-\u003eoffset == IORING_FILE_INDEX_ALLOC) {\n \t\tret = io_files_update_with_index_alloc(req, issue_flags);\n@@ -869,27 +900,70 @@ bool io_check_coalesce_buffer(struct page **page_array, int nr_pages,\n \treturn true;\n }\n \n+static struct io_rsrc_node *io_register_dmabuf_desc(struct io_ring_ctx *ctx,\n+\t\t\t\t\t\t struct io_uring_regbuf_desc *desc)\n+{\n+\tstruct io_rsrc_node *node = NULL;\n+\tstruct io_mapped_ubuf *imu = NULL;\n+\tint ret;\n+\n+\tnode = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER);\n+\tif (!node)\n+\t\treturn ERR_PTR(-ENOMEM);\n+\n+\timu = io_alloc_imu(ctx, 0);\n+\tif (!imu) {\n+\t\tret = -ENOMEM;\n+\t\tgoto err;\n+\t}\n+\tmemset(imu, 0, sizeof(*imu));\n+\trefcount_set(\u0026imu-\u003erefs, 1);\n+\n+\tret = io_register_dmabuf(ctx, desc, imu);\n+\tif (ret)\n+\t\tgoto err;\n+\tnode-\u003ebuf = imu;\n+\treturn node;\n+err:\n+\tif (imu)\n+\t\tio_free_imu(ctx, imu);\n+\tif (node)\n+\t\tio_cache_free(\u0026ctx-\u003enode_cache, node);\n+\treturn ERR_PTR(ret);\n+}\n+\n static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,\n-\t\t\t\t\t\t struct iovec *iov)\n+\t\t\t\t\t\t struct io_uring_regbuf_desc *desc)\n {\n+\tunsigned long uaddr = (unsigned long)desc-\u003euaddr;\n+\tsize_t size = desc-\u003esize;\n \tstruct io_mapped_ubuf *imu = NULL;\n \tstruct page **pages = NULL;\n \tstruct io_rsrc_node *node;\n \tunsigned long off;\n-\tsize_t size;\n \tint ret, nr_pages, i;\n \tstruct io_imu_folio_data data;\n \tbool coalesced = false;\n \n-\tif (!iov-\u003eiov_base) {\n-\t\tif (iov-\u003eiov_len)\n+\tif (desc-\u003etype \u003e= __IO_REGBUF_TYPE_MAX)\n+\t\treturn ERR_PTR(-EINVAL);\n+\tif (!mem_is_zero(\u0026desc-\u003e__resv, sizeof(desc-\u003e__resv)) || desc-\u003eflags)\n+\t\treturn ERR_PTR(-EINVAL);\n+\n+\tif (desc-\u003etype == IO_REGBUF_TYPE_DMABUF)\n+\t\treturn io_register_dmabuf_desc(ctx, desc);\n+\n+\tif (desc-\u003edmabuf_fd || desc-\u003etarget_fd)\n+\t\treturn ERR_PTR(-EINVAL);\n+\n+\tif (desc-\u003etype == IO_REGBUF_TYPE_EMPTY) {\n+\t\tif (uaddr || size)\n \t\t\treturn ERR_PTR(-EFAULT);\n \t\t/* remove the buffer without installing a new one */\n \t\treturn NULL;\n \t}\n \n-\tret = io_validate_user_buf_range((unsigned long)iov-\u003eiov_base,\n-\t\t\t\t\t iov-\u003eiov_len);\n+\tret = io_validate_user_buf_range(uaddr, size);\n \tif (ret)\n \t\treturn ERR_PTR(ret);\n \n@@ -898,8 +972,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,\n \t\treturn ERR_PTR(-ENOMEM);\n \n \tret = -ENOMEM;\n-\tpages = io_pin_pages((unsigned long) iov-\u003eiov_base, iov-\u003eiov_len,\n-\t\t\t\t\u0026nr_pages);\n+\tpages = io_pin_pages(uaddr, size, \u0026nr_pages);\n \tif (IS_ERR(pages)) {\n \t\tret = PTR_ERR(pages);\n \t\tpages = NULL;\n@@ -921,10 +994,9 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,\n \tif (ret)\n \t\tgoto done;\n \n-\tsize = iov-\u003eiov_len;\n \t/* store original address for later verification */\n-\timu-\u003eubuf = (unsigned long) iov-\u003eiov_base;\n-\timu-\u003elen = iov-\u003eiov_len;\n+\timu-\u003eubuf = uaddr;\n+\timu-\u003elen = size;\n \timu-\u003efolio_shift = PAGE_SHIFT;\n \timu-\u003erelease = io_release_ubuf;\n \timu-\u003epriv = imu;\n@@ -934,7 +1006,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,\n \t\timu-\u003efolio_shift = data.folio_shift;\n \trefcount_set(\u0026imu-\u003erefs, 1);\n \n-\toff = (unsigned long)iov-\u003eiov_base \u0026 ~PAGE_MASK;\n+\toff = uaddr \u0026 ~PAGE_MASK;\n \tif (coalesced)\n \t\toff += data.first_folio_page_idx \u003c\u003c PAGE_SHIFT;\n \n@@ -986,6 +1058,7 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,\n \t\tmemset(iov, 0, sizeof(*iov));\n \n \tfor (i = 0; i \u003c nr_args; i++) {\n+\t\tstruct io_uring_regbuf_desc desc;\n \t\tstruct io_rsrc_node *node;\n \t\tu64 tag = 0;\n \n@@ -1009,7 +1082,8 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,\n \t\t\t}\n \t\t}\n \n-\t\tnode = io_sqe_buffer_register(ctx, iov);\n+\t\tio_iov_to_regbuf_desc(iov, \u0026desc);\n+\t\tnode = io_sqe_buffer_register(ctx, \u0026desc);\n \t\tif (IS_ERR(node)) {\n \t\t\tret = PTR_ERR(node);\n \t\t\tbreak;\n@@ -1206,9 +1280,12 @@ static int io_import_kbuf(int ddir, struct iov_iter *iter,\n \treturn 0;\n }\n \n-static int io_import_fixed(int ddir, struct iov_iter *iter,\n+static int io_import_fixed(struct io_kiocb *req,\n+\t\t\t int ddir, struct iov_iter *iter,\n \t\t\t struct io_mapped_ubuf *imu,\n-\t\t\t u64 buf_addr, size_t len)\n+\t\t\t u64 buf_addr, size_t len,\n+\t\t\t unsigned issue_flags,\n+\t\t\t unsigned import_flags)\n {\n \tconst struct bio_vec *bvec;\n \tsize_t folio_mask;\n@@ -1228,6 +1305,11 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,\n \n \toffset = buf_addr - imu-\u003eubuf;\n \n+\tif (imu-\u003eflags \u0026 IO_REGBUF_F_DMABUF) {\n+\t\tif (!(import_flags \u0026 IO_REGBUF_IMPORT_ALLOW_DMABUF))\n+\t\t\treturn -EFAULT;\n+\t\treturn io_import_dmabuf_map(req, ddir, iter, imu, len, offset);\n+\t}\n \tif (imu-\u003eflags \u0026 IO_REGBUF_F_KBUF)\n \t\treturn io_import_kbuf(ddir, iter, imu, len, offset);\n \n@@ -1281,16 +1363,17 @@ inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,\n \treturn NULL;\n }\n \n-int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,\n+int __io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,\n \t\t\tu64 buf_addr, size_t len, int ddir,\n-\t\t\tunsigned issue_flags)\n+\t\t\tunsigned issue_flags, unsigned import_flags)\n {\n \tstruct io_rsrc_node *node;\n \n \tnode = io_find_buf_node(req, issue_flags);\n \tif (!node)\n \t\treturn -EFAULT;\n-\treturn io_import_fixed(ddir, iter, node-\u003ebuf, buf_addr, len);\n+\treturn io_import_fixed(req, ddir, iter, node-\u003ebuf, buf_addr, len,\n+\t\t\t\tissue_flags, import_flags);\n }\n \n static int io_buffer_acct_cloned_hpages(struct io_ring_ctx *ctx,\n@@ -1422,6 +1505,11 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx\n \t\tif (!src_node) {\n \t\t\tdst_node = NULL;\n \t\t} else {\n+\t\t\tif (src_node-\u003ebuf-\u003eflags \u0026 IO_REGBUF_F_UNCLONEABLE) {\n+\t\t\t\tio_rsrc_data_free(ctx, \u0026data);\n+\t\t\t\treturn -EOPNOTSUPP;\n+\t\t\t}\n+\n \t\t\tdst_node = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER);\n \t\t\tif (!dst_node) {\n \t\t\t\tio_rsrc_data_free(ctx, \u0026data);\n@@ -1692,9 +1780,9 @@ static int io_kern_bvec_size(struct iovec *iov, unsigned nr_iovs,\n \treturn 0;\n }\n \n-int io_import_reg_vec(int ddir, struct iov_iter *iter,\n+int __io_import_reg_vec(int ddir, struct iov_iter *iter,\n \t\t\tstruct io_kiocb *req, struct iou_vec *vec,\n-\t\t\tunsigned nr_iovs, unsigned issue_flags)\n+\t\t\tunsigned nr_iovs, unsigned issue_flags, unsigned import_flags)\n {\n \tstruct io_rsrc_node *node;\n \tstruct io_mapped_ubuf *imu;\n@@ -1712,7 +1800,9 @@ int io_import_reg_vec(int ddir, struct iov_iter *iter,\n \tiovec_off = vec-\u003enr - nr_iovs;\n \tiov = vec-\u003eiovec + iovec_off;\n \n-\tif (imu-\u003eflags \u0026 IO_REGBUF_F_KBUF) {\n+\tif (imu-\u003eflags \u0026 IO_REGBUF_F_DMABUF) {\n+\t\treturn -EOPNOTSUPP;\n+\t} else if (imu-\u003eflags \u0026 IO_REGBUF_F_KBUF) {\n \t\tint ret = io_kern_bvec_size(iov, nr_iovs, imu, \u0026nr_segs);\n \n \t\tif (unlikely(ret))\ndiff --git a/io_uring/rsrc.h b/io_uring/rsrc.h\nindex 9ef88383b3636..d893cc5e580a0 100644\n--- a/io_uring/rsrc.h\n+++ b/io_uring/rsrc.h\n@@ -26,7 +26,13 @@ struct io_rsrc_node {\n };\n \n enum {\n-\tIO_REGBUF_F_KBUF\t\t= 1,\n+\tIO_REGBUF_F_KBUF\t\t= 1 \u003c\u003c 0,\n+\tIO_REGBUF_F_UNCLONEABLE\t\t= 1 \u003c\u003c 1,\n+\tIO_REGBUF_F_DMABUF\t\t= 1 \u003c\u003c 3,\n+};\n+\n+enum {\n+\tIO_REGBUF_IMPORT_ALLOW_DMABUF\t\t= 1 \u003c\u003c 1,\n };\n \n struct io_mapped_ubuf {\n@@ -61,12 +67,28 @@ int io_rsrc_data_alloc(struct io_rsrc_data *data, unsigned nr);\n \n struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,\n \t\t\t\t unsigned issue_flags);\n-int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,\n+int __io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,\n \t\t\tu64 buf_addr, size_t len, int ddir,\n-\t\t\tunsigned issue_flags);\n-int io_import_reg_vec(int ddir, struct iov_iter *iter,\n+\t\t\tunsigned issue_flags, unsigned import_flags);\n+int __io_import_reg_vec(int ddir, struct iov_iter *iter,\n \t\t\tstruct io_kiocb *req, struct iou_vec *vec,\n-\t\t\tunsigned nr_iovs, unsigned issue_flags);\n+\t\t\tunsigned nr_iovs, unsigned issue_flags,\n+\t\t\tunsigned import_flags);\n+\n+static inline int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,\n+\t\t\t\t u64 buf_addr, size_t len, int ddir,\n+\t\t\t\t unsigned issue_flags)\n+{\n+\treturn __io_import_reg_buf(req, iter, buf_addr, len, ddir, issue_flags, 0);\n+}\n+\n+static inline int io_import_reg_vec(int ddir, struct iov_iter *iter,\n+\t\t\t\t struct io_kiocb *req, struct iou_vec *vec,\n+\t\t\t\t unsigned nr_iovs, unsigned issue_flags)\n+{\n+\treturn __io_import_reg_vec(ddir, iter, req, vec, nr_iovs, issue_flags, 0);\n+}\n+\n int io_prep_reg_iovec(struct io_kiocb *req, struct iou_vec *iv,\n \t\t\tconst struct iovec __user *uvec, size_t uvec_segs);\n \ndiff --git a/io_uring/rw.c b/io_uring/rw.c\nindex 999d9a1cc5a56..d33b925a848e5 100644\n--- a/io_uring/rw.c\n+++ b/io_uring/rw.c\n@@ -23,6 +23,7 @@\n #include \"rsrc.h\"\n #include \"poll.h\"\n #include \"rw.h\"\n+#include \"dma-buf.h\"\n \n static void io_complete_rw(struct kiocb *kiocb, long res);\n static void io_complete_rw_iopoll(struct kiocb *kiocb, long res);\n@@ -358,13 +359,18 @@ static int io_init_rw_fixed(struct io_kiocb *req, unsigned int issue_flags,\n \tstruct io_async_rw *io = req-\u003easync_data;\n \tint ret;\n \n-\tif (io-\u003ebytes_done)\n-\t\treturn 0;\n+\tif (!io-\u003ebytes_done) {\n+\t\tret = __io_import_reg_buf(req, \u0026io-\u003eiter, rw-\u003eaddr, rw-\u003elen, ddir,\n+\t\t\t\t\t issue_flags, IO_REGBUF_IMPORT_ALLOW_DMABUF);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t\tiov_iter_save_state(\u0026io-\u003eiter, \u0026io-\u003eiter_state);\n+\t}\n \n-\tret = io_import_reg_buf(req, \u0026io-\u003eiter, rw-\u003eaddr, rw-\u003elen, ddir,\n-\t\t\t\tissue_flags);\n-\tiov_iter_save_state(\u0026io-\u003eiter, \u0026io-\u003eiter_state);\n-\treturn ret;\n+\tret = io_attach_dmabuf_map(req, \u0026io-\u003eiter, issue_flags);\n+\tif (ret)\n+\t\treturn ret;\n+\treturn 0;\n }\n \n int io_prep_read_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe)\n@@ -577,6 +583,8 @@ static void io_complete_rw(struct kiocb *kiocb, long res)\n \tstruct io_rw *rw = container_of(kiocb, struct io_rw, kiocb);\n \tstruct io_kiocb *req = cmd_to_io_kiocb(rw);\n \n+\tio_detach_dmabuf_map(req);\n+\n \t/* ring owner may block in freeze_super() before task_work runs */\n \tif (kiocb-\u003eki_flags \u0026 IOCB_WRITE)\n \t\tio_req_end_write(req);\n@@ -698,7 +706,7 @@ static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)\n \t !(kiocb-\u003eki_filp-\u003ef_flags \u0026 O_NONBLOCK))\n \t\treturn -EAGAIN;\n \tif ((req-\u003eflags \u0026 REQ_F_BUF_NODE) \u0026\u0026\n-\t (req-\u003ebuf_node-\u003ebuf-\u003eflags \u0026 IO_REGBUF_F_KBUF))\n+\t (req-\u003ebuf_node-\u003ebuf-\u003eflags \u0026 (IO_REGBUF_F_KBUF|IO_REGBUF_F_DMABUF)))\n \t\treturn -EFAULT;\n \n \tppos = io_kiocb_ppos(kiocb);\n@@ -1226,7 +1234,10 @@ int io_read_fixed(struct io_kiocb *req, unsigned int issue_flags)\n \tif (unlikely(ret))\n \t\treturn ret;\n \n-\treturn io_read(req, issue_flags);\n+\tret = io_read(req, issue_flags);\n+\tif (ret != -EIOCBQUEUED)\n+\t\tio_detach_dmabuf_map(req);\n+\treturn ret;\n }\n \n int io_write_fixed(struct io_kiocb *req, unsigned int issue_flags)\n@@ -1237,7 +1248,11 @@ int io_write_fixed(struct io_kiocb *req, unsigned int issue_flags)\n \tif (unlikely(ret))\n \t\treturn ret;\n \n-\treturn io_write(req, issue_flags);\n+\tret = io_write(req, issue_flags);\n+\tif (ret != -EIOCBQUEUED)\n+\t\tio_detach_dmabuf_map(req);\n+\treturn ret;\n+\n }\n \n void io_rw_fail(struct io_kiocb *req)\n"
} |
| 2/1 | 2026/10/07 01:56 | agent | patch-evaluator |
12mModel:core Args: null Results: {
"EnableConfigs": [
"IO_URING",
"DMA_SHARED_BUFFER",
"BLK_DEV_NVME",
"DMABUF_HEAPS",
"DMABUF_HEAPS_SYSTEM",
"UDMABUF",
"BLK_DEV_DM"
],
"FocusSymbols": [
"io_register_dmabuf",
"io_register_rsrc_update",
"io_sqe_buffers_register",
"__io_import_reg_buf",
"io_read_fixed",
"io_write_fixed",
"bio_iov_iter_set",
"bio_split_io_at",
"nvme_rq_setup_dmabuf",
"__nvme_init_dma_buf_io_ctx",
"__nvme_pci_remove_dmabuf"
],
"Reasoning": "The patch introduces support for dma-buf backed fixed buffers in io_uring, the block layer, and NVMe PCI host driver. It adds new registration logic (IORING_RSRC_UPDATE_EXTENDED, IO_REGBUF_TYPE_DMABUF), bio cloning/splitting adjustments for dma-buf bios, and NVMe request PRP/SGL construction from dma-buf scatterlists. These changes modify core reachable subsystems (io_uring, block layer) and QEMU-emulated hardware drivers (NVMe PCI). Fuzzing is warranted to uncover boundary issues, lifecycle bugs, and regressions in fixed buffer and bio iter handling.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 94b94c945655f70393579916fdfa996691884372
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Oct 7 01:56:37 2026 +0000
syz-cluster: applied patch under review
diff --git a/block/bio.c b/block/bio.c
index b48091c7663fa..1e0d9714c5413 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -881,7 +881,11 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
bio->bi_write_stream = bio_src->bi_write_stream;
bio->bi_bvec_gap_bit = bio_src->bi_bvec_gap_bit;
bio->bi_iter = bio_src->bi_iter;
- bio->bi_io_vec = bio_src->bi_io_vec;
+
+ if (op_is_dmabuf(bio->bi_opf))
+ bio->bi_dmabuf_map = bio_src->bi_dmabuf_map;
+ else
+ bio->bi_io_vec = bio_src->bi_io_vec;
if (bio->bi_bdev) {
if (bio->bi_bdev == bio_src->bi_bdev &&
@@ -1204,16 +1208,23 @@ EXPORT_SYMBOL_GPL(__bio_release_pages);
bool bio_iov_iter_set(struct bio *bio, const struct iov_iter *iter)
{
- if (!iov_iter_is_bvec(iter))
+ if (!iov_iter_is_bvec(iter) && !iov_iter_is_dmabuf_map(iter))
return false;
WARN_ON_ONCE(bio->bi_max_vecs);
+ static_assert(offsetof(struct bio, bi_io_vec) ==
+ offsetof(struct bio, bi_dmabuf_map));
+ static_assert(offsetof(struct iov_iter, bvec) ==
+ offsetof(struct iov_iter, dmabuf_map));
+
bio->bi_io_vec = (struct bio_vec *)iter->bvec;
bio->bi_iter.bi_idx = 0;
bio->bi_iter.bi_offset = iter->iov_offset;
bio->bi_iter.bi_size = iov_iter_count(iter);
bio_set_flag(bio, BIO_CLONED);
+ if (iov_iter_is_dmabuf_map(iter))
+ bio->bi_opf |= REQ_NOMERGE | REQ_DMABUF;
return true;
}
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 258a726071d12..18f014ff3314b 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -9,6 +9,7 @@
#include <linux/blk-integrity.h>
#include <linux/part_stat.h>
#include <linux/blk-cgroup.h>
+#include <linux/dma-buf-io.h>
#include <trace/events/block.h>
@@ -319,6 +320,41 @@ static inline unsigned int bvec_seg_gap(struct bio_vec *bvprv,
return bv->bv_offset | (bvprv->bv_offset + bvprv->bv_len);
}
+static inline int bio_split_io_at_dmabuf(struct bio *bio,
+ const struct queue_limits *lim, unsigned *segs,
+ unsigned max_bytes, unsigned len_align_mask,
+ unsigned start_align_mask)
+{
+ unsigned bytes = min(bio->bi_iter.bi_size, max_bytes);
+ unsigned seg_shift = bio->bi_dmabuf_map->min_seg_shift;
+ unsigned offset = bio->bi_iter.bi_offset & ((1U << seg_shift) - 1);
+ u64 max_segs_bytes;
+
+ /*
+ * dma-buf maps don't expose the underlying segmentation, but they're
+ * guaranteed to not have alignment gaps, we only need to check the
+ * start and length alignment.
+ */
+ if ((bio->bi_iter.bi_offset & start_align_mask) ||
+ (bio->bi_iter.bi_size & len_align_mask))
+ return -EINVAL;
+
+ /* Presented as a single contiguous range into the dma-buf */
+ *segs = 1;
+
+ /*
+ * Limit by the number of segments by using the minimal segment size.
+ * Any I/O consisting of N full segments should be able to cover at
+ * least N multiplied by the segment size. It's stricter than walking
+ * the segments and might cause extra splitting.
+ */
+ max_segs_bytes = (u64)lim->max_segments << seg_shift;
+ bytes = min_t(u64, bytes, max_segs_bytes - offset);
+ if (bytes != bio->bi_iter.bi_size)
+ return bytes;
+ return 0;
+}
+
/**
* bio_split_io_at - check if and where to split a bio
* @bio: [in] bio to be split
@@ -346,6 +382,19 @@ int bio_split_io_at(struct bio *bio, const struct queue_limits *lim,
len_align_mask |= (bc->bc_key->crypto_cfg.data_unit_size - 1);
}
+ if (op_is_dmabuf(bio->bi_opf)) {
+ int ret;
+
+ ret = bio_split_io_at_dmabuf(bio, lim, &nsegs, max_bytes,
+ len_align_mask, start_align_mask);
+ if (ret < 0)
+ return ret;
+ if (!ret)
+ goto out;
+ bytes = ret;
+ goto split;
+ }
+
bio_for_each_bvec(bv, bio, iter) {
if (bv.bv_offset & start_align_mask ||
bv.bv_len & len_align_mask)
@@ -376,6 +425,7 @@ int bio_split_io_at(struct bio *bio, const struct queue_limits *lim,
bvprvp = &bvprv;
}
+out:
*segs = nsegs;
bio->bi_bvec_gap_bit = ffs(gaps);
return 0;
diff --git a/block/fops.c b/block/fops.c
index 9905ed24a1578..e9da48ab73be6 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -362,7 +362,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,
* Users don't rely on the iterator being in any particular
* state for async I/O returning -EIOCBQUEUED, hence we can
* avoid expensive iov_iter_advance(). Bypass
- * bio_iov_iter_get_pages() and set the bvec directly.
+ * bio_iov_iter_get_pages() and set the bvec/dmabuf directly.
*/
if (!bio_iov_iter_set(bio, iter)) {
ret = blkdev_iov_iter_get_pages(bio, iter, bdev);
@@ -730,6 +730,9 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from)
static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from)
{
+ if (unlikely(iov_iter_is_dmabuf_map(from)))
+ return -EOPNOTSUPP;
+
return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops, NULL,
NULL);
}
@@ -855,6 +858,11 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
if (ret < 0 || !count)
goto reexpand;
}
+ if (unlikely(iov_iter_is_dmabuf_map(to))) {
+ if (!ret)
+ ret = -EOPNOTSUPP;
+ goto reexpand;
+ }
/*
* Take i_rwsem and invalidate_lock to avoid racing with set_blocksize
@@ -958,6 +966,19 @@ static int blkdev_mmap_prepare(struct vm_area_desc *desc)
return generic_file_mmap_prepare(desc);
}
+static int blkdev_init_dma_buf_io_ctx(struct file *file,
+ struct dma_buf_io_ctx *ctx)
+{
+ struct block_device *bdev = file_bdev(file);
+ struct gendisk *disk = bdev->bd_disk;
+
+ if (!(file->f_flags & O_DIRECT))
+ return -EINVAL;
+ if (!disk->fops->init_dma_buf_io_ctx)
+ return -EOPNOTSUPP;
+ return disk->fops->init_dma_buf_io_ctx(bdev, ctx);
+}
+
const struct file_operations def_blk_fops = {
.open = blkdev_open,
.release = blkdev_release,
@@ -976,6 +997,7 @@ const struct file_operations def_blk_fops = {
.fallocate = blkdev_fallocate,
.uring_cmd = blkdev_uring_cmd,
.fop_flags = FOP_BUFFER_RASYNC | FOP_DONTCACHE,
+ .init_dma_buf_io_ctx = blkdev_init_dma_buf_io_ctx,
};
static __init int blkdev_init(void)
diff --git a/drivers/md/dm-io-rewind.c b/drivers/md/dm-io-rewind.c
index 04f3fc8aeb6f9..b22719c6411cf 100644
--- a/drivers/md/dm-io-rewind.c
+++ b/drivers/md/dm-io-rewind.c
@@ -113,10 +113,12 @@ static inline void dm_bio_rewind_iter(const struct bio *bio,
iter->bi_sector -= bytes >> 9;
/* No advance means no rewind */
- if (bio_no_advance_iter(bio))
+ if (bio_no_advance_iter(bio)) {
iter->bi_size += bytes;
- else
+ iter->bi_offset -= bytes;
+ } else {
dm_bvec_iter_rewind(bio->bi_io_vec, iter, bytes);
+ }
}
/**
diff --git a/drivers/nvme/host/Makefile b/drivers/nvme/host/Makefile
index 67563a69f7dcc..8288b986d7131 100644
--- a/drivers/nvme/host/Makefile
+++ b/drivers/nvme/host/Makefile
@@ -21,6 +21,7 @@ nvme-core-$(CONFIG_NVME_HWMON) += hwmon.o
nvme-core-$(CONFIG_NVME_HOST_AUTH) += auth.o
nvme-y += pci.o
+nvme-$(CONFIG_DMA_SHARED_BUFFER) += pci-dmabuf.o
nvme-fabrics-y += fabrics.o
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7eb0f9fe6b18d..2f9b2262f77cd 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2708,6 +2708,17 @@ static int nvme_report_zones(struct gendisk *disk, sector_t sector,
#define nvme_report_zones NULL
#endif /* CONFIG_BLK_DEV_ZONED */
+static int nvme_init_dma_buf_io_ctx(struct block_device *bdev,
+ struct dma_buf_io_ctx *ctx)
+{
+ struct nvme_ns *ns = bdev->bd_disk->private_data;
+ struct nvme_ctrl *ctrl = ns->ctrl;
+
+ if (!ctrl->ops->init_dma_buf_io_ctx)
+ return -EINVAL;
+ return ctrl->ops->init_dma_buf_io_ctx(ctrl, ctx);
+}
+
const struct block_device_operations nvme_bdev_ops = {
.owner = THIS_MODULE,
.ioctl = nvme_ioctl,
@@ -2718,6 +2729,7 @@ const struct block_device_operations nvme_bdev_ops = {
.get_unique_id = nvme_get_unique_id,
.report_zones = nvme_report_zones,
.pr_ops = &nvme_pr_ops,
+ .init_dma_buf_io_ctx = nvme_init_dma_buf_io_ctx,
};
static int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a643c4723a69b..be32e9a5ca5a1 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -668,6 +668,8 @@ struct nvme_ctrl_ops {
int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
void (*print_device_info)(struct nvme_ctrl *ctrl);
bool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);
+ int (*init_dma_buf_io_ctx)(struct nvme_ctrl *ctrl,
+ struct dma_buf_io_ctx *ctx);
unsigned long (*get_virt_boundary)(struct nvme_ctrl *ctrl, bool is_admin);
};
diff --git a/drivers/nvme/host/pci-dmabuf.c b/drivers/nvme/host/pci-dmabuf.c
new file mode 100644
index 0000000000000..d58a38a75d673
--- /dev/null
+++ b/drivers/nvme/host/pci-dmabuf.c
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2026 Pavel Begunkov <asml.silence@gmail.com>
+ */
+
+#include <linux/dma-resv.h>
+
+#include "pci-dmabuf.h"
+
+static void nvme_dmabuf_invalidate_mappings(struct dma_buf_attachment *attach)
+{
+ struct dma_buf_io_ctx *ctx = attach->importer_priv;
+
+ dma_buf_io_invalidate_mappings(ctx);
+}
+
+static const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {
+ .invalidate_mappings = nvme_dmabuf_invalidate_mappings,
+ .allow_peer2peer = true,
+};
+
+static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)
+{
+ unsigned nr_entries = ctx->dmabuf->size / NVME_CTRL_PAGE_SIZE;
+ struct nvme_dma_buf_io_ctx *nvme_ctx = ctx->dev_priv;
+ struct dma_buf_attachment *attach = nvme_ctx->attach;
+ unsigned long tmp, i = 0;
+ struct nvme_dmabuf_map *map;
+ struct scatterlist *sg;
+ struct sg_table *sgt;
+ int ret;
+
+ dma_resv_assert_held(ctx->dmabuf->resv);
+
+ if (ctx->dmabuf->size % NVME_CTRL_PAGE_SIZE)
+ return ERR_PTR(-EINVAL);
+
+ map = kvmalloc_flex(*map, dma_list, nr_entries);
+ if (!map)
+ return ERR_PTR(-ENOMEM);
+ map->nr_entries = nr_entries;
+
+ sgt = dma_buf_map_attachment(attach, ctx->dir);
+ if (IS_ERR(sgt)) {
+ ret = PTR_ERR(sgt);
+ sgt = NULL;
+ goto err;
+ }
+
+ for_each_sgtable_dma_sg(sgt, sg, tmp) {
+ dma_addr_t dma_addr = sg_dma_address(sg);
+ unsigned long sg_len = sg_dma_len(sg);
+
+ if ((sg_len % NVME_CTRL_PAGE_SIZE) ||
+ (dma_addr % NVME_CTRL_PAGE_SIZE)) {
+ ret = -EINVAL;
+ goto err;
+ }
+ while (sg_len) {
+ map->dma_list[i++] = dma_addr;
+ dma_addr += NVME_CTRL_PAGE_SIZE;
+ sg_len -= NVME_CTRL_PAGE_SIZE;
+ }
+ }
+
+ ret = dma_buf_io_init_map(ctx, &map->base, sgt);
+ if (ret)
+ goto err;
+ map->sgt = sgt;
+ return &map->base;
+err:
+ if (sgt)
+ dma_buf_unmap_attachment(attach, sgt, ctx->dir);
+ kvfree(map);
+ return ERR_PTR(ret);
+}
+
+static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,
+ struct dma_buf_io_map *map_base)
+{
+ struct nvme_dma_buf_io_ctx *nvme_ctx = ctx->dev_priv;
+ struct nvme_dmabuf_map *map = to_nvme_dmabuf_map(map_base);
+
+ dma_resv_assert_held(ctx->dmabuf->resv);
+
+ dma_buf_unmap_attachment(nvme_ctx->attach, map->sgt, ctx->dir);
+ kvfree(map);
+}
+
+static void nvme_dma_buf_io_release(struct dma_buf_io_ctx *base_ctx)
+{
+ struct nvme_dma_buf_io_ctx *ctx = base_ctx->dev_priv;
+ struct nvme_dma_buf_list *buf_list = ctx->buf_list;
+
+ mutex_lock(&buf_list->lock);
+ if (!list_empty(&ctx->list)) {
+ dma_buf_detach(ctx->base->dmabuf, ctx->attach);
+ list_del_init(&ctx->list);
+ }
+ mutex_unlock(&buf_list->lock);
+
+ nvme_put_ctrl(ctx->ctrl);
+ kfree(ctx);
+}
+
+void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)
+{
+ struct nvme_dma_buf_io_ctx *ctx, *tmp;
+
+ mutex_lock(&list->lock);
+ list_for_each_entry_safe(ctx, tmp, &list->ctxs, list) {
+ dma_buf_io_detach(ctx->base);
+ dma_buf_detach(ctx->base->dmabuf, ctx->attach);
+ list_del_init(&ctx->list);
+ }
+ mutex_unlock(&list->lock);
+}
+
+const struct dma_buf_io_ops nvme_dma_buf_io_ops = {
+ .map = nvme_dma_buf_io_map,
+ .unmap = nvme_dma_buf_io_unmap,
+ .release = nvme_dma_buf_io_release,
+};
+
+static int nvme_init_io_ctx_locked(struct nvme_ctrl *ctrl,
+ struct nvme_dma_buf_list *buf_list,
+ struct dma_buf_io_ctx *ctx)
+{
+ struct nvme_dma_buf_io_ctx *nvme_ctx;
+ struct dma_buf_attachment *attach;
+
+ nvme_ctx = kzalloc_obj(*nvme_ctx);
+ if (!nvme_ctx)
+ return -ENOMEM;
+
+ attach = dma_buf_dynamic_attach(ctx->dmabuf, ctrl->dev,
+ &nvme_dmabuf_importer_ops, ctx);
+ if (IS_ERR(attach)) {
+ kfree(nvme_ctx);
+ return PTR_ERR(attach);
+ }
+
+ nvme_get_ctrl(ctrl);
+ list_add(&nvme_ctx->list, &buf_list->ctxs);
+ nvme_ctx->attach = attach;
+ nvme_ctx->base = ctx;
+ nvme_ctx->ctrl = ctrl;
+ nvme_ctx->buf_list = buf_list;
+ ctx->dev_priv = nvme_ctx;
+ ctx->dev_ops = &nvme_dma_buf_io_ops;
+ return 0;
+}
+
+int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,
+ struct nvme_dma_buf_list *buf_list,
+ struct dma_buf_io_ctx *ctx)
+{
+ int ret;
+
+ mutex_lock(&buf_list->lock);
+ ret = nvme_init_io_ctx_locked(ctrl, buf_list, ctx);
+ mutex_unlock(&buf_list->lock);
+ return ret;
+}
diff --git a/drivers/nvme/host/pci-dmabuf.h b/drivers/nvme/host/pci-dmabuf.h
new file mode 100644
index 0000000000000..8e91f7f4ece5a
--- /dev/null
+++ b/drivers/nvme/host/pci-dmabuf.h
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2026 Pavel Begunkov <asml.silence@gmail.com>
+ */
+
+#ifndef _NVME_PCI_DMABUF_H
+#define _NVME_PCI_DMABUF_H
+
+#include <linux/dma-buf-io.h>
+
+#include "nvme.h"
+
+struct nvme_dma_buf_list {
+ struct list_head ctxs;
+ struct mutex lock;
+};
+
+struct nvme_dma_buf_io_ctx {
+ struct dma_buf_attachment *attach;
+ struct nvme_dma_buf_list *buf_list;
+ struct dma_buf_io_ctx *base;
+ struct nvme_ctrl *ctrl;
+ struct list_head list;
+};
+
+struct nvme_dmabuf_map {
+ struct dma_buf_io_map base;
+ struct sg_table *sgt;
+ unsigned nr_entries;
+ dma_addr_t dma_list[] __counted_by(nr_entries);
+};
+
+static inline struct nvme_dmabuf_map *to_nvme_dmabuf_map(
+ struct dma_buf_io_map *map)
+{
+ return container_of(map, struct nvme_dmabuf_map, base);
+}
+
+static inline struct nvme_dmabuf_map *nvme_req_to_map(struct request *req)
+{
+ struct dma_buf_io_map *map = req->bio->bi_dmabuf_map;
+
+ return to_nvme_dmabuf_map(map);
+}
+
+void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list);
+int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,
+ struct nvme_dma_buf_list *buf_list,
+ struct dma_buf_io_ctx *ctx);
+
+static inline void nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)
+{
+ if (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ __nvme_pci_remove_dmabuf(list);
+}
+
+static inline int nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,
+ struct nvme_dma_buf_list *buf_list,
+ struct dma_buf_io_ctx *ctx)
+{
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return -EOPNOTSUPP;
+ return __nvme_init_dma_buf_io_ctx(ctrl, buf_list, ctx);
+}
+
+static inline void nvme_init_buf_list(struct nvme_dma_buf_list *buf_list)
+{
+ INIT_LIST_HEAD(&buf_list->ctxs);
+ mutex_init(&buf_list->lock);
+}
+
+
+#endif /* _NVME_PCI_DMABUF_H */
\ No newline at end of file
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 77317e5d00f9f..79b3c1092e4d1 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -30,6 +30,7 @@
#include "trace.h"
#include "nvme.h"
+#include "pci-dmabuf.h"
#define SQ_SIZE(q) ((q)->q_depth << (q)->sqes)
#define CQ_SIZE(q) ((q)->q_depth * sizeof(struct nvme_completion))
@@ -318,6 +319,7 @@ struct nvme_dev {
bool hmb;
struct sg_table *hmb_sgt;
mempool_t *dmavec_mempool;
+ struct nvme_dma_buf_list dmabufs;
/* shadow doorbell buffer support: */
__le32 *dbbuf_dbs;
@@ -865,6 +867,76 @@ static void nvme_free_descriptors(struct request *req)
}
}
+static blk_status_t nvme_rq_setup_dmabuf_map(struct request *req,
+ struct nvme_queue *nvmeq)
+{
+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
+ struct nvme_dmabuf_map *map = nvme_req_to_map(req);
+ unsigned bvec_done = req->bio->bi_iter.bi_offset;
+ unsigned map_idx = bvec_done / NVME_CTRL_PAGE_SIZE;
+ unsigned offset = bvec_done & (NVME_CTRL_PAGE_SIZE - 1);
+ int length = blk_rq_payload_bytes(req) - (NVME_CTRL_PAGE_SIZE - offset);
+ dma_addr_t *dma_list = map->dma_list;
+ u64 prp1_dma = dma_list[map_idx++] + offset;
+ u64 dma_addr, prp2_dma;
+ dma_addr_t prp_dma;
+ __le64 *prp_list;
+ unsigned i;
+
+ if (length <= 0) {
+ prp2_dma = 0;
+ goto done;
+ }
+
+ if (length <= NVME_CTRL_PAGE_SIZE) {
+ prp2_dma = dma_list[map_idx];
+ goto done;
+ }
+
+ if (DIV_ROUND_UP(length, NVME_CTRL_PAGE_SIZE) <=
+ NVME_SMALL_POOL_SIZE / sizeof(__le64))
+ iod->flags |= IOD_SMALL_DESCRIPTOR;
+
+ prp_list = dma_pool_alloc(nvme_dma_pool(nvmeq, iod), GFP_ATOMIC,
+ &prp_dma);
+ if (!prp_list)
+ return BLK_STS_RESOURCE;
+
+ iod->descriptors[iod->nr_descriptors++] = prp_list;
+ prp2_dma = prp_dma;
+ i = 0;
+ for (;;) {
+ if (i == NVME_CTRL_PAGE_SIZE >> 3) {
+ __le64 *old_prp_list = prp_list;
+
+ prp_list = dma_pool_alloc(nvmeq->descriptor_pools.large,
+ GFP_ATOMIC, &prp_dma);
+ if (!prp_list)
+ goto free_prps;
+ iod->descriptors[iod->nr_descriptors++] = prp_list;
+ prp_list[0] = old_prp_list[i - 1];
+ old_prp_list[i - 1] = cpu_to_le64(prp_dma);
+ i = 1;
+ }
+
+ dma_addr = dma_list[map_idx++];
+ prp_list[i++] = cpu_to_le64(dma_addr);
+
+ length -= NVME_CTRL_PAGE_SIZE;
+ if (length <= 0)
+ break;
+ }
+done:
+ iod->cmd.common.dptr.prp1 = cpu_to_le64(prp1_dma);
+ iod->cmd.common.dptr.prp2 = cpu_to_le64(prp2_dma);
+ return BLK_STS_OK;
+free_prps:
+ iod->cmd.common.dptr.prp1 = cpu_to_le64(prp1_dma);
+ iod->cmd.common.dptr.prp2 = cpu_to_le64(prp2_dma);
+ nvme_free_descriptors(req);
+ return BLK_STS_RESOURCE;
+}
+
static void nvme_free_prps(struct request *req, unsigned int attrs)
{
struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
@@ -943,6 +1015,9 @@ static void nvme_unmap_data(struct request *req)
struct device *dma_dev = nvmeq->dev->dev;
unsigned int attrs = 0;
+ if (blk_mq_rq_is_dmabuf(req))
+ goto out_free_desc;
+
if (iod->flags & IOD_SINGLE_SEGMENT) {
static_assert(offsetof(union nvme_data_ptr, prp1) ==
offsetof(union nvme_data_ptr, sgl.addr));
@@ -967,6 +1042,7 @@ static void nvme_unmap_data(struct request *req)
nvme_free_prps(req, attrs);
}
+out_free_desc:
if (iod->nr_descriptors)
nvme_free_descriptors(req);
}
@@ -1148,13 +1224,19 @@ static blk_status_t nvme_pci_setup_data_prp(struct request *req,
}
static void nvme_pci_sgl_set_data(struct nvme_sgl_desc *sge,
- struct blk_dma_iter *iter)
+ dma_addr_t addr, u32 len)
{
- sge->addr = cpu_to_le64(iter->addr);
- sge->length = cpu_to_le32(iter->len);
+ sge->addr = cpu_to_le64(addr);
+ sge->length = cpu_to_le32(len);
sge->type = NVME_SGL_FMT_DATA_DESC << 4;
}
+static void nvme_pci_dma_iter_set_sgl(struct nvme_sgl_desc *sge,
+ struct blk_dma_iter *iter)
+{
+ nvme_pci_sgl_set_data(sge, iter->addr, iter->len);
+}
+
static void nvme_pci_sgl_set_seg(struct nvme_sgl_desc *sge,
dma_addr_t dma_addr, int entries)
{
@@ -1163,6 +1245,142 @@ static void nvme_pci_sgl_set_seg(struct nvme_sgl_desc *sge,
sge->type = NVME_SGL_FMT_LAST_SEG_DESC << 4;
}
+static unsigned int nvme_pci_dmabuf_sgl_nents(struct request *req)
+{
+ struct bio *bio = req->bio;
+ struct nvme_dmabuf_map *map = to_nvme_dmabuf_map(bio->bi_dmabuf_map);
+ struct scatterlist *sg;
+ unsigned long tmp;
+ size_t offset = bio->bi_iter.bi_offset;
+ size_t remaining = blk_rq_payload_bytes(req);
+ unsigned int nents = 0;
+
+ for_each_sgtable_dma_sg(map->sgt, sg, tmp) {
+ size_t sg_len = sg_dma_len(sg);
+
+ if (!remaining)
+ break;
+ if (offset >= sg_len) {
+ offset -= sg_len;
+ continue;
+ }
+
+ sg_len -= offset;
+ offset = 0;
+
+ do {
+ size_t chunk = min(remaining, sg_len);
+
+ nents++;
+ sg_len -= chunk;
+ remaining -= chunk;
+ } while (sg_len && remaining);
+ }
+
+ if (unlikely(remaining))
+ return 0;
+
+ return nents;
+}
+
+static blk_status_t nvme_rq_setup_dmabuf_sgl(struct request *req,
+ struct nvme_queue *nvmeq, unsigned int entries)
+{
+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
+ struct nvme_dmabuf_map *map = nvme_req_to_map(req);
+ size_t length = blk_rq_payload_bytes(req);
+ struct nvme_sgl_desc *sg_list = &iod->cmd.common.dptr.sgl;
+ size_t offset = req->bio->bi_iter.bi_offset;
+ bool pooled = entries > 1;
+ dma_addr_t sgl_dma = 0;
+ unsigned int mapped = 0;
+ unsigned long tmp;
+ struct scatterlist *sg;
+ size_t remaining = length;
+
+ if (!entries)
+ return BLK_STS_IOERR;
+
+ iod->cmd.common.flags = NVME_CMD_SGL_METABUF;
+ iod->total_len = length;
+
+ /* entries == 1 fits in the inline descriptor; more needs a pool. */
+ if (pooled) {
+ if (entries <= NVME_SMALL_POOL_SIZE / sizeof(*sg_list))
+ iod->flags |= IOD_SMALL_DESCRIPTOR;
+
+ sg_list = dma_pool_alloc(nvme_dma_pool(nvmeq, iod), GFP_ATOMIC,
+ &sgl_dma);
+ if (!sg_list)
+ return BLK_STS_RESOURCE;
+ iod->descriptors[iod->nr_descriptors++] = sg_list;
+ }
+
+ for_each_sgtable_dma_sg(map->sgt, sg, tmp) {
+ size_t sg_len = sg_dma_len(sg);
+ dma_addr_t addr = sg_dma_address(sg);
+
+ if (!remaining)
+ break;
+ if (offset >= sg_len) {
+ offset -= sg_len;
+ continue;
+ }
+
+ addr += offset;
+ sg_len -= offset;
+ offset = 0;
+
+ do {
+ u32 chunk = min_t(size_t, remaining, sg_len);
+
+ if (WARN_ON_ONCE(mapped == entries))
+ goto err_free;
+ nvme_pci_sgl_set_data(&sg_list[mapped++], addr, chunk);
+
+ addr += chunk;
+ sg_len -= chunk;
+ remaining -= chunk;
+ } while (sg_len && remaining);
+ }
+
+ if (unlikely(remaining))
+ goto err_free;
+
+ if (pooled)
+ nvme_pci_sgl_set_seg(&iod->cmd.common.dptr.sgl, sgl_dma,
+ mapped);
+ return BLK_STS_OK;
+err_free:
+ if (pooled) {
+ iod->nr_descriptors--;
+ dma_pool_free(nvme_dma_pool(nvmeq, iod), sg_list, sgl_dma);
+ }
+ return BLK_STS_IOERR;
+}
+
+static blk_status_t nvme_rq_setup_dmabuf(struct request *req,
+ struct nvme_queue *nvmeq, enum nvme_use_sgl use_sgl)
+{
+ unsigned int entries;
+ size_t avg_seg;
+
+ if (use_sgl == SGL_UNSUPPORTED)
+ return nvme_rq_setup_dmabuf_map(req, nvmeq);
+
+ entries = nvme_pci_dmabuf_sgl_nents(req);
+
+ if (use_sgl == SGL_FORCED)
+ return nvme_rq_setup_dmabuf_sgl(req, nvmeq, entries);
+
+ avg_seg = entries ?
+ DIV_ROUND_UP(blk_rq_payload_bytes(req), entries) : 0;
+ if (sgl_threshold && avg_seg >= sgl_threshold)
+ return nvme_rq_setup_dmabuf_sgl(req, nvmeq, entries);
+
+ return nvme_rq_setup_dmabuf_map(req, nvmeq);
+}
+
static blk_status_t nvme_pci_setup_data_sgl(struct request *req,
struct blk_dma_iter *iter)
{
@@ -1177,7 +1395,7 @@ static blk_status_t nvme_pci_setup_data_sgl(struct request *req,
iod->cmd.common.flags = NVME_CMD_SGL_METABUF;
if (entries == 1 || blk_rq_dma_map_coalesce(&iod->dma_state)) {
- nvme_pci_sgl_set_data(&iod->cmd.common.dptr.sgl, iter);
+ nvme_pci_dma_iter_set_sgl(&iod->cmd.common.dptr.sgl, iter);
iod->total_len += iter->len;
return BLK_STS_OK;
}
@@ -1199,7 +1417,7 @@ static blk_status_t nvme_pci_setup_data_sgl(struct request *req,
iter->status = BLK_STS_IOERR;
break;
}
- nvme_pci_sgl_set_data(&sg_list[mapped++], iter);
+ nvme_pci_dma_iter_set_sgl(&sg_list[mapped++], iter);
iod->total_len += iter->len;
} while (blk_rq_dma_map_iter_next(req, nvmeq->dev->dev, iter));
@@ -1257,6 +1475,9 @@ static blk_status_t nvme_map_data(struct request *req)
struct blk_dma_iter iter;
blk_status_t ret;
+ if (blk_mq_rq_is_dmabuf(req))
+ return nvme_rq_setup_dmabuf(req, nvmeq, use_sgl);
+
/*
* Try to skip the DMA iterator for single segment requests, as that
* significantly improves performances for small I/O sizes.
@@ -1359,13 +1580,13 @@ static blk_status_t nvme_pci_setup_meta_iter(struct request *req)
iod->cmd.common.metadata = cpu_to_le64(sgl_dma);
if (entries == 1) {
iod->meta_total_len = iter.len;
- nvme_pci_sgl_set_data(sg_list, &iter);
+ nvme_pci_dma_iter_set_sgl(sg_list, &iter);
return BLK_STS_OK;
}
sgl_dma += sizeof(*sg_list);
do {
- nvme_pci_sgl_set_data(&sg_list[++i], &iter);
+ nvme_pci_dma_iter_set_sgl(&sg_list[++i], &iter);
iod->meta_total_len += iter.len;
} while (blk_rq_integrity_dma_map_iter_next(req, dev->dev, &iter));
@@ -3357,6 +3578,9 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
nvme_unquiesce_admin_queue(&dev->ctrl);
}
mutex_unlock(&dev->shutdown_lock);
+
+ if (shutdown)
+ nvme_pci_remove_dmabuf(&dev->dmabufs);
}
static int nvme_disable_prepare_reset(struct nvme_dev *dev, bool shutdown)
@@ -3564,6 +3788,14 @@ static unsigned long nvme_pci_get_virt_boundary(struct nvme_ctrl *ctrl,
return 0;
}
+static int nvme_pci_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,
+ struct dma_buf_io_ctx *ctx)
+{
+ struct nvme_dev *dev = to_nvme_dev(ctrl);
+
+ return nvme_init_dma_buf_io_ctx(ctrl, &dev->dmabufs, ctx);
+}
+
static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
.name = "pcie",
.module = THIS_MODULE,
@@ -3579,6 +3811,7 @@ static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
.print_device_info = nvme_pci_print_device_info,
.supports_pci_p2pdma = nvme_pci_supports_pci_p2pdma,
.get_virt_boundary = nvme_pci_get_virt_boundary,
+ .init_dma_buf_io_ctx = nvme_pci_init_dma_buf_io_ctx,
};
static int nvme_dev_map(struct nvme_dev *dev)
@@ -3701,6 +3934,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev,
return ERR_PTR(-ENOMEM);
INIT_WORK(&dev->ctrl.reset_work, nvme_reset_work);
mutex_init(&dev->shutdown_lock);
+ nvme_init_buf_list(&dev->dmabufs);
dev->nr_write_queues = write_queues;
dev->nr_poll_queues = poll_queues;
@@ -4346,5 +4580,6 @@ MODULE_AUTHOR("Matthew Wilcox <willy@linux.intel.com>");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");
MODULE_DESCRIPTION("NVMe host PCIe transport driver");
+MODULE_IMPORT_NS("DMA_BUF");
module_init(nvme_init);
module_exit(nvme_exit);
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 17944e44b5849..7a794ce723b84 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -80,7 +80,8 @@ static inline bool bio_no_advance_iter(const struct bio *bio)
{
return bio_op(bio) == REQ_OP_DISCARD ||
bio_op(bio) == REQ_OP_SECURE_ERASE ||
- bio_op(bio) == REQ_OP_WRITE_ZEROES;
+ bio_op(bio) == REQ_OP_WRITE_ZEROES ||
+ op_is_dmabuf(bio->bi_opf);
}
static inline void *bio_data(struct bio *bio)
@@ -113,11 +114,13 @@ static inline void bio_advance_iter(const struct bio *bio,
{
iter->bi_sector += bytes >> 9;
- if (bio_no_advance_iter(bio))
+ if (bio_no_advance_iter(bio)) {
iter->bi_size -= bytes;
- else
+ iter->bi_offset += bytes;
+ } else {
bvec_iter_advance(bio->bi_io_vec, iter, bytes);
/* TODO: It is reasonable to complete bio with error here. */
+ }
}
/* @bytes should be less or equal to bvec[i->bi_idx].bv_len */
@@ -127,10 +130,12 @@ static inline void bio_advance_iter_single(const struct bio *bio,
{
iter->bi_sector += bytes >> 9;
- if (bio_no_advance_iter(bio))
+ if (bio_no_advance_iter(bio)) {
iter->bi_size -= bytes;
- else
+ iter->bi_offset += bytes;
+ } else {
bvec_iter_advance_single(bio->bi_io_vec, iter, bytes);
+ }
}
void __bio_advance(struct bio *, unsigned bytes);
@@ -434,12 +439,12 @@ static inline void bio_wouldblock_error(struct bio *bio)
/*
* Calculate number of bvec segments that should be allocated to fit data
- * pointed by @iter. If @iter is backed by bvec it's going to be reused
- * instead of allocating a new one.
+ * pointed by @iter. If @iter is backed by a bvec or a dmabuf, the bvec array /
+ * the dma map are going to be reused, and so no extra allocation is required.
*/
static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)
{
- if (iov_iter_is_bvec(iter))
+ if (iov_iter_is_bvec(iter) || iov_iter_is_dmabuf_map(iter))
return 0;
return iov_iter_npages(iter, max_segs);
}
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index af878597afb8c..7c7504c84e090 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -1017,6 +1017,13 @@ static inline void *blk_mq_rq_to_pdu(struct request *rq)
return rq + 1;
}
+static inline bool blk_mq_rq_is_dmabuf(struct request *rq)
+{
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return false;
+ return rq->bio && op_is_dmabuf(rq->bio->bi_opf);
+}
+
static inline struct blk_mq_hw_ctx *queue_hctx(struct request_queue *q, int id)
{
struct blk_mq_hw_ctx *hctx;
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 98e21b4cbf328..0cc09b975d8ff 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -233,7 +233,12 @@ struct bio {
atomic_t __bi_remaining;
/* The actual vec list, preserved by bio_reset() */
- struct bio_vec *bi_io_vec;
+ union {
+ struct bio_vec *bi_io_vec;
+ /* Driver specific dma map, valid IFF REQ_DMABUF is set */
+ struct dma_buf_io_map *bi_dmabuf_map;
+ };
+
struct bvec_iter bi_iter;
union {
@@ -402,6 +407,7 @@ enum req_flag_bits {
__REQ_DRV, /* for driver use */
__REQ_FS_PRIVATE, /* for file system (submitter) use */
__REQ_ATOMIC, /* for atomic write operations */
+ __REQ_DMABUF, /* Using premmaped dma buffers */
/*
* Command specific flags, keep last:
*/
@@ -434,6 +440,7 @@ enum req_flag_bits {
#define REQ_DRV (__force blk_opf_t)(1ULL << __REQ_DRV)
#define REQ_FS_PRIVATE (__force blk_opf_t)(1ULL << __REQ_FS_PRIVATE)
#define REQ_ATOMIC (__force blk_opf_t)(1ULL << __REQ_ATOMIC)
+#define REQ_DMABUF (__force blk_opf_t)(1ULL << __REQ_DMABUF)
#define REQ_NOUNMAP (__force blk_opf_t)(1ULL << __REQ_NOUNMAP)
@@ -487,6 +494,11 @@ static inline bool op_is_discard(blk_opf_t op)
return (op & REQ_OP_MASK) == REQ_OP_DISCARD;
}
+static inline bool op_is_dmabuf(blk_opf_t op)
+{
+ return op & REQ_DMABUF;
+}
+
/*
* Check if a bio or request operation is a zone management operation.
*/
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index d003a9d2d1f6c..2d5c30823aab9 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1599,6 +1599,8 @@ struct block_device_operations {
/* returns the length of the identifier or a negative errno: */
int (*get_unique_id)(struct gendisk *disk, u8 id[16],
enum blk_unique_id id_type);
+ int (*init_dma_buf_io_ctx)(struct block_device *,
+ struct dma_buf_io_ctx *);
struct module *owner;
const struct pr_ops *pr_ops;
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index fc566ee1c1ff1..b63914ff56e33 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -108,7 +108,8 @@ struct bvec_iter {
unsigned int bi_idx;
/*
- * Current offset in the bvec entry pointed to by `bi_idx`.
+ * Current offset in the bvec entry pointed to by `bi_idx` or into
+ * a dma-buf map.
*/
unsigned int bi_offset;
} __packed __aligned(4);
diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
index 90fea94ad2029..73cd11d173df0 100644
--- a/include/linux/io_uring_types.h
+++ b/include/linux/io_uring_types.h
@@ -11,6 +11,7 @@
struct iou_loop_params;
struct io_uring_bpf_ops;
+struct dma_buf_io_map;
enum {
/*
@@ -610,6 +611,7 @@ enum {
REQ_F_IMPORT_BUFFER_BIT,
REQ_F_SQE_COPIED_BIT,
REQ_F_IOPOLL_BIT,
+ REQ_F_DMABUF_BIT,
/* not a real bit, just to check we're not overflowing the space */
__REQ_F_LAST_BIT,
@@ -705,6 +707,8 @@ enum {
REQ_F_SQE_COPIED = IO_REQ_FLAG(REQ_F_SQE_COPIED_BIT),
/* request must be iopolled to completion (set in ->issue()) */
REQ_F_IOPOLL = IO_REQ_FLAG(REQ_F_IOPOLL_BIT),
+ /* there is a dma map attached to request that needs to be dropped */
+ REQ_F_DMABUF = IO_REQ_FLAG(REQ_F_DMABUF_BIT),
};
struct io_tw_req {
@@ -827,6 +831,7 @@ struct io_kiocb {
/* custom credentials, valid IFF REQ_F_CREDS is set */
const struct cred *creds;
struct io_wq_work work;
+ struct dma_buf_io_map *dmabuf_map;
struct io_big_cqe {
u64 extra1;
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index b42b66b424a76..b456f45fa8de7 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -791,13 +791,42 @@ struct io_uring_rsrc_update {
struct io_uring_rsrc_update2 {
__u32 offset;
- __u32 resv;
+ __u32 flags;
__aligned_u64 data;
__aligned_u64 tags;
__u32 nr;
__u32 resv2;
};
+/* struct io_uring_rsrc_update2::flags */
+enum io_uring_rsrc_reg_flags {
+ /*
+ * Use the extended descriptor format for buffer updates,
+ * see struct io_uring_regbuf_desc
+ */
+ IORING_RSRC_UPDATE_EXTENDED = 1U << 1,
+};
+
+/* Buffer registration type, passed in struct io_uring_regbuf_desc::type */
+enum io_uring_regbuf_type {
+ IO_REGBUF_TYPE_EMPTY,
+ IO_REGBUF_TYPE_UADDR,
+ IO_REGBUF_TYPE_DMABUF,
+
+ __IO_REGBUF_TYPE_MAX,
+};
+
+struct io_uring_regbuf_desc {
+ __u32 type; /* enum io_uring_regbuf_type */
+ __u32 flags;
+ __u64 size;
+ __u64 uaddr;
+
+ __s32 dmabuf_fd;
+ __s32 target_fd;
+ __u64 __resv[6];
+};
+
/* Skip updating fd indexes set to this value in the fd table */
#define IORING_REGISTER_FILES_SKIP (-2)
diff --git a/io_uring/Makefile b/io_uring/Makefile
index c54e328d14104..965bb60e9f7b1 100644
--- a/io_uring/Makefile
+++ b/io_uring/Makefile
@@ -26,3 +26,4 @@ obj-$(CONFIG_PROC_FS) += fdinfo.o
obj-$(CONFIG_IO_URING_MOCK_FILE) += mock_file.o
obj-$(CONFIG_IO_URING_BPF) += bpf_filter.o
obj-$(CONFIG_IO_URING_BPF_OPS) += bpf-ops.o
+obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o
diff --git a/io_uring/dma-buf.c b/io_uring/dma-buf.c
new file mode 100644
index 0000000000000..f40c9d87ed8aa
--- /dev/null
+++ b/io_uring/dma-buf.c
@@ -0,0 +1,68 @@
+#include "dma-buf.h"
+
+static inline void io_release_dmabuf(void *priv)
+{
+ struct io_buf_dma *bd = priv;
+
+ fput(bd->target_file);
+ dma_buf_io_ctx_release(bd->ctx);
+ kfree(bd);
+}
+
+int io_register_dmabuf(struct io_ring_ctx *ctx,
+ struct io_uring_regbuf_desc *desc,
+ struct io_mapped_ubuf *imu)
+{
+ struct io_buf_dma *bd = NULL;
+ struct file *target_file = NULL;
+ struct dma_buf *dmabuf = NULL;
+ int ret;
+
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return -EOPNOTSUPP;
+ if (ctx->flags & IORING_SETUP_IOPOLL)
+ return -EOPNOTSUPP;
+ if (desc->uaddr || desc->size)
+ return -EINVAL;
+
+ bd = kzalloc(sizeof(*bd), GFP_KERNEL);
+ if (!bd)
+ return -ENOMEM;
+
+ target_file = fget(desc->target_fd);
+ if (!target_file) {
+ ret = -EBADF;
+ goto err;
+ }
+ dmabuf = dma_buf_get(desc->dmabuf_fd);
+ if (IS_ERR(dmabuf)) {
+ ret = PTR_ERR(dmabuf);
+ dmabuf = NULL;
+ goto err;
+ }
+ ret = io_validate_user_buf_range(0, dmabuf->size);
+ if (ret)
+ goto err;
+
+ ret = dma_buf_io_ctx_create(target_file, dmabuf, DMA_BIDIRECTIONAL,
+ &bd->ctx);
+ if (ret)
+ goto err;
+
+ bd->target_file = target_file;
+ imu->len = dmabuf->size;
+ imu->release = io_release_dmabuf;
+ imu->priv = bd;
+ imu->flags = IO_REGBUF_F_DMABUF;
+ imu->dir = IO_BUF_DEST | IO_BUF_SOURCE;
+ dma_buf_put(dmabuf);
+ return 0;
+err:
+ kfree(bd);
+ if (target_file)
+ fput(target_file);
+ if (dmabuf)
+ dma_buf_put(dmabuf);
+ return ret;
+}
+
diff --git a/io_uring/dma-buf.h b/io_uring/dma-buf.h
new file mode 100644
index 0000000000000..10d2efdd8c9f1
--- /dev/null
+++ b/io_uring/dma-buf.h
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef IOU_DMA_BUF_H
+#define IOU_DMA_BUF_H
+
+#include <linux/dma-buf-io.h>
+#include <linux/io_uring_types.h>
+
+#include "rsrc.h"
+
+struct io_buf_dma {
+ struct dma_buf_io_ctx *ctx;
+ struct file *target_file;
+};
+
+static inline void io_detach_dmabuf_map(struct io_kiocb *req)
+{
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return;
+ if (!(req->flags & REQ_F_DMABUF) || !req->dmabuf_map)
+ return;
+ dma_buf_io_map_drop(req->dmabuf_map);
+ req->dmabuf_map = NULL;
+}
+
+static inline int io_attach_dmabuf_map(struct io_kiocb *req,
+ struct iov_iter *iter,
+ unsigned issue_flags)
+{
+ bool nowait = issue_flags & IO_URING_F_NONBLOCK;
+ struct dma_buf_io_map *map;
+ struct io_buf_dma *bd;
+
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return -EOPNOTSUPP;
+ if (!(req->flags & REQ_F_DMABUF))
+ return 0;
+
+ bd = req->buf_node->buf->priv;
+ map = dma_buf_io_get_map(bd->ctx, nowait);
+ if (unlikely(IS_ERR(map)))
+ return PTR_ERR(map);
+ req->dmabuf_map = map;
+ iter->dmabuf_map = map;
+ return 0;
+}
+
+static inline int io_import_dmabuf_map(struct io_kiocb *req,
+ int ddir, struct iov_iter *iter,
+ struct io_mapped_ubuf *imu,
+ size_t len, size_t offset)
+{
+ struct io_buf_dma *bd = imu->priv;
+
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return -EOPNOTSUPP;
+ if (req->file != bd->target_file)
+ return -EBADF;
+ req->flags |= REQ_F_DMABUF;
+ iov_iter_dmabuf_map(iter, ddir, NULL, offset, len);
+ return 0;
+}
+
+int io_register_dmabuf(struct io_ring_ctx *ctx,
+ struct io_uring_regbuf_desc *desc,
+ struct io_mapped_ubuf *imu);
+
+#endif /* IOU_DMA_BUF_H */
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 1efaf29514e8d..d6f7cbf731eb2 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -10,6 +10,7 @@
#include <linux/compat.h>
#include <linux/io_uring.h>
#include <linux/io_uring/cmd.h>
+#include <linux/dma-buf-io.h>
#include <uapi/linux/io_uring.h>
@@ -19,6 +20,7 @@
#include "rsrc.h"
#include "memmap.h"
#include "register.h"
+#include "dma-buf.h"
struct io_rsrc_update {
struct file *file;
@@ -28,7 +30,7 @@ struct io_rsrc_update {
};
static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
- struct iovec *iov);
+ struct io_uring_regbuf_desc *desc);
static int hpage_acct_ref(struct io_ring_ctx *ctx, struct page *hpage,
bool *acct_new)
@@ -81,6 +83,18 @@ static bool hpage_acct_unref(struct io_ring_ctx *ctx, struct page *hpage)
#define IO_CACHED_BVECS_SEGS 32
+static void io_iov_to_regbuf_desc(const struct iovec *iov,
+ struct io_uring_regbuf_desc *desc)
+{
+ *desc = (struct io_uring_regbuf_desc) {
+ .type = IO_REGBUF_TYPE_UADDR,
+ .uaddr = (u64)(uintptr_t)iov->iov_base,
+ .size = iov->iov_len,
+ };
+ if (!desc->uaddr)
+ desc->type = IO_REGBUF_TYPE_EMPTY;
+}
+
int __io_account_mem(struct user_struct *user, unsigned long nr_pages)
{
unsigned long page_limit, cur_pages, new_pages;
@@ -326,6 +340,8 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
return -ENXIO;
if (up->offset + nr_args > ctx->file_table.data.nr)
return -EINVAL;
+ if (up->flags)
+ return -EINVAL;
for (done = 0; done < nr_args; done++) {
u64 tag = 0;
@@ -385,9 +401,8 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
struct io_uring_rsrc_update2 *up,
unsigned int nr_args)
{
+ bool extended = up->flags & IORING_RSRC_UPDATE_EXTENDED;
u64 __user *tags = u64_to_user_ptr(up->tags);
- struct iovec fast_iov, *iov;
- struct iovec __user *uvec;
u64 user_data = up->data;
__u32 done;
int i, err;
@@ -396,26 +411,49 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
return -ENXIO;
if (up->offset + nr_args > ctx->buf_table.nr)
return -EINVAL;
+ if (up->flags & ~IORING_RSRC_UPDATE_EXTENDED)
+ return -EINVAL;
for (done = 0; done < nr_args; done++) {
+ struct io_uring_regbuf_desc desc;
struct io_rsrc_node *node;
u64 tag = 0;
- uvec = u64_to_user_ptr(user_data);
- iov = iovec_from_user(uvec, 1, 1, &fast_iov, io_is_compat(ctx));
- if (IS_ERR(iov)) {
- err = PTR_ERR(iov);
- break;
- }
if (tags && copy_from_user(&tag, &tags[done], sizeof(tag))) {
err = -EFAULT;
break;
}
- node = io_sqe_buffer_register(ctx, iov);
+
+ if (extended) {
+ if (copy_from_user(&desc, u64_to_user_ptr(user_data),
+ sizeof(desc))) {
+ err = -EFAULT;
+ break;
+ }
+ user_data += sizeof(desc);
+ } else {
+ struct iovec __user *uvec = u64_to_user_ptr(user_data);
+ struct iovec fast_iov, *iov;
+
+ if (io_is_compat(ctx))
+ user_data += sizeof(struct compat_iovec);
+ else
+ user_data += sizeof(struct iovec);
+
+ iov = iovec_from_user(uvec, 1, 1, &fast_iov, io_is_compat(ctx));
+ if (IS_ERR(iov)) {
+ err = PTR_ERR(iov);
+ break;
+ }
+ io_iov_to_regbuf_desc(iov, &desc);
+ }
+
+ node = io_sqe_buffer_register(ctx, &desc);
if (IS_ERR(node)) {
err = PTR_ERR(node);
break;
}
+
if (tag) {
if (!node) {
err = -EINVAL;
@@ -426,10 +464,6 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
i = array_index_nospec(up->offset + done, ctx->buf_table.nr);
io_reset_rsrc_node(ctx, &ctx->buf_table, i);
ctx->buf_table.nodes[i] = node;
- if (io_is_compat(ctx))
- user_data += sizeof(struct compat_iovec);
- else
- user_data += sizeof(struct iovec);
}
return done ? done : err;
}
@@ -464,7 +498,7 @@ int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,
memset(&up, 0, sizeof(up));
if (copy_from_user(&up, arg, sizeof(struct io_uring_rsrc_update)))
return -EFAULT;
- if (up.resv || up.resv2)
+ if (up.resv2)
return -EINVAL;
return __io_register_rsrc_update(ctx, IORING_RSRC_FILE, &up, nr_args);
}
@@ -478,7 +512,7 @@ int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg,
return -EINVAL;
if (copy_from_user(&up, arg, sizeof(up)))
return -EFAULT;
- if (!up.nr || up.resv || up.resv2)
+ if (!up.nr || up.resv2)
return -EINVAL;
return __io_register_rsrc_update(ctx, type, &up, up.nr);
}
@@ -578,12 +612,9 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
struct io_uring_rsrc_update2 up2;
int ret;
+ memset(&up2, 0, sizeof(up2));
up2.offset = up->offset;
up2.data = up->arg;
- up2.nr = 0;
- up2.tags = 0;
- up2.resv = 0;
- up2.resv2 = 0;
if (up->offset == IORING_FILE_INDEX_ALLOC) {
ret = io_files_update_with_index_alloc(req, issue_flags);
@@ -869,27 +900,70 @@ bool io_check_coalesce_buffer(struct page **page_array, int nr_pages,
return true;
}
+static struct io_rsrc_node *io_register_dmabuf_desc(struct io_ring_ctx *ctx,
+ struct io_uring_regbuf_desc *desc)
+{
+ struct io_rsrc_node *node = NULL;
+ struct io_mapped_ubuf *imu = NULL;
+ int ret;
+
+ node = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER);
+ if (!node)
+ return ERR_PTR(-ENOMEM);
+
+ imu = io_alloc_imu(ctx, 0);
+ if (!imu) {
+ ret = -ENOMEM;
+ goto err;
+ }
+ memset(imu, 0, sizeof(*imu));
+ refcount_set(&imu->refs, 1);
+
+ ret = io_register_dmabuf(ctx, desc, imu);
+ if (ret)
+ goto err;
+ node->buf = imu;
+ return node;
+err:
+ if (imu)
+ io_free_imu(ctx, imu);
+ if (node)
+ io_cache_free(&ctx->node_cache, node);
+ return ERR_PTR(ret);
+}
+
static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
- struct iovec *iov)
+ struct io_uring_regbuf_desc *desc)
{
+ unsigned long uaddr = (unsigned long)desc->uaddr;
+ size_t size = desc->size;
struct io_mapped_ubuf *imu = NULL;
struct page **pages = NULL;
struct io_rsrc_node *node;
unsigned long off;
- size_t size;
int ret, nr_pages, i;
struct io_imu_folio_data data;
bool coalesced = false;
- if (!iov->iov_base) {
- if (iov->iov_len)
+ if (desc->type >= __IO_REGBUF_TYPE_MAX)
+ return ERR_PTR(-EINVAL);
+ if (!mem_is_zero(&desc->__resv, sizeof(desc->__resv)) || desc->flags)
+ return ERR_PTR(-EINVAL);
+
+ if (desc->type == IO_REGBUF_TYPE_DMABUF)
+ return io_register_dmabuf_desc(ctx, desc);
+
+ if (desc->dmabuf_fd || desc->target_fd)
+ return ERR_PTR(-EINVAL);
+
+ if (desc->type == IO_REGBUF_TYPE_EMPTY) {
+ if (uaddr || size)
return ERR_PTR(-EFAULT);
/* remove the buffer without installing a new one */
return NULL;
}
- ret = io_validate_user_buf_range((unsigned long)iov->iov_base,
- iov->iov_len);
+ ret = io_validate_user_buf_range(uaddr, size);
if (ret)
return ERR_PTR(ret);
@@ -898,8 +972,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
return ERR_PTR(-ENOMEM);
ret = -ENOMEM;
- pages = io_pin_pages((unsigned long) iov->iov_base, iov->iov_len,
- &nr_pages);
+ pages = io_pin_pages(uaddr, size, &nr_pages);
if (IS_ERR(pages)) {
ret = PTR_ERR(pages);
pages = NULL;
@@ -921,10 +994,9 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
if (ret)
goto done;
- size = iov->iov_len;
/* store original address for later verification */
- imu->ubuf = (unsigned long) iov->iov_base;
- imu->len = iov->iov_len;
+ imu->ubuf = uaddr;
+ imu->len = size;
imu->folio_shift = PAGE_SHIFT;
imu->release = io_release_ubuf;
imu->priv = imu;
@@ -934,7 +1006,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
imu->folio_shift = data.folio_shift;
refcount_set(&imu->refs, 1);
- off = (unsigned long)iov->iov_base & ~PAGE_MASK;
+ off = uaddr & ~PAGE_MASK;
if (coalesced)
off += data.first_folio_page_idx << PAGE_SHIFT;
@@ -986,6 +1058,7 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
memset(iov, 0, sizeof(*iov));
for (i = 0; i < nr_args; i++) {
+ struct io_uring_regbuf_desc desc;
struct io_rsrc_node *node;
u64 tag = 0;
@@ -1009,7 +1082,8 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
}
}
- node = io_sqe_buffer_register(ctx, iov);
+ io_iov_to_regbuf_desc(iov, &desc);
+ node = io_sqe_buffer_register(ctx, &desc);
if (IS_ERR(node)) {
ret = PTR_ERR(node);
break;
@@ -1206,9 +1280,12 @@ static int io_import_kbuf(int ddir, struct iov_iter *iter,
return 0;
}
-static int io_import_fixed(int ddir, struct iov_iter *iter,
+static int io_import_fixed(struct io_kiocb *req,
+ int ddir, struct iov_iter *iter,
struct io_mapped_ubuf *imu,
- u64 buf_addr, size_t len)
+ u64 buf_addr, size_t len,
+ unsigned issue_flags,
+ unsigned import_flags)
{
const struct bio_vec *bvec;
size_t folio_mask;
@@ -1228,6 +1305,11 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
offset = buf_addr - imu->ubuf;
+ if (imu->flags & IO_REGBUF_F_DMABUF) {
+ if (!(import_flags & IO_REGBUF_IMPORT_ALLOW_DMABUF))
+ return -EFAULT;
+ return io_import_dmabuf_map(req, ddir, iter, imu, len, offset);
+ }
if (imu->flags & IO_REGBUF_F_KBUF)
return io_import_kbuf(ddir, iter, imu, len, offset);
@@ -1281,16 +1363,17 @@ inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
return NULL;
}
-int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
+int __io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
u64 buf_addr, size_t len, int ddir,
- unsigned issue_flags)
+ unsigned issue_flags, unsigned import_flags)
{
struct io_rsrc_node *node;
node = io_find_buf_node(req, issue_flags);
if (!node)
return -EFAULT;
- return io_import_fixed(ddir, iter, node->buf, buf_addr, len);
+ return io_import_fixed(req, ddir, iter, node->buf, buf_addr, len,
+ issue_flags, import_flags);
}
static int io_buffer_acct_cloned_hpages(struct io_ring_ctx *ctx,
@@ -1422,6 +1505,11 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
if (!src_node) {
dst_node = NULL;
} else {
+ if (src_node->buf->flags & IO_REGBUF_F_UNCLONEABLE) {
+ io_rsrc_data_free(ctx, &data);
+ return -EOPNOTSUPP;
+ }
+
dst_node = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER);
if (!dst_node) {
io_rsrc_data_free(ctx, &data);
@@ -1692,9 +1780,9 @@ static int io_kern_bvec_size(struct iovec *iov, unsigned nr_iovs,
return 0;
}
-int io_import_reg_vec(int ddir, struct iov_iter *iter,
+int __io_import_reg_vec(int ddir, struct iov_iter *iter,
struct io_kiocb *req, struct iou_vec *vec,
- unsigned nr_iovs, unsigned issue_flags)
+ unsigned nr_iovs, unsigned issue_flags, unsigned import_flags)
{
struct io_rsrc_node *node;
struct io_mapped_ubuf *imu;
@@ -1712,7 +1800,9 @@ int io_import_reg_vec(int ddir, struct iov_iter *iter,
iovec_off = vec->nr - nr_iovs;
iov = vec->iovec + iovec_off;
- if (imu->flags & IO_REGBUF_F_KBUF) {
+ if (imu->flags & IO_REGBUF_F_DMABUF) {
+ return -EOPNOTSUPP;
+ } else if (imu->flags & IO_REGBUF_F_KBUF) {
int ret = io_kern_bvec_size(iov, nr_iovs, imu, &nr_segs);
if (unlikely(ret))
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 9ef88383b3636..d893cc5e580a0 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -26,7 +26,13 @@ struct io_rsrc_node {
};
enum {
- IO_REGBUF_F_KBUF = 1,
+ IO_REGBUF_F_KBUF = 1 << 0,
+ IO_REGBUF_F_UNCLONEABLE = 1 << 1,
+ IO_REGBUF_F_DMABUF = 1 << 3,
+};
+
+enum {
+ IO_REGBUF_IMPORT_ALLOW_DMABUF = 1 << 1,
};
struct io_mapped_ubuf {
@@ -61,12 +67,28 @@ int io_rsrc_data_alloc(struct io_rsrc_data *data, unsigned nr);
struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
unsigned issue_flags);
-int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
+int __io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
u64 buf_addr, size_t len, int ddir,
- unsigned issue_flags);
-int io_import_reg_vec(int ddir, struct iov_iter *iter,
+ unsigned issue_flags, unsigned import_flags);
+int __io_import_reg_vec(int ddir, struct iov_iter *iter,
struct io_kiocb *req, struct iou_vec *vec,
- unsigned nr_iovs, unsigned issue_flags);
+ unsigned nr_iovs, unsigned issue_flags,
+ unsigned import_flags);
+
+static inline int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
+ u64 buf_addr, size_t len, int ddir,
+ unsigned issue_flags)
+{
+ return __io_import_reg_buf(req, iter, buf_addr, len, ddir, issue_flags, 0);
+}
+
+static inline int io_import_reg_vec(int ddir, struct iov_iter *iter,
+ struct io_kiocb *req, struct iou_vec *vec,
+ unsigned nr_iovs, unsigned issue_flags)
+{
+ return __io_import_reg_vec(ddir, iter, req, vec, nr_iovs, issue_flags, 0);
+}
+
int io_prep_reg_iovec(struct io_kiocb *req, struct iou_vec *iv,
const struct iovec __user *uvec, size_t uvec_segs);
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 999d9a1cc5a56..d33b925a848e5 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -23,6 +23,7 @@
#include "rsrc.h"
#include "poll.h"
#include "rw.h"
+#include "dma-buf.h"
static void io_complete_rw(struct kiocb *kiocb, long res);
static void io_complete_rw_iopoll(struct kiocb *kiocb, long res);
@@ -358,13 +359,18 @@ static int io_init_rw_fixed(struct io_kiocb *req, unsigned int issue_flags,
struct io_async_rw *io = req->async_data;
int ret;
- if (io->bytes_done)
- return 0;
+ if (!io->bytes_done) {
+ ret = __io_import_reg_buf(req, &io->iter, rw->addr, rw->len, ddir,
+ issue_flags, IO_REGBUF_IMPORT_ALLOW_DMABUF);
+ if (ret)
+ return ret;
+ iov_iter_save_state(&io->iter, &io->iter_state);
+ }
- ret = io_import_reg_buf(req, &io->iter, rw->addr, rw->len, ddir,
- issue_flags);
- iov_iter_save_state(&io->iter, &io->iter_state);
- return ret;
+ ret = io_attach_dmabuf_map(req, &io->iter, issue_flags);
+ if (ret)
+ return ret;
+ return 0;
}
int io_prep_read_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe)
@@ -577,6 +583,8 @@ static void io_complete_rw(struct kiocb *kiocb, long res)
struct io_rw *rw = container_of(kiocb, struct io_rw, kiocb);
struct io_kiocb *req = cmd_to_io_kiocb(rw);
+ io_detach_dmabuf_map(req);
+
/* ring owner may block in freeze_super() before task_work runs */
if (kiocb->ki_flags & IOCB_WRITE)
io_req_end_write(req);
@@ -698,7 +706,7 @@ static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)
!(kiocb->ki_filp->f_flags & O_NONBLOCK))
return -EAGAIN;
if ((req->flags & REQ_F_BUF_NODE) &&
- (req->buf_node->buf->flags & IO_REGBUF_F_KBUF))
+ (req->buf_node->buf->flags & (IO_REGBUF_F_KBUF|IO_REGBUF_F_DMABUF)))
return -EFAULT;
ppos = io_kiocb_ppos(kiocb);
@@ -1226,7 +1234,10 @@ int io_read_fixed(struct io_kiocb *req, unsigned int issue_flags)
if (unlikely(ret))
return ret;
- return io_read(req, issue_flags);
+ ret = io_read(req, issue_flags);
+ if (ret != -EIOCBQUEUED)
+ io_detach_dmabuf_map(req);
+ return ret;
}
int io_write_fixed(struct io_kiocb *req, unsigned int issue_flags)
@@ -1237,7 +1248,11 @@ int io_write_fixed(struct io_kiocb *req, unsigned int issue_flags)
if (unlikely(ret))
return ret;
- return io_write(req, issue_flags);
+ ret = io_write(req, issue_flags);
+ if (ret != -EIOCBQUEUED)
+ io_detach_dmabuf_map(req);
+ return ret;
+
}
void io_rw_fail(struct io_kiocb *req)
|
| 3/2 | 2026/10/07 01:56 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26623 output: 37 thoughts: 1082 Thoughts: **Analyzing the Dma-buf Integration Patch** Okay, let's dive into this patch. My initial impression is that this is significant, encompassing substantial changes across multiple layers, from the block layer all the way up to io_uring and NVMe. A quick scan tells me that this patch is all about incorporating DMA-BUF fixed buffer support, which I've been expecting for a while. First, it looks like there are adjustments to `bio` and related structures in `bio.c`, `blk-merge.c`, and `fops.c`. These are the core building blocks for I/O operations and DMA-BUF interaction within the kernel's block layer so that is the first port of call, and where I'd expect most changes. I see functions being added or modified such as `__bio_clone`, `bio_iov_iter_set`, `bio_split_io_at_dmabuf`, `__blkdev_direct_IO_async`, and `blkdev_buffered_write`. Also, important `init` functions. Then there's the NVMe side. The inclusion of new files `pci-dmabuf.c` and `pci-dmabuf.h`, and modifications to `core.c`, `pci.c`, `nvme.h` are clearly crucial. Functions like `nvme_init_dma_buf_io_ctx`, `nvme_rq_setup_dmabuf_map`, and `nvme_map_data` are all indicators of how DMA-BUF is being integrated into the NVMe driver's operation. It's integrating the dma-buf framework with the NVMe controller operations. The include files are expanded to include dma-buf awareness. `blk_types.h`, `blkdev.h`, `bio.h` and others now include the relevant enums, structs and macros. Finally, the io_uring side is very interesting. There are new files `dma-buf.c` and `dma-buf.h` as well as changes to `rsrc.c`, `rw.c`, `rsrc.h` and the related Makefiles. Functions like `io_register_dmabuf`, `io_iov_to_regbuf_desc`, and others related to resource management and I/O submission/completion are being modified. This suggests the io_uring subsystem is being enhanced to work with DMA-BUF for direct, efficient I/O, which is what I suspected. I'm keen to see how these different components interact, and how the memory management is handled. This seems like a significant step toward zero-copy and reduced overhead for I/O operations across different devices, particularly for NVMe and potential future DMA-BUF consumers. I'll need to go through each of these areas in more detail, perhaps using `grepper` or exploring the repository, to understand the specifics. This seems like a promising enhancement. |
| 4/2 | 2026/10/07 01:56 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_DMA_SHARED_BUFFER",
"PathPrefixes": [
"drivers/",
"io_uring/"
]
}Results: {
"Output": "drivers/Makefile=78=obj-y\t\t\t\t+= dax/\ndrivers/Makefile:79:obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/\ndrivers/Makefile-80-obj-$(CONFIG_NUBUS)\t\t+= nubus/\n--\ndrivers/iommu/iommufd/io_pagetable.c=482=int iopt_map_file_pages(struct iommufd_ctx *ictx, struct io_pagetable *iopt,\n--\ndrivers/iommu/iommufd/io_pagetable.c-497-\tstart_byte = start - ALIGN_DOWN(start, PAGE_SIZE);\ndrivers/iommu/iommufd/io_pagetable.c:498:\tif (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\ndrivers/iommu/iommufd/io_pagetable.c-499-\t\tdmabuf = dma_buf_get(fd);\n--\ndrivers/iommu/iommufd/io_pagetable.h=251=static inline bool iopt_is_dmabuf(struct iopt_pages *pages)\ndrivers/iommu/iommufd/io_pagetable.h-252-{\ndrivers/iommu/iommufd/io_pagetable.h:253:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\ndrivers/iommu/iommufd/io_pagetable.h-254-\t\treturn false;\n--\ndrivers/iommu/iommufd/pages.c=1527=struct iopt_pages *iopt_alloc_dmabuf_pages(struct iommufd_ctx *ictx,\n--\ndrivers/iommu/iommufd/pages.c-1536-\ndrivers/iommu/iommufd/pages.c:1537:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\ndrivers/iommu/iommufd/pages.c-1538-\t\treturn ERR_PTR(-EOPNOTSUPP);\n--\ndrivers/nvme/host/Makefile=23=nvme-y\t\t\t\t\t+= pci.o\ndrivers/nvme/host/Makefile:24:nvme-$(CONFIG_DMA_SHARED_BUFFER)\t+= pci-dmabuf.o\ndrivers/nvme/host/Makefile-25-\n--\ndrivers/nvme/host/pci-dmabuf.h=51=static inline void nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\ndrivers/nvme/host/pci-dmabuf.h-52-{\ndrivers/nvme/host/pci-dmabuf.h:53:\tif (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\ndrivers/nvme/host/pci-dmabuf.h-54-\t\t__nvme_pci_remove_dmabuf(list);\n--\ndrivers/nvme/host/pci-dmabuf.h=57=static inline int nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\n--\ndrivers/nvme/host/pci-dmabuf.h-60-{\ndrivers/nvme/host/pci-dmabuf.h:61:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\ndrivers/nvme/host/pci-dmabuf.h-62-\t\treturn -EOPNOTSUPP;\n--\nio_uring/Makefile=28=obj-$(CONFIG_IO_URING_BPF_OPS) += bpf-ops.o\nio_uring/Makefile:29:obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o\n--\nio_uring/dma-buf.c=12=int io_register_dmabuf(struct io_ring_ctx *ctx,\n--\nio_uring/dma-buf.c-20-\nio_uring/dma-buf.c:21:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\nio_uring/dma-buf.c-22-\t\treturn -EOPNOTSUPP;\n--\nio_uring/dma-buf.h=15=static inline void io_detach_dmabuf_map(struct io_kiocb *req)\nio_uring/dma-buf.h-16-{\nio_uring/dma-buf.h:17:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\nio_uring/dma-buf.h-18-\t\treturn;\n--\nio_uring/dma-buf.h=25=static inline int io_attach_dmabuf_map(struct io_kiocb *req,\n--\nio_uring/dma-buf.h-32-\nio_uring/dma-buf.h:33:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\nio_uring/dma-buf.h-34-\t\treturn -EOPNOTSUPP;\n--\nio_uring/dma-buf.h=47=static inline int io_import_dmabuf_map(struct io_kiocb *req,\n--\nio_uring/dma-buf.h-53-\nio_uring/dma-buf.h:54:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\nio_uring/dma-buf.h-55-\t\treturn -EOPNOTSUPP;\n--\nio_uring/zcrx.c=130=static void io_unmap_dmabuf(struct io_zcrx_mem *mem)\nio_uring/zcrx.c-131-{\nio_uring/zcrx.c:132:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\nio_uring/zcrx.c-133-\t\treturn;\n--\nio_uring/zcrx.c=143=static void io_release_dmabuf(struct io_zcrx_mem *mem)\nio_uring/zcrx.c-144-{\nio_uring/zcrx.c:145:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\nio_uring/zcrx.c-146-\t\treturn;\n--\nio_uring/zcrx.c=152=static int io_import_dmabuf(struct io_zcrx_ifq *ifq,\n--\nio_uring/zcrx.c-166-\t\treturn -EINVAL;\nio_uring/zcrx.c:167:\tif (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))\nio_uring/zcrx.c-168-\t\treturn -EINVAL;\n"
} |
| 5/2 | 2026/10/07 01:56 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30055 output: 29 thoughts: 25 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Investigating `CONFIG_DMA_SHARED_BUFFER`** Alright, let's dive in. My immediate thought is to check out the Kconfig entry for `CONFIG_DMA_SHARED_BUFFER`. I need to understand its exact purpose, what functionality it unlocks, and, importantly, the conditions under which it becomes enabled within the kernel configuration. This isn't just about knowing *that* it exists; I need to quickly grasp the logical flow and dependencies. I'll need to trace the boolean logic. Is it architecture-specific? Driver-specific? Does it depend on other, more fundamental DMA-related configuration options? Knowing the "why" and "when" will be crucial for understanding its impact on my own work – probably performance, resource management, or maybe even debugging a DMA-related issue. Understanding its definition and dependencies is the first step to knowing how it interacts with the system. |
| 6/2 | 2026/10/07 01:57 | tool | grepper |
0mArgs:{
"Expression": "config DMA_SHARED_BUFFER",
"PathPrefixes": [
"drivers/"
]
}Results: {
"Output": "drivers/base/Kconfig=213=source \"drivers/base/regmap/Kconfig\"\ndrivers/base/Kconfig-214-\ndrivers/base/Kconfig:215:config DMA_SHARED_BUFFER\ndrivers/base/Kconfig-216-\tbool\n"
} |
| 7/2 | 2026/10/07 01:57 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30393 output: 34 thoughts: 19 Thoughts: Here's a summary of my thought process, tailored for an expert like yourself: **Diving into the Kernel's Configuration Landscape** Okay, time to get to the heart of the matter. I need to understand the configuration options for a specific driver. I'm going to navigate directly to the `drivers/base/Kconfig` file, focusing around line 215. This usually indicates the region of code responsible for defining core settings within the base driver framework, which is often a good starting point for understanding how a specific driver integrates or how its behaviour can be altered. I expect to find some fundamental configuration variables defined there that will provide context or be useful for troubleshooting later. Let's see what's there... I'll be looking for relevant `config` statements, `depends on` clauses, and potential help text that sheds light on what's going on. |
| 8/2 | 2026/10/07 01:57 | tool | read-file |
0mArgs:{
"File": "drivers/base/Kconfig",
"FirstLine": 210,
"LineCount": 20
}Results: {
"Contents": " 210:\t\tbool\n 211:\t\tselect GLOB\n 212:\t\n 213:\tsource \"drivers/base/regmap/Kconfig\"\n 214:\t\n 215:\tconfig DMA_SHARED_BUFFER\n 216:\t\tbool\n 217:\t\tdefault n\n 218:\t\tselect IRQ_WORK\n 219:\t\thelp\n 220:\t\t This option enables the framework for buffer-sharing between\n 221:\t\t multiple drivers. A buffer is associated with a file using driver\n 222:\t\t APIs extension; the file's descriptor can then be passed on to other\n 223:\t\t driver.\n 224:\t\n 225:\tconfig GENERIC_ARCH_TOPOLOGY\n 226:\t\tbool\n 227:\t\thelp\n 228:\t\t Enable support for architectures common topology code: e.g., parsing\n 229:\t\t CPU capacity information from DT, usage of such information for\n"
} |
| 9/2 | 2026/10/07 01:57 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30893 output: 20 thoughts: 42 Thoughts: Okay, here's my take on those thoughts, presented as a first-person expert summary: **Unpacking DMA_SHARED_BUFFER's Dependencies** Alright, so `DMA_SHARED_BUFFER` is defined as a boolean, but there's no direct prompt associated with it. That means its state – true or false – is likely being determined *implicitly* by the configuration of other settings. I need to figure out which ones. It's time to leverage my tools. I'll fire up `grepper` and see which other configs are referencing and influencing this one. I need to trace the dependencies to understand the conditions under which `DMA_SHARED_BUFFER` gets enabled or disabled. This will give me a better understanding of the overall system configuration. |
| 10/2 | 2026/10/07 01:57 | tool | grepper |
0mArgs:{
"Expression": "select DMA_SHARED_BUFFER"
}Results: {
"Output": "Documentation/driver-api/dma-buf.rst=65=Any exporters or users of the dma-buf buffer sharing framework must have a\nDocumentation/driver-api/dma-buf.rst:66:'select DMA_SHARED_BUFFER' in their respective Kconfigs.\nDocumentation/driver-api/dma-buf.rst-67-\n--\ndrivers/accel/habanalabs/Kconfig=6=config DRM_ACCEL_HABANALABS\n--\ndrivers/accel/habanalabs/Kconfig-12-\tselect HWMON\ndrivers/accel/habanalabs/Kconfig:13:\tselect DMA_SHARED_BUFFER\ndrivers/accel/habanalabs/Kconfig-14-\tselect CRC32\n--\ndrivers/dma-buf/Kconfig=4=config SYNC_FILE\n--\ndrivers/dma-buf/Kconfig-6-\tdefault n\ndrivers/dma-buf/Kconfig:7:\tselect DMA_SHARED_BUFFER\ndrivers/dma-buf/Kconfig-8-\thelp\n--\ndrivers/dma-buf/Kconfig=52=config DMABUF_KUNIT_TEST\n--\ndrivers/dma-buf/Kconfig-54-\tdepends on KUNIT\ndrivers/dma-buf/Kconfig:55:\tselect DMA_SHARED_BUFFER\ndrivers/dma-buf/Kconfig-56-\tdefault KUNIT_ALL_TESTS\n--\ndrivers/dma-buf/Kconfig=60=menuconfig DMABUF_HEAPS\ndrivers/dma-buf/Kconfig-61-\tbool \"DMA-BUF Userland Memory Heaps\"\ndrivers/dma-buf/Kconfig:62:\tselect DMA_SHARED_BUFFER\ndrivers/dma-buf/Kconfig-63-\thelp\n--\ndrivers/gpu/drm/Kconfig=8=menuconfig DRM\n--\ndrivers/gpu/drm/Kconfig-13-\tselect I2C\ndrivers/gpu/drm/Kconfig:14:\tselect DMA_SHARED_BUFFER\ndrivers/gpu/drm/Kconfig-15-\tselect SYNC_FILE\n--\ndrivers/gpu/host1x/Kconfig=6=config TEGRA_HOST1X\n--\ndrivers/gpu/host1x/Kconfig-8-\tdepends on ARCH_TEGRA || COMPILE_TEST\ndrivers/gpu/host1x/Kconfig:9:\tselect DMA_SHARED_BUFFER\ndrivers/gpu/host1x/Kconfig-10-\tselect TEGRA_HOST1X_CONTEXT_BUS\n--\ndrivers/iio/Kconfig=15=config IIO_BUFFER\ndrivers/iio/Kconfig-16-\tbool \"Enable buffer support within IIO\"\ndrivers/iio/Kconfig:17:\tselect DMA_SHARED_BUFFER\ndrivers/iio/Kconfig-18-\thelp\n--\ndrivers/infiniband/Kconfig=2=menuconfig INFINIBAND\n--\ndrivers/infiniband/Kconfig-7-\tdepends on !ALPHA\ndrivers/infiniband/Kconfig:8:\tselect DMA_SHARED_BUFFER\ndrivers/infiniband/Kconfig-9-\tselect IRQ_POLL\n--\ndrivers/infiniband/Kconfig=44=config INFINIBAND_USER_MEM\n--\ndrivers/infiniband/Kconfig-47-\tdepends on MMU\ndrivers/infiniband/Kconfig:48:\tselect DMA_SHARED_BUFFER\ndrivers/infiniband/Kconfig-49-\tdefault y\n--\ndrivers/iommu/iommufd/Kconfig=51=config IOMMUFD_TEST\n--\ndrivers/iommu/iommufd/Kconfig-56-\tdepends on IOMMU_PT_AMDV1=y || IOMMUFD=IOMMU_PT_AMDV1\ndrivers/iommu/iommufd/Kconfig:57:\tselect DMA_SHARED_BUFFER\ndrivers/iommu/iommufd/Kconfig-58-\tselect IOMMUFD_DRIVER\n--\ndrivers/media/common/videobuf2/Kconfig=3=config VIDEOBUF2_CORE\ndrivers/media/common/videobuf2/Kconfig:4:\tselect DMA_SHARED_BUFFER\ndrivers/media/common/videobuf2/Kconfig-5-\ttristate\n--\ndrivers/media/common/videobuf2/Kconfig=13=config VIDEOBUF2_DMA_CONTIG\n--\ndrivers/media/common/videobuf2/Kconfig-16-\tselect VIDEOBUF2_MEMOPS\ndrivers/media/common/videobuf2/Kconfig:17:\tselect DMA_SHARED_BUFFER\ndrivers/media/common/videobuf2/Kconfig-18-\ndrivers/media/common/videobuf2/Kconfig=19=config VIDEOBUF2_VMALLOC\n--\ndrivers/media/common/videobuf2/Kconfig-22-\tselect VIDEOBUF2_MEMOPS\ndrivers/media/common/videobuf2/Kconfig:23:\tselect DMA_SHARED_BUFFER\ndrivers/media/common/videobuf2/Kconfig-24-\n--\ndrivers/media/platform/nvidia/tegra-vde/Kconfig=1=config VIDEO_TEGRA_VDE\n--\ndrivers/media/platform/nvidia/tegra-vde/Kconfig-6-\tdepends on VIDEO_DEV\ndrivers/media/platform/nvidia/tegra-vde/Kconfig:7:\tselect DMA_SHARED_BUFFER\ndrivers/media/platform/nvidia/tegra-vde/Kconfig-8-\tselect IOMMU_IOVA\n--\ndrivers/misc/Kconfig=266=config QCOM_FASTRPC\n--\ndrivers/misc/Kconfig-269-\tdepends on RPMSG\ndrivers/misc/Kconfig:270:\tselect DMA_SHARED_BUFFER\ndrivers/misc/Kconfig-271-\tselect QCOM_SCM\n--\ndrivers/tee/Kconfig=3=menuconfig TEE\n--\ndrivers/tee/Kconfig-6-\tselect CRYPTO_LIB_SHA1\ndrivers/tee/Kconfig:7:\tselect DMA_SHARED_BUFFER\ndrivers/tee/Kconfig-8-\tselect GENERIC_ALLOCATOR\n--\ndrivers/usb/gadget/Kconfig=192=config USB_F_FS\ndrivers/usb/gadget/Kconfig:193:\tselect DMA_SHARED_BUFFER\ndrivers/usb/gadget/Kconfig-194-\ttristate\n--\ndrivers/xen/Kconfig=145=config XEN_GNTDEV_DMABUF\n--\ndrivers/xen/Kconfig-147-\tdepends on XEN_GNTDEV \u0026\u0026 XEN_GRANT_DMA_ALLOC\ndrivers/xen/Kconfig:148:\tselect DMA_SHARED_BUFFER\ndrivers/xen/Kconfig-149-\thelp\n--\nsamples/Kconfig=230=config SAMPLE_VFIO_MDEV_MBOCHS\n--\nsamples/Kconfig-233-\tselect VFIO_MDEV\nsamples/Kconfig:234:\tselect DMA_SHARED_BUFFER\nsamples/Kconfig-235-\thelp\n--\nsound/soc/fsl/Kconfig=6=config SND_SOC_FSL_ASRC\n--\nsound/soc/fsl/Kconfig-8-\tdepends on HAS_DMA\nsound/soc/fsl/Kconfig:9:\tselect DMA_SHARED_BUFFER\nsound/soc/fsl/Kconfig-10-\tselect REGMAP_MMIO\n"
} |
| 11/2 | 2026/10/07 01:57 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32920 output: 34 thoughts: 109 Thoughts: **Investigating DMA-BUF Allocation Strategies** Okay, so I'm thinking about the low-level details of DMA buffer allocation here, particularly when dealing with the likes of `DMABUF_HEAPS`, `DRM`, and `SYNC_FILE`. I need a robust method for choosing the appropriate backend, and it seems like the best approach is to select `DMA_SHARED_BUFFER`. I'm also seeing that `DMABUF_HEAPS` is frequently used for allocating dma-bufs from user space – specifically, through that `/dev/dma_heap/...` interface. I should verify this assumption and gain a deeper understanding of it. Given my focus on `DMABUF_HEAPS`, the next logical step is to check its configuration options in the kernel's Kconfig system. I might need to look for specific options like `DMABUF_HEAPS_SYSTEM` or related settings to understand the available configuration options. I'll need to dig into `drivers/dma-buf/heaps/Kconfig` to fully grasp the available options. |
| 12/2 | 2026/10/07 01:58 | tool | grepper |
0mArgs:{
"Expression": "DMABUF_HEAPS",
"PathPrefixes": [
"drivers/dma-buf/"
]
}Results: {
"Output": "drivers/dma-buf/Kconfig=52=config DMABUF_KUNIT_TEST\n--\ndrivers/dma-buf/Kconfig-59-\ndrivers/dma-buf/Kconfig:60:menuconfig DMABUF_HEAPS\ndrivers/dma-buf/Kconfig-61-\tbool \"DMA-BUF Userland Memory Heaps\"\n--\ndrivers/dma-buf/Makefile=2=obj-y := dma-buf.o dma-fence.o dma-fence-array.o dma-fence-chain.o \\\ndrivers/dma-buf/Makefile-3-\t dma-fence-unwrap.o dma-resv.o dma-buf-mapping.o\ndrivers/dma-buf/Makefile:4:obj-$(CONFIG_DMABUF_HEAPS)\t+= dma-heap.o\ndrivers/dma-buf/Makefile:5:obj-$(CONFIG_DMABUF_HEAPS)\t+= heaps/\ndrivers/dma-buf/Makefile-6-obj-$(CONFIG_SYNC_FILE)\t\t+= sync_file.o\n--\ndrivers/dma-buf/heaps/Kconfig:1:config DMABUF_HEAPS_SYSTEM\ndrivers/dma-buf/heaps/Kconfig-2-\ttristate \"DMA-BUF System Heap\"\ndrivers/dma-buf/heaps/Kconfig:3:\tdepends on DMABUF_HEAPS\ndrivers/dma-buf/heaps/Kconfig-4-\thelp\n--\ndrivers/dma-buf/heaps/Kconfig-7-\ndrivers/dma-buf/heaps/Kconfig:8:config DMABUF_HEAPS_SYSTEM_CC_SHARED\ndrivers/dma-buf/heaps/Kconfig-9-\tbool \"DMA-BUF System Heap for decrypted CoCo VMs\"\ndrivers/dma-buf/heaps/Kconfig:10:\tdepends on DMABUF_HEAPS \u0026\u0026 ARCH_HAS_MEM_ENCRYPT \u0026\u0026 DMABUF_HEAPS_SYSTEM=y\ndrivers/dma-buf/heaps/Kconfig-11-\thelp\n--\ndrivers/dma-buf/heaps/Kconfig-15-\ndrivers/dma-buf/heaps/Kconfig:16:config DMABUF_HEAPS_CMA\ndrivers/dma-buf/heaps/Kconfig-17-\ttristate \"DMA-BUF CMA Heap\"\ndrivers/dma-buf/heaps/Kconfig:18:\tdepends on DMABUF_HEAPS \u0026\u0026 DMA_CMA\ndrivers/dma-buf/heaps/Kconfig-19-\thelp\n--\ndrivers/dma-buf/heaps/Makefile-1-# SPDX-License-Identifier: GPL-2.0\ndrivers/dma-buf/heaps/Makefile:2:obj-$(CONFIG_DMABUF_HEAPS_SYSTEM)\t+= system_heap.o\ndrivers/dma-buf/heaps/Makefile:3:obj-$(CONFIG_DMABUF_HEAPS_CMA)\t\t+= cma_heap.o\n--\ndrivers/dma-buf/heaps/system_heap.c=43=struct dma_heap_attachment {\n--\ndrivers/dma-buf/heaps/system_heap.c-50-\ndrivers/dma-buf/heaps/system_heap.c:51:#define cc_shared_buffer(b) (IS_ENABLED(CONFIG_DMABUF_HEAPS_SYSTEM_CC_SHARED) \u0026\u0026 \\\ndrivers/dma-buf/heaps/system_heap.c-52-\t\t\t\t(b)-\u003ecc_shared)\n--\ndrivers/dma-buf/heaps/system_heap.c=517=static int __init system_heap_create(void)\n--\ndrivers/dma-buf/heaps/system_heap.c-530-\tif (IS_ENABLED(CONFIG_HIGHMEM) ||\ndrivers/dma-buf/heaps/system_heap.c:531:\t !IS_ENABLED(CONFIG_DMABUF_HEAPS_SYSTEM_CC_SHARED) ||\ndrivers/dma-buf/heaps/system_heap.c-532-\t !cc_platform_has(CC_ATTR_MEM_ENCRYPT))\n"
} |
| 13/2 | 2026/10/07 01:58 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34311 output: 39 thoughts: 48 Thoughts: Okay, let's dive into this. Here's my thought process on dissecting DMA-BUF I/O and the `dma-buf-io.h` header: **Diving Deep into DMA-BUF I/O** Alright, I need a refresher on how the DMA-BUF I/O mechanism operates. It's time to refresh my understanding and confirm it's still what I remember. The obvious place to start is the header file itself – `include/linux/dma-buf-io.h`. I'll either pull it up directly in my editor or use `grep` to quickly scan the kernel source for all instances of that header. This should give me a clear picture of its defined structures, functions, and macros. From there, I'll review and clarify how `dma-buf` operations are structured and their interaction with the I/O system, likely touching on things like memory mapping, buffer allocation, and synchronization. Gotta stay sharp! |
| 14/2 | 2026/10/07 01:58 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io",
"PathPrefixes": [
"include/",
"drivers/dma-buf/"
]
}Results: {
"Output": "drivers/dma-buf/dma-buf.c=492=static long dma_buf_import_sync_file(struct dma_buf *dmabuf,\n--\ndrivers/dma-buf/dma-buf.c-539-\ndrivers/dma-buf/dma-buf.c:540:static long dma_buf_ioctl(struct file *file,\ndrivers/dma-buf/dma-buf.c-541-\t\t\t unsigned int cmd, unsigned long arg)\n--\ndrivers/dma-buf/dma-buf.c=609=static const struct file_operations dma_buf_fops = {\n--\ndrivers/dma-buf/dma-buf.c-613-\t.poll\t\t= dma_buf_poll,\ndrivers/dma-buf/dma-buf.c:614:\t.unlocked_ioctl\t= dma_buf_ioctl,\ndrivers/dma-buf/dma-buf.c-615-\t.compat_ioctl\t= compat_ptr_ioctl,\n--\ninclude/linux/blk_types.h=210=struct bio {\n--\ninclude/linux/blk_types.h-238-\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\ninclude/linux/blk_types.h:239:\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\ninclude/linux/blk_types.h-240-\t};\n--\ninclude/linux/blkdev.h=1577=struct block_device_operations {\n--\ninclude/linux/blkdev.h-1601-\t\t\tenum blk_unique_id id_type);\ninclude/linux/blkdev.h:1602:\tint (*init_dma_buf_io_ctx)(struct block_device *,\ninclude/linux/blkdev.h:1603:\t\t\t\t struct dma_buf_io_ctx *);\ninclude/linux/blkdev.h-1604-\tstruct module *owner;\n--\ninclude/linux/io_uring_types.h=13=struct io_uring_bpf_ops;\ninclude/linux/io_uring_types.h:14:struct dma_buf_io_map;\ninclude/linux/io_uring_types.h-15-\n--\ninclude/linux/io_uring_types.h=759=struct io_kiocb {\n--\ninclude/linux/io_uring_types.h-833-\tstruct io_wq_work\t\twork;\ninclude/linux/io_uring_types.h:834:\tstruct dma_buf_io_map\t\t*dmabuf_map;\ninclude/linux/io_uring_types.h-835-\n--\ninclude/linux/vfio_pci_core.h=249=vfio_pci_core_get_iomap(struct vfio_pci_core_device *vdev, unsigned int bar)\n--\ninclude/linux/vfio_pci_core.h-259-\ninclude/linux/vfio_pci_core.h:260:int vfio_pci_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,\ninclude/linux/vfio_pci_core.h-261-\t\t\t\t struct phys_vec *phys);\n"
} |
| 15/2 | 2026/10/07 01:58 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35447 output: 22 thoughts: 22 Thoughts: Okay, here's my summary, tailored for an expert audience, as if I'm thinking these thoughts myself: **Locating the Target Header** Alright, time to get this show on the road. I need to find the `dma-buf-io.h` header within the kernel source tree. No need to manually crawl through directories; that's inefficient. My gut tells me this will be straightforward. I'm going to leverage `grepper`. It's the most expedient way to hunt down a file, especially when I know the exact name. Let's get this quick search started. |
| 16/2 | 2026/10/07 01:58 | tool | grepper |
0mArgs:{
"Expression": "dma-buf-io\\.h"
}Results: {
"Output": "block/blk-merge.c-11-#include \u003clinux/blk-cgroup.h\u003e\nblock/blk-merge.c:12:#include \u003clinux/dma-buf-io.h\u003e\nblock/blk-merge.c-13-\n--\ndrivers/nvme/host/pci-dmabuf.h-8-\ndrivers/nvme/host/pci-dmabuf.h:9:#include \u003clinux/dma-buf-io.h\u003e\ndrivers/nvme/host/pci-dmabuf.h-10-\n--\nio_uring/dma-buf.h-4-\nio_uring/dma-buf.h:5:#include \u003clinux/dma-buf-io.h\u003e\nio_uring/dma-buf.h-6-#include \u003clinux/io_uring_types.h\u003e\n--\nio_uring/rsrc.c-12-#include \u003clinux/io_uring/cmd.h\u003e\nio_uring/rsrc.c:13:#include \u003clinux/dma-buf-io.h\u003e\nio_uring/rsrc.c-14-\n"
} |
| 17/2 | 2026/10/07 01:58 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35900 output: 22 thoughts: 20 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Hunting Down `linux/dma-buf-io.h`** Alright, let's get down to brass tacks. I need to pinpoint the definition of `linux/dma-buf-io.h`. It's a fundamental header for dma-buf operations, so it's likely a critical part of the core Linux kernel. I'll need to remember where that header is in the source tree! Hopefully it's in the place I expect. My first thought is probably the generic DMA-BUF implementation. I will start by querying my code search tools to find it or its inclusions. That should quickly narrow down the location and which kernel versions have it, or its various revisions. A fast search will give me the best results, as I can quickly see what the different versions are. This should be a relatively straightforward search-and-find mission. No need to overthink it; the standard location is usually in the kernel source, or in some sub-directory. I expect it'll be in the `include/linux/` directory, or maybe within a more specific DMA-related sub-directory within there. If I'm lucky, a quick `grep` or `find` command will get me the answer immediately. If not, I'll need to refine my search terms or consider broader searches across the kernel tree. Let's get to it! |
| 18/2 | 2026/10/07 01:59 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_ctx"
}Results: {
"Output": "block/fops.c=959=static int blkdev_mmap_prepare(struct vm_area_desc *desc)\n--\nblock/fops.c-968-\nblock/fops.c:969:static int blkdev_init_dma_buf_io_ctx(struct file *file,\nblock/fops.c:970:\t\t\t\t struct dma_buf_io_ctx *ctx)\nblock/fops.c-971-{\n--\nblock/fops.c-976-\t\treturn -EINVAL;\nblock/fops.c:977:\tif (!disk-\u003efops-\u003einit_dma_buf_io_ctx)\nblock/fops.c-978-\t\treturn -EOPNOTSUPP;\nblock/fops.c:979:\treturn disk-\u003efops-\u003einit_dma_buf_io_ctx(bdev, ctx);\nblock/fops.c-980-}\n--\nblock/fops.c=982=const struct file_operations def_blk_fops = {\n--\nblock/fops.c-999-\t.fop_flags\t= FOP_BUFFER_RASYNC | FOP_DONTCACHE,\nblock/fops.c:1000:\t.init_dma_buf_io_ctx = blkdev_init_dma_buf_io_ctx,\nblock/fops.c-1001-};\n--\ndrivers/nvme/host/core.c=2702=static int nvme_report_zones(struct gendisk *disk, sector_t sector,\n--\ndrivers/nvme/host/core.c-2710-\ndrivers/nvme/host/core.c:2711:static int nvme_init_dma_buf_io_ctx(struct block_device *bdev,\ndrivers/nvme/host/core.c:2712:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/core.c-2713-{\n--\ndrivers/nvme/host/core.c-2716-\ndrivers/nvme/host/core.c:2717:\tif (!ctrl-\u003eops-\u003einit_dma_buf_io_ctx)\ndrivers/nvme/host/core.c-2718-\t\treturn -EINVAL;\ndrivers/nvme/host/core.c:2719:\treturn ctrl-\u003eops-\u003einit_dma_buf_io_ctx(ctrl, ctx);\ndrivers/nvme/host/core.c-2720-}\n--\ndrivers/nvme/host/core.c=2722=const struct block_device_operations nvme_bdev_ops = {\n--\ndrivers/nvme/host/core.c-2731-\t.pr_ops\t\t= \u0026nvme_pr_ops,\ndrivers/nvme/host/core.c:2732:\t.init_dma_buf_io_ctx = nvme_init_dma_buf_io_ctx,\ndrivers/nvme/host/core.c-2733-};\n--\ndrivers/nvme/host/nvme.h=651=struct nvme_ctrl_ops {\n--\ndrivers/nvme/host/nvme.h-670-\tbool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);\ndrivers/nvme/host/nvme.h:671:\tint (*init_dma_buf_io_ctx)(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/nvme.h:672:\t\t\t\t struct dma_buf_io_ctx *ctx);\ndrivers/nvme/host/nvme.h-673-\tunsigned long (*get_virt_boundary)(struct nvme_ctrl *ctrl, bool is_admin);\n--\ndrivers/nvme/host/pci-dmabuf.c=10=static void nvme_dmabuf_invalidate_mappings(struct dma_buf_attachment *attach)\ndrivers/nvme/host/pci-dmabuf.c-11-{\ndrivers/nvme/host/pci-dmabuf.c:12:\tstruct dma_buf_io_ctx *ctx = attach-\u003eimporter_priv;\ndrivers/nvme/host/pci-dmabuf.c-13-\n--\ndrivers/nvme/host/pci-dmabuf.c=17=static const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {\n--\ndrivers/nvme/host/pci-dmabuf.c-21-\ndrivers/nvme/host/pci-dmabuf.c:22:static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-23-{\ndrivers/nvme/host/pci-dmabuf.c-24-\tunsigned nr_entries = ctx-\u003edmabuf-\u003esize / NVME_CTRL_PAGE_SIZE;\ndrivers/nvme/host/pci-dmabuf.c:25:\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-26-\tstruct dma_buf_attachment *attach = nvme_ctx-\u003eattach;\n--\ndrivers/nvme/host/pci-dmabuf.c-77-\ndrivers/nvme/host/pci-dmabuf.c:78:static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,\ndrivers/nvme/host/pci-dmabuf.c-79-\t\tstruct dma_buf_io_map *map_base)\ndrivers/nvme/host/pci-dmabuf.c-80-{\ndrivers/nvme/host/pci-dmabuf.c:81:\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-82-\tstruct nvme_dmabuf_map *map = to_nvme_dmabuf_map(map_base);\n--\ndrivers/nvme/host/pci-dmabuf.c-89-\ndrivers/nvme/host/pci-dmabuf.c:90:static void nvme_dma_buf_io_release(struct dma_buf_io_ctx *base_ctx)\ndrivers/nvme/host/pci-dmabuf.c-91-{\ndrivers/nvme/host/pci-dmabuf.c:92:\tstruct nvme_dma_buf_io_ctx *ctx = base_ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-93-\tstruct nvme_dma_buf_list *buf_list = ctx-\u003ebuf_list;\n--\ndrivers/nvme/host/pci-dmabuf.c=106=void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\ndrivers/nvme/host/pci-dmabuf.c-107-{\ndrivers/nvme/host/pci-dmabuf.c:108:\tstruct nvme_dma_buf_io_ctx *ctx, *tmp;\ndrivers/nvme/host/pci-dmabuf.c-109-\n--\ndrivers/nvme/host/pci-dmabuf.c=125=static int nvme_init_io_ctx_locked(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.c-126-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.c:127:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-128-{\ndrivers/nvme/host/pci-dmabuf.c:129:\tstruct nvme_dma_buf_io_ctx *nvme_ctx;\ndrivers/nvme/host/pci-dmabuf.c-130-\tstruct dma_buf_attachment *attach;\n--\ndrivers/nvme/host/pci-dmabuf.c-153-\ndrivers/nvme/host/pci-dmabuf.c:154:int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.c-155-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.c:156:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-157-{\n--\ndrivers/nvme/host/pci-dmabuf.h=13=struct nvme_dma_buf_list {\n--\ndrivers/nvme/host/pci-dmabuf.h-17-\ndrivers/nvme/host/pci-dmabuf.h:18:struct nvme_dma_buf_io_ctx {\ndrivers/nvme/host/pci-dmabuf.h-19-\tstruct dma_buf_attachment *attach;\ndrivers/nvme/host/pci-dmabuf.h-20-\tstruct nvme_dma_buf_list *buf_list;\ndrivers/nvme/host/pci-dmabuf.h:21:\tstruct dma_buf_io_ctx *base;\ndrivers/nvme/host/pci-dmabuf.h-22-\tstruct nvme_ctrl *ctrl;\n--\ndrivers/nvme/host/pci-dmabuf.h=46=void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list);\ndrivers/nvme/host/pci-dmabuf.h:47:int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.h-48-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.h:49:\t\tstruct dma_buf_io_ctx *ctx);\ndrivers/nvme/host/pci-dmabuf.h-50-\ndrivers/nvme/host/pci-dmabuf.h=51=static inline void nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\n--\ndrivers/nvme/host/pci-dmabuf.h-56-\ndrivers/nvme/host/pci-dmabuf.h:57:static inline int nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.h-58-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.h:59:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.h-60-{\n--\ndrivers/nvme/host/pci-dmabuf.h-62-\t\treturn -EOPNOTSUPP;\ndrivers/nvme/host/pci-dmabuf.h:63:\treturn __nvme_init_dma_buf_io_ctx(ctrl, buf_list, ctx);\ndrivers/nvme/host/pci-dmabuf.h-64-}\n--\ndrivers/nvme/host/pci.c=3783=static unsigned long nvme_pci_get_virt_boundary(struct nvme_ctrl *ctrl,\n--\ndrivers/nvme/host/pci.c-3790-\ndrivers/nvme/host/pci.c:3791:static int nvme_pci_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci.c:3792:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci.c-3793-{\n--\ndrivers/nvme/host/pci.c-3795-\ndrivers/nvme/host/pci.c:3796:\treturn nvme_init_dma_buf_io_ctx(ctrl, \u0026dev-\u003edmabufs, ctx);\ndrivers/nvme/host/pci.c-3797-}\n--\ndrivers/nvme/host/pci.c=3799=static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {\n--\ndrivers/nvme/host/pci.c-3813-\t.get_virt_boundary\t= nvme_pci_get_virt_boundary,\ndrivers/nvme/host/pci.c:3814:\t.init_dma_buf_io_ctx\t= nvme_pci_init_dma_buf_io_ctx,\ndrivers/nvme/host/pci.c-3815-};\n--\ninclude/linux/blkdev.h=1577=struct block_device_operations {\n--\ninclude/linux/blkdev.h-1601-\t\t\tenum blk_unique_id id_type);\ninclude/linux/blkdev.h:1602:\tint (*init_dma_buf_io_ctx)(struct block_device *,\ninclude/linux/blkdev.h:1603:\t\t\t\t struct dma_buf_io_ctx *);\ninclude/linux/blkdev.h-1604-\tstruct module *owner;\n--\nio_uring/dma-buf.c=3=static inline void io_release_dmabuf(void *priv)\n--\nio_uring/dma-buf.c-7-\tfput(bd-\u003etarget_file);\nio_uring/dma-buf.c:8:\tdma_buf_io_ctx_release(bd-\u003ectx);\nio_uring/dma-buf.c-9-\tkfree(bd);\n--\nio_uring/dma-buf.c=12=int io_register_dmabuf(struct io_ring_ctx *ctx,\n--\nio_uring/dma-buf.c-46-\nio_uring/dma-buf.c:47:\tret = dma_buf_io_ctx_create(target_file, dmabuf, DMA_BIDIRECTIONAL,\nio_uring/dma-buf.c-48-\t\t\t\t \u0026bd-\u003ectx);\n--\nio_uring/dma-buf.h=10=struct io_buf_dma {\nio_uring/dma-buf.h:11:\tstruct dma_buf_io_ctx\t\t*ctx;\nio_uring/dma-buf.h-12-\tstruct file\t\t\t*target_file;\n"
} |
| 19/2 | 2026/10/07 01:59 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40017 output: 38 thoughts: 37 Thoughts: Here's my thought process, summarized as you requested: **Navigating the Kernel's DMA-BUF I/O Header** Okay, so I need to get my hands on `include/linux/dma-buf-io.h`. First, a quick sanity check: does this file even *exist*? I can't just assume. Alright, time to lean on the tools. I'll reach for either `read-file` if I know the exact path or, more likely, a trusty `grepper` search across the kernel source. That'll quickly tell me if it's there and point me to the correct location if it is. It's usually faster than manually browsing the directory structure, and ensures accuracy. |
| 20/2 | 2026/10/07 01:59 | tool | read-file |
0mError:the file does not exist Args: {
"File": "include/linux/dma-buf-io.h",
"FirstLine": 1,
"LineCount": 80
}Results: {
"error": "the file does not exist"
} |
| 21/2 | 2026/10/07 01:59 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40267 output: 20 thoughts: 63 Thoughts: Here's my thought process, as if I were reviewing this: **Investigating a Missing Header File** Okay, hold on a minute. The code's trying to include `include/linux/dma-buf-io.h`, but my initial check is telling me that file doesn't exist where I expect it to. This is a red flag. What's going on? And then...why is `git grep` even finding instances of `#include <linux/dma-buf-io.h>` in the first place? That contradicts my expectation. I need to figure out what's going on here. Let's start by trying a broader search; I'll scan the entire tree for files containing the string `dma-buf-io` to see if it's lurking under a different name or in an unexpected location. Maybe there's a typo, an alias, or a more subtle issue at play. |
| 22/2 | 2026/10/07 01:59 | tool | grepper |
0mArgs:{
"Expression": "dma-buf-io"
}Results: {
"Output": "block/blk-merge.c-11-#include \u003clinux/blk-cgroup.h\u003e\nblock/blk-merge.c:12:#include \u003clinux/dma-buf-io.h\u003e\nblock/blk-merge.c-13-\n--\ndrivers/nvme/host/pci-dmabuf.h-8-\ndrivers/nvme/host/pci-dmabuf.h:9:#include \u003clinux/dma-buf-io.h\u003e\ndrivers/nvme/host/pci-dmabuf.h-10-\n--\nio_uring/dma-buf.h-4-\nio_uring/dma-buf.h:5:#include \u003clinux/dma-buf-io.h\u003e\nio_uring/dma-buf.h-6-#include \u003clinux/io_uring_types.h\u003e\n--\nio_uring/rsrc.c-12-#include \u003clinux/io_uring/cmd.h\u003e\nio_uring/rsrc.c:13:#include \u003clinux/dma-buf-io.h\u003e\nio_uring/rsrc.c-14-\n"
} |
| 23/2 | 2026/10/07 01:59 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40828 output: 24 thoughts: 27 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Debugging a DMA-BUF Context Creation** Okay, hold on a second. I need to track down the definition of `dma_buf_io_ctx_create`. It's buried in the kernel source, and I can't immediately recall where it lives off the top of my head. Time to fire up `grepper`. I'll use it to quickly pinpoint the header file and, ideally, the relevant source file where that function is declared and implemented. Knowing its location is the crucial first step to understanding its purpose and potential issues I might be encountering upstream from its use. Let's see what `grepper` uncovers. |
| 24/2 | 2026/10/07 01:59 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_ctx_create"
}Results: {
"Output": "io_uring/dma-buf.c=12=int io_register_dmabuf(struct io_ring_ctx *ctx,\n--\nio_uring/dma-buf.c-46-\nio_uring/dma-buf.c:47:\tret = dma_buf_io_ctx_create(target_file, dmabuf, DMA_BIDIRECTIONAL,\nio_uring/dma-buf.c-48-\t\t\t\t \u0026bd-\u003ectx);\n"
} |
| 25/2 | 2026/10/07 01:59 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41160 output: 23 thoughts: 186 Thoughts: **Debugging a Missing Header File** Okay, so `dma_buf_io_ctx_create` is only defined in `io_uring/dma-buf.c`? That's... unusual. Where else could it possibly be? My initial instinct is to check the entire tree, obviously. Let's see... I'll start with `git status` or a quick look at recent commits to see if `linux/dma-buf-io.h` was perhaps added recently on this branch, or maybe just missed somehow. Actually, `git log` is probably more effective, seeing as it provides a clearer history of changes. Let's start there. Hold on, I only have `grepper`, `read-file`, and `codesearch-dir-index` available to me in the working environment. Okay, let's try `read-file` on `include/linux/dma-buf-io.h`. Wait, it said the file doesn't exist? That's really strange. Ok, time to think... Alright, new strategy. Let's use `codesearch-dir-index` to look for anything under `include/linux/`, or even just grep for `dma_buf_io_ctx` across all the include files. This should either confirm the file exists somewhere, or reveal the issue if there is another file I have access to that has this functionality. |
| 26/2 | 2026/10/07 01:59 | tool | grepper |
0mArgs:{
"Expression": "struct dma_buf_io_ctx"
}Results: {
"Output": "block/fops.c=969=static int blkdev_init_dma_buf_io_ctx(struct file *file,\nblock/fops.c:970:\t\t\t\t struct dma_buf_io_ctx *ctx)\nblock/fops.c-971-{\n--\ndrivers/nvme/host/core.c=2711=static int nvme_init_dma_buf_io_ctx(struct block_device *bdev,\ndrivers/nvme/host/core.c:2712:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/core.c-2713-{\n--\ndrivers/nvme/host/nvme.h=651=struct nvme_ctrl_ops {\n--\ndrivers/nvme/host/nvme.h-671-\tint (*init_dma_buf_io_ctx)(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/nvme.h:672:\t\t\t\t struct dma_buf_io_ctx *ctx);\ndrivers/nvme/host/nvme.h-673-\tunsigned long (*get_virt_boundary)(struct nvme_ctrl *ctrl, bool is_admin);\n--\ndrivers/nvme/host/pci-dmabuf.c=10=static void nvme_dmabuf_invalidate_mappings(struct dma_buf_attachment *attach)\ndrivers/nvme/host/pci-dmabuf.c-11-{\ndrivers/nvme/host/pci-dmabuf.c:12:\tstruct dma_buf_io_ctx *ctx = attach-\u003eimporter_priv;\ndrivers/nvme/host/pci-dmabuf.c-13-\n--\ndrivers/nvme/host/pci-dmabuf.c=17=static const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {\n--\ndrivers/nvme/host/pci-dmabuf.c-21-\ndrivers/nvme/host/pci-dmabuf.c:22:static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-23-{\n--\ndrivers/nvme/host/pci-dmabuf.c-77-\ndrivers/nvme/host/pci-dmabuf.c:78:static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,\ndrivers/nvme/host/pci-dmabuf.c-79-\t\tstruct dma_buf_io_map *map_base)\n--\ndrivers/nvme/host/pci-dmabuf.c-89-\ndrivers/nvme/host/pci-dmabuf.c:90:static void nvme_dma_buf_io_release(struct dma_buf_io_ctx *base_ctx)\ndrivers/nvme/host/pci-dmabuf.c-91-{\n--\ndrivers/nvme/host/pci-dmabuf.c=125=static int nvme_init_io_ctx_locked(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.c-126-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.c:127:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-128-{\n--\ndrivers/nvme/host/pci-dmabuf.c=154=int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.c-155-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.c:156:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-157-{\n--\ndrivers/nvme/host/pci-dmabuf.h=18=struct nvme_dma_buf_io_ctx {\n--\ndrivers/nvme/host/pci-dmabuf.h-20-\tstruct nvme_dma_buf_list *buf_list;\ndrivers/nvme/host/pci-dmabuf.h:21:\tstruct dma_buf_io_ctx *base;\ndrivers/nvme/host/pci-dmabuf.h-22-\tstruct nvme_ctrl *ctrl;\n--\ndrivers/nvme/host/pci-dmabuf.h=47=int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.h-48-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.h:49:\t\tstruct dma_buf_io_ctx *ctx);\ndrivers/nvme/host/pci-dmabuf.h-50-\n--\ndrivers/nvme/host/pci-dmabuf.h=57=static inline int nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.h-58-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.h:59:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.h-60-{\n--\ndrivers/nvme/host/pci.c=3791=static int nvme_pci_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci.c:3792:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci.c-3793-{\n--\ninclude/linux/blkdev.h=1577=struct block_device_operations {\n--\ninclude/linux/blkdev.h-1602-\tint (*init_dma_buf_io_ctx)(struct block_device *,\ninclude/linux/blkdev.h:1603:\t\t\t\t struct dma_buf_io_ctx *);\ninclude/linux/blkdev.h-1604-\tstruct module *owner;\n--\nio_uring/dma-buf.h=10=struct io_buf_dma {\nio_uring/dma-buf.h:11:\tstruct dma_buf_io_ctx\t\t*ctx;\nio_uring/dma-buf.h-12-\tstruct file\t\t\t*target_file;\n"
} |
| 27/2 | 2026/10/07 01:59 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43410 output: 31 thoughts: 51 Thoughts: **Locating the Elusive Structure** Okay, first thought: Where *is* `struct dma_buf_io_ctx` actually defined? I was sure I'd seen it somewhere, but a quick scan isn't turning anything up. That's odd. Why hasn't it popped up in any of the expected headers? It's usually good practice to keep these things well-documented and accessible. Okay, let's take a more methodical approach. Time to go dig around in `include/`. Gotta start at the source and see if it's lurking there. This feels like one of those situations where the definition is probably being pulled in via some indirect include, or maybe it's conditionally compiled in based on some configuration option. Let's find it. |
| 28/2 | 2026/10/07 01:59 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_ctx",
"PathPrefixes": [
"include/"
]
}Results: {
"Output": "include/linux/blkdev.h=1577=struct block_device_operations {\n--\ninclude/linux/blkdev.h-1601-\t\t\tenum blk_unique_id id_type);\ninclude/linux/blkdev.h:1602:\tint (*init_dma_buf_io_ctx)(struct block_device *,\ninclude/linux/blkdev.h:1603:\t\t\t\t struct dma_buf_io_ctx *);\ninclude/linux/blkdev.h-1604-\tstruct module *owner;\n"
} |
| 29/2 | 2026/10/07 01:59 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43801 output: 31 thoughts: 85 Thoughts: **Debugging a Missing Header** Okay, hold on a second. I was expecting to see something from `include/linux/dma-buf-io.h`, but it's not showing up. That's strange. First thought, does this file even *exist* in the Git repository? Okay, a quick check of the file system says the `read-file` command tells me it "does not exist." Alright, let's back up and double-check, because the file should be there. I'll use `grepper` to search within the `include/linux` directory for anything matching "dma\_buf\_io." Hopefully, that will give me some clues about whether the file is named something slightly different, or if it is included somewhere under a different header file. |
| 30/2 | 2026/10/07 02:00 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io",
"PathPrefixes": [
"include/linux/"
]
}Results: {
"Output": "include/linux/blk_types.h=210=struct bio {\n--\ninclude/linux/blk_types.h-238-\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\ninclude/linux/blk_types.h:239:\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\ninclude/linux/blk_types.h-240-\t};\n--\ninclude/linux/blkdev.h=1577=struct block_device_operations {\n--\ninclude/linux/blkdev.h-1601-\t\t\tenum blk_unique_id id_type);\ninclude/linux/blkdev.h:1602:\tint (*init_dma_buf_io_ctx)(struct block_device *,\ninclude/linux/blkdev.h:1603:\t\t\t\t struct dma_buf_io_ctx *);\ninclude/linux/blkdev.h-1604-\tstruct module *owner;\n--\ninclude/linux/io_uring_types.h=13=struct io_uring_bpf_ops;\ninclude/linux/io_uring_types.h:14:struct dma_buf_io_map;\ninclude/linux/io_uring_types.h-15-\n--\ninclude/linux/io_uring_types.h=759=struct io_kiocb {\n--\ninclude/linux/io_uring_types.h-833-\tstruct io_wq_work\t\twork;\ninclude/linux/io_uring_types.h:834:\tstruct dma_buf_io_map\t\t*dmabuf_map;\ninclude/linux/io_uring_types.h-835-\n--\ninclude/linux/vfio_pci_core.h=249=vfio_pci_core_get_iomap(struct vfio_pci_core_device *vdev, unsigned int bar)\n--\ninclude/linux/vfio_pci_core.h-259-\ninclude/linux/vfio_pci_core.h:260:int vfio_pci_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,\ninclude/linux/vfio_pci_core.h-261-\t\t\t\t struct phys_vec *phys);\n"
} |
| 31/2 | 2026/10/07 02:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44664 output: 24 thoughts: 665 Thoughts: **Investigating the Missing Header** Okay, hold on a second. Something's not right here. The diff includes `#include <linux/dma-buf-io.h>` in `block/blk-merge.c`, but... is it actually in the `include/` directory? Could it be uncommitted, untracked, or part of a previous or later patch? Hmm, `git grep` should only search tracked files in HEAD, the index, or the worktree, so if it's missing from the index it won't show up. Why was that include statement in the diff for `block/blk-merge.c` in the first place? And wait a minute, the complete diff shows *a lot* of files: `block/bio.c`, `block/blk-merge.c`, `block/fops.c`, `drivers/md/dm-io-rewind.c`, `drivers/nvme/host/Makefile`, `drivers/nvme/host/core.c`, `drivers/nvme/host/nvme.h`, `drivers/nvme/host/pci-dmabuf.c`, `drivers/nvme/host/pci-dmabuf.h`, `drivers/nvme/host/pci.c`, `include/linux/bio.h`, `include/linux/blk-mq.h`, `include/linux/blk_types.h`, `include/linux/blkdev.h`, `include/linux/bvec.h`, `include/linux/io_uring_types.h`, `include/uapi/linux/io_uring.h`, `io_uring/Makefile`, `io_uring/dma-buf.c`, `io_uring/dma-buf.h`, `io_uring/rsrc.c`, `io_uring/rsrc.h`, and `io_uring/rw.c`. I don't see `include/linux/dma-buf-io.h` in the files listed in the diff! Right, so it's *not* in the committed changes, that's what's fishy. Let me think, perhaps it was in an untracked file, or part of a series where a patch is missing or already applied? Let's check `include/linux/dma-buf` or search for the `dma-buf-io.h` name somehow. I need to search the commit history (if possible) or check the git status. Since I only have `grepper` at my disposal, I'm going to grep for symbols, like `dma_buf_io_init_map` or `dma_buf_io_get_map`. Hopefully that helps me track this down. |
| 32/2 | 2026/10/07 02:01 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_init_map"
}Results: {
"Output": "drivers/nvme/host/pci-dmabuf.c=22=static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\n--\ndrivers/nvme/host/pci-dmabuf.c-65-\ndrivers/nvme/host/pci-dmabuf.c:66:\tret = dma_buf_io_init_map(ctx, \u0026map-\u003ebase, sgt);\ndrivers/nvme/host/pci-dmabuf.c-67-\tif (ret)\n"
} |
| 33/2 | 2026/10/07 02:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46111 output: 25 thoughts: 66 Thoughts: Here's my summary, as if I were thinking these thoughts: **Navigating the DMA Buffer Landscape** Okay, so I'm focusing on this `dma_buf_io_init_map` function, and it seems like it's exclusively defined within `drivers/nvme/host/pci-dmabuf.c`. That's a bit surprising; I'd expect something more generic, or at least a wider use. This definitely seems specific to NVMe's interaction with DMA buffers in this PCI context. But... hold on a second. What about `iov_iter_is_dmabuf_map`? That rings a bell, and I can't quite place where it lives. It should at least be closely related. Let's not make assumptions - time to fire up `grepper` and see exactly where that one is declared. Gotta get the full picture here. |
| 34/2 | 2026/10/07 02:01 | tool | grepper |
0mArgs:{
"Expression": "iov_iter_is_dmabuf_map"
}Results: {
"Output": "block/bio.c=1209=bool bio_iov_iter_set(struct bio *bio, const struct iov_iter *iter)\nblock/bio.c-1210-{\nblock/bio.c:1211:\tif (!iov_iter_is_bvec(iter) \u0026\u0026 !iov_iter_is_dmabuf_map(iter))\nblock/bio.c-1212-\t\treturn false;\n--\nblock/bio.c-1225-\tbio_set_flag(bio, BIO_CLONED);\nblock/bio.c:1226:\tif (iov_iter_is_dmabuf_map(iter))\nblock/bio.c-1227-\t\tbio-\u003ebi_opf |= REQ_NOMERGE | REQ_DMABUF;\n--\nblock/fops.c=731=static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from)\nblock/fops.c-732-{\nblock/fops.c:733:\tif (unlikely(iov_iter_is_dmabuf_map(from)))\nblock/fops.c-734-\t\treturn -EOPNOTSUPP;\n--\nblock/fops.c=823=static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)\n--\nblock/fops.c-860-\t}\nblock/fops.c:861:\tif (unlikely(iov_iter_is_dmabuf_map(to))) {\nblock/fops.c-862-\t\tif (!ret)\n--\ninclude/linux/bio.h=445=static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)\ninclude/linux/bio.h-446-{\ninclude/linux/bio.h:447:\tif (iov_iter_is_bvec(iter) || iov_iter_is_dmabuf_map(iter))\ninclude/linux/bio.h-448-\t\treturn 0;\n"
} |
| 35/2 | 2026/10/07 02:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46935 output: 34 thoughts: 31 Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience: **Investigating `iov_iter_is_dmabuf_map`** Right, let's see... I'm pretty sure I've come across `iov_iter_is_dmabuf_map` before, but the exact definition is escaping me at the moment. Time to track it down. My first instinct, given the naming convention, is that it's going to be related to scatter-gather I/O and probably dmabuf integration, so `include/linux/uio.h` is the logical place to start. Hopefully, it's defined there, or at least declared, so I can chase down the source from there. Let's dig in and see what we find. |
| 36/2 | 2026/10/07 02:01 | tool | grepper |
0mArgs:{
"Expression": "iov_iter_is_dmabuf_map",
"PathPrefixes": [
"include/"
]
}Results: {
"Output": "include/linux/bio.h=445=static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)\ninclude/linux/bio.h-446-{\ninclude/linux/bio.h:447:\tif (iov_iter_is_bvec(iter) || iov_iter_is_dmabuf_map(iter))\ninclude/linux/bio.h-448-\t\treturn 0;\n"
} |
| 37/2 | 2026/10/07 02:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 47299 output: 32 thoughts: 44 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Debugging a Missing Symbol** Hold on a second, something feels off. I was expecting to find `iov_iter_is_dmabuf_map` defined within `include/linux/uio.h`, but it's not there. That's unusual, and immediately raises a red flag. Before I start going down a rabbit hole, the first thing I need to do is confirm my assumption. Let's immediately double-check the contents of `include/linux/uio.h` and ensure I haven't misremembered or am looking in the wrong place. Is there a simple oversight, or is there a bigger reason the function isn't where I anticipate it to be? |
| 38/2 | 2026/10/07 02:01 | tool | grepper |
0mArgs:{
"Expression": "iov_iter",
"PathPrefixes": [
"include/linux/uio.h"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 258 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (1 files in total):\ninclude/linux/uio.h:92\n\ninclude/linux/uio.h=14=struct folio_queue;\ninclude/linux/uio.h-15-\ninclude/linux/uio.h:16:typedef unsigned int __bitwise iov_iter_extraction_t;\ninclude/linux/uio.h-17-\n--\ninclude/linux/uio.h=23=enum iter_type {\n--\ninclude/linux/uio.h-36-\ninclude/linux/uio.h:37:struct iov_iter_state {\ninclude/linux/uio.h-38-\tsize_t iov_offset;\n--\ninclude/linux/uio.h-42-\ninclude/linux/uio.h:43:struct iov_iter {\ninclude/linux/uio.h-44-\tu8 iter_type;\n--\ninclude/linux/uio.h=87=struct uio_meta {\n--\ninclude/linux/uio.h-90-\tu64\t\t\tseed;\ninclude/linux/uio.h:91:\tstruct iov_iter\t\titer;\ninclude/linux/uio.h-92-};\ninclude/linux/uio.h-93-\ninclude/linux/uio.h:94:static inline const struct iovec *iter_iov(const struct iov_iter *iter)\ninclude/linux/uio.h-95-{\n--\ninclude/linux/uio.h-102-\ninclude/linux/uio.h:103:static inline size_t iter_iov_len(const struct iov_iter *i)\ninclude/linux/uio.h-104-{\n--\ninclude/linux/uio.h-109-\ninclude/linux/uio.h:110:static inline enum iter_type iov_iter_type(const struct iov_iter *i)\ninclude/linux/uio.h-111-{\n--\ninclude/linux/uio.h-114-\ninclude/linux/uio.h:115:static inline void iov_iter_save_state(struct iov_iter *iter,\ninclude/linux/uio.h:116:\t\t\t\t struct iov_iter_state *state)\ninclude/linux/uio.h-117-{\n--\ninclude/linux/uio.h-122-\ninclude/linux/uio.h:123:static inline bool iter_is_ubuf(const struct iov_iter *i)\ninclude/linux/uio.h-124-{\ninclude/linux/uio.h:125:\treturn iov_iter_type(i) == ITER_UBUF;\ninclude/linux/uio.h-126-}\ninclude/linux/uio.h-127-\ninclude/linux/uio.h:128:static inline bool iter_is_iovec(const struct iov_iter *i)\ninclude/linux/uio.h-129-{\ninclude/linux/uio.h:130:\treturn iov_iter_type(i) == ITER_IOVEC;\ninclude/linux/uio.h-131-}\ninclude/linux/uio.h-132-\ninclude/linux/uio.h:133:static inline bool iov_iter_is_kvec(const struct iov_iter *i)\ninclude/linux/uio.h-134-{\ninclude/linux/uio.h:135:\treturn iov_iter_type(i) == ITER_KVEC;\ninclude/linux/uio.h-136-}\ninclude/linux/uio.h-137-\ninclude/linux/uio.h:138:static inline bool iov_iter_is_bvec(const struct iov_iter *i)\ninclude/linux/uio.h-139-{\ninclude/linux/uio.h:140:\treturn iov_iter_type(i) == ITER_BVEC;\ninclude/linux/uio.h-141-}\ninclude/linux/uio.h-142-\ninclude/linux/uio.h:143:static inline bool iov_iter_is_discard(const struct iov_iter *i)\ninclude/linux/uio.h-144-{\ninclude/linux/uio.h:145:\treturn iov_iter_type(i) == ITER_DISCARD;\ninclude/linux/uio.h-146-}\ninclude/linux/uio.h-147-\ninclude/linux/uio.h:148:static inline bool iov_iter_is_folioq(const struct iov_iter *i)\ninclude/linux/uio.h-149-{\ninclude/linux/uio.h:150:\treturn iov_iter_type(i) == ITER_FOLIOQ;\ninclude/linux/uio.h-151-}\ninclude/linux/uio.h-152-\ninclude/linux/uio.h:153:static inline bool iov_iter_is_xarray(const struct iov_iter *i)\ninclude/linux/uio.h-154-{\ninclude/linux/uio.h:155:\treturn iov_iter_type(i) == ITER_XARRAY;\ninclude/linux/uio.h-156-}\ninclude/linux/uio.h-157-\ninclude/linux/uio.h:158:static inline unsigned char iov_iter_rw(const struct iov_iter *i)\ninclude/linux/uio.h-159-{\n--\ninclude/linux/uio.h-162-\ninclude/linux/uio.h:163:static inline bool user_backed_iter(const struct iov_iter *i)\ninclude/linux/uio.h-164-{\n--\ninclude/linux/uio.h=175=static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)\n--\ninclude/linux/uio.h-184-\ninclude/linux/uio.h:185:void iov_iter_advance(struct iov_iter *i, size_t bytes);\ninclude/linux/uio.h:186:void iov_iter_revert(struct iov_iter *i, size_t bytes);\ninclude/linux/uio.h:187:size_t fault_in_iov_iter_readable(const struct iov_iter *i, size_t bytes);\ninclude/linux/uio.h:188:size_t fault_in_iov_iter_writeable(const struct iov_iter *i, size_t bytes);\ninclude/linux/uio.h:189:size_t iov_iter_single_seg_count(const struct iov_iter *i);\ninclude/linux/uio.h-190-size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,\ninclude/linux/uio.h:191:\t\t\t struct iov_iter *i);\ninclude/linux/uio.h-192-size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes,\ninclude/linux/uio.h:193:\t\t\t struct iov_iter *i);\ninclude/linux/uio.h-194-size_t copy_folio_from_iter_atomic(struct folio *folio, size_t offset,\ninclude/linux/uio.h:195:\t\tsize_t bytes, struct iov_iter *i);\ninclude/linux/uio.h-196-\ninclude/linux/uio.h:197:size_t _copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i);\ninclude/linux/uio.h:198:size_t _copy_from_iter(void *addr, size_t bytes, struct iov_iter *i);\ninclude/linux/uio.h:199:size_t _copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i);\ninclude/linux/uio.h-200-\ninclude/linux/uio.h=201=static inline size_t copy_folio_to_iter(struct folio *folio, size_t offset,\ninclude/linux/uio.h:202:\t\tsize_t bytes, struct iov_iter *i)\ninclude/linux/uio.h-203-{\n--\ninclude/linux/uio.h=207=static inline size_t copy_folio_from_iter(struct folio *folio, size_t offset,\ninclude/linux/uio.h:208:\t\t\t\t\t size_t bytes, struct iov_iter *i)\ninclude/linux/uio.h-209-{\n--\ninclude/linux/uio.h=213=size_t copy_page_to_iter_nofault(struct page *page, unsigned offset,\ninclude/linux/uio.h:214:\t\t\t\t size_t bytes, struct iov_iter *i);\ninclude/linux/uio.h-215-\ninclude/linux/uio.h=216=static __always_inline __must_check\ninclude/linux/uio.h:217:size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)\ninclude/linux/uio.h-218-{\n--\ninclude/linux/uio.h=224=static __always_inline __must_check\ninclude/linux/uio.h:225:size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i)\ninclude/linux/uio.h-226-{\n--\ninclude/linux/uio.h=232=static __always_inline __must_check\ninclude/linux/uio.h:233:bool copy_to_iter_full(const void *addr, size_t bytes, struct iov_iter *i)\ninclude/linux/uio.h-234-{\n--\ninclude/linux/uio.h-237-\t\treturn true;\ninclude/linux/uio.h:238:\tiov_iter_revert(i, copied);\ninclude/linux/uio.h-239-\treturn false;\n--\ninclude/linux/uio.h=242=static __always_inline __must_check\ninclude/linux/uio.h:243:bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)\ninclude/linux/uio.h-244-{\n--\ninclude/linux/uio.h-247-\t\treturn true;\ninclude/linux/uio.h:248:\tiov_iter_revert(i, copied);\ninclude/linux/uio.h-249-\treturn false;\n--\ninclude/linux/uio.h=252=static __always_inline __must_check\ninclude/linux/uio.h:253:size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i)\ninclude/linux/uio.h-254-{\n--\ninclude/linux/uio.h=260=static __always_inline __must_check\ninclude/linux/uio.h:261:bool copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter *i)\ninclude/linux/uio.h-262-{\n--\ninclude/linux/uio.h-265-\t\treturn true;\ninclude/linux/uio.h:266:\tiov_iter_revert(i, copied);\ninclude/linux/uio.h-267-\treturn false;\n--\ninclude/linux/uio.h-276- */\ninclude/linux/uio.h:277:size_t _copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i);\ninclude/linux/uio.h-278-#else\n--\ninclude/linux/uio.h-282-#ifdef CONFIG_ARCH_HAS_COPY_MC\ninclude/linux/uio.h:283:size_t _copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i);\ninclude/linux/uio.h-284-#else\n--\ninclude/linux/uio.h-287-\ninclude/linux/uio.h:288:size_t iov_iter_zero(size_t bytes, struct iov_iter *);\ninclude/linux/uio.h:289:unsigned long iov_iter_alignment(const struct iov_iter *i);\ninclude/linux/uio.h:290:unsigned long iov_iter_gap_alignment(const struct iov_iter *i);\ninclude/linux/uio.h:291:void iov_iter_init(struct iov_iter *i, unsigned int direction, const struct iovec *iov,\ninclude/linux/uio.h-292-\t\t\tunsigned long nr_segs, size_t count);\ninclude/linux/uio.h:293:void iov_iter_kvec(struct iov_iter *i, unsigned int direction, const struct kvec *kvec,\ninclude/linux/uio.h-294-\t\t\tunsigned long nr_segs, size_t count);\ninclude/linux/uio.h:295:void iov_iter_bvec(struct iov_iter *i, unsigned int direction, const struct bio_vec *bvec,\ninclude/linux/uio.h-296-\t\t\tunsigned long nr_segs, size_t count);\ninclude/linux/uio.h:297:void iov_iter_discard(struct iov_iter *i, unsigned int direction, size_t count);\ninclude/linux/uio.h:298:void iov_iter_folio_queue(struct iov_iter *i, unsigned int direction,\ninclude/linux/uio.h-299-\t\t\t const struct folio_queue *folioq,\ninclude/linux/uio.h-300-\t\t\t unsigned int first_slot, unsigned int offset, size_t count);\ninclude/linux/uio.h:301:void iov_iter_xarray(struct iov_iter *i, unsigned int direction, struct xarray *xarray,\ninclude/linux/uio.h-302-\t\t loff_t start, size_t count);\ninclude/linux/uio.h:303:ssize_t iov_iter_get_pages2(struct iov_iter *i, struct page **pages,\ninclude/linux/uio.h-304-\t\t\tsize_t maxsize, unsigned maxpages, size_t *start);\ninclude/linux/uio.h:305:ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i, struct page ***pages,\ninclude/linux/uio.h-306-\t\t\tsize_t maxsize, size_t *start);\ninclude/linux/uio.h:307:int iov_iter_npages(const struct iov_iter *i, int maxpages);\ninclude/linux/uio.h:308:void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state);\ninclude/linux/uio.h-309-\ninclude/linux/uio.h:310:const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags);\ninclude/linux/uio.h-311-\ninclude/linux/uio.h:312:static inline size_t iov_iter_count(const struct iov_iter *i)\ninclude/linux/uio.h-313-{\n--\ninclude/linux/uio.h-317-/*\ninclude/linux/uio.h:318: * Cap the iov_iter by given limit; note that the second argument is\ninclude/linux/uio.h-319- * *not* the new size - it's upper limit for such. Passing it a value\ninclude/linux/uio.h:320: * greater than the amount of data in iov_iter is fine - it'll just do\ninclude/linux/uio.h-321- * nothing in that case.\ninclude/linux/uio.h-322- */\ninclude/linux/uio.h:323:static inline void iov_iter_truncate(struct iov_iter *i, u64 count)\ninclude/linux/uio.h-324-{\n--\ninclude/linux/uio.h-338- */\ninclude/linux/uio.h:339:static inline void iov_iter_reexpand(struct iov_iter *i, size_t count)\ninclude/linux/uio.h-340-{\n--\ninclude/linux/uio.h=344=static inline int\ninclude/linux/uio.h:345:iov_iter_npages_cap(struct iov_iter *i, int maxpages, size_t max_bytes)\ninclude/linux/uio.h-346-{\n--\ninclude/linux/uio.h-349-\n\n"
} |
| 39/2 | 2026/10/07 02:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51949 output: 25 thoughts: 85 Thoughts: Here's my thought process, as it unfolded: **Debugging a Kernel Header Inclusion** Okay, hold on a second! I was just expecting to find `iov_iter_is_dmabuf_map` defined in `include/linux/uio.h`, but it's not there! That's... unexpected. Where *is* that function defined? I'm going to have to do a much broader search now. Time to go hunting across the entire codebase to locate where `iov_iter_is_dmabuf_map` actually resides. Let's fire up the search tools and dig deep. |
| 40/2 | 2026/10/07 02:02 | tool | grepper |
0mArgs:{
"Expression": "iov_iter_is_dmabuf_map"
}Results: {
"Output": "block/bio.c=1209=bool bio_iov_iter_set(struct bio *bio, const struct iov_iter *iter)\nblock/bio.c-1210-{\nblock/bio.c:1211:\tif (!iov_iter_is_bvec(iter) \u0026\u0026 !iov_iter_is_dmabuf_map(iter))\nblock/bio.c-1212-\t\treturn false;\n--\nblock/bio.c-1225-\tbio_set_flag(bio, BIO_CLONED);\nblock/bio.c:1226:\tif (iov_iter_is_dmabuf_map(iter))\nblock/bio.c-1227-\t\tbio-\u003ebi_opf |= REQ_NOMERGE | REQ_DMABUF;\n--\nblock/fops.c=731=static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from)\nblock/fops.c-732-{\nblock/fops.c:733:\tif (unlikely(iov_iter_is_dmabuf_map(from)))\nblock/fops.c-734-\t\treturn -EOPNOTSUPP;\n--\nblock/fops.c=823=static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)\n--\nblock/fops.c-860-\t}\nblock/fops.c:861:\tif (unlikely(iov_iter_is_dmabuf_map(to))) {\nblock/fops.c-862-\t\tif (!ret)\n--\ninclude/linux/bio.h=445=static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)\ninclude/linux/bio.h-446-{\ninclude/linux/bio.h:447:\tif (iov_iter_is_bvec(iter) || iov_iter_is_dmabuf_map(iter))\ninclude/linux/bio.h-448-\t\treturn 0;\n"
} |
| 41/2 | 2026/10/07 02:02 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 52732 output: 35 thoughts: 94 Thoughts: Here's my thought process, as requested: **Investigating the Scope of `iov_iter_is_dmabuf_map`** Alright, that's interesting. I see that `iov_iter_is_dmabuf_map` is only referenced in four files, which is a manageable scope. My next thought is, where exactly is the `dmabuf_map` field defined within the `struct iov_iter`? Time to dive into the definition of `struct iov_iter`. Let's check `include/linux/uio.h`. I'll want to focus specifically on lines 40 through 80, that's usually where the important structural information resides. |
| 42/2 | 2026/10/07 02:02 | tool | read-file |
0mArgs:{
"File": "include/linux/uio.h",
"FirstLine": 40,
"LineCount": 40
}Results: {
"Contents": " 40:\t\tunsigned long nr_segs;\n 41:\t};\n 42:\t\n 43:\tstruct iov_iter {\n 44:\t\tu8 iter_type;\n 45:\t\tbool nofault;\n 46:\t\tbool data_source;\n 47:\t\tsize_t iov_offset;\n 48:\t\t/*\n 49:\t\t * Hack alert: overlay ubuf_iovec with iovec + count, so\n 50:\t\t * that the members resolve correctly regardless of the type\n 51:\t\t * of iterator used. This means that you can use:\n 52:\t\t *\n 53:\t\t * \u0026iter-\u003e__ubuf_iovec or iter-\u003e__iov\n 54:\t\t *\n 55:\t\t * interchangably for the user_backed cases, hence simplifying\n 56:\t\t * some of the cases that need to deal with both.\n 57:\t\t */\n 58:\t\tunion {\n 59:\t\t\t/*\n 60:\t\t\t * This really should be a const, but we cannot do that without\n 61:\t\t\t * also modifying any of the zero-filling iter init functions.\n 62:\t\t\t * Leave it non-const for now, but it should be treated as such.\n 63:\t\t\t */\n 64:\t\t\tstruct iovec __ubuf_iovec;\n 65:\t\t\tstruct {\n 66:\t\t\t\tunion {\n 67:\t\t\t\t\t/* use iter_iov() to get the current vec */\n 68:\t\t\t\t\tconst struct iovec *__iov;\n 69:\t\t\t\t\tconst struct kvec *kvec;\n 70:\t\t\t\t\tconst struct bio_vec *bvec;\n 71:\t\t\t\t\tconst struct folio_queue *folioq;\n 72:\t\t\t\t\tstruct xarray *xarray;\n 73:\t\t\t\t\tvoid __user *ubuf;\n 74:\t\t\t\t};\n 75:\t\t\t\tsize_t count;\n 76:\t\t\t};\n 77:\t\t};\n 78:\t\tunion {\n 79:\t\t\tunsigned long nr_segs;\n"
} |
| 43/2 | 2026/10/07 02:02 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53524 output: 19 thoughts: 384 Thoughts: **Investigating the Missing `dmabuf_map`** Okay, so I'm looking at this code and immediately I see something's off. *`iov_iter` doesn't have `dmabuf_map`*? That's not right. I remember seeing it, or at least expecting it to be there. This is core functionality, it should be present. Then I start to dig deeper. I'm seeing `bio.c` make assertions about the offset of `bi_io_vec` and `bi_dmabuf_map` within the `bio` struct, which means they're effectively the same! And then, even more confusingly, `io_uring/dma-buf.h` seems to directly use `dmabuf_map` with iterators. I'm starting to get a bit bewildered. What gives? `io_import_dmabuf_map` is right there, and `bio_split_io_at_dmabuf` is using `dmabuf_map` as well! I'm now thinking, where are the definitions? Where is `iov_iter_dmabuf_map` and the `struct dma_buf_io_map` that it refers to? It's nowhere in the obvious places. I'm starting to wonder if I'm missing something obvious... could `include/linux/dma-buf-io.h` be in another branch, or did a patch series not compile because it depends on missing commits? Did the build fail silently? This smells like a problem with a patch, or an incomplete import. I need to get to the bottom of this. I don't have direct access to git commands right now, but what did the git grep results say? Let's search across the entire repository and see what pops up for "dmabuf_map". It's time to find out where this thing is hiding! |
| 44/2 | 2026/10/07 02:02 | tool | grepper |
0mArgs:{
"Expression": "dmabuf_map"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 227 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (17 files in total):\nblock/bio.c:5\nblock/blk-merge.c:1\nblock/fops.c:2\ndrivers/accel/ivpu/ivpu_gem_userptr.c:2\ndrivers/infiniband/core/umem_dmabuf.c:3\ndrivers/infiniband/core/uverbs_std_types_dmabuf.c:2\ndrivers/infiniband/hw/mlx5/odp.c:1\ndrivers/nvme/host/pci-dmabuf.c:2\ndrivers/nvme/host/pci-dmabuf.h:6\ndrivers/nvme/host/pci.c:6\ninclude/linux/bio.h:1\ninclude/linux/blk_types.h:1\ninclude/linux/io_uring_types.h:1\ninclude/rdma/ib_umem.h:2\nio_uring/dma-buf.h:9\nio_uring/rsrc.c:1\nio_uring/rw.c:4\n\nblock/bio.c=876=static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)\n--\nblock/bio.c-885-\tif (op_is_dmabuf(bio-\u003ebi_opf))\nblock/bio.c:886:\t\tbio-\u003ebi_dmabuf_map = bio_src-\u003ebi_dmabuf_map;\nblock/bio.c-887-\telse\n--\nblock/bio.c=1209=bool bio_iov_iter_set(struct bio *bio, const struct iov_iter *iter)\nblock/bio.c-1210-{\nblock/bio.c:1211:\tif (!iov_iter_is_bvec(iter) \u0026\u0026 !iov_iter_is_dmabuf_map(iter))\nblock/bio.c-1212-\t\treturn false;\n--\nblock/bio.c-1216-\tstatic_assert(offsetof(struct bio, bi_io_vec) ==\nblock/bio.c:1217:\t\t offsetof(struct bio, bi_dmabuf_map));\nblock/bio.c-1218-\tstatic_assert(offsetof(struct iov_iter, bvec) ==\nblock/bio.c:1219:\t\t offsetof(struct iov_iter, dmabuf_map));\nblock/bio.c-1220-\n--\nblock/bio.c-1225-\tbio_set_flag(bio, BIO_CLONED);\nblock/bio.c:1226:\tif (iov_iter_is_dmabuf_map(iter))\nblock/bio.c-1227-\t\tbio-\u003ebi_opf |= REQ_NOMERGE | REQ_DMABUF;\n--\nblock/blk-merge.c=323=static inline int bio_split_io_at_dmabuf(struct bio *bio,\n--\nblock/blk-merge.c-328-\tunsigned bytes = min(bio-\u003ebi_iter.bi_size, max_bytes);\nblock/blk-merge.c:329:\tunsigned seg_shift = bio-\u003ebi_dmabuf_map-\u003emin_seg_shift;\nblock/blk-merge.c-330-\tunsigned offset = bio-\u003ebi_iter.bi_offset \u0026 ((1U \u003c\u003c seg_shift) - 1);\n--\nblock/fops.c=731=static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from)\nblock/fops.c-732-{\nblock/fops.c:733:\tif (unlikely(iov_iter_is_dmabuf_map(from)))\nblock/fops.c-734-\t\treturn -EOPNOTSUPP;\n--\nblock/fops.c=823=static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)\n--\nblock/fops.c-860-\t}\nblock/fops.c:861:\tif (unlikely(iov_iter_is_dmabuf_map(to))) {\nblock/fops.c-862-\t\tif (!ret)\n--\ndrivers/accel/ivpu/ivpu_gem_userptr.c=22=static struct sg_table *\ndrivers/accel/ivpu/ivpu_gem_userptr.c:23:ivpu_gem_userptr_dmabuf_map(struct dma_buf_attachment *attachment,\ndrivers/accel/ivpu/ivpu_gem_userptr.c-24-\t\t\t enum dma_data_direction direction)\n--\ndrivers/accel/ivpu/ivpu_gem_userptr.c=58=static const struct dma_buf_ops ivpu_gem_userptr_dmabuf_ops = {\ndrivers/accel/ivpu/ivpu_gem_userptr.c:59:\t.map_dma_buf = ivpu_gem_userptr_dmabuf_map,\ndrivers/accel/ivpu/ivpu_gem_userptr.c-60-\t.unmap_dma_buf = ivpu_gem_userptr_dmabuf_unmap,\n--\ndrivers/infiniband/core/umem_dmabuf.c=13=MODULE_IMPORT_NS(\"DMA_BUF\");\ndrivers/infiniband/core/umem_dmabuf.c-14-\ndrivers/infiniband/core/umem_dmabuf.c:15:int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)\ndrivers/infiniband/core/umem_dmabuf.c-16-{\n--\ndrivers/infiniband/core/umem_dmabuf.c-83-}\ndrivers/infiniband/core/umem_dmabuf.c:84:EXPORT_SYMBOL(ib_umem_dmabuf_map_pages);\ndrivers/infiniband/core/umem_dmabuf.c-85-\n--\ndrivers/infiniband/core/umem_dmabuf.c=214=ib_umem_dmabuf_get_pinned_and_lock(struct ib_device *device,\n--\ndrivers/infiniband/core/umem_dmabuf.c-234-\ndrivers/infiniband/core/umem_dmabuf.c:235:\terr = ib_umem_dmabuf_map_pages(umem_dmabuf);\ndrivers/infiniband/core/umem_dmabuf.c-236-\tif (err)\n--\ndrivers/infiniband/core/uverbs_std_types_dmabuf.c=24=static struct sg_table *\ndrivers/infiniband/core/uverbs_std_types_dmabuf.c:25:uverbs_dmabuf_map(struct dma_buf_attachment *attachment,\ndrivers/infiniband/core/uverbs_std_types_dmabuf.c-26-\t\t enum dma_data_direction dir)\n--\ndrivers/infiniband/core/uverbs_std_types_dmabuf.c=79=static const struct dma_buf_ops uverbs_dmabuf_ops = {\ndrivers/infiniband/core/uverbs_std_types_dmabuf.c-80-\t.attach = uverbs_dmabuf_attach,\ndrivers/infiniband/core/uverbs_std_types_dmabuf.c:81:\t.map_dma_buf = uverbs_dmabuf_map,\ndrivers/infiniband/core/uverbs_std_types_dmabuf.c-82-\t.unmap_dma_buf = uverbs_dmabuf_unmap,\n--\ndrivers/infiniband/hw/mlx5/odp.c=839=static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt,\n--\ndrivers/infiniband/hw/mlx5/odp.c-854-\tdma_resv_lock(umem_dmabuf-\u003eattach-\u003edmabuf-\u003eresv, NULL);\ndrivers/infiniband/hw/mlx5/odp.c:855:\terr = ib_umem_dmabuf_map_pages(umem_dmabuf);\ndrivers/infiniband/hw/mlx5/odp.c-856-\tif (err) {\n--\ndrivers/nvme/host/pci-dmabuf.c=22=static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\n--\ndrivers/nvme/host/pci-dmabuf.c-27-\tunsigned long tmp, i = 0;\ndrivers/nvme/host/pci-dmabuf.c:28:\tstruct nvme_dmabuf_map *map;\ndrivers/nvme/host/pci-dmabuf.c-29-\tstruct scatterlist *sg;\n--\ndrivers/nvme/host/pci-dmabuf.c=78=static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,\n--\ndrivers/nvme/host/pci-dmabuf.c-81-\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c:82:\tstruct nvme_dmabuf_map *map = to_nvme_dmabuf_map(map_base);\ndrivers/nvme/host/pci-dmabuf.c-83-\n--\ndrivers/nvme/host/pci-dmabuf.h=18=struct nvme_dma_buf_io_ctx {\n--\ndrivers/nvme/host/pci-dmabuf.h-25-\ndrivers/nvme/host/pci-dmabuf.h:26:struct nvme_dmabuf_map {\ndrivers/nvme/host/pci-dmabuf.h-27-\tstruct dma_buf_io_map base;\n--\ndrivers/nvme/host/pci-dmabuf.h-32-\ndrivers/nvme/host/pci-dmabuf.h:33:static inline struct nvme_dmabuf_map *to_nvme_dmabuf_map(\ndrivers/nvme/host/pci-dmabuf.h-34-\tstruct dma_buf_io_map *map)\ndrivers/nvme/host/pci-dmabuf.h-35-{\ndrivers/nvme/host/pci-dmabuf.h:36:\treturn container_of(map, struct nvme_dmabuf_map, base);\ndrivers/nvme/host/pci-dmabuf.h-37-}\ndrivers/nvme/host/pci-dmabuf.h-38-\ndrivers/nvme/host/pci-dmabuf.h:39:static inline struct nvme_dmabuf_map *nvme_req_to_map(struct request *req)\ndrivers/nvme/host/pci-dmabuf.h-40-{\ndrivers/nvme/host/pci-dmabuf.h:41:\tstruct dma_buf_io_map *map = req-\u003ebio-\u003ebi_dmabuf_map;\ndrivers/nvme/host/pci-dmabuf.h-42-\ndrivers/nvme/host/pci-dmabuf.h:43:\treturn to_nvme_dmabuf_map(map);\ndrivers/nvme/host/pci-dmabuf.h-44-}\n--\ndrivers/nvme/host/pci.c=846=static void nvme_free_descriptors(struct request *req)\n--\ndrivers/nvme/host/pci.c-869-\ndrivers/nvme/host/pci.c:870:static blk_status_t nvme_rq_setup_dmabuf_map(struct request *req,\ndrivers/nvme/host/pci.c-871-\t\tstruct nvme_queue *nvmeq)\n--\ndrivers/nvme/host/pci.c-873-\tstruct nvme_iod *iod = blk_mq_rq_to_pdu(req);\ndrivers/nvme/host/pci.c:874:\tstruct nvme_dmabuf_map *map = nvme_req_to_map(req);\ndrivers/nvme/host/pci.c-875-\tunsigned bvec_done = req-\u003ebio-\u003ebi_iter.bi_offset;\n--\ndrivers/nvme/host/pci.c=1248=static unsigned int nvme_pci_dmabuf_sgl_nents(struct request *req)\n--\ndrivers/nvme/host/pci.c-1250-\tstruct bio *bio = req-\u003ebio;\ndrivers/nvme/host/pci.c:1251:\tstruct nvme_dmabuf_map *map = to_nvme_dmabuf_map(bio-\u003ebi_dmabuf_map);\ndrivers/nvme/host/pci.c-1252-\tstruct scatterlist *sg;\n--\ndrivers/nvme/host/pci.c=1286=static blk_status_t nvme_rq_setup_dmabuf_sgl(struct request *req,\n--\ndrivers/nvme/host/pci.c-1289-\tstruct nvme_iod *iod = blk_mq_rq_to_pdu(req);\ndrivers/nvme/host/pci.c:1290:\tstruct nvme_dmabuf_map *map = nvme_req_to_map(req);\ndrivers/nvme/host/pci.c-1291-\tsize_t length = blk_rq_payload_bytes(req);\n--\ndrivers/nvme/host/pci.c=1362=static blk_status_t nvme_rq_setup_dmabuf(struct request *req,\n--\ndrivers/nvme/host/pci.c-1368-\tif (use_sgl == SGL_UNSUPPORTED)\ndrivers/nvme/host/pci.c:1369:\t\treturn nvme_rq_setup_dmabuf_map(req, nvmeq);\ndrivers/nvme/host/pci.c-1370-\n--\ndrivers/nvme/host/pci.c-1380-\ndrivers/nvme/host/pci.c:1381:\treturn nvme_rq_setup_dmabuf_map(req, nvmeq);\ndrivers/nvme/host/pci.c-1382-}\n--\ninclude/linux/bio.h=445=static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)\ninclude/linux/bio.h-446-{\ninclude/linux/bio.h:447:\tif (iov_iter_is_bvec(iter) || iov_iter_is_dmabuf_map(iter))\ninclude/linux/bio.h-448-\t\treturn 0;\n--\ninclude/linux/blk_types.h=210=struct bio {\n--\ninclude/linux/blk_types.h-238-\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\ninclude/linux/blk_types.h:239:\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\ninclude/linux/blk_types.h-240-\t};\n--\ninclude/linux/io_uring_types.h=759=struct io_kiocb {\n--\ninclude/linux/io_uring_types.h-833-\tstruct io_wq_work\t\twork;\ninclude/linux/io_uring_types.h:834:\tstruct dma_buf_io_map\t\t*dmabuf_map;\ninclude/linux/io_uring_types.h-835-\n--\ninclude/rdma/ib_umem.h=170=ib_umem_dmabuf_get_pinned_with_dma_device(struct ib_device *device,\n--\ninclude/rdma/ib_umem.h-173-\t\t\t\t\t int fd, int access);\ninclude/rdma/ib_umem.h:174:int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf);\ninclude/rdma/ib_umem.h-175-void ib_umem_dmabuf_unmap_pages(struct ib_umem_dmabuf *umem_dmabuf);\n--\ninclude/rdma/ib_umem.h=277=ib_umem_dmabuf_get_pinned_with_dma_device(struct ib_device *device,\n--\ninclude/rdma/ib_umem.h-284-\ninclude/rdma/ib_umem.h:285:static inline int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)\ninclude/rdma/ib_umem.h-286-{\n--\nio_uring/dma-buf.h=10=struct io_buf_dma {\n--\nio_uring/dma-buf.h-14-\nio_uring/dma-buf.h:15:static inline void io_detach_dmabuf_map(struct io_kiocb *req)\nio_uring/dma-buf.h-16-{\n--\nio_uring/dma-buf.h-18-\t\treturn;\nio_uring/dma-buf.h:19:\tif (!(req-\u003eflags \u0026 REQ_F_DMABUF) || !req-\u003edmabuf_map)\nio_uring/dma-buf.h-20-\t\treturn;\nio_uring/dma-buf.h:21:\tdma_buf_io_map_drop(req-\u003edmabuf_map);\nio_uring/dma-buf.h:22:\treq-\u003edmabuf_map = NULL;\nio_uring/dma-buf.h-23-}\nio_uring/dma-buf.h-24-\nio_uring/dma-buf.h:25:static inline int io_attach_dmabuf_map(struct io_kiocb *req,\nio_uring/dma-buf.h-26-\t\t\t\t\tstruct iov_iter *iter,\n--\nio_uring/dma-buf.h-41-\t\treturn PTR_ERR(map);\nio_uring/dma-buf.h:42:\treq-\u003edmabuf_map = map;\nio_uring/dma-buf.h:43:\titer-\u003edmabuf_map = map;\nio_uring/dma-buf.h-44-\treturn 0;\n--\nio_uring/dma-buf.h-46-\nio_uring/dma-buf.h:47:static inline int io_import_dmabuf_map(struct io_kiocb *req,\nio_uring/dma-buf.h-48-\t\t\t\tint ddir, struct iov_iter *iter,\n--\nio_uring/dma-buf.h-58-\treq-\u003eflags |= REQ_F_DMABUF;\nio_uring/dma-buf.h:59:\tiov_iter_dmabuf_map(iter, ddir, NULL, offset, len);\nio_uring/dma-buf.h-60-\treturn 0;\n--\nio_uring/rsrc.c=1283=static int io_import_fixed(struct io_kiocb *req,\n--\n\n"
} |
| 45/2 | 2026/10/07 02:02 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 59375 output: 24 thoughts: 50 Thoughts: Here's my thought process, summarized as you requested: **Investigating DMA-BUF Implementation** Okay, hold on a second! I need to quickly pivot and examine the `drivers/dma-buf` subsystem. My focus is on understanding the current state of its implementation. Let me confirm the directory structure first. Specifically, I need to know if the `drivers/dma-buf` directory exists in the codebase. Then, to make sure I get a good overview of the contents of the directory, I should use `codesearch-dir-index` and look for the directory to see what is indexed in that location. This should provide the information I need. |
| 46/2 | 2026/10/07 02:03 | tool | codesearch-dir-index |
0mArgs:{
"Dir": "drivers/dma-buf"
}Results: {
"Files": [
"dma-buf-mapping.c",
"dma-buf.c",
"dma-fence-array.c",
"dma-fence-chain.c",
"dma-fence-unwrap.c",
"dma-fence.c",
"dma-heap.c",
"dma-resv.c",
"st-dma-fence-chain.c",
"st-dma-fence-unwrap.c",
"st-dma-fence.c",
"st-dma-resv.c",
"sw_sync.c",
"sync_debug.c",
"sync_debug.h",
"sync_file.c",
"sync_trace.h",
"udmabuf.c"
],
"Subdirs": [
"heaps"
]
} |
| 47/2 | 2026/10/07 02:03 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 59789 output: 24 thoughts: 36 Thoughts: Here's my thought process, as if I were thinking it: **Digging into DMA Buffer Mapping** Okay, hold on a second. I'm looking at this code, and I'm seeing a call to `dma_buf_io_map_drop`. But I'm drawing a blank on its definition. It's a key function in DMA buffer management, and I need to understand its behaviour and context. Right. Time to crack open the search tools. Let's get this done. I'm going to search for `dma_buf_io_map_drop` to see where it's defined and get some context. This is core to understanding this portion of the code. Let's see what we find! |
| 48/2 | 2026/10/07 02:03 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_map_drop"
}Results: {
"Output": "io_uring/dma-buf.h=15=static inline void io_detach_dmabuf_map(struct io_kiocb *req)\n--\nio_uring/dma-buf.h-20-\t\treturn;\nio_uring/dma-buf.h:21:\tdma_buf_io_map_drop(req-\u003edmabuf_map);\nio_uring/dma-buf.h-22-\treq-\u003edmabuf_map = NULL;\n"
} |
| 49/2 | 2026/10/07 02:03 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 60138 output: 31 thoughts: 158 Thoughts: Here's my thought process, as it unfolded: **Debugging a Missing Header** Okay, so `dma_buf_io_map_drop`... that function should be in `io_uring/dma-buf.h`, right? But, something feels off... it's *only* in that one place. Hmm, why am I not seeing `include/linux/dma-buf-io.h` in the code tree? That's definitely where I'd expect it. Hang on a second. Could this patch series have been submitted out of order, missing its first part? Perhaps `dma-buf-io.h` *was* supposed to be part of an earlier patch? Or... let's check a bit more broadly. I'll search inside `include/linux/dma-buf` or just plain `include/linux/`. Maybe it was renamed or moved? Let's rule out any other possibilities first. Actually, before I get too deep, let's just make sure, has *any* header in the kernel been named `dma-buf-io.h`? A quick search for that file name will tell me. Alright, I'm going to leverage `grepper` here. I'll run `grepper` on `Expression: dma_buf_io_map` inside the `include/` directory. That should quickly tell me if the kernel has any use of that function. That'll narrow it down and give me some clues! |
| 50/2 | 2026/10/07 02:03 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_map",
"PathPrefixes": [
"include/"
]
}Results: {
"Output": "include/linux/blk_types.h=210=struct bio {\n--\ninclude/linux/blk_types.h-238-\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\ninclude/linux/blk_types.h:239:\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\ninclude/linux/blk_types.h-240-\t};\n--\ninclude/linux/io_uring_types.h=13=struct io_uring_bpf_ops;\ninclude/linux/io_uring_types.h:14:struct dma_buf_io_map;\ninclude/linux/io_uring_types.h-15-\n--\ninclude/linux/io_uring_types.h=759=struct io_kiocb {\n--\ninclude/linux/io_uring_types.h-833-\tstruct io_wq_work\t\twork;\ninclude/linux/io_uring_types.h:834:\tstruct dma_buf_io_map\t\t*dmabuf_map;\ninclude/linux/io_uring_types.h-835-\n"
} |
| 51/2 | 2026/10/07 02:03 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 60949 output: 33 thoughts: 788 Thoughts: **Debugging a Missing Header File** Okay, so I'm digging into this compilation issue, and my first instinct is to check for the missing header file, `linux/dma-buf-io.h`. A quick search in the Git tree shows a few files including it: `block/blk-merge.c`, `drivers/nvme/host/pci-dmabuf.h`, `io_uring/dma-buf.h`, and `io_uring/rsrc.c`. Hmm, could the compilation error be as simple as this header being absent? That's the obvious first thing to check. The next question: why would it be missing? I need to understand the history. Since I don't have a direct `git log` tool, I have to rely on the available tools: `grepper`, `codesearch-dir-index`, `read-file`, `set-results`. The prompt mentions that the changes have *already* been applied, and are the HEAD commit. The commit message mentions that it's a squash or merge of a patch series, likely io_uring or nvme dma-buf related. Right, so if this is part of a patch series, perhaps `linux/dma-buf-io.h` was in a *different* patch in the series, or maybe it was an RFC where only a portion was applied? Or perhaps this is dependent on a complete patch series? I should try to reconstruct the entire series to understand this dependency. Then, there's another clue. I remember `iov_iter_dmabuf_map` and `iov_iter_is_dmabuf_map`. Those were in `include/linux/uio.h` in the *original* patch series that introduced the header. But now I'm back to thinking about this compilation issue. Now, if `linux/dma-buf-io.h` doesn't exist, will this patch compile if `CONFIG_DMA_SHARED_BUFFER` is enabled? And if that isn't the case? In `block/blk-merge.c` and `io_uring/rsrc.c`, the `#include` is unconditional! That means whether `CONFIG_DMA_SHARED_BUFFER` is set or not, this will break if the header is not available! A `fatal error: linux/dma-buf-io.h: No such file or directory` is inevitable. Okay, let's stop guessing and verify. I need to absolutely confirm that `include/linux/dma-buf-io.h` *really* doesn't exist. Let me check the output from `read-file`, it returned "error: the file does not exist." Let me test `read-file` on `include/linux/bio.h` to make sure the tool is working as expected. |
| 52/2 | 2026/10/07 02:03 | tool | read-file |
0mArgs:{
"File": "include/linux/bio.h",
"FirstLine": 1,
"LineCount": 10
}Results: {
"Contents": " 1:\t/* SPDX-License-Identifier: GPL-2.0 */\n 2:\t/*\n 3:\t * Copyright (C) 2001 Jens Axboe \u003caxboe@suse.de\u003e\n 4:\t */\n 5:\t#ifndef __LINUX_BIO_H\n 6:\t#define __LINUX_BIO_H\n 7:\t\n 8:\t#include \u003clinux/mempool.h\u003e\n 9:\t/* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */\n 10:\t#include \u003clinux/blk_types.h\u003e\n"
} |
| 53/2 | 2026/10/07 02:03 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 62542 output: 30 thoughts: 58 Thoughts: Here's my thought process, as it stands: **Exploring Kernel Bio and DMA-BUF Integration** Okay, so `read-file` seems to be interacting with `include/linux/bio.h`. That's the starting point. I need to understand the connection. My immediate instinct is to leverage my tooling. I'll fire up `codesearch-dir-index` and point it at the `include/linux/` directory. That should give me a quick overview of how `bio` is used throughout the kernel's include files. Alternatively, I'll directly search within `include/linux/` to determine if there are other files related to `dma-buf`. I need to figure out how these concepts relate. |
| 54/2 | 2026/10/07 02:03 | tool | grepper |
0mError:no matches Args: {
"Expression": ".*",
"PathPrefixes": [
"include/linux/dma-buf"
]
}Results: {
"error": "no matches"
} |
| 55/2 | 2026/10/07 02:03 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 62800 output: 31 thoughts: 38 Thoughts: Here's my thought process, summarized as you requested: **Investigating DMA-BUF Definitions** Okay, so I need to track down the definitions related to `dma-buf` within the Linux kernel's include files. My initial approach is to be precise: I'll focus on the `#ifndef` directives that guard the definition of the `DMA_BUF` macro (or potentially the surrounding structure/function definitions). This is because I want to understand *how* the feature is conditionally enabled or defined. It's the most reliable way to find the primary declaration points. I will search within the `include/linux/` directory, as this is the standard location for kernel headers. I'll use `grep` with the appropriate regular expression to look for `#ifndef.*DMA_BUF` to identify the relevant files. This should give me a good starting point for further investigation. |
| 56/2 | 2026/10/07 02:03 | tool | grepper |
0mArgs:{
"Expression": "#ifndef.*DMA_BUF",
"PathPrefixes": [
"include/linux/"
]
}Results: {
"Output": "include/linux/dma-buf-mapping.h-5- */\ninclude/linux/dma-buf-mapping.h:6:#ifndef __DMA_BUF_MAPPING_H__\ninclude/linux/dma-buf-mapping.h-7-#define __DMA_BUF_MAPPING_H__\n--\ninclude/linux/dma-buf.h-12- */\ninclude/linux/dma-buf.h:13:#ifndef __DMA_BUF_H__\ninclude/linux/dma-buf.h-14-#define __DMA_BUF_H__\n--\ninclude/linux/iio/buffer-dma.h-6-\ninclude/linux/iio/buffer-dma.h:7:#ifndef __INDUSTRIALIO_DMA_BUFFER_H__\ninclude/linux/iio/buffer-dma.h-8-#define __INDUSTRIALIO_DMA_BUFFER_H__\n--\ninclude/linux/virtio_dma_buf.h-7-\ninclude/linux/virtio_dma_buf.h:8:#ifndef _LINUX_VIRTIO_DMA_BUF_H\ninclude/linux/virtio_dma_buf.h-9-#define _LINUX_VIRTIO_DMA_BUF_H\n"
} |
| 57/2 | 2026/10/07 02:03 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 63357 output: 28 thoughts: 4058 Thoughts: **Initial Assessment: Critical Compilation Failure & Fuzzing Justification** Okay, so I've got a serious problem on my hands. This patch, as presented, is fundamentally broken. `linux/dma-buf-io.h` is missing outright! Functions like `iov_iter_is_dmabuf_map` are used extensively in core block layer, NVMe, and even io_uring code, but are *nowhere* defined. The `iov_iter::dmabuf_map` member isn't even present in `struct iov_iter`! Compilations are failing all over the place. This raises serious red flags. This indicates a missing dependency or an incomplete patch application. My initial reaction is this is not "ready for prime time" because it can't even *build*. However, the instructions and guidelines provided are very clear. The prompt is asking if this is worth fuzzing *given* that it is applied. Let's carefully consider the criteria. The "negative criteria" for *not* fuzzing don't mention a blanket "compilation failure." The focus is on unreachable code, documentation changes, and non-kernel parts. The important test is whether the *modified* code touches reachable code. Now I am thinking about the "positive criteria." This patch touches *deeply* into the core subsystems: io_uring, the block layer (crucial for I/O), and NVMe! And even Device Mapper! These are not niche drivers. They are at the heart of how the kernel handles I/O. Furthermore, the NVMe driver *is* emulated in QEMU, making it reachable by syzkaller. This patch is modifying data structures, refactoring code around io_uring's extended descriptor support, and making I/O paths more efficient. While it might look like a "minor" addition, these are core subsystems and data structure refactoring, which means the changes must be fuzzed as part of syzkaller's goals. The fact that the patch causes compilation failure and missing symbols is concerning. This strongly suggests missing dependencies. I must examine the context. Is this a single patch extracted from a series? The prompt mentions syzkaller extracting patches from email. This points towards partial application and potential missing dependencies. My working hypothesis is that this patch *should* compile and *should* introduce changes and tests. The failures indicate a dependency on another patch or configuration which hasn't been applied. I now need to determine the *minimal* set of `CONFIG_` options needed to make this patch build and to enable the code paths it modifies. I see `CONFIG_IO_URING`, `CONFIG_BLK_DEV_NVME`, and potentially a `CONFIG_DMA_SHARED_BUFFER`. I'll need to check the Kconfig files carefully. It looks like `DMA_SHARED_BUFFER` is not directly exposed as a config. I need to understand what configs enable it, specifically `DMABUF_HEAPS` or the others, such as `DRM` and `UDMABUF`. Syzkaller can probably set them directly, so I should be fine. In conclusion, *despite* the compilation failures, the patch touches core subsystems and reachable hardware (NVMe), making it *worth fuzzing*. It is critical to identify and set the correct `CONFIG_` options to make the code compile and be reachable within the fuzzer. My evaluation is that this should be fuzzed if dependencies can be resolved. |
| 58/2 | 2026/10/07 02:04 | tool | grepper |
0mArgs:{
"Expression": "config UDMABUF",
"PathPrefixes": [
"drivers/"
]
}Results: {
"Output": "drivers/dma-buf/Kconfig=20=config SW_SYNC\n--\ndrivers/dma-buf/Kconfig-32-\ndrivers/dma-buf/Kconfig:33:config UDMABUF\ndrivers/dma-buf/Kconfig-34-\tbool \"userspace dmabuf misc driver\"\n"
} |
| 59/2 | 2026/10/07 02:04 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 68284 output: 36 thoughts: 21 Thoughts: Here's a summary of my thought process, as requested: **Diving into the DMA-BUF Kconfig** Okay, time to dig into the `drivers/dma-buf/Kconfig` file. I'm specifically interested in line 33, hopefully that'll provide some clarity. I need to understand how certain DMA-BUF features are configured, and Kconfig is the usual place to start for kernel configuration. I expect it to describe the dependencies, defaults, and option relationships for those particular features. Hopefully it's well-commented. I'll be looking for any hints about the underlying logic or design choices. Let's see what we've got! |
| 60/2 | 2026/10/07 02:04 | tool | read-file |
0mArgs:{
"File": "drivers/dma-buf/Kconfig",
"FirstLine": 30,
"LineCount": 25
}Results: {
"Contents": " 30:\t\t WARNING: improper use of this can result in deadlocking kernel\n 31:\t\t drivers from userspace. Intended for test and debug only.\n 32:\t\n 33:\tconfig UDMABUF\n 34:\t\tbool \"userspace dmabuf misc driver\"\n 35:\t\tdefault n\n 36:\t\tdepends on DMA_SHARED_BUFFER\n 37:\t\tdepends on MEMFD_CREATE || COMPILE_TEST\n 38:\t\tdepends on MMU\n 39:\t\thelp\n 40:\t\t A driver to let userspace turn memfd regions into dma-bufs.\n 41:\t\t Qemu can use this to create host dmabufs for guest framebuffers.\n 42:\t\n 43:\tconfig DMABUF_DEBUG\n 44:\t\tbool \"DMA-BUF debug checks\"\n 45:\t\tdepends on DMA_SHARED_BUFFER\n 46:\t\tdefault y if DEBUG_KERNEL\n 47:\t\thelp\n 48:\t\t This option enables additional checks for DMA-BUF importers and\n 49:\t\t exporters. Specifically it validates that importers do not peek at the\n 50:\t\t underlying struct page when they import a buffer.\n 51:\t\n 52:\tconfig DMABUF_KUNIT_TEST\n 53:\t\ttristate \"KUnit tests for DMA-BUF\" if !KUNIT_ALL_TESTS\n 54:\t\tdepends on KUNIT\n"
} |
| 61/2 | 2026/10/07 02:04 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 68849 output: 34 thoughts: 716 Thoughts: **Analyzing Kernel Configuration Dependencies** Okay, so I need to figure out the minimal set of kernel configurations to enable certain functionalities, specifically related to `UDMABUF`, `io_uring`, and NVMe interaction with DMA-BUF. My initial thought is that `UDMABUF` depends on `DMA_SHARED_BUFFER`. Makes sense. But what *selects* `DMA_SHARED_BUFFER`? Let's check those `Kconfig` files. Right, back to `DMABUF_HEAPS`. Here it is in `drivers/dma-buf/Kconfig`: `menuconfig DMABUF_HEAPS` *selects* `DMA_SHARED_BUFFER`. Good. And then there's `SYNC_FILE`: `config SYNC_FILE` also *selects* `DMA_SHARED_BUFFER`. Okay, that's two options. Now, wait a minute... Let's look at how this is *used*. In `drivers/nvme/host/Makefile`, I see `nvme-$(CONFIG_DMA_SHARED_BUFFER) += pci-dmabuf.o`. And in `io_uring/Makefile`, it's `obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o`. That's a direct conditional inclusion! So the `Makefile` itself is using `CONFIG_DMA_SHARED_BUFFER`. This is important. Remembering the instructions, we have to find specific `CONFIG_` options, and strip the prefix. The instructions say to inspect `Kconfig` files and `#ifdef` guards, and check "depends on" lines. I need to strip the "CONFIG_" prefix. So, `DMA_SHARED_BUFFER` is directly used in the `Makefile`s and `#if` statements, meaning enabling `DMA_SHARED_BUFFER` should be directly specified, without worrying about something that selects it! Wait, does `kconfig` allow setting `CONFIG_DMA_SHARED_BUFFER=y` if something selects it, or should I include the thing that selects it? Ah, right! With syzkaller, `kconfig` generation tools, it can often be selected by `DMABUF_HEAPS` or even `DRM`. But! This does remind me that `DMABUF_HEAPS` *could* be useful anyway. To test `dma-buf` with `io_uring` and NVMe, userspace is going to need a DMA-BUF file descriptor. That `dmabuf_fd`, where does it come from? Ah, right! Userspace gets it from `/dev/dma_heap/...` (which needs `CONFIG_DMABUF_HEAPS` and `CONFIG_DMABUF_HEAPS_SYSTEM`), from `/dev/udmabuf` (if `CONFIG_UDMABUF` is set), or from DRM/vgem! Got it. So, putting it all together, the *core* configs I need are likely `DMA_SHARED_BUFFER`, `BLK_DEV_NVME`, and `IO_URING`. Let's check `BLK_DEV_NVME` in `drivers/nvme/host/Kconfig` to be sure. |
| 62/2 | 2026/10/07 02:04 | tool | grepper |
0mArgs:{
"Expression": "config BLK_DEV_NVME",
"PathPrefixes": [
"drivers/nvme/"
]
}Results: {
"Output": "drivers/nvme/host/Kconfig=2=config NVME_CORE\n--\ndrivers/nvme/host/Kconfig-4-\ndrivers/nvme/host/Kconfig:5:config BLK_DEV_NVME\ndrivers/nvme/host/Kconfig-6-\ttristate \"NVM Express block device\"\n"
} |
| 63/2 | 2026/10/07 02:04 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 70387 output: 35 thoughts: 22 Thoughts: Here's my summary, as though I'm processing the `drivers/nvme/host/Kconfig` file: **Navigating the NVMe Host Configuration Options** Alright, let's dive into this `Kconfig` file for the NVMe host driver. Lines 1 through 20 are where the initial configuration options reside, and my initial goal is to understand how these options are structured and what they're intended to control. I need to quickly grasp the high-level organization to see what's configurable from the kernel build side. Are we talking about core driver features, debugging capabilities, or perhaps device-specific quirks? I'll be looking for things like: * The scope of the configuration options, are they general or platform specific? * The overall structure to see if things are grouped logically or scattered. * Whether these options are basic enablement flags, or more granular settings. Hopefully, this provides a starting point in configuring the NVMe host drivers! |
| 64/2 | 2026/10/07 02:05 | tool | read-file |
0mArgs:{
"File": "drivers/nvme/host/Kconfig",
"FirstLine": 1,
"LineCount": 20
}Results: {
"Contents": " 1:\t# SPDX-License-Identifier: GPL-2.0-only\n 2:\tconfig NVME_CORE\n 3:\t\ttristate\n 4:\t\n 5:\tconfig BLK_DEV_NVME\n 6:\t\ttristate \"NVM Express block device\"\n 7:\t\tdepends on PCI \u0026\u0026 BLOCK\n 8:\t\tselect NVME_CORE\n 9:\t\thelp\n 10:\t\t The NVM Express driver is for solid state drives directly\n 11:\t\t connected to the PCI or PCI Express bus. If you know you\n 12:\t\t don't have one of these, it is safe to answer N.\n 13:\t\n 14:\t\t To compile this driver as a module, choose M here: the\n 15:\t\t module will be called nvme.\n 16:\t\n 17:\tconfig NVME_MULTIPATH\n 18:\t\tbool \"NVMe multipath support\"\n 19:\t\tdepends on NVME_CORE\n 20:\t\thelp\n"
} |
| 65/2 | 2026/10/07 02:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 70914 output: 31 thoughts: 69 Thoughts: Here's my thought process, distilled: **Navigating NVMe Dependency and Device Mapper Configuration** Okay, so I'm thinking about the `BLK_DEV_NVME` driver. Naturally, it relies on the `PCI` and `BLOCK` subsystems – that's expected. No surprises there. But, I need to be completely thorough, especially with block devices. Wait, hold on. I need to investigate the Device Mapper side of this. Specifically, I'm thinking about `dm-io-rewind.c`. This is crucial for understanding how the system handles block device rewinds, so I need to know which configurations build that specific file. Let me check the `drivers/md/Makefile` to see how that driver gets compiled. That should give me the configuration variables I need to understand the dependencies and compilation path for `dm-io-rewind.c` and by extension, its relationship to the NVMe driver. |
| 66/2 | 2026/10/07 02:05 | tool | grepper |
0mArgs:{
"Expression": "dm-io-rewind",
"PathPrefixes": [
"drivers/md/"
]
}Results: {
"Output": "drivers/md/Makefile=6=dm-mod-y\t+= dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \\\ndrivers/md/Makefile-7-\t\t dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o dm-stats.o \\\ndrivers/md/Makefile:8:\t\t dm-rq.o dm-io-rewind.o\ndrivers/md/Makefile-9-dm-multipath-y\t+= dm-path-selector.o dm-mpath.o\n"
} |
| 67/2 | 2026/10/07 02:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 71358 output: 18 thoughts: 51 Thoughts: Here's my thought process, as it stands: **Navigating Kernel Dependencies for I/O Rewinding** Okay, so I'm looking at `dm-io-rewind.o` here. Right, that's definitely part of the `dm-mod` module. And that, I know, is tied to `CONFIG_BLK_DEV_DM`. Got it. Just confirming that mental link. Now, I need to see how this interacts, or potentially *could* interact, with `IO_URING`. I'll want to dig into `init/Kconfig` or wherever the relevant Kconfig options reside. Let's see what the dependencies are, if it's enabled, or if it causes any conflicts. This is where the real interesting stuff is going to come out. |
| 68/2 | 2026/10/07 02:05 | tool | grepper |
0mArgs:{
"Expression": "config IO_URING"
}Results: {
"Output": "init/Kconfig=1952=config AIO\n--\ninit/Kconfig-1959-\ninit/Kconfig:1960:config IO_URING\ninit/Kconfig-1961-\tbool \"Enable IO uring support\" if EXPERT\n--\ninit/Kconfig=1969=config GCOV_PROFILE_URING\n--\ninit/Kconfig-1981-\ninit/Kconfig:1982:config IO_URING_MOCK_FILE\ninit/Kconfig-1983-\ttristate \"Enable io_uring mock files (Experimental)\" if EXPERT\n--\nio_uring/Kconfig-5-\nio_uring/Kconfig:6:config IO_URING_ZCRX\nio_uring/Kconfig-7-\tdef_bool y\n--\nio_uring/Kconfig-12-\nio_uring/Kconfig:13:config IO_URING_BPF\nio_uring/Kconfig-14-\tdef_bool y\n--\nio_uring/Kconfig-17-\nio_uring/Kconfig:18:config IO_URING_BPF_OPS\nio_uring/Kconfig-19-\tdef_bool y\n"
} |
| 69/2 | 2026/10/07 02:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 71896 output: 24 thoughts: 126 Thoughts: **Investigating the Missing DMA-BUF IO Definition**
Okay, so `IO_URING` is confirmed as a feature option within `init/Kconfig` – good, we're on track. Now, I need to circle back to that compilation hiccup with `read-file`. Specifically, why did it choke on `include/linux/dma-buf-io.h`? That's the real puzzle.
Hang on… why *didn't* that header file exist in the first place? It should be there. Perhaps a stale build configuration issue, a pathing problem, or maybe it's conditionally compiled. But I need to quickly determine if there's any code referencing this structure.
Let’s not waste any more time on speculation. Let's do a quick scan to see if there is any code in the kernel which defines, or references the structure `dma_buf_io_map`. Time for a full, brute-force grep across the entire source tree looking for `struct dma_buf_io_map {`. A solid, definitive test will show if there’s any potential conflict. From there, I'll know where to look next.
|
| 70/2 | 2026/10/07 02:05 | tool | grepper |
0mError:no matches Args: {
"Expression": "struct dma_buf_io_map \\{"
}Results: {
"error": "no matches"
} |
| 71/2 | 2026/10/07 02:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 72311 output: 19 thoughts: 35 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Debugging a DMA Buffer Issue** Alright, I'm hitting a wall. That `struct dma_buf_io_map` definition... I'm getting absolutely no hits in my current context. That's a red flag. Something's not right with my assumed definitions, or maybe it's been moved to a completely different header file than I'm expecting. Okay, deep breath. Time for a broader search. Let's cast a wider net. I'm going to scan the entire project tree for occurrences of `min_seg_shift`. That variable is a pretty core piece of DMA buffer management. If that shows up, then I can examine where it is defined, and possibly, follow that trail to where `struct dma_buf_io_map` is now. This should at least give me a pointer on how this is all supposed to work and what changed since I was last in this code. It's a brute-force approach, but it should be able to get me back on track. I'll need to remember to filter out any false positives from comments or documentation. |
| 72/2 | 2026/10/07 02:05 | tool | grepper |
0mArgs:{
"Expression": "min_seg_shift"
}Results: {
"Output": "block/blk-merge.c=323=static inline int bio_split_io_at_dmabuf(struct bio *bio,\n--\nblock/blk-merge.c-328-\tunsigned bytes = min(bio-\u003ebi_iter.bi_size, max_bytes);\nblock/blk-merge.c:329:\tunsigned seg_shift = bio-\u003ebi_dmabuf_map-\u003emin_seg_shift;\nblock/blk-merge.c-330-\tunsigned offset = bio-\u003ebi_iter.bi_offset \u0026 ((1U \u003c\u003c seg_shift) - 1);\n"
} |
| 73/2 | 2026/10/07 02:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 72770 output: 24 thoughts: 47 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Targeted Code Exploration Begins** Alright, that's interesting. It looks like `min_seg_shift` is exclusively defined within the `block/blk-merge.c` file. This immediately narrows the scope of investigation and potential impact. My instincts tell me this is a key piece of information that will inform my next steps. Now, let's cast a wider net to understand how this function interacts with the rest of the DMA buffer subsystem. I will perform a global search across the entire codebase, specifically for `dma_buf_io_ctx_release`. Understanding the points of interaction will give me a better understanding of how the two items are related, and if the first is being used in the second. |
| 74/2 | 2026/10/07 02:05 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_ctx_release"
}Results: {
"Output": "io_uring/dma-buf.c=3=static inline void io_release_dmabuf(void *priv)\n--\nio_uring/dma-buf.c-7-\tfput(bd-\u003etarget_file);\nio_uring/dma-buf.c:8:\tdma_buf_io_ctx_release(bd-\u003ectx);\nio_uring/dma-buf.c-9-\tkfree(bd);\n"
} |
| 75/2 | 2026/10/07 02:05 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 73127 output: 24 thoughts: 47 Thoughts: Okay, let's see... **Investigating the `dma_buf` Context Release** Hmm, so `dma_buf_io_ctx_release`... that's the function we're interested in, and according to this quick search, it's *only* defined within `io_uring/dma-buf.c`. Alright, that narrows the scope considerably. Now, given we're dealing with DMA-BUF and IO_uring interactions, I'll bet there's an invalidation step associated with the context release to ensure cache coherency. Let's see if we can get a handle on the function that handles that by searching for `dma_buf_io_invalidate_mappings`. That should lead to the surrounding code which handles this type of context release. |
| 76/2 | 2026/10/07 02:05 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_invalidate_mappings"
}Results: {
"Output": "drivers/nvme/host/pci-dmabuf.c=10=static void nvme_dmabuf_invalidate_mappings(struct dma_buf_attachment *attach)\n--\ndrivers/nvme/host/pci-dmabuf.c-13-\ndrivers/nvme/host/pci-dmabuf.c:14:\tdma_buf_io_invalidate_mappings(ctx);\ndrivers/nvme/host/pci-dmabuf.c-15-}\n"
} |
| 77/2 | 2026/10/07 02:05 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 73500 output: 22 thoughts: 50 Thoughts: Here's my summary, as the thought process unfolds: **Locating DMA Buffer Detachment** Okay, so `dma_buf_io_invalidate_mappings` is exclusively found within the NVMe PCI DMABUF driver, specifically in `drivers/nvme/host/pci-dmabuf.c`. That's a very targeted use case, but not necessarily where the detachment might occur. To get a more complete picture, let's broaden the search. I need to find where the `dma_buf` is detached. Let me see if I can use that function to trace the process backward to its origin. Let's move onto searching for the `dma_buf_io_detach` function and see where *that* lives. |
| 78/2 | 2026/10/07 02:07 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_detach"
}Results: {
"Output": "drivers/nvme/host/pci-dmabuf.c=106=void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\n--\ndrivers/nvme/host/pci-dmabuf.c-111-\tlist_for_each_entry_safe(ctx, tmp, \u0026list-\u003ectxs, list) {\ndrivers/nvme/host/pci-dmabuf.c:112:\t\tdma_buf_io_detach(ctx-\u003ebase);\ndrivers/nvme/host/pci-dmabuf.c-113-\t\tdma_buf_detach(ctx-\u003ebase-\u003edmabuf, ctx-\u003eattach);\n"
} |
| 79/2 | 2026/10/07 02:07 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 73917 output: 33 thoughts: 2481 Thoughts: **Triage Decision: WorthFuzzing=true** Okay, here's what I've got. This patch series is clearly missing the crucial commit introducing `include/linux/dma-buf-io.h` and the underlying infrastructure in `drivers/dma-buf/` and `iov_iter` for dma-buf support. That's a red flag. The patch could have been submitted incorrectly, or perhaps it's a piece of a larger series that was applied out of order. But the triage process demands rigorous adherence. The syzkaller instructions are clear. The primary consideration is whether the code is *reachable*. And this code is definitely reachable. Section 2, the "negative criteria," simply doesn't apply. This patch touches: - `io_uring` - The block layer - NVMe, which is accessible via virtio/nvme-pci, - DM. Section 3, the "positive criteria," *all* apply, this is a modification to core subsystems and touches reachable drivers, so it's a definite 'true' for `WorthFuzzing`. Now, for `FocusSymbols`, I need to identify the right functions to target. The guidance is to avoid ubiquitous functions (allocators, memory managers) and focus on specific feature logic and entry points. Static inlines are tricky, so I need to find the non-static callers. Here's my analysis of functions in this patch: * **`io_uring/dma-buf.c`:** `io_register_dmabuf` (direct API entrypoint) is a good starting point. * **`io_uring/rsrc.c`:** `io_sqe_buffers_register`, `io_register_rsrc_update`, `io_register_files_update`, `__io_import_reg_buf`, `__io_import_reg_vec`. * **`io_uring/rw.c`:** `io_read_fixed`, `io_write_fixed`. * **`block/bio.c`:** `bio_iov_iter_set`, `bio_split_io_at`, * **`block/fops.c`:** `blkdev_direct_write`, `blkdev_buffered_write`, `blkdev_read_iter`. * **`drivers/nvme/host/pci-dmabuf.c`:** `__nvme_init_dma_buf_io_ctx`, `__nvme_pci_remove_dmabuf`. * **`drivers/nvme/host/pci.c`:** No suitable focus symbols. * **`drivers/nvme/host/core.c`:** No suitable focus symbols. * **`drivers/md/dm-io-rewind.c`:** No direct entry points, but `dm_bio_rewind_iter` is present, it's called by `dm_io_rewind` For `EnableConfigs`, I'll need to enable everything needed to test all of the above: `IO_URING`, `BLK_DEV`, `NVME`, `DM_MULTIPATH` (just in case), and all necessary supporting options. **In summary:** * `WorthFuzzing`: true * `FocusSymbols`: `io_register_dmabuf`, `io_sqe_buffers_register`, `io_register_rsrc_update`, `io_register_files_update`, `__io_import_reg_buf`, `__io_import_reg_vec`, `io_read_fixed`, `io_write_fixed`, `bio_iov_iter_set`, `bio_split_io_at`, `blkdev_direct_write`, `blkdev_buffered_write`, `blkdev_read_iter`, `__nvme_init_dma_buf_io_ctx`, `__nvme_pci_remove_dmabuf`. * `EnableConfigs`: `IO_URING=y`, `BLK_DEV=y`, `NVME=y`, `DM_MULTIPATH=y`, all support * `Reasoning`: The patch modifies reachable code in core subsystems (io_uring, block, nvme, dm), so must be fuzzed. The focus symbols are relevant entry points and feature-specific functions and their callees. |
| 80/2 | 2026/10/07 02:08 | tool | grepper |
0mArgs:{
"Expression": "dm_bio_rewind_iter",
"PathPrefixes": [
"drivers/md/"
]
}Results: {
"Output": "drivers/md/dm-io-rewind.c=104=static inline void dm_bio_crypt_rewind(struct bio *bio, unsigned int bytes)\n--\ndrivers/md/dm-io-rewind.c-109-\ndrivers/md/dm-io-rewind.c:110:static inline void dm_bio_rewind_iter(const struct bio *bio,\ndrivers/md/dm-io-rewind.c-111-\t\t\t\t struct bvec_iter *iter, unsigned int bytes)\n--\ndrivers/md/dm-io-rewind.c=134=static void dm_bio_rewind(struct bio *bio, unsigned int bytes)\n--\ndrivers/md/dm-io-rewind.c-141-\ndrivers/md/dm-io-rewind.c:142:\tdm_bio_rewind_iter(bio, \u0026bio-\u003ebi_iter, bytes);\ndrivers/md/dm-io-rewind.c-143-}\n"
} |
| 81/2 | 2026/10/07 02:08 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 77654 output: 31 thoughts: 25 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Investigating the dm_bio_rewind Function in dm-io-rewind.c** Alright, let's dive into this. My initial thought process revolves around understanding the call graph for `dm_bio_rewind`. I need to figure out which other functions within the `dm-io-rewind.c` code base, and potentially even elsewhere in the Device Mapper stack, are actually invoking `dm_bio_rewind`. This isn't just a curiosity; knowing its callers is absolutely crucial for any comprehensive analysis. I need to trace back from the rewind function to understand the context in which it's being used. What triggers this rewind? What problem is it designed to solve, and what is its role in the overall I/O flow? Specifically I want to see how the bio is used before the function and what happens to the bio after the function. Any related data structures used are also of interest. Getting that broader picture will be key for any effective debugging, optimization, or extension of this functionality. |
| 82/2 | 2026/10/07 02:08 | tool | grepper |
0mArgs:{
"Expression": "dm_bio_rewind",
"PathPrefixes": [
"drivers/md/"
]
}Results: {
"Output": "drivers/md/dm-io-rewind.c=104=static inline void dm_bio_crypt_rewind(struct bio *bio, unsigned int bytes)\n--\ndrivers/md/dm-io-rewind.c-109-\ndrivers/md/dm-io-rewind.c:110:static inline void dm_bio_rewind_iter(const struct bio *bio,\ndrivers/md/dm-io-rewind.c-111-\t\t\t\t struct bvec_iter *iter, unsigned int bytes)\n--\ndrivers/md/dm-io-rewind.c-124-/**\ndrivers/md/dm-io-rewind.c:125: * dm_bio_rewind - update -\u003ebi_iter of @bio by rewinding @bytes.\ndrivers/md/dm-io-rewind.c-126- * @bio: bio to rewind\n--\ndrivers/md/dm-io-rewind.c-133- */\ndrivers/md/dm-io-rewind.c:134:static void dm_bio_rewind(struct bio *bio, unsigned int bytes)\ndrivers/md/dm-io-rewind.c-135-{\n--\ndrivers/md/dm-io-rewind.c-141-\ndrivers/md/dm-io-rewind.c:142:\tdm_bio_rewind_iter(bio, \u0026bio-\u003ebi_iter, bytes);\ndrivers/md/dm-io-rewind.c-143-}\n--\ndrivers/md/dm-io-rewind.c=145=void dm_io_rewind(struct dm_io *io, struct bio_set *bs)\n--\ndrivers/md/dm-io-rewind.c-150-\t/*\ndrivers/md/dm-io-rewind.c:151:\t * dm_bio_rewind can restore to previous position since the\ndrivers/md/dm-io-rewind.c-152-\t * end sector is fixed for original bio, but we still need\n--\ndrivers/md/dm-io-rewind.c-154-\t */\ndrivers/md/dm-io-rewind.c:155:\tdm_bio_rewind(new_orig, ((io-\u003esector_offset \u003c\u003c 9) -\ndrivers/md/dm-io-rewind.c-156-\t\t\t\t orig-\u003ebi_iter.bi_size));\n"
} |
| 83/2 | 2026/10/07 02:08 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 78540 output: 348 thoughts: 1021 Thoughts: **Analysis of io_uring DMA-BUF Integration** Okay, so the non-static function is `dm_io_rewind` – good to keep in mind. Now, let's nail down the critical focus symbols for this integration. I'm seeing a clear pattern here, they're mostly specific entrypoints and core implementation functions associated with the new DMA-BUF feature and modifications. We have: `io_register_dmabuf`, `io_register_rsrc_update`, `__io_import_reg_buf`, `io_read_fixed`, `io_write_fixed`, `bio_iov_iter_set`, `bio_split_io_at`, `__nvme_init_dma_buf_io_ctx`, `nvme_rq_setup_dmabuf`, and `__nvme_pci_remove_dmabuf`. These cover registration, resource updates, buffer handling, read/write ops (with dmabuf attach/detach), bio manipulations, and NVMe-specific setup and teardown. Time to look at the config requirements, making sure everything is reachable. We're dealing with `IO_URING` (for the core io_uring modules), `DMA_SHARED_BUFFER` (for DMA-BUF support, which also includes the shared buffer), `BLK_DEV_NVME` (for NVMe integration, naturally), and crucially, `DMABUF_HEAPS` or `UDMABUF` to provide a user-space mechanism for allocating the dmabufs and registering them. `BLK_DEV_DM` is included as well, it appears, for dm-io-rewind. Just to double-check, let's list all the options without the `CONFIG_` prefix. We have `IO_URING`, `DMA_SHARED_BUFFER`, `BLK_DEV_NVME`, `DMABUF_HEAPS`, `DMABUF_HEAPS_SYSTEM`, `UDMABUF`, and `BLK_DEV_DM`. Aha, good to verify that `DMABUF_HEAPS` and `DMABUF_HEAPS_SYSTEM` are indeed necessary. They are the user-space interface – without a way to get a dmabuf file descriptor from somewhere (e.g., dma_heap or udmabuf), userspace can't use `IORING_REGISTER_BUFFERS_UPDATE` with `IO_REGBUF_TYPE_DMABUF`. Double-checking `DMABUF_HEAPS_SYSTEM` in `drivers/dma-buf/heaps/Kconfig` confirms it depends on `DMABUF_HEAPS`, as expected. One last check. `BLK_DEV_NVME` depends on `PCI` and `BLOCK`, which is standard. `PCI` is standard on amd64. All good. Alright, verdict time. This is *definitely* worth fuzzing. I have a concise explanation and a solid list of focus symbols. So, the fuzzing verdict: `WorthFuzzing: true`, `Reasoning: Concise explanation of the fuzzing verdict.` `FocusSymbols`: [`io_register_dmabuf`, `io_register_rsrc_update`, `__io_import_reg_buf`, `io_read_fixed`, `io_write_fixed`, `bio_iov_iter_set`, `bio_split_io_at`, `nvme_rq_setup_dmabuf`, `__nvme_init_dma_buf_io_ctx`, `__nvme_pci_remove_dmabuf`] `EnableConfigs`: [`IO_URING`, `DMA_SHARED_BUFFER`, `BLK_DEV_NVME`, `DMABUF_HEAPS`, `UDMABUF`, `BLK_DEV_DM`] Everything's clear. Calling `set-results`. |
| 84/2 | 2026/10/07 02:09 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"IO_URING",
"DMA_SHARED_BUFFER",
"BLK_DEV_NVME",
"DMABUF_HEAPS",
"DMABUF_HEAPS_SYSTEM",
"UDMABUF",
"BLK_DEV_DM"
],
"FocusSymbols": [
"io_register_dmabuf",
"io_register_rsrc_update",
"io_sqe_buffers_register",
"__io_import_reg_buf",
"io_read_fixed",
"io_write_fixed",
"bio_iov_iter_set",
"bio_split_io_at",
"nvme_rq_setup_dmabuf",
"__nvme_init_dma_buf_io_ctx",
"__nvme_pci_remove_dmabuf"
],
"Reasoning": "The patch introduces support for dma-buf backed fixed buffers in io_uring, the block layer, and NVMe PCI host driver. It adds new registration logic (IORING_RSRC_UPDATE_EXTENDED, IO_REGBUF_TYPE_DMABUF), bio cloning/splitting adjustments for dma-buf bios, and NVMe request PRP/SGL construction from dma-buf scatterlists. These changes modify core reachable subsystems (io_uring, block layer) and QEMU-emulated hardware drivers (NVMe PCI). Fuzzing is warranted to uncover boundary issues, lifecycle bugs, and regressions in fixed buffer and bio iter handling.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"IO_URING",
"DMA_SHARED_BUFFER",
"BLK_DEV_NVME",
"DMABUF_HEAPS",
"DMABUF_HEAPS_SYSTEM",
"UDMABUF",
"BLK_DEV_DM"
],
"FocusSymbols": [
"io_register_dmabuf",
"io_register_rsrc_update",
"io_sqe_buffers_register",
"__io_import_reg_buf",
"io_read_fixed",
"io_write_fixed",
"bio_iov_iter_set",
"bio_split_io_at",
"nvme_rq_setup_dmabuf",
"__nvme_init_dma_buf_io_ctx",
"__nvme_pci_remove_dmabuf"
],
"Reasoning": "The patch introduces support for dma-buf backed fixed buffers in io_uring, the block layer, and NVMe PCI host driver. It adds new registration logic (IORING_RSRC_UPDATE_EXTENDED, IO_REGBUF_TYPE_DMABUF), bio cloning/splitting adjustments for dma-buf bios, and NVMe request PRP/SGL construction from dma-buf scatterlists. These changes modify core reachable subsystems (io_uring, block layer) and QEMU-emulated hardware drivers (NVMe PCI). Fuzzing is warranted to uncover boundary issues, lifecycle bugs, and regressions in fixed buffer and bio iter handling.",
"WorthFuzzing": true
} |
| 85/1 | 2026/10/07 02:09 | action | If |
19mArgs:{
"WorthFuzzing": true
}Results: null |
| 86/2 | 2026/10/07 02:09 | agent | kmsan-evaluator |
19mModel:core Args: null Results: {
"KMSANReasoning": "The patch series adds support for direct I/O to/from DMA-BUF memory in io_uring, the block layer, and the NVMe PCIe driver.\n\nEvaluating KMSAN applicability:\n1. Kernel-to-user info-leaks: No kernel structures are copied or leaked to user space (no copy_to_user, put_user, netlink skbs, etc.). The new UAPI structs (such as struct io_uring_regbuf_desc and io_uring_rsrc_update2) are only copied from user space to kernel space.\n2. Uninitialized memory reads/branches: All newly introduced or modified kernel structures on the stack and heap are fully initialized or zeroed:\n - io_files_update zeroes `up2` via memset(\u0026up2, 0, sizeof(up2)).\n - io_iov_to_regbuf_desc zeroes unspecified fields via C99 compound literal initialization.\n - io_register_dmabuf allocates `bd` via kzalloc.\n - io_register_dmabuf_desc zeroes `imu` via memset(imu, 0, sizeof(*imu)).\n - nvme_init_io_ctx_locked allocates `nvme_ctx` via kzalloc_obj.\n - In nvme_dma_buf_io_map, struct nvme_dmabuf_map has all struct fields initialized before use.\n - No conditional branches or control flow rely on uninitialized memory.\n\nEvaluating KASAN / LOCKDEP applicability:\nThe primary failure modes introduced by this patch series involve DMA buffer lifetime management (dma_buf attachment/detachment, refcounts, use-after-free), scatterlist and segment index calculations (potential out-of-bounds accesses in map-\u003edma_list or sg_list descriptors), and lock ordering (buf_list-\u003elock and dma-resv locks). These issues are thoroughly covered by standard KASAN, LOCKDEP, and standard bug detectors.\n\nTherefore, there is no risk of uninitialized memory use that would justify spawning an expensive dedicated KMSAN fuzzing session.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 94b94c945655f70393579916fdfa996691884372
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Oct 7 01:56:37 2026 +0000
syz-cluster: applied patch under review
diff --git a/block/bio.c b/block/bio.c
index b48091c7663fa..1e0d9714c5413 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -881,7 +881,11 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
bio->bi_write_stream = bio_src->bi_write_stream;
bio->bi_bvec_gap_bit = bio_src->bi_bvec_gap_bit;
bio->bi_iter = bio_src->bi_iter;
- bio->bi_io_vec = bio_src->bi_io_vec;
+
+ if (op_is_dmabuf(bio->bi_opf))
+ bio->bi_dmabuf_map = bio_src->bi_dmabuf_map;
+ else
+ bio->bi_io_vec = bio_src->bi_io_vec;
if (bio->bi_bdev) {
if (bio->bi_bdev == bio_src->bi_bdev &&
@@ -1204,16 +1208,23 @@ EXPORT_SYMBOL_GPL(__bio_release_pages);
bool bio_iov_iter_set(struct bio *bio, const struct iov_iter *iter)
{
- if (!iov_iter_is_bvec(iter))
+ if (!iov_iter_is_bvec(iter) && !iov_iter_is_dmabuf_map(iter))
return false;
WARN_ON_ONCE(bio->bi_max_vecs);
+ static_assert(offsetof(struct bio, bi_io_vec) ==
+ offsetof(struct bio, bi_dmabuf_map));
+ static_assert(offsetof(struct iov_iter, bvec) ==
+ offsetof(struct iov_iter, dmabuf_map));
+
bio->bi_io_vec = (struct bio_vec *)iter->bvec;
bio->bi_iter.bi_idx = 0;
bio->bi_iter.bi_offset = iter->iov_offset;
bio->bi_iter.bi_size = iov_iter_count(iter);
bio_set_flag(bio, BIO_CLONED);
+ if (iov_iter_is_dmabuf_map(iter))
+ bio->bi_opf |= REQ_NOMERGE | REQ_DMABUF;
return true;
}
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 258a726071d12..18f014ff3314b 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -9,6 +9,7 @@
#include <linux/blk-integrity.h>
#include <linux/part_stat.h>
#include <linux/blk-cgroup.h>
+#include <linux/dma-buf-io.h>
#include <trace/events/block.h>
@@ -319,6 +320,41 @@ static inline unsigned int bvec_seg_gap(struct bio_vec *bvprv,
return bv->bv_offset | (bvprv->bv_offset + bvprv->bv_len);
}
+static inline int bio_split_io_at_dmabuf(struct bio *bio,
+ const struct queue_limits *lim, unsigned *segs,
+ unsigned max_bytes, unsigned len_align_mask,
+ unsigned start_align_mask)
+{
+ unsigned bytes = min(bio->bi_iter.bi_size, max_bytes);
+ unsigned seg_shift = bio->bi_dmabuf_map->min_seg_shift;
+ unsigned offset = bio->bi_iter.bi_offset & ((1U << seg_shift) - 1);
+ u64 max_segs_bytes;
+
+ /*
+ * dma-buf maps don't expose the underlying segmentation, but they're
+ * guaranteed to not have alignment gaps, we only need to check the
+ * start and length alignment.
+ */
+ if ((bio->bi_iter.bi_offset & start_align_mask) ||
+ (bio->bi_iter.bi_size & len_align_mask))
+ return -EINVAL;
+
+ /* Presented as a single contiguous range into the dma-buf */
+ *segs = 1;
+
+ /*
+ * Limit by the number of segments by using the minimal segment size.
+ * Any I/O consisting of N full segments should be able to cover at
+ * least N multiplied by the segment size. It's stricter than walking
+ * the segments and might cause extra splitting.
+ */
+ max_segs_bytes = (u64)lim->max_segments << seg_shift;
+ bytes = min_t(u64, bytes, max_segs_bytes - offset);
+ if (bytes != bio->bi_iter.bi_size)
+ return bytes;
+ return 0;
+}
+
/**
* bio_split_io_at - check if and where to split a bio
* @bio: [in] bio to be split
@@ -346,6 +382,19 @@ int bio_split_io_at(struct bio *bio, const struct queue_limits *lim,
len_align_mask |= (bc->bc_key->crypto_cfg.data_unit_size - 1);
}
+ if (op_is_dmabuf(bio->bi_opf)) {
+ int ret;
+
+ ret = bio_split_io_at_dmabuf(bio, lim, &nsegs, max_bytes,
+ len_align_mask, start_align_mask);
+ if (ret < 0)
+ return ret;
+ if (!ret)
+ goto out;
+ bytes = ret;
+ goto split;
+ }
+
bio_for_each_bvec(bv, bio, iter) {
if (bv.bv_offset & start_align_mask ||
bv.bv_len & len_align_mask)
@@ -376,6 +425,7 @@ int bio_split_io_at(struct bio *bio, const struct queue_limits *lim,
bvprvp = &bvprv;
}
+out:
*segs = nsegs;
bio->bi_bvec_gap_bit = ffs(gaps);
return 0;
diff --git a/block/fops.c b/block/fops.c
index 9905ed24a1578..e9da48ab73be6 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -362,7 +362,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,
* Users don't rely on the iterator being in any particular
* state for async I/O returning -EIOCBQUEUED, hence we can
* avoid expensive iov_iter_advance(). Bypass
- * bio_iov_iter_get_pages() and set the bvec directly.
+ * bio_iov_iter_get_pages() and set the bvec/dmabuf directly.
*/
if (!bio_iov_iter_set(bio, iter)) {
ret = blkdev_iov_iter_get_pages(bio, iter, bdev);
@@ -730,6 +730,9 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from)
static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from)
{
+ if (unlikely(iov_iter_is_dmabuf_map(from)))
+ return -EOPNOTSUPP;
+
return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops, NULL,
NULL);
}
@@ -855,6 +858,11 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
if (ret < 0 || !count)
goto reexpand;
}
+ if (unlikely(iov_iter_is_dmabuf_map(to))) {
+ if (!ret)
+ ret = -EOPNOTSUPP;
+ goto reexpand;
+ }
/*
* Take i_rwsem and invalidate_lock to avoid racing with set_blocksize
@@ -958,6 +966,19 @@ static int blkdev_mmap_prepare(struct vm_area_desc *desc)
return generic_file_mmap_prepare(desc);
}
+static int blkdev_init_dma_buf_io_ctx(struct file *file,
+ struct dma_buf_io_ctx *ctx)
+{
+ struct block_device *bdev = file_bdev(file);
+ struct gendisk *disk = bdev->bd_disk;
+
+ if (!(file->f_flags & O_DIRECT))
+ return -EINVAL;
+ if (!disk->fops->init_dma_buf_io_ctx)
+ return -EOPNOTSUPP;
+ return disk->fops->init_dma_buf_io_ctx(bdev, ctx);
+}
+
const struct file_operations def_blk_fops = {
.open = blkdev_open,
.release = blkdev_release,
@@ -976,6 +997,7 @@ const struct file_operations def_blk_fops = {
.fallocate = blkdev_fallocate,
.uring_cmd = blkdev_uring_cmd,
.fop_flags = FOP_BUFFER_RASYNC | FOP_DONTCACHE,
+ .init_dma_buf_io_ctx = blkdev_init_dma_buf_io_ctx,
};
static __init int blkdev_init(void)
diff --git a/drivers/md/dm-io-rewind.c b/drivers/md/dm-io-rewind.c
index 04f3fc8aeb6f9..b22719c6411cf 100644
--- a/drivers/md/dm-io-rewind.c
+++ b/drivers/md/dm-io-rewind.c
@@ -113,10 +113,12 @@ static inline void dm_bio_rewind_iter(const struct bio *bio,
iter->bi_sector -= bytes >> 9;
/* No advance means no rewind */
- if (bio_no_advance_iter(bio))
+ if (bio_no_advance_iter(bio)) {
iter->bi_size += bytes;
- else
+ iter->bi_offset -= bytes;
+ } else {
dm_bvec_iter_rewind(bio->bi_io_vec, iter, bytes);
+ }
}
/**
diff --git a/drivers/nvme/host/Makefile b/drivers/nvme/host/Makefile
index 67563a69f7dcc..8288b986d7131 100644
--- a/drivers/nvme/host/Makefile
+++ b/drivers/nvme/host/Makefile
@@ -21,6 +21,7 @@ nvme-core-$(CONFIG_NVME_HWMON) += hwmon.o
nvme-core-$(CONFIG_NVME_HOST_AUTH) += auth.o
nvme-y += pci.o
+nvme-$(CONFIG_DMA_SHARED_BUFFER) += pci-dmabuf.o
nvme-fabrics-y += fabrics.o
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7eb0f9fe6b18d..2f9b2262f77cd 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2708,6 +2708,17 @@ static int nvme_report_zones(struct gendisk *disk, sector_t sector,
#define nvme_report_zones NULL
#endif /* CONFIG_BLK_DEV_ZONED */
+static int nvme_init_dma_buf_io_ctx(struct block_device *bdev,
+ struct dma_buf_io_ctx *ctx)
+{
+ struct nvme_ns *ns = bdev->bd_disk->private_data;
+ struct nvme_ctrl *ctrl = ns->ctrl;
+
+ if (!ctrl->ops->init_dma_buf_io_ctx)
+ return -EINVAL;
+ return ctrl->ops->init_dma_buf_io_ctx(ctrl, ctx);
+}
+
const struct block_device_operations nvme_bdev_ops = {
.owner = THIS_MODULE,
.ioctl = nvme_ioctl,
@@ -2718,6 +2729,7 @@ const struct block_device_operations nvme_bdev_ops = {
.get_unique_id = nvme_get_unique_id,
.report_zones = nvme_report_zones,
.pr_ops = &nvme_pr_ops,
+ .init_dma_buf_io_ctx = nvme_init_dma_buf_io_ctx,
};
static int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a643c4723a69b..be32e9a5ca5a1 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -668,6 +668,8 @@ struct nvme_ctrl_ops {
int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
void (*print_device_info)(struct nvme_ctrl *ctrl);
bool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);
+ int (*init_dma_buf_io_ctx)(struct nvme_ctrl *ctrl,
+ struct dma_buf_io_ctx *ctx);
unsigned long (*get_virt_boundary)(struct nvme_ctrl *ctrl, bool is_admin);
};
diff --git a/drivers/nvme/host/pci-dmabuf.c b/drivers/nvme/host/pci-dmabuf.c
new file mode 100644
index 0000000000000..d58a38a75d673
--- /dev/null
+++ b/drivers/nvme/host/pci-dmabuf.c
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2026 Pavel Begunkov <asml.silence@gmail.com>
+ */
+
+#include <linux/dma-resv.h>
+
+#include "pci-dmabuf.h"
+
+static void nvme_dmabuf_invalidate_mappings(struct dma_buf_attachment *attach)
+{
+ struct dma_buf_io_ctx *ctx = attach->importer_priv;
+
+ dma_buf_io_invalidate_mappings(ctx);
+}
+
+static const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {
+ .invalidate_mappings = nvme_dmabuf_invalidate_mappings,
+ .allow_peer2peer = true,
+};
+
+static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)
+{
+ unsigned nr_entries = ctx->dmabuf->size / NVME_CTRL_PAGE_SIZE;
+ struct nvme_dma_buf_io_ctx *nvme_ctx = ctx->dev_priv;
+ struct dma_buf_attachment *attach = nvme_ctx->attach;
+ unsigned long tmp, i = 0;
+ struct nvme_dmabuf_map *map;
+ struct scatterlist *sg;
+ struct sg_table *sgt;
+ int ret;
+
+ dma_resv_assert_held(ctx->dmabuf->resv);
+
+ if (ctx->dmabuf->size % NVME_CTRL_PAGE_SIZE)
+ return ERR_PTR(-EINVAL);
+
+ map = kvmalloc_flex(*map, dma_list, nr_entries);
+ if (!map)
+ return ERR_PTR(-ENOMEM);
+ map->nr_entries = nr_entries;
+
+ sgt = dma_buf_map_attachment(attach, ctx->dir);
+ if (IS_ERR(sgt)) {
+ ret = PTR_ERR(sgt);
+ sgt = NULL;
+ goto err;
+ }
+
+ for_each_sgtable_dma_sg(sgt, sg, tmp) {
+ dma_addr_t dma_addr = sg_dma_address(sg);
+ unsigned long sg_len = sg_dma_len(sg);
+
+ if ((sg_len % NVME_CTRL_PAGE_SIZE) ||
+ (dma_addr % NVME_CTRL_PAGE_SIZE)) {
+ ret = -EINVAL;
+ goto err;
+ }
+ while (sg_len) {
+ map->dma_list[i++] = dma_addr;
+ dma_addr += NVME_CTRL_PAGE_SIZE;
+ sg_len -= NVME_CTRL_PAGE_SIZE;
+ }
+ }
+
+ ret = dma_buf_io_init_map(ctx, &map->base, sgt);
+ if (ret)
+ goto err;
+ map->sgt = sgt;
+ return &map->base;
+err:
+ if (sgt)
+ dma_buf_unmap_attachment(attach, sgt, ctx->dir);
+ kvfree(map);
+ return ERR_PTR(ret);
+}
+
+static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,
+ struct dma_buf_io_map *map_base)
+{
+ struct nvme_dma_buf_io_ctx *nvme_ctx = ctx->dev_priv;
+ struct nvme_dmabuf_map *map = to_nvme_dmabuf_map(map_base);
+
+ dma_resv_assert_held(ctx->dmabuf->resv);
+
+ dma_buf_unmap_attachment(nvme_ctx->attach, map->sgt, ctx->dir);
+ kvfree(map);
+}
+
+static void nvme_dma_buf_io_release(struct dma_buf_io_ctx *base_ctx)
+{
+ struct nvme_dma_buf_io_ctx *ctx = base_ctx->dev_priv;
+ struct nvme_dma_buf_list *buf_list = ctx->buf_list;
+
+ mutex_lock(&buf_list->lock);
+ if (!list_empty(&ctx->list)) {
+ dma_buf_detach(ctx->base->dmabuf, ctx->attach);
+ list_del_init(&ctx->list);
+ }
+ mutex_unlock(&buf_list->lock);
+
+ nvme_put_ctrl(ctx->ctrl);
+ kfree(ctx);
+}
+
+void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)
+{
+ struct nvme_dma_buf_io_ctx *ctx, *tmp;
+
+ mutex_lock(&list->lock);
+ list_for_each_entry_safe(ctx, tmp, &list->ctxs, list) {
+ dma_buf_io_detach(ctx->base);
+ dma_buf_detach(ctx->base->dmabuf, ctx->attach);
+ list_del_init(&ctx->list);
+ }
+ mutex_unlock(&list->lock);
+}
+
+const struct dma_buf_io_ops nvme_dma_buf_io_ops = {
+ .map = nvme_dma_buf_io_map,
+ .unmap = nvme_dma_buf_io_unmap,
+ .release = nvme_dma_buf_io_release,
+};
+
+static int nvme_init_io_ctx_locked(struct nvme_ctrl *ctrl,
+ struct nvme_dma_buf_list *buf_list,
+ struct dma_buf_io_ctx *ctx)
+{
+ struct nvme_dma_buf_io_ctx *nvme_ctx;
+ struct dma_buf_attachment *attach;
+
+ nvme_ctx = kzalloc_obj(*nvme_ctx);
+ if (!nvme_ctx)
+ return -ENOMEM;
+
+ attach = dma_buf_dynamic_attach(ctx->dmabuf, ctrl->dev,
+ &nvme_dmabuf_importer_ops, ctx);
+ if (IS_ERR(attach)) {
+ kfree(nvme_ctx);
+ return PTR_ERR(attach);
+ }
+
+ nvme_get_ctrl(ctrl);
+ list_add(&nvme_ctx->list, &buf_list->ctxs);
+ nvme_ctx->attach = attach;
+ nvme_ctx->base = ctx;
+ nvme_ctx->ctrl = ctrl;
+ nvme_ctx->buf_list = buf_list;
+ ctx->dev_priv = nvme_ctx;
+ ctx->dev_ops = &nvme_dma_buf_io_ops;
+ return 0;
+}
+
+int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,
+ struct nvme_dma_buf_list *buf_list,
+ struct dma_buf_io_ctx *ctx)
+{
+ int ret;
+
+ mutex_lock(&buf_list->lock);
+ ret = nvme_init_io_ctx_locked(ctrl, buf_list, ctx);
+ mutex_unlock(&buf_list->lock);
+ return ret;
+}
diff --git a/drivers/nvme/host/pci-dmabuf.h b/drivers/nvme/host/pci-dmabuf.h
new file mode 100644
index 0000000000000..8e91f7f4ece5a
--- /dev/null
+++ b/drivers/nvme/host/pci-dmabuf.h
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2026 Pavel Begunkov <asml.silence@gmail.com>
+ */
+
+#ifndef _NVME_PCI_DMABUF_H
+#define _NVME_PCI_DMABUF_H
+
+#include <linux/dma-buf-io.h>
+
+#include "nvme.h"
+
+struct nvme_dma_buf_list {
+ struct list_head ctxs;
+ struct mutex lock;
+};
+
+struct nvme_dma_buf_io_ctx {
+ struct dma_buf_attachment *attach;
+ struct nvme_dma_buf_list *buf_list;
+ struct dma_buf_io_ctx *base;
+ struct nvme_ctrl *ctrl;
+ struct list_head list;
+};
+
+struct nvme_dmabuf_map {
+ struct dma_buf_io_map base;
+ struct sg_table *sgt;
+ unsigned nr_entries;
+ dma_addr_t dma_list[] __counted_by(nr_entries);
+};
+
+static inline struct nvme_dmabuf_map *to_nvme_dmabuf_map(
+ struct dma_buf_io_map *map)
+{
+ return container_of(map, struct nvme_dmabuf_map, base);
+}
+
+static inline struct nvme_dmabuf_map *nvme_req_to_map(struct request *req)
+{
+ struct dma_buf_io_map *map = req->bio->bi_dmabuf_map;
+
+ return to_nvme_dmabuf_map(map);
+}
+
+void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list);
+int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,
+ struct nvme_dma_buf_list *buf_list,
+ struct dma_buf_io_ctx *ctx);
+
+static inline void nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)
+{
+ if (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ __nvme_pci_remove_dmabuf(list);
+}
+
+static inline int nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,
+ struct nvme_dma_buf_list *buf_list,
+ struct dma_buf_io_ctx *ctx)
+{
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return -EOPNOTSUPP;
+ return __nvme_init_dma_buf_io_ctx(ctrl, buf_list, ctx);
+}
+
+static inline void nvme_init_buf_list(struct nvme_dma_buf_list *buf_list)
+{
+ INIT_LIST_HEAD(&buf_list->ctxs);
+ mutex_init(&buf_list->lock);
+}
+
+
+#endif /* _NVME_PCI_DMABUF_H */
\ No newline at end of file
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 77317e5d00f9f..79b3c1092e4d1 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -30,6 +30,7 @@
#include "trace.h"
#include "nvme.h"
+#include "pci-dmabuf.h"
#define SQ_SIZE(q) ((q)->q_depth << (q)->sqes)
#define CQ_SIZE(q) ((q)->q_depth * sizeof(struct nvme_completion))
@@ -318,6 +319,7 @@ struct nvme_dev {
bool hmb;
struct sg_table *hmb_sgt;
mempool_t *dmavec_mempool;
+ struct nvme_dma_buf_list dmabufs;
/* shadow doorbell buffer support: */
__le32 *dbbuf_dbs;
@@ -865,6 +867,76 @@ static void nvme_free_descriptors(struct request *req)
}
}
+static blk_status_t nvme_rq_setup_dmabuf_map(struct request *req,
+ struct nvme_queue *nvmeq)
+{
+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
+ struct nvme_dmabuf_map *map = nvme_req_to_map(req);
+ unsigned bvec_done = req->bio->bi_iter.bi_offset;
+ unsigned map_idx = bvec_done / NVME_CTRL_PAGE_SIZE;
+ unsigned offset = bvec_done & (NVME_CTRL_PAGE_SIZE - 1);
+ int length = blk_rq_payload_bytes(req) - (NVME_CTRL_PAGE_SIZE - offset);
+ dma_addr_t *dma_list = map->dma_list;
+ u64 prp1_dma = dma_list[map_idx++] + offset;
+ u64 dma_addr, prp2_dma;
+ dma_addr_t prp_dma;
+ __le64 *prp_list;
+ unsigned i;
+
+ if (length <= 0) {
+ prp2_dma = 0;
+ goto done;
+ }
+
+ if (length <= NVME_CTRL_PAGE_SIZE) {
+ prp2_dma = dma_list[map_idx];
+ goto done;
+ }
+
+ if (DIV_ROUND_UP(length, NVME_CTRL_PAGE_SIZE) <=
+ NVME_SMALL_POOL_SIZE / sizeof(__le64))
+ iod->flags |= IOD_SMALL_DESCRIPTOR;
+
+ prp_list = dma_pool_alloc(nvme_dma_pool(nvmeq, iod), GFP_ATOMIC,
+ &prp_dma);
+ if (!prp_list)
+ return BLK_STS_RESOURCE;
+
+ iod->descriptors[iod->nr_descriptors++] = prp_list;
+ prp2_dma = prp_dma;
+ i = 0;
+ for (;;) {
+ if (i == NVME_CTRL_PAGE_SIZE >> 3) {
+ __le64 *old_prp_list = prp_list;
+
+ prp_list = dma_pool_alloc(nvmeq->descriptor_pools.large,
+ GFP_ATOMIC, &prp_dma);
+ if (!prp_list)
+ goto free_prps;
+ iod->descriptors[iod->nr_descriptors++] = prp_list;
+ prp_list[0] = old_prp_list[i - 1];
+ old_prp_list[i - 1] = cpu_to_le64(prp_dma);
+ i = 1;
+ }
+
+ dma_addr = dma_list[map_idx++];
+ prp_list[i++] = cpu_to_le64(dma_addr);
+
+ length -= NVME_CTRL_PAGE_SIZE;
+ if (length <= 0)
+ break;
+ }
+done:
+ iod->cmd.common.dptr.prp1 = cpu_to_le64(prp1_dma);
+ iod->cmd.common.dptr.prp2 = cpu_to_le64(prp2_dma);
+ return BLK_STS_OK;
+free_prps:
+ iod->cmd.common.dptr.prp1 = cpu_to_le64(prp1_dma);
+ iod->cmd.common.dptr.prp2 = cpu_to_le64(prp2_dma);
+ nvme_free_descriptors(req);
+ return BLK_STS_RESOURCE;
+}
+
static void nvme_free_prps(struct request *req, unsigned int attrs)
{
struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
@@ -943,6 +1015,9 @@ static void nvme_unmap_data(struct request *req)
struct device *dma_dev = nvmeq->dev->dev;
unsigned int attrs = 0;
+ if (blk_mq_rq_is_dmabuf(req))
+ goto out_free_desc;
+
if (iod->flags & IOD_SINGLE_SEGMENT) {
static_assert(offsetof(union nvme_data_ptr, prp1) ==
offsetof(union nvme_data_ptr, sgl.addr));
@@ -967,6 +1042,7 @@ static void nvme_unmap_data(struct request *req)
nvme_free_prps(req, attrs);
}
+out_free_desc:
if (iod->nr_descriptors)
nvme_free_descriptors(req);
}
@@ -1148,13 +1224,19 @@ static blk_status_t nvme_pci_setup_data_prp(struct request *req,
}
static void nvme_pci_sgl_set_data(struct nvme_sgl_desc *sge,
- struct blk_dma_iter *iter)
+ dma_addr_t addr, u32 len)
{
- sge->addr = cpu_to_le64(iter->addr);
- sge->length = cpu_to_le32(iter->len);
+ sge->addr = cpu_to_le64(addr);
+ sge->length = cpu_to_le32(len);
sge->type = NVME_SGL_FMT_DATA_DESC << 4;
}
+static void nvme_pci_dma_iter_set_sgl(struct nvme_sgl_desc *sge,
+ struct blk_dma_iter *iter)
+{
+ nvme_pci_sgl_set_data(sge, iter->addr, iter->len);
+}
+
static void nvme_pci_sgl_set_seg(struct nvme_sgl_desc *sge,
dma_addr_t dma_addr, int entries)
{
@@ -1163,6 +1245,142 @@ static void nvme_pci_sgl_set_seg(struct nvme_sgl_desc *sge,
sge->type = NVME_SGL_FMT_LAST_SEG_DESC << 4;
}
+static unsigned int nvme_pci_dmabuf_sgl_nents(struct request *req)
+{
+ struct bio *bio = req->bio;
+ struct nvme_dmabuf_map *map = to_nvme_dmabuf_map(bio->bi_dmabuf_map);
+ struct scatterlist *sg;
+ unsigned long tmp;
+ size_t offset = bio->bi_iter.bi_offset;
+ size_t remaining = blk_rq_payload_bytes(req);
+ unsigned int nents = 0;
+
+ for_each_sgtable_dma_sg(map->sgt, sg, tmp) {
+ size_t sg_len = sg_dma_len(sg);
+
+ if (!remaining)
+ break;
+ if (offset >= sg_len) {
+ offset -= sg_len;
+ continue;
+ }
+
+ sg_len -= offset;
+ offset = 0;
+
+ do {
+ size_t chunk = min(remaining, sg_len);
+
+ nents++;
+ sg_len -= chunk;
+ remaining -= chunk;
+ } while (sg_len && remaining);
+ }
+
+ if (unlikely(remaining))
+ return 0;
+
+ return nents;
+}
+
+static blk_status_t nvme_rq_setup_dmabuf_sgl(struct request *req,
+ struct nvme_queue *nvmeq, unsigned int entries)
+{
+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
+ struct nvme_dmabuf_map *map = nvme_req_to_map(req);
+ size_t length = blk_rq_payload_bytes(req);
+ struct nvme_sgl_desc *sg_list = &iod->cmd.common.dptr.sgl;
+ size_t offset = req->bio->bi_iter.bi_offset;
+ bool pooled = entries > 1;
+ dma_addr_t sgl_dma = 0;
+ unsigned int mapped = 0;
+ unsigned long tmp;
+ struct scatterlist *sg;
+ size_t remaining = length;
+
+ if (!entries)
+ return BLK_STS_IOERR;
+
+ iod->cmd.common.flags = NVME_CMD_SGL_METABUF;
+ iod->total_len = length;
+
+ /* entries == 1 fits in the inline descriptor; more needs a pool. */
+ if (pooled) {
+ if (entries <= NVME_SMALL_POOL_SIZE / sizeof(*sg_list))
+ iod->flags |= IOD_SMALL_DESCRIPTOR;
+
+ sg_list = dma_pool_alloc(nvme_dma_pool(nvmeq, iod), GFP_ATOMIC,
+ &sgl_dma);
+ if (!sg_list)
+ return BLK_STS_RESOURCE;
+ iod->descriptors[iod->nr_descriptors++] = sg_list;
+ }
+
+ for_each_sgtable_dma_sg(map->sgt, sg, tmp) {
+ size_t sg_len = sg_dma_len(sg);
+ dma_addr_t addr = sg_dma_address(sg);
+
+ if (!remaining)
+ break;
+ if (offset >= sg_len) {
+ offset -= sg_len;
+ continue;
+ }
+
+ addr += offset;
+ sg_len -= offset;
+ offset = 0;
+
+ do {
+ u32 chunk = min_t(size_t, remaining, sg_len);
+
+ if (WARN_ON_ONCE(mapped == entries))
+ goto err_free;
+ nvme_pci_sgl_set_data(&sg_list[mapped++], addr, chunk);
+
+ addr += chunk;
+ sg_len -= chunk;
+ remaining -= chunk;
+ } while (sg_len && remaining);
+ }
+
+ if (unlikely(remaining))
+ goto err_free;
+
+ if (pooled)
+ nvme_pci_sgl_set_seg(&iod->cmd.common.dptr.sgl, sgl_dma,
+ mapped);
+ return BLK_STS_OK;
+err_free:
+ if (pooled) {
+ iod->nr_descriptors--;
+ dma_pool_free(nvme_dma_pool(nvmeq, iod), sg_list, sgl_dma);
+ }
+ return BLK_STS_IOERR;
+}
+
+static blk_status_t nvme_rq_setup_dmabuf(struct request *req,
+ struct nvme_queue *nvmeq, enum nvme_use_sgl use_sgl)
+{
+ unsigned int entries;
+ size_t avg_seg;
+
+ if (use_sgl == SGL_UNSUPPORTED)
+ return nvme_rq_setup_dmabuf_map(req, nvmeq);
+
+ entries = nvme_pci_dmabuf_sgl_nents(req);
+
+ if (use_sgl == SGL_FORCED)
+ return nvme_rq_setup_dmabuf_sgl(req, nvmeq, entries);
+
+ avg_seg = entries ?
+ DIV_ROUND_UP(blk_rq_payload_bytes(req), entries) : 0;
+ if (sgl_threshold && avg_seg >= sgl_threshold)
+ return nvme_rq_setup_dmabuf_sgl(req, nvmeq, entries);
+
+ return nvme_rq_setup_dmabuf_map(req, nvmeq);
+}
+
static blk_status_t nvme_pci_setup_data_sgl(struct request *req,
struct blk_dma_iter *iter)
{
@@ -1177,7 +1395,7 @@ static blk_status_t nvme_pci_setup_data_sgl(struct request *req,
iod->cmd.common.flags = NVME_CMD_SGL_METABUF;
if (entries == 1 || blk_rq_dma_map_coalesce(&iod->dma_state)) {
- nvme_pci_sgl_set_data(&iod->cmd.common.dptr.sgl, iter);
+ nvme_pci_dma_iter_set_sgl(&iod->cmd.common.dptr.sgl, iter);
iod->total_len += iter->len;
return BLK_STS_OK;
}
@@ -1199,7 +1417,7 @@ static blk_status_t nvme_pci_setup_data_sgl(struct request *req,
iter->status = BLK_STS_IOERR;
break;
}
- nvme_pci_sgl_set_data(&sg_list[mapped++], iter);
+ nvme_pci_dma_iter_set_sgl(&sg_list[mapped++], iter);
iod->total_len += iter->len;
} while (blk_rq_dma_map_iter_next(req, nvmeq->dev->dev, iter));
@@ -1257,6 +1475,9 @@ static blk_status_t nvme_map_data(struct request *req)
struct blk_dma_iter iter;
blk_status_t ret;
+ if (blk_mq_rq_is_dmabuf(req))
+ return nvme_rq_setup_dmabuf(req, nvmeq, use_sgl);
+
/*
* Try to skip the DMA iterator for single segment requests, as that
* significantly improves performances for small I/O sizes.
@@ -1359,13 +1580,13 @@ static blk_status_t nvme_pci_setup_meta_iter(struct request *req)
iod->cmd.common.metadata = cpu_to_le64(sgl_dma);
if (entries == 1) {
iod->meta_total_len = iter.len;
- nvme_pci_sgl_set_data(sg_list, &iter);
+ nvme_pci_dma_iter_set_sgl(sg_list, &iter);
return BLK_STS_OK;
}
sgl_dma += sizeof(*sg_list);
do {
- nvme_pci_sgl_set_data(&sg_list[++i], &iter);
+ nvme_pci_dma_iter_set_sgl(&sg_list[++i], &iter);
iod->meta_total_len += iter.len;
} while (blk_rq_integrity_dma_map_iter_next(req, dev->dev, &iter));
@@ -3357,6 +3578,9 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
nvme_unquiesce_admin_queue(&dev->ctrl);
}
mutex_unlock(&dev->shutdown_lock);
+
+ if (shutdown)
+ nvme_pci_remove_dmabuf(&dev->dmabufs);
}
static int nvme_disable_prepare_reset(struct nvme_dev *dev, bool shutdown)
@@ -3564,6 +3788,14 @@ static unsigned long nvme_pci_get_virt_boundary(struct nvme_ctrl *ctrl,
return 0;
}
+static int nvme_pci_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,
+ struct dma_buf_io_ctx *ctx)
+{
+ struct nvme_dev *dev = to_nvme_dev(ctrl);
+
+ return nvme_init_dma_buf_io_ctx(ctrl, &dev->dmabufs, ctx);
+}
+
static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
.name = "pcie",
.module = THIS_MODULE,
@@ -3579,6 +3811,7 @@ static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
.print_device_info = nvme_pci_print_device_info,
.supports_pci_p2pdma = nvme_pci_supports_pci_p2pdma,
.get_virt_boundary = nvme_pci_get_virt_boundary,
+ .init_dma_buf_io_ctx = nvme_pci_init_dma_buf_io_ctx,
};
static int nvme_dev_map(struct nvme_dev *dev)
@@ -3701,6 +3934,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev,
return ERR_PTR(-ENOMEM);
INIT_WORK(&dev->ctrl.reset_work, nvme_reset_work);
mutex_init(&dev->shutdown_lock);
+ nvme_init_buf_list(&dev->dmabufs);
dev->nr_write_queues = write_queues;
dev->nr_poll_queues = poll_queues;
@@ -4346,5 +4580,6 @@ MODULE_AUTHOR("Matthew Wilcox <willy@linux.intel.com>");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");
MODULE_DESCRIPTION("NVMe host PCIe transport driver");
+MODULE_IMPORT_NS("DMA_BUF");
module_init(nvme_init);
module_exit(nvme_exit);
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 17944e44b5849..7a794ce723b84 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -80,7 +80,8 @@ static inline bool bio_no_advance_iter(const struct bio *bio)
{
return bio_op(bio) == REQ_OP_DISCARD ||
bio_op(bio) == REQ_OP_SECURE_ERASE ||
- bio_op(bio) == REQ_OP_WRITE_ZEROES;
+ bio_op(bio) == REQ_OP_WRITE_ZEROES ||
+ op_is_dmabuf(bio->bi_opf);
}
static inline void *bio_data(struct bio *bio)
@@ -113,11 +114,13 @@ static inline void bio_advance_iter(const struct bio *bio,
{
iter->bi_sector += bytes >> 9;
- if (bio_no_advance_iter(bio))
+ if (bio_no_advance_iter(bio)) {
iter->bi_size -= bytes;
- else
+ iter->bi_offset += bytes;
+ } else {
bvec_iter_advance(bio->bi_io_vec, iter, bytes);
/* TODO: It is reasonable to complete bio with error here. */
+ }
}
/* @bytes should be less or equal to bvec[i->bi_idx].bv_len */
@@ -127,10 +130,12 @@ static inline void bio_advance_iter_single(const struct bio *bio,
{
iter->bi_sector += bytes >> 9;
- if (bio_no_advance_iter(bio))
+ if (bio_no_advance_iter(bio)) {
iter->bi_size -= bytes;
- else
+ iter->bi_offset += bytes;
+ } else {
bvec_iter_advance_single(bio->bi_io_vec, iter, bytes);
+ }
}
void __bio_advance(struct bio *, unsigned bytes);
@@ -434,12 +439,12 @@ static inline void bio_wouldblock_error(struct bio *bio)
/*
* Calculate number of bvec segments that should be allocated to fit data
- * pointed by @iter. If @iter is backed by bvec it's going to be reused
- * instead of allocating a new one.
+ * pointed by @iter. If @iter is backed by a bvec or a dmabuf, the bvec array /
+ * the dma map are going to be reused, and so no extra allocation is required.
*/
static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)
{
- if (iov_iter_is_bvec(iter))
+ if (iov_iter_is_bvec(iter) || iov_iter_is_dmabuf_map(iter))
return 0;
return iov_iter_npages(iter, max_segs);
}
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index af878597afb8c..7c7504c84e090 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -1017,6 +1017,13 @@ static inline void *blk_mq_rq_to_pdu(struct request *rq)
return rq + 1;
}
+static inline bool blk_mq_rq_is_dmabuf(struct request *rq)
+{
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return false;
+ return rq->bio && op_is_dmabuf(rq->bio->bi_opf);
+}
+
static inline struct blk_mq_hw_ctx *queue_hctx(struct request_queue *q, int id)
{
struct blk_mq_hw_ctx *hctx;
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 98e21b4cbf328..0cc09b975d8ff 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -233,7 +233,12 @@ struct bio {
atomic_t __bi_remaining;
/* The actual vec list, preserved by bio_reset() */
- struct bio_vec *bi_io_vec;
+ union {
+ struct bio_vec *bi_io_vec;
+ /* Driver specific dma map, valid IFF REQ_DMABUF is set */
+ struct dma_buf_io_map *bi_dmabuf_map;
+ };
+
struct bvec_iter bi_iter;
union {
@@ -402,6 +407,7 @@ enum req_flag_bits {
__REQ_DRV, /* for driver use */
__REQ_FS_PRIVATE, /* for file system (submitter) use */
__REQ_ATOMIC, /* for atomic write operations */
+ __REQ_DMABUF, /* Using premmaped dma buffers */
/*
* Command specific flags, keep last:
*/
@@ -434,6 +440,7 @@ enum req_flag_bits {
#define REQ_DRV (__force blk_opf_t)(1ULL << __REQ_DRV)
#define REQ_FS_PRIVATE (__force blk_opf_t)(1ULL << __REQ_FS_PRIVATE)
#define REQ_ATOMIC (__force blk_opf_t)(1ULL << __REQ_ATOMIC)
+#define REQ_DMABUF (__force blk_opf_t)(1ULL << __REQ_DMABUF)
#define REQ_NOUNMAP (__force blk_opf_t)(1ULL << __REQ_NOUNMAP)
@@ -487,6 +494,11 @@ static inline bool op_is_discard(blk_opf_t op)
return (op & REQ_OP_MASK) == REQ_OP_DISCARD;
}
+static inline bool op_is_dmabuf(blk_opf_t op)
+{
+ return op & REQ_DMABUF;
+}
+
/*
* Check if a bio or request operation is a zone management operation.
*/
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index d003a9d2d1f6c..2d5c30823aab9 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1599,6 +1599,8 @@ struct block_device_operations {
/* returns the length of the identifier or a negative errno: */
int (*get_unique_id)(struct gendisk *disk, u8 id[16],
enum blk_unique_id id_type);
+ int (*init_dma_buf_io_ctx)(struct block_device *,
+ struct dma_buf_io_ctx *);
struct module *owner;
const struct pr_ops *pr_ops;
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index fc566ee1c1ff1..b63914ff56e33 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -108,7 +108,8 @@ struct bvec_iter {
unsigned int bi_idx;
/*
- * Current offset in the bvec entry pointed to by `bi_idx`.
+ * Current offset in the bvec entry pointed to by `bi_idx` or into
+ * a dma-buf map.
*/
unsigned int bi_offset;
} __packed __aligned(4);
diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
index 90fea94ad2029..73cd11d173df0 100644
--- a/include/linux/io_uring_types.h
+++ b/include/linux/io_uring_types.h
@@ -11,6 +11,7 @@
struct iou_loop_params;
struct io_uring_bpf_ops;
+struct dma_buf_io_map;
enum {
/*
@@ -610,6 +611,7 @@ enum {
REQ_F_IMPORT_BUFFER_BIT,
REQ_F_SQE_COPIED_BIT,
REQ_F_IOPOLL_BIT,
+ REQ_F_DMABUF_BIT,
/* not a real bit, just to check we're not overflowing the space */
__REQ_F_LAST_BIT,
@@ -705,6 +707,8 @@ enum {
REQ_F_SQE_COPIED = IO_REQ_FLAG(REQ_F_SQE_COPIED_BIT),
/* request must be iopolled to completion (set in ->issue()) */
REQ_F_IOPOLL = IO_REQ_FLAG(REQ_F_IOPOLL_BIT),
+ /* there is a dma map attached to request that needs to be dropped */
+ REQ_F_DMABUF = IO_REQ_FLAG(REQ_F_DMABUF_BIT),
};
struct io_tw_req {
@@ -827,6 +831,7 @@ struct io_kiocb {
/* custom credentials, valid IFF REQ_F_CREDS is set */
const struct cred *creds;
struct io_wq_work work;
+ struct dma_buf_io_map *dmabuf_map;
struct io_big_cqe {
u64 extra1;
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index b42b66b424a76..b456f45fa8de7 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -791,13 +791,42 @@ struct io_uring_rsrc_update {
struct io_uring_rsrc_update2 {
__u32 offset;
- __u32 resv;
+ __u32 flags;
__aligned_u64 data;
__aligned_u64 tags;
__u32 nr;
__u32 resv2;
};
+/* struct io_uring_rsrc_update2::flags */
+enum io_uring_rsrc_reg_flags {
+ /*
+ * Use the extended descriptor format for buffer updates,
+ * see struct io_uring_regbuf_desc
+ */
+ IORING_RSRC_UPDATE_EXTENDED = 1U << 1,
+};
+
+/* Buffer registration type, passed in struct io_uring_regbuf_desc::type */
+enum io_uring_regbuf_type {
+ IO_REGBUF_TYPE_EMPTY,
+ IO_REGBUF_TYPE_UADDR,
+ IO_REGBUF_TYPE_DMABUF,
+
+ __IO_REGBUF_TYPE_MAX,
+};
+
+struct io_uring_regbuf_desc {
+ __u32 type; /* enum io_uring_regbuf_type */
+ __u32 flags;
+ __u64 size;
+ __u64 uaddr;
+
+ __s32 dmabuf_fd;
+ __s32 target_fd;
+ __u64 __resv[6];
+};
+
/* Skip updating fd indexes set to this value in the fd table */
#define IORING_REGISTER_FILES_SKIP (-2)
diff --git a/io_uring/Makefile b/io_uring/Makefile
index c54e328d14104..965bb60e9f7b1 100644
--- a/io_uring/Makefile
+++ b/io_uring/Makefile
@@ -26,3 +26,4 @@ obj-$(CONFIG_PROC_FS) += fdinfo.o
obj-$(CONFIG_IO_URING_MOCK_FILE) += mock_file.o
obj-$(CONFIG_IO_URING_BPF) += bpf_filter.o
obj-$(CONFIG_IO_URING_BPF_OPS) += bpf-ops.o
+obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o
diff --git a/io_uring/dma-buf.c b/io_uring/dma-buf.c
new file mode 100644
index 0000000000000..f40c9d87ed8aa
--- /dev/null
+++ b/io_uring/dma-buf.c
@@ -0,0 +1,68 @@
+#include "dma-buf.h"
+
+static inline void io_release_dmabuf(void *priv)
+{
+ struct io_buf_dma *bd = priv;
+
+ fput(bd->target_file);
+ dma_buf_io_ctx_release(bd->ctx);
+ kfree(bd);
+}
+
+int io_register_dmabuf(struct io_ring_ctx *ctx,
+ struct io_uring_regbuf_desc *desc,
+ struct io_mapped_ubuf *imu)
+{
+ struct io_buf_dma *bd = NULL;
+ struct file *target_file = NULL;
+ struct dma_buf *dmabuf = NULL;
+ int ret;
+
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return -EOPNOTSUPP;
+ if (ctx->flags & IORING_SETUP_IOPOLL)
+ return -EOPNOTSUPP;
+ if (desc->uaddr || desc->size)
+ return -EINVAL;
+
+ bd = kzalloc(sizeof(*bd), GFP_KERNEL);
+ if (!bd)
+ return -ENOMEM;
+
+ target_file = fget(desc->target_fd);
+ if (!target_file) {
+ ret = -EBADF;
+ goto err;
+ }
+ dmabuf = dma_buf_get(desc->dmabuf_fd);
+ if (IS_ERR(dmabuf)) {
+ ret = PTR_ERR(dmabuf);
+ dmabuf = NULL;
+ goto err;
+ }
+ ret = io_validate_user_buf_range(0, dmabuf->size);
+ if (ret)
+ goto err;
+
+ ret = dma_buf_io_ctx_create(target_file, dmabuf, DMA_BIDIRECTIONAL,
+ &bd->ctx);
+ if (ret)
+ goto err;
+
+ bd->target_file = target_file;
+ imu->len = dmabuf->size;
+ imu->release = io_release_dmabuf;
+ imu->priv = bd;
+ imu->flags = IO_REGBUF_F_DMABUF;
+ imu->dir = IO_BUF_DEST | IO_BUF_SOURCE;
+ dma_buf_put(dmabuf);
+ return 0;
+err:
+ kfree(bd);
+ if (target_file)
+ fput(target_file);
+ if (dmabuf)
+ dma_buf_put(dmabuf);
+ return ret;
+}
+
diff --git a/io_uring/dma-buf.h b/io_uring/dma-buf.h
new file mode 100644
index 0000000000000..10d2efdd8c9f1
--- /dev/null
+++ b/io_uring/dma-buf.h
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef IOU_DMA_BUF_H
+#define IOU_DMA_BUF_H
+
+#include <linux/dma-buf-io.h>
+#include <linux/io_uring_types.h>
+
+#include "rsrc.h"
+
+struct io_buf_dma {
+ struct dma_buf_io_ctx *ctx;
+ struct file *target_file;
+};
+
+static inline void io_detach_dmabuf_map(struct io_kiocb *req)
+{
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return;
+ if (!(req->flags & REQ_F_DMABUF) || !req->dmabuf_map)
+ return;
+ dma_buf_io_map_drop(req->dmabuf_map);
+ req->dmabuf_map = NULL;
+}
+
+static inline int io_attach_dmabuf_map(struct io_kiocb *req,
+ struct iov_iter *iter,
+ unsigned issue_flags)
+{
+ bool nowait = issue_flags & IO_URING_F_NONBLOCK;
+ struct dma_buf_io_map *map;
+ struct io_buf_dma *bd;
+
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return -EOPNOTSUPP;
+ if (!(req->flags & REQ_F_DMABUF))
+ return 0;
+
+ bd = req->buf_node->buf->priv;
+ map = dma_buf_io_get_map(bd->ctx, nowait);
+ if (unlikely(IS_ERR(map)))
+ return PTR_ERR(map);
+ req->dmabuf_map = map;
+ iter->dmabuf_map = map;
+ return 0;
+}
+
+static inline int io_import_dmabuf_map(struct io_kiocb *req,
+ int ddir, struct iov_iter *iter,
+ struct io_mapped_ubuf *imu,
+ size_t len, size_t offset)
+{
+ struct io_buf_dma *bd = imu->priv;
+
+ if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+ return -EOPNOTSUPP;
+ if (req->file != bd->target_file)
+ return -EBADF;
+ req->flags |= REQ_F_DMABUF;
+ iov_iter_dmabuf_map(iter, ddir, NULL, offset, len);
+ return 0;
+}
+
+int io_register_dmabuf(struct io_ring_ctx *ctx,
+ struct io_uring_regbuf_desc *desc,
+ struct io_mapped_ubuf *imu);
+
+#endif /* IOU_DMA_BUF_H */
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 1efaf29514e8d..d6f7cbf731eb2 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -10,6 +10,7 @@
#include <linux/compat.h>
#include <linux/io_uring.h>
#include <linux/io_uring/cmd.h>
+#include <linux/dma-buf-io.h>
#include <uapi/linux/io_uring.h>
@@ -19,6 +20,7 @@
#include "rsrc.h"
#include "memmap.h"
#include "register.h"
+#include "dma-buf.h"
struct io_rsrc_update {
struct file *file;
@@ -28,7 +30,7 @@ struct io_rsrc_update {
};
static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
- struct iovec *iov);
+ struct io_uring_regbuf_desc *desc);
static int hpage_acct_ref(struct io_ring_ctx *ctx, struct page *hpage,
bool *acct_new)
@@ -81,6 +83,18 @@ static bool hpage_acct_unref(struct io_ring_ctx *ctx, struct page *hpage)
#define IO_CACHED_BVECS_SEGS 32
+static void io_iov_to_regbuf_desc(const struct iovec *iov,
+ struct io_uring_regbuf_desc *desc)
+{
+ *desc = (struct io_uring_regbuf_desc) {
+ .type = IO_REGBUF_TYPE_UADDR,
+ .uaddr = (u64)(uintptr_t)iov->iov_base,
+ .size = iov->iov_len,
+ };
+ if (!desc->uaddr)
+ desc->type = IO_REGBUF_TYPE_EMPTY;
+}
+
int __io_account_mem(struct user_struct *user, unsigned long nr_pages)
{
unsigned long page_limit, cur_pages, new_pages;
@@ -326,6 +340,8 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
return -ENXIO;
if (up->offset + nr_args > ctx->file_table.data.nr)
return -EINVAL;
+ if (up->flags)
+ return -EINVAL;
for (done = 0; done < nr_args; done++) {
u64 tag = 0;
@@ -385,9 +401,8 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
struct io_uring_rsrc_update2 *up,
unsigned int nr_args)
{
+ bool extended = up->flags & IORING_RSRC_UPDATE_EXTENDED;
u64 __user *tags = u64_to_user_ptr(up->tags);
- struct iovec fast_iov, *iov;
- struct iovec __user *uvec;
u64 user_data = up->data;
__u32 done;
int i, err;
@@ -396,26 +411,49 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
return -ENXIO;
if (up->offset + nr_args > ctx->buf_table.nr)
return -EINVAL;
+ if (up->flags & ~IORING_RSRC_UPDATE_EXTENDED)
+ return -EINVAL;
for (done = 0; done < nr_args; done++) {
+ struct io_uring_regbuf_desc desc;
struct io_rsrc_node *node;
u64 tag = 0;
- uvec = u64_to_user_ptr(user_data);
- iov = iovec_from_user(uvec, 1, 1, &fast_iov, io_is_compat(ctx));
- if (IS_ERR(iov)) {
- err = PTR_ERR(iov);
- break;
- }
if (tags && copy_from_user(&tag, &tags[done], sizeof(tag))) {
err = -EFAULT;
break;
}
- node = io_sqe_buffer_register(ctx, iov);
+
+ if (extended) {
+ if (copy_from_user(&desc, u64_to_user_ptr(user_data),
+ sizeof(desc))) {
+ err = -EFAULT;
+ break;
+ }
+ user_data += sizeof(desc);
+ } else {
+ struct iovec __user *uvec = u64_to_user_ptr(user_data);
+ struct iovec fast_iov, *iov;
+
+ if (io_is_compat(ctx))
+ user_data += sizeof(struct compat_iovec);
+ else
+ user_data += sizeof(struct iovec);
+
+ iov = iovec_from_user(uvec, 1, 1, &fast_iov, io_is_compat(ctx));
+ if (IS_ERR(iov)) {
+ err = PTR_ERR(iov);
+ break;
+ }
+ io_iov_to_regbuf_desc(iov, &desc);
+ }
+
+ node = io_sqe_buffer_register(ctx, &desc);
if (IS_ERR(node)) {
err = PTR_ERR(node);
break;
}
+
if (tag) {
if (!node) {
err = -EINVAL;
@@ -426,10 +464,6 @@ static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,
i = array_index_nospec(up->offset + done, ctx->buf_table.nr);
io_reset_rsrc_node(ctx, &ctx->buf_table, i);
ctx->buf_table.nodes[i] = node;
- if (io_is_compat(ctx))
- user_data += sizeof(struct compat_iovec);
- else
- user_data += sizeof(struct iovec);
}
return done ? done : err;
}
@@ -464,7 +498,7 @@ int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,
memset(&up, 0, sizeof(up));
if (copy_from_user(&up, arg, sizeof(struct io_uring_rsrc_update)))
return -EFAULT;
- if (up.resv || up.resv2)
+ if (up.resv2)
return -EINVAL;
return __io_register_rsrc_update(ctx, IORING_RSRC_FILE, &up, nr_args);
}
@@ -478,7 +512,7 @@ int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg,
return -EINVAL;
if (copy_from_user(&up, arg, sizeof(up)))
return -EFAULT;
- if (!up.nr || up.resv || up.resv2)
+ if (!up.nr || up.resv2)
return -EINVAL;
return __io_register_rsrc_update(ctx, type, &up, up.nr);
}
@@ -578,12 +612,9 @@ int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
struct io_uring_rsrc_update2 up2;
int ret;
+ memset(&up2, 0, sizeof(up2));
up2.offset = up->offset;
up2.data = up->arg;
- up2.nr = 0;
- up2.tags = 0;
- up2.resv = 0;
- up2.resv2 = 0;
if (up->offset == IORING_FILE_INDEX_ALLOC) {
ret = io_files_update_with_index_alloc(req, issue_flags);
@@ -869,27 +900,70 @@ bool io_check_coalesce_buffer(struct page **page_array, int nr_pages,
return true;
}
+static struct io_rsrc_node *io_register_dmabuf_desc(struct io_ring_ctx *ctx,
+ struct io_uring_regbuf_desc *desc)
+{
+ struct io_rsrc_node *node = NULL;
+ struct io_mapped_ubuf *imu = NULL;
+ int ret;
+
+ node = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER);
+ if (!node)
+ return ERR_PTR(-ENOMEM);
+
+ imu = io_alloc_imu(ctx, 0);
+ if (!imu) {
+ ret = -ENOMEM;
+ goto err;
+ }
+ memset(imu, 0, sizeof(*imu));
+ refcount_set(&imu->refs, 1);
+
+ ret = io_register_dmabuf(ctx, desc, imu);
+ if (ret)
+ goto err;
+ node->buf = imu;
+ return node;
+err:
+ if (imu)
+ io_free_imu(ctx, imu);
+ if (node)
+ io_cache_free(&ctx->node_cache, node);
+ return ERR_PTR(ret);
+}
+
static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
- struct iovec *iov)
+ struct io_uring_regbuf_desc *desc)
{
+ unsigned long uaddr = (unsigned long)desc->uaddr;
+ size_t size = desc->size;
struct io_mapped_ubuf *imu = NULL;
struct page **pages = NULL;
struct io_rsrc_node *node;
unsigned long off;
- size_t size;
int ret, nr_pages, i;
struct io_imu_folio_data data;
bool coalesced = false;
- if (!iov->iov_base) {
- if (iov->iov_len)
+ if (desc->type >= __IO_REGBUF_TYPE_MAX)
+ return ERR_PTR(-EINVAL);
+ if (!mem_is_zero(&desc->__resv, sizeof(desc->__resv)) || desc->flags)
+ return ERR_PTR(-EINVAL);
+
+ if (desc->type == IO_REGBUF_TYPE_DMABUF)
+ return io_register_dmabuf_desc(ctx, desc);
+
+ if (desc->dmabuf_fd || desc->target_fd)
+ return ERR_PTR(-EINVAL);
+
+ if (desc->type == IO_REGBUF_TYPE_EMPTY) {
+ if (uaddr || size)
return ERR_PTR(-EFAULT);
/* remove the buffer without installing a new one */
return NULL;
}
- ret = io_validate_user_buf_range((unsigned long)iov->iov_base,
- iov->iov_len);
+ ret = io_validate_user_buf_range(uaddr, size);
if (ret)
return ERR_PTR(ret);
@@ -898,8 +972,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
return ERR_PTR(-ENOMEM);
ret = -ENOMEM;
- pages = io_pin_pages((unsigned long) iov->iov_base, iov->iov_len,
- &nr_pages);
+ pages = io_pin_pages(uaddr, size, &nr_pages);
if (IS_ERR(pages)) {
ret = PTR_ERR(pages);
pages = NULL;
@@ -921,10 +994,9 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
if (ret)
goto done;
- size = iov->iov_len;
/* store original address for later verification */
- imu->ubuf = (unsigned long) iov->iov_base;
- imu->len = iov->iov_len;
+ imu->ubuf = uaddr;
+ imu->len = size;
imu->folio_shift = PAGE_SHIFT;
imu->release = io_release_ubuf;
imu->priv = imu;
@@ -934,7 +1006,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
imu->folio_shift = data.folio_shift;
refcount_set(&imu->refs, 1);
- off = (unsigned long)iov->iov_base & ~PAGE_MASK;
+ off = uaddr & ~PAGE_MASK;
if (coalesced)
off += data.first_folio_page_idx << PAGE_SHIFT;
@@ -986,6 +1058,7 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
memset(iov, 0, sizeof(*iov));
for (i = 0; i < nr_args; i++) {
+ struct io_uring_regbuf_desc desc;
struct io_rsrc_node *node;
u64 tag = 0;
@@ -1009,7 +1082,8 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
}
}
- node = io_sqe_buffer_register(ctx, iov);
+ io_iov_to_regbuf_desc(iov, &desc);
+ node = io_sqe_buffer_register(ctx, &desc);
if (IS_ERR(node)) {
ret = PTR_ERR(node);
break;
@@ -1206,9 +1280,12 @@ static int io_import_kbuf(int ddir, struct iov_iter *iter,
return 0;
}
-static int io_import_fixed(int ddir, struct iov_iter *iter,
+static int io_import_fixed(struct io_kiocb *req,
+ int ddir, struct iov_iter *iter,
struct io_mapped_ubuf *imu,
- u64 buf_addr, size_t len)
+ u64 buf_addr, size_t len,
+ unsigned issue_flags,
+ unsigned import_flags)
{
const struct bio_vec *bvec;
size_t folio_mask;
@@ -1228,6 +1305,11 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
offset = buf_addr - imu->ubuf;
+ if (imu->flags & IO_REGBUF_F_DMABUF) {
+ if (!(import_flags & IO_REGBUF_IMPORT_ALLOW_DMABUF))
+ return -EFAULT;
+ return io_import_dmabuf_map(req, ddir, iter, imu, len, offset);
+ }
if (imu->flags & IO_REGBUF_F_KBUF)
return io_import_kbuf(ddir, iter, imu, len, offset);
@@ -1281,16 +1363,17 @@ inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
return NULL;
}
-int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
+int __io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
u64 buf_addr, size_t len, int ddir,
- unsigned issue_flags)
+ unsigned issue_flags, unsigned import_flags)
{
struct io_rsrc_node *node;
node = io_find_buf_node(req, issue_flags);
if (!node)
return -EFAULT;
- return io_import_fixed(ddir, iter, node->buf, buf_addr, len);
+ return io_import_fixed(req, ddir, iter, node->buf, buf_addr, len,
+ issue_flags, import_flags);
}
static int io_buffer_acct_cloned_hpages(struct io_ring_ctx *ctx,
@@ -1422,6 +1505,11 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
if (!src_node) {
dst_node = NULL;
} else {
+ if (src_node->buf->flags & IO_REGBUF_F_UNCLONEABLE) {
+ io_rsrc_data_free(ctx, &data);
+ return -EOPNOTSUPP;
+ }
+
dst_node = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER);
if (!dst_node) {
io_rsrc_data_free(ctx, &data);
@@ -1692,9 +1780,9 @@ static int io_kern_bvec_size(struct iovec *iov, unsigned nr_iovs,
return 0;
}
-int io_import_reg_vec(int ddir, struct iov_iter *iter,
+int __io_import_reg_vec(int ddir, struct iov_iter *iter,
struct io_kiocb *req, struct iou_vec *vec,
- unsigned nr_iovs, unsigned issue_flags)
+ unsigned nr_iovs, unsigned issue_flags, unsigned import_flags)
{
struct io_rsrc_node *node;
struct io_mapped_ubuf *imu;
@@ -1712,7 +1800,9 @@ int io_import_reg_vec(int ddir, struct iov_iter *iter,
iovec_off = vec->nr - nr_iovs;
iov = vec->iovec + iovec_off;
- if (imu->flags & IO_REGBUF_F_KBUF) {
+ if (imu->flags & IO_REGBUF_F_DMABUF) {
+ return -EOPNOTSUPP;
+ } else if (imu->flags & IO_REGBUF_F_KBUF) {
int ret = io_kern_bvec_size(iov, nr_iovs, imu, &nr_segs);
if (unlikely(ret))
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 9ef88383b3636..d893cc5e580a0 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -26,7 +26,13 @@ struct io_rsrc_node {
};
enum {
- IO_REGBUF_F_KBUF = 1,
+ IO_REGBUF_F_KBUF = 1 << 0,
+ IO_REGBUF_F_UNCLONEABLE = 1 << 1,
+ IO_REGBUF_F_DMABUF = 1 << 3,
+};
+
+enum {
+ IO_REGBUF_IMPORT_ALLOW_DMABUF = 1 << 1,
};
struct io_mapped_ubuf {
@@ -61,12 +67,28 @@ int io_rsrc_data_alloc(struct io_rsrc_data *data, unsigned nr);
struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
unsigned issue_flags);
-int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
+int __io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
u64 buf_addr, size_t len, int ddir,
- unsigned issue_flags);
-int io_import_reg_vec(int ddir, struct iov_iter *iter,
+ unsigned issue_flags, unsigned import_flags);
+int __io_import_reg_vec(int ddir, struct iov_iter *iter,
struct io_kiocb *req, struct iou_vec *vec,
- unsigned nr_iovs, unsigned issue_flags);
+ unsigned nr_iovs, unsigned issue_flags,
+ unsigned import_flags);
+
+static inline int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
+ u64 buf_addr, size_t len, int ddir,
+ unsigned issue_flags)
+{
+ return __io_import_reg_buf(req, iter, buf_addr, len, ddir, issue_flags, 0);
+}
+
+static inline int io_import_reg_vec(int ddir, struct iov_iter *iter,
+ struct io_kiocb *req, struct iou_vec *vec,
+ unsigned nr_iovs, unsigned issue_flags)
+{
+ return __io_import_reg_vec(ddir, iter, req, vec, nr_iovs, issue_flags, 0);
+}
+
int io_prep_reg_iovec(struct io_kiocb *req, struct iou_vec *iv,
const struct iovec __user *uvec, size_t uvec_segs);
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 999d9a1cc5a56..d33b925a848e5 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -23,6 +23,7 @@
#include "rsrc.h"
#include "poll.h"
#include "rw.h"
+#include "dma-buf.h"
static void io_complete_rw(struct kiocb *kiocb, long res);
static void io_complete_rw_iopoll(struct kiocb *kiocb, long res);
@@ -358,13 +359,18 @@ static int io_init_rw_fixed(struct io_kiocb *req, unsigned int issue_flags,
struct io_async_rw *io = req->async_data;
int ret;
- if (io->bytes_done)
- return 0;
+ if (!io->bytes_done) {
+ ret = __io_import_reg_buf(req, &io->iter, rw->addr, rw->len, ddir,
+ issue_flags, IO_REGBUF_IMPORT_ALLOW_DMABUF);
+ if (ret)
+ return ret;
+ iov_iter_save_state(&io->iter, &io->iter_state);
+ }
- ret = io_import_reg_buf(req, &io->iter, rw->addr, rw->len, ddir,
- issue_flags);
- iov_iter_save_state(&io->iter, &io->iter_state);
- return ret;
+ ret = io_attach_dmabuf_map(req, &io->iter, issue_flags);
+ if (ret)
+ return ret;
+ return 0;
}
int io_prep_read_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe)
@@ -577,6 +583,8 @@ static void io_complete_rw(struct kiocb *kiocb, long res)
struct io_rw *rw = container_of(kiocb, struct io_rw, kiocb);
struct io_kiocb *req = cmd_to_io_kiocb(rw);
+ io_detach_dmabuf_map(req);
+
/* ring owner may block in freeze_super() before task_work runs */
if (kiocb->ki_flags & IOCB_WRITE)
io_req_end_write(req);
@@ -698,7 +706,7 @@ static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)
!(kiocb->ki_filp->f_flags & O_NONBLOCK))
return -EAGAIN;
if ((req->flags & REQ_F_BUF_NODE) &&
- (req->buf_node->buf->flags & IO_REGBUF_F_KBUF))
+ (req->buf_node->buf->flags & (IO_REGBUF_F_KBUF|IO_REGBUF_F_DMABUF)))
return -EFAULT;
ppos = io_kiocb_ppos(kiocb);
@@ -1226,7 +1234,10 @@ int io_read_fixed(struct io_kiocb *req, unsigned int issue_flags)
if (unlikely(ret))
return ret;
- return io_read(req, issue_flags);
+ ret = io_read(req, issue_flags);
+ if (ret != -EIOCBQUEUED)
+ io_detach_dmabuf_map(req);
+ return ret;
}
int io_write_fixed(struct io_kiocb *req, unsigned int issue_flags)
@@ -1237,7 +1248,11 @@ int io_write_fixed(struct io_kiocb *req, unsigned int issue_flags)
if (unlikely(ret))
return ret;
- return io_write(req, issue_flags);
+ ret = io_write(req, issue_flags);
+ if (ret != -EIOCBQUEUED)
+ io_detach_dmabuf_map(req);
+ return ret;
+
}
void io_rw_fail(struct io_kiocb *req)
|
| 87/3 | 2026/10/07 02:09 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25835 output: 31 thoughts: 1665 Thoughts: **KMSAN Evaluation of DMA-BUF Integration** Okay, let's dive into this patch series. My task is to determine if these code changes warrant a dedicated KMSAN fuzzing session. The key is to look for the introduction or exposure of *uninitialized memory* risks that are *only* detectable by KMSAN. I need to carefully analyze each changed component and its potential impact on memory initialization. First, the `block/bio.c` changes look interesting. The addition of `bi_dmabuf_map` and the conditional logic around it in `__bio_clone` and `bio_iov_iter_set` needs scrutiny. There are now multiple codepaths depending on whether we're dealing with `bi_io_vec` or `bi_dmabuf_map`. Any misuse of these structures *before* they're properly populated could be a KMSAN issue. The static asserts are good, but I need to confirm the assumptions hold under all circumstances, especially error paths. The `block/blk-merge.c` change, with `bio_split_io_at_dmabuf`, is related to DMA-buf bio splitting and might introduce a new set of data dependencies and control flow to consider. I need to see how these split operations interact with memory initialization. `block/fops.c` now rejects dmabuf in `blkdev_buffered_write` and read. Okay, rejection may not introduce a risk. The new `blkdev_init_dma_buf_io_ctx` and the `def_blk_fops` hooks are where the action might be. If this code touches uninitialized data, or relies on it, it could trigger KMSAN. The modification in `drivers/md/dm-io-rewind.c` is important. Rewinding an iterator that involves a DMA-buf potentially introduces a race or incorrect access pattern. I need to be sure that `iter->bi_size` and `iter->bi_offset` are initialized correctly based on `bio_no_advance_iter`. The NVMe driver changes with `nvme_init_dma_buf_io_ctx`, and the new PCI DMA-buf support is a high-risk area. I need to carefully check `nvme_dma_buf_io_map`, `nvme_dma_buf_io_unmap`, and their interaction with the DMA engine. DMA-buf has a lot of places for uninitialized memory risks. The `include/linux/bio.h`, `include/linux/blk-mq.h`, `include/linux/blk_types.h` and `include/linux/io_uring_types.h` header files are defining new structures, bitfields, and macros. These are *definitions* of data structures, not necessarily where initialization happens. I need to look for where they *used*. The `io_uring` changes, with the new `io_release_dmabuf`, `io_register_dmabuf`, etc., are *very* concerning. DMA-buf integration with io_uring opens up a whole new attack surface. Anything that touches `io_kiocb`, `dma_buf_io_map`, and the dmabuf descriptors require careful scrutiny. In particular, any new codepaths that involve registering, attaching, detaching and importing these descriptors could introduce vulnerabilities if the internal state is not managed correctly. I need to confirm all the paths that touch the above by reading the code, and how they use the new data structures and flags. In particular, DMA-buf I/O involves a lot of device-specific operations and interactions, which are perfect candidates for subtle memory errors. To properly evaluate, I need to check the definition of `dma-buf-io.h` and if this is a part of DMA-buf peer-to-peer or block I/O with DMA-buf in io_uring. I will search the git log and the codebase using `grepper` or other methods, to look for related commits and files. This is not complete yet, and I would need to analyze the code based on the data to make a better determination. |
| 88/3 | 2026/10/07 02:09 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_map",
"PathPrefixes": [
"include/"
]
}Results: {
"Output": "include/linux/blk_types.h=210=struct bio {\n--\ninclude/linux/blk_types.h-238-\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\ninclude/linux/blk_types.h:239:\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\ninclude/linux/blk_types.h-240-\t};\n--\ninclude/linux/io_uring_types.h=13=struct io_uring_bpf_ops;\ninclude/linux/io_uring_types.h:14:struct dma_buf_io_map;\ninclude/linux/io_uring_types.h-15-\n--\ninclude/linux/io_uring_types.h=759=struct io_kiocb {\n--\ninclude/linux/io_uring_types.h-833-\tstruct io_wq_work\t\twork;\ninclude/linux/io_uring_types.h:834:\tstruct dma_buf_io_map\t\t*dmabuf_map;\ninclude/linux/io_uring_types.h-835-\n"
} |
| 89/3 | 2026/10/07 02:09 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28716 output: 34 thoughts: 16 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Hunting Down `linux/dma-buf-io.h`** Alright, let's dive in. My immediate thought is, "Where's `linux/dma-buf-io.h` hiding?" It's a key header, probably containing definitions for DMA-BUF-specific I/O operations, considering the name. I need to locate it within the kernel source tree. Typically, I'd expect it to be in `include/linux/` or a related subdirectory, perhaps something more specific if it relates to a particular subsystem. I'm thinking it's probably *not* in `drivers/` directly. My mental map of the kernel's include structure suggests `include/linux/` is the most likely starting point. This header probably contains structures, inline functions, macros, and maybe some related types. I'm expecting to find declarations related to buffer sharing, synchronization primitives used with DMA-BUF, and, obviously, the I/O interface itself. I'll need to know where it resides within the broader DMA-BUF framework – is it core functionality, or associated with a particular consumer or producer? Knowing its location is the first step; then I can start digging into the details within. |
| 90/3 | 2026/10/07 02:09 | tool | grepper |
0mArgs:{
"Expression": "struct dma_buf_io_map",
"PathPrefixes": [
"include/linux/"
]
}Results: {
"Output": "include/linux/blk_types.h=210=struct bio {\n--\ninclude/linux/blk_types.h-238-\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\ninclude/linux/blk_types.h:239:\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\ninclude/linux/blk_types.h-240-\t};\n--\ninclude/linux/io_uring_types.h=13=struct io_uring_bpf_ops;\ninclude/linux/io_uring_types.h:14:struct dma_buf_io_map;\ninclude/linux/io_uring_types.h-15-\n--\ninclude/linux/io_uring_types.h=759=struct io_kiocb {\n--\ninclude/linux/io_uring_types.h-833-\tstruct io_wq_work\t\twork;\ninclude/linux/io_uring_types.h:834:\tstruct dma_buf_io_map\t\t*dmabuf_map;\ninclude/linux/io_uring_types.h-835-\n"
} |
| 91/3 | 2026/10/07 02:09 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29337 output: 20 thoughts: 18 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Locating the dma-buf-io.h Header** Okay, so I need to find the definition of `dma-buf-io.h`. Given my work with DMA buffers and I/O, this should be straightforward. I'm going to start by quickly checking the standard kernel include paths. If it's a core component, it should be in one of the usual suspects like `/include/linux/` or perhaps under `/drivers/dma-buf/`. I'll mentally prioritize those locations first. If it's a more project-specific or board-specific include, then I'll need to expand my search to include the relevant driver trees, but I doubt it. If I'm really stuck, `find` or `grep` will be my next best friend. The name itself suggests a core functionality, but I always approach this type of thing with a systematic approach. |
| 92/3 | 2026/10/07 02:09 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 287 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (17 files in total):\nblock/fops.c:5\ndrivers/dma-buf/dma-buf.c:2\ndrivers/iommu/iommufd/iommufd_private.h:2\ndrivers/iommu/iommufd/pages.c:6\ndrivers/iommu/iommufd/selftest.c:1\ndrivers/nvme/host/core.c:5\ndrivers/nvme/host/nvme.h:2\ndrivers/nvme/host/pci-dmabuf.c:21\ndrivers/nvme/host/pci-dmabuf.h:10\ndrivers/nvme/host/pci.c:4\ndrivers/vfio/pci/vfio_pci_dmabuf.c:2\ninclude/linux/blk_types.h:1\ninclude/linux/blkdev.h:2\ninclude/linux/io_uring_types.h:2\ninclude/linux/vfio_pci_core.h:1\nio_uring/dma-buf.c:2\nio_uring/dma-buf.h:4\n\nblock/fops.c=959=static int blkdev_mmap_prepare(struct vm_area_desc *desc)\n--\nblock/fops.c-968-\nblock/fops.c:969:static int blkdev_init_dma_buf_io_ctx(struct file *file,\nblock/fops.c:970:\t\t\t\t struct dma_buf_io_ctx *ctx)\nblock/fops.c-971-{\n--\nblock/fops.c-976-\t\treturn -EINVAL;\nblock/fops.c:977:\tif (!disk-\u003efops-\u003einit_dma_buf_io_ctx)\nblock/fops.c-978-\t\treturn -EOPNOTSUPP;\nblock/fops.c:979:\treturn disk-\u003efops-\u003einit_dma_buf_io_ctx(bdev, ctx);\nblock/fops.c-980-}\n--\nblock/fops.c=982=const struct file_operations def_blk_fops = {\n--\nblock/fops.c-999-\t.fop_flags\t= FOP_BUFFER_RASYNC | FOP_DONTCACHE,\nblock/fops.c:1000:\t.init_dma_buf_io_ctx = blkdev_init_dma_buf_io_ctx,\nblock/fops.c-1001-};\n--\ndrivers/dma-buf/dma-buf.c=492=static long dma_buf_import_sync_file(struct dma_buf *dmabuf,\n--\ndrivers/dma-buf/dma-buf.c-539-\ndrivers/dma-buf/dma-buf.c:540:static long dma_buf_ioctl(struct file *file,\ndrivers/dma-buf/dma-buf.c-541-\t\t\t unsigned int cmd, unsigned long arg)\n--\ndrivers/dma-buf/dma-buf.c=609=static const struct file_operations dma_buf_fops = {\n--\ndrivers/dma-buf/dma-buf.c-613-\t.poll\t\t= dma_buf_poll,\ndrivers/dma-buf/dma-buf.c:614:\t.unlocked_ioctl\t= dma_buf_ioctl,\ndrivers/dma-buf/dma-buf.c-615-\t.compat_ioctl\t= compat_ptr_ioctl,\n--\ndrivers/iommu/iommufd/iommufd_private.h=741=bool iommufd_selftest_is_mock_dev(struct device *dev);\ndrivers/iommu/iommufd/iommufd_private.h:742:int iommufd_test_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,\ndrivers/iommu/iommufd/iommufd_private.h-743-\t\t\t\t struct phys_vec *phys);\n--\ndrivers/iommu/iommufd/iommufd_private.h=765=static inline int\ndrivers/iommu/iommufd/iommufd_private.h:766:iommufd_test_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,\ndrivers/iommu/iommufd/iommufd_private.h-767-\t\t\t\t struct phys_vec *phys)\n--\ndrivers/iommu/iommufd/pages.c=1462=static int\ndrivers/iommu/iommufd/pages.c:1463:sym_vfio_pci_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,\ndrivers/iommu/iommufd/pages.c-1464-\t\t\t\t struct phys_vec *phys)\ndrivers/iommu/iommufd/pages.c-1465-{\ndrivers/iommu/iommufd/pages.c:1466:\ttypeof(\u0026vfio_pci_dma_buf_iommufd_map) fn;\ndrivers/iommu/iommufd/pages.c-1467-\tint rc;\ndrivers/iommu/iommufd/pages.c-1468-\ndrivers/iommu/iommufd/pages.c:1469:\trc = iommufd_test_dma_buf_iommufd_map(attachment, phys);\ndrivers/iommu/iommufd/pages.c-1470-\tif (rc != -EOPNOTSUPP)\n--\ndrivers/iommu/iommufd/pages.c-1475-\ndrivers/iommu/iommufd/pages.c:1476:\tfn = symbol_get(vfio_pci_dma_buf_iommufd_map);\ndrivers/iommu/iommufd/pages.c-1477-\tif (!fn)\n--\ndrivers/iommu/iommufd/pages.c-1479-\trc = fn(attachment, phys);\ndrivers/iommu/iommufd/pages.c:1480:\tsymbol_put(vfio_pci_dma_buf_iommufd_map);\ndrivers/iommu/iommufd/pages.c-1481-\treturn rc;\n--\ndrivers/iommu/iommufd/pages.c=1484=static int iopt_map_dmabuf(struct iommufd_ctx *ictx, struct iopt_pages *pages,\n--\ndrivers/iommu/iommufd/pages.c-1508-\ndrivers/iommu/iommufd/pages.c:1509:\trc = sym_vfio_pci_dma_buf_iommufd_map(attach, \u0026pages-\u003edmabuf.phys);\ndrivers/iommu/iommufd/pages.c-1510-\tif (rc)\n--\ndrivers/iommu/iommufd/selftest.c=1997=static const struct dma_buf_ops iommufd_test_dmabuf_ops = {\n--\ndrivers/iommu/iommufd/selftest.c-2004-\ndrivers/iommu/iommufd/selftest.c:2005:int iommufd_test_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,\ndrivers/iommu/iommufd/selftest.c-2006-\t\t\t\t struct phys_vec *phys)\n--\ndrivers/nvme/host/core.c=2702=static int nvme_report_zones(struct gendisk *disk, sector_t sector,\n--\ndrivers/nvme/host/core.c-2710-\ndrivers/nvme/host/core.c:2711:static int nvme_init_dma_buf_io_ctx(struct block_device *bdev,\ndrivers/nvme/host/core.c:2712:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/core.c-2713-{\n--\ndrivers/nvme/host/core.c-2716-\ndrivers/nvme/host/core.c:2717:\tif (!ctrl-\u003eops-\u003einit_dma_buf_io_ctx)\ndrivers/nvme/host/core.c-2718-\t\treturn -EINVAL;\ndrivers/nvme/host/core.c:2719:\treturn ctrl-\u003eops-\u003einit_dma_buf_io_ctx(ctrl, ctx);\ndrivers/nvme/host/core.c-2720-}\n--\ndrivers/nvme/host/core.c=2722=const struct block_device_operations nvme_bdev_ops = {\n--\ndrivers/nvme/host/core.c-2731-\t.pr_ops\t\t= \u0026nvme_pr_ops,\ndrivers/nvme/host/core.c:2732:\t.init_dma_buf_io_ctx = nvme_init_dma_buf_io_ctx,\ndrivers/nvme/host/core.c-2733-};\n--\ndrivers/nvme/host/nvme.h=651=struct nvme_ctrl_ops {\n--\ndrivers/nvme/host/nvme.h-670-\tbool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);\ndrivers/nvme/host/nvme.h:671:\tint (*init_dma_buf_io_ctx)(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/nvme.h:672:\t\t\t\t struct dma_buf_io_ctx *ctx);\ndrivers/nvme/host/nvme.h-673-\tunsigned long (*get_virt_boundary)(struct nvme_ctrl *ctrl, bool is_admin);\n--\ndrivers/nvme/host/pci-dmabuf.c=10=static void nvme_dmabuf_invalidate_mappings(struct dma_buf_attachment *attach)\ndrivers/nvme/host/pci-dmabuf.c-11-{\ndrivers/nvme/host/pci-dmabuf.c:12:\tstruct dma_buf_io_ctx *ctx = attach-\u003eimporter_priv;\ndrivers/nvme/host/pci-dmabuf.c-13-\ndrivers/nvme/host/pci-dmabuf.c:14:\tdma_buf_io_invalidate_mappings(ctx);\ndrivers/nvme/host/pci-dmabuf.c-15-}\n--\ndrivers/nvme/host/pci-dmabuf.c=17=static const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {\n--\ndrivers/nvme/host/pci-dmabuf.c-21-\ndrivers/nvme/host/pci-dmabuf.c:22:static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-23-{\ndrivers/nvme/host/pci-dmabuf.c-24-\tunsigned nr_entries = ctx-\u003edmabuf-\u003esize / NVME_CTRL_PAGE_SIZE;\ndrivers/nvme/host/pci-dmabuf.c:25:\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-26-\tstruct dma_buf_attachment *attach = nvme_ctx-\u003eattach;\n--\ndrivers/nvme/host/pci-dmabuf.c-65-\ndrivers/nvme/host/pci-dmabuf.c:66:\tret = dma_buf_io_init_map(ctx, \u0026map-\u003ebase, sgt);\ndrivers/nvme/host/pci-dmabuf.c-67-\tif (ret)\n--\ndrivers/nvme/host/pci-dmabuf.c-77-\ndrivers/nvme/host/pci-dmabuf.c:78:static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,\ndrivers/nvme/host/pci-dmabuf.c:79:\t\tstruct dma_buf_io_map *map_base)\ndrivers/nvme/host/pci-dmabuf.c-80-{\ndrivers/nvme/host/pci-dmabuf.c:81:\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-82-\tstruct nvme_dmabuf_map *map = to_nvme_dmabuf_map(map_base);\n--\ndrivers/nvme/host/pci-dmabuf.c-89-\ndrivers/nvme/host/pci-dmabuf.c:90:static void nvme_dma_buf_io_release(struct dma_buf_io_ctx *base_ctx)\ndrivers/nvme/host/pci-dmabuf.c-91-{\ndrivers/nvme/host/pci-dmabuf.c:92:\tstruct nvme_dma_buf_io_ctx *ctx = base_ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-93-\tstruct nvme_dma_buf_list *buf_list = ctx-\u003ebuf_list;\n--\ndrivers/nvme/host/pci-dmabuf.c=106=void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\ndrivers/nvme/host/pci-dmabuf.c-107-{\ndrivers/nvme/host/pci-dmabuf.c:108:\tstruct nvme_dma_buf_io_ctx *ctx, *tmp;\ndrivers/nvme/host/pci-dmabuf.c-109-\n--\ndrivers/nvme/host/pci-dmabuf.c-111-\tlist_for_each_entry_safe(ctx, tmp, \u0026list-\u003ectxs, list) {\ndrivers/nvme/host/pci-dmabuf.c:112:\t\tdma_buf_io_detach(ctx-\u003ebase);\ndrivers/nvme/host/pci-dmabuf.c-113-\t\tdma_buf_detach(ctx-\u003ebase-\u003edmabuf, ctx-\u003eattach);\n--\ndrivers/nvme/host/pci-dmabuf.c-118-\ndrivers/nvme/host/pci-dmabuf.c:119:const struct dma_buf_io_ops nvme_dma_buf_io_ops = {\ndrivers/nvme/host/pci-dmabuf.c:120:\t.map\t\t= nvme_dma_buf_io_map,\ndrivers/nvme/host/pci-dmabuf.c:121:\t.unmap\t\t= nvme_dma_buf_io_unmap,\ndrivers/nvme/host/pci-dmabuf.c:122:\t.release\t= nvme_dma_buf_io_release,\ndrivers/nvme/host/pci-dmabuf.c-123-};\n--\ndrivers/nvme/host/pci-dmabuf.c=125=static int nvme_init_io_ctx_locked(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.c-126-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.c:127:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-128-{\ndrivers/nvme/host/pci-dmabuf.c:129:\tstruct nvme_dma_buf_io_ctx *nvme_ctx;\ndrivers/nvme/host/pci-dmabuf.c-130-\tstruct dma_buf_attachment *attach;\n--\ndrivers/nvme/host/pci-dmabuf.c-149-\tctx-\u003edev_priv = nvme_ctx;\ndrivers/nvme/host/pci-dmabuf.c:150:\tctx-\u003edev_ops = \u0026nvme_dma_buf_io_ops;\ndrivers/nvme/host/pci-dmabuf.c-151-\treturn 0;\n--\ndrivers/nvme/host/pci-dmabuf.c-153-\ndrivers/nvme/host/pci-dmabuf.c:154:int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.c-155-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.c:156:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-157-{\n--\ndrivers/nvme/host/pci-dmabuf.h=13=struct nvme_dma_buf_list {\n--\ndrivers/nvme/host/pci-dmabuf.h-17-\ndrivers/nvme/host/pci-dmabuf.h:18:struct nvme_dma_buf_io_ctx {\ndrivers/nvme/host/pci-dmabuf.h-19-\tstruct dma_buf_attachment *attach;\ndrivers/nvme/host/pci-dmabuf.h-20-\tstruct nvme_dma_buf_list *buf_list;\ndrivers/nvme/host/pci-dmabuf.h:21:\tstruct dma_buf_io_ctx *base;\ndrivers/nvme/host/pci-dmabuf.h-22-\tstruct nvme_ctrl *ctrl;\n--\ndrivers/nvme/host/pci-dmabuf.h=26=struct nvme_dmabuf_map {\ndrivers/nvme/host/pci-dmabuf.h:27:\tstruct dma_buf_io_map base;\ndrivers/nvme/host/pci-dmabuf.h-28-\tstruct sg_table *sgt;\n--\ndrivers/nvme/host/pci-dmabuf.h=33=static inline struct nvme_dmabuf_map *to_nvme_dmabuf_map(\ndrivers/nvme/host/pci-dmabuf.h:34:\tstruct dma_buf_io_map *map)\ndrivers/nvme/host/pci-dmabuf.h-35-{\n--\ndrivers/nvme/host/pci-dmabuf.h=39=static inline struct nvme_dmabuf_map *nvme_req_to_map(struct request *req)\ndrivers/nvme/host/pci-dmabuf.h-40-{\ndrivers/nvme/host/pci-dmabuf.h:41:\tstruct dma_buf_io_map *map = req-\u003ebio-\u003ebi_dmabuf_map;\ndrivers/nvme/host/pci-dmabuf.h-42-\n--\ndrivers/nvme/host/pci-dmabuf.h=46=void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list);\ndrivers/nvme/host/pci-dmabuf.h:47:int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.h-48-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.h:49:\t\tstruct dma_buf_io_ctx *ctx);\ndrivers/nvme/host/pci-dmabuf.h-50-\ndrivers/nvme/host/pci-dmabuf.h=51=static inline void nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\n--\ndrivers/nvme/host/pci-dmabuf.h-56-\ndrivers/nvme/host/pci-dmabuf.h:57:static inline int nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.h-58-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.h:59:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.h-60-{\n--\ndrivers/nvme/host/pci-dmabuf.h-62-\t\treturn -EOPNOTSUPP;\ndrivers/nvme/host/pci-dmabuf.h:63:\treturn __nvme_init_dma_buf_io_ctx(ctrl, buf_list, ctx);\ndrivers/nvme/host/pci-dmabuf.h-64-}\n--\n\n"
} |
| 93/3 | 2026/10/07 02:10 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35050 output: 22 thoughts: 30 Thoughts: Okay, let's see. My first thought is: **Locating the DMA-BUF I/O Header** Alright, I need to get my bearings. I'm looking for the header file `linux/dma-buf-io.h`. But where exactly is it located within the kernel source tree? I need to quickly ascertain its path to understand its dependencies and how it's integrated within the DMA-BUF subsystem. Let's start the search... |
| 94/3 | 2026/10/07 02:10 | tool | grepper |
0mArgs:{
"Expression": "dma-buf-io\\.h"
}Results: {
"Output": "block/blk-merge.c-11-#include \u003clinux/blk-cgroup.h\u003e\nblock/blk-merge.c:12:#include \u003clinux/dma-buf-io.h\u003e\nblock/blk-merge.c-13-\n--\ndrivers/nvme/host/pci-dmabuf.h-8-\ndrivers/nvme/host/pci-dmabuf.h:9:#include \u003clinux/dma-buf-io.h\u003e\ndrivers/nvme/host/pci-dmabuf.h-10-\n--\nio_uring/dma-buf.h-4-\nio_uring/dma-buf.h:5:#include \u003clinux/dma-buf-io.h\u003e\nio_uring/dma-buf.h-6-#include \u003clinux/io_uring_types.h\u003e\n--\nio_uring/rsrc.c-12-#include \u003clinux/io_uring/cmd.h\u003e\nio_uring/rsrc.c:13:#include \u003clinux/dma-buf-io.h\u003e\nio_uring/rsrc.c-14-\n"
} |
| 95/3 | 2026/10/07 02:10 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35480 output: 39 thoughts: 28 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Analyzing DMA-BUF IO Implementation** Okay, first things first, `include/linux/dma-buf-io.h` *has* to be present within the kernel source tree. We wouldn't be here otherwise. Time to pull that header file up and get a clear picture of what's defined there. My mental model of DMA-BUF interaction hinges on a solid grasp of these data structures and function prototypes. This is the bedrock of understanding how DMA-BUF IO interacts with the larger system, the underlying primitives used for memory mapping, and any potential abstractions the kernel exposes for buffer management. I need to refresh my understanding of the fundamental building blocks and refresh my understanding of how they fit together. Let's see what we're working with here. |
| 96/3 | 2026/10/07 02:11 | tool | read-file |
0mError:the file does not exist Args: {
"File": "include/linux/dma-buf-io.h",
"FirstLine": 1,
"LineCount": 100
}Results: {
"error": "the file does not exist"
} |
| 97/3 | 2026/10/07 02:11 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35742 output: 31 thoughts: 32 Thoughts: Okay, here's my summary, tailored for an expert audience, in the first person, reflecting the described thought process: **Debugging a Missing Header File** Alright, that's odd. The system just spat back at me "the file does not exist". Classic. Okay, so instead of panicking, let's step back and diagnose. I need to figure out where this `dma-buf-io.h` is actually located on the system. Clearly, it's not where the compiler is expecting it. Since I don't have this memorized, it's `grepper` time. Let's fire that up and hunt it down. Hopefully, it's just a simple path issue, and a quick `-I` flag fix will resolve it. But hey, at least I know what's going on now. |
| 98/3 | 2026/10/07 02:11 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_map",
"PathPrefixes": [
"include/"
]
}Results: {
"Output": "include/linux/blk_types.h=210=struct bio {\n--\ninclude/linux/blk_types.h-238-\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\ninclude/linux/blk_types.h:239:\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\ninclude/linux/blk_types.h-240-\t};\n--\ninclude/linux/io_uring_types.h=13=struct io_uring_bpf_ops;\ninclude/linux/io_uring_types.h:14:struct dma_buf_io_map;\ninclude/linux/io_uring_types.h-15-\n--\ninclude/linux/io_uring_types.h=759=struct io_kiocb {\n--\ninclude/linux/io_uring_types.h-833-\tstruct io_wq_work\t\twork;\ninclude/linux/io_uring_types.h:834:\tstruct dma_buf_io_map\t\t*dmabuf_map;\ninclude/linux/io_uring_types.h-835-\n"
} |
| 99/3 | 2026/10/07 02:11 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36279 output: 23 thoughts: 160 Thoughts: Okay, let me quickly summarize what I'm thinking here. **Investigating Unexpected Header Inclusion** Hmm, that's odd. I just ran a `grep` for `dma-buf-io.h` and the results are showing up in places I wouldn't have immediately expected, specifically `block/blk-merge.c`, `drivers/nvme/host/pci-dmabuf.h`, and the `io_uring` directory. That's a little curious; I'd have thought its usage would be more tightly coupled to DMA-buf specific code. Let me double-check that by listing what files I have available in `include/linux/` that might be relevant. My next step is to get a better handle on the relevant include files. |
| 100/3 | 2026/10/07 02:12 | tool | grepper |
0mArgs:{
"Expression": "struct dma_buf_io_map"
}Results: {
"Output": "drivers/nvme/host/pci-dmabuf.c=17=static const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {\n--\ndrivers/nvme/host/pci-dmabuf.c-21-\ndrivers/nvme/host/pci-dmabuf.c:22:static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-23-{\n--\ndrivers/nvme/host/pci-dmabuf.c=78=static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,\ndrivers/nvme/host/pci-dmabuf.c:79:\t\tstruct dma_buf_io_map *map_base)\ndrivers/nvme/host/pci-dmabuf.c-80-{\n--\ndrivers/nvme/host/pci-dmabuf.h=26=struct nvme_dmabuf_map {\ndrivers/nvme/host/pci-dmabuf.h:27:\tstruct dma_buf_io_map base;\ndrivers/nvme/host/pci-dmabuf.h-28-\tstruct sg_table *sgt;\n--\ndrivers/nvme/host/pci-dmabuf.h=33=static inline struct nvme_dmabuf_map *to_nvme_dmabuf_map(\ndrivers/nvme/host/pci-dmabuf.h:34:\tstruct dma_buf_io_map *map)\ndrivers/nvme/host/pci-dmabuf.h-35-{\n--\ndrivers/nvme/host/pci-dmabuf.h=39=static inline struct nvme_dmabuf_map *nvme_req_to_map(struct request *req)\ndrivers/nvme/host/pci-dmabuf.h-40-{\ndrivers/nvme/host/pci-dmabuf.h:41:\tstruct dma_buf_io_map *map = req-\u003ebio-\u003ebi_dmabuf_map;\ndrivers/nvme/host/pci-dmabuf.h-42-\n--\ninclude/linux/blk_types.h=210=struct bio {\n--\ninclude/linux/blk_types.h-238-\t\t/* Driver specific dma map, valid IFF REQ_DMABUF is set */\ninclude/linux/blk_types.h:239:\t\tstruct dma_buf_io_map\t*bi_dmabuf_map;\ninclude/linux/blk_types.h-240-\t};\n--\ninclude/linux/io_uring_types.h=13=struct io_uring_bpf_ops;\ninclude/linux/io_uring_types.h:14:struct dma_buf_io_map;\ninclude/linux/io_uring_types.h-15-\n--\ninclude/linux/io_uring_types.h=759=struct io_kiocb {\n--\ninclude/linux/io_uring_types.h-833-\tstruct io_wq_work\t\twork;\ninclude/linux/io_uring_types.h:834:\tstruct dma_buf_io_map\t\t*dmabuf_map;\ninclude/linux/io_uring_types.h-835-\n--\nio_uring/dma-buf.h=25=static inline int io_attach_dmabuf_map(struct io_kiocb *req,\n--\nio_uring/dma-buf.h-29-\tbool nowait = issue_flags \u0026 IO_URING_F_NONBLOCK;\nio_uring/dma-buf.h:30:\tstruct dma_buf_io_map *map;\nio_uring/dma-buf.h-31-\tstruct io_buf_dma *bd;\n"
} |
| 101/3 | 2026/10/07 02:12 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37623 output: 21 thoughts: 44 Thoughts: Okay, let's see. My first thought is: **Where is this `dma-buf-io.h` header file in the 6.x Linux kernel include directories? I can't seem to find it!** That's odd. It should be there. Let's start with the basics. I need to quickly determine whether I'm missing something obvious. I'll need to check the Git logs to see if it was removed or renamed in recent releases, or if there's been some reorganization of the include paths. Maybe a `git status` check is in order, just to rule out local modifications that might be interfering with my search. If those don't pan out, I'll fall back to listing the contents of `include/linux` directly. That should give me a good, raw overview of what's *actually* present in the include tree and help me pinpoint if it's placed elsewhere. |
| 102/3 | 2026/10/07 02:12 | tool | codesearch-dir-index |
0mArgs:{
"Dir": "include/linux"
}Results: {
"Files": [
"8250_pci.h",
"acct.h",
"acpi.h",
"acpi_amd_wbrf.h",
"acpi_dma.h",
"acpi_iort.h",
"acpi_mdio.h",
"acpi_pmtmr.h",
"acpi_rimt.h",
"acpi_viot.h",
"adb.h",
"adfs_fs.h",
"adi-axi-common.h",
"adreno-smmu-priv.h",
"adxl.h",
"aer.h",
"agp_backend.h",
"agpgart.h",
"ahci-remap.h",
"ahci_platform.h",
"aio.h",
"alarmtimer.h",
"alcor_pci.h",
"align.h",
"alloc_tag.h",
"altera_jtaguart.h",
"altera_uart.h",
"amd-iommu.h",
"amd-pmf-io.h",
"annotate.h",
"anon_inodes.h",
"aperture.h",
"apm-emulation.h",
"apm_bios.h",
"apple-gmux.h",
"arch_topology.h",
"args.h",
"arm-cci.h",
"arm-smccc.h",
"arm_ffa.h",
"arm_mpam.h",
"arm_sdei.h",
"armada-37xx-rwtm-mailbox.h",
"array_size.h",
"ascii85.h",
"asn1.h",
"asn1_ber_bytecode.h",
"asn1_decoder.h",
"asn1_encoder.h",
"assoc_array.h",
"assoc_array_priv.h",
"async.h",
"async_tx.h",
"ata.h",
"ata_platform.h",
"atm.h",
"atmdev.h",
"atmel-isc-media.h",
"atmel-ssc.h",
"atmel_pdc.h",
"atomic.h",
"attribute_container.h",
"audit.h",
"audit_arch.h",
"auto_dev-ioctl.h",
"auto_fs.h",
"auxiliary_bus.h",
"auxvec.h",
"average.h",
"backing-dev-defs.h",
"backing-dev.h",
"backing-file.h",
"backlight.h",
"badblocks.h",
"balloon.h",
"base64.h",
"bcd.h",
"bch.h",
"bcm47xx_nvram.h",
"bcm47xx_sprom.h",
"bcm47xx_wdt.h",
"bcm963xx_nvram.h",
"bcm963xx_tag.h",
"binfmt_misc.h",
"binfmts.h",
"bio-integrity.h",
"bio.h",
"bit_spinlock.h",
"bitfield.h",
"bitmap-str.h",
"bitmap.h",
"bitops.h",
"bitrev.h",
"bits.h",
"blk-cgroup.h",
"blk-crypto-profile.h",
"blk-crypto.h",
"blk-integrity.h",
"blk-mq-dma.h",
"blk-mq.h",
"blk-pm.h",
"blk_plug.h",
"blk_types.h",
"blkdev.h",
"blkpg.h",
"blktrace_api.h",
"blockgroup_lock.h",
"bma150.h",
"bootconfig.h",
"bottom_half.h",
"bpf-cgroup-defs.h",
"bpf-cgroup.h",
"bpf-netns.h",
"bpf.h",
"bpf_crypto.h",
"bpf_defs.h",
"bpf_ksock.h",
"bpf_lirc.h",
"bpf_local_storage.h",
"bpf_lsm.h",
"bpf_mem_alloc.h",
"bpf_mprog.h",
"bpf_trace.h",
"bpf_types.h",
"bpf_verifier.h",
"bpfptr.h",
"brcmphy.h",
"bsearch.h",
"bsg-lib.h",
"bsg.h",
"btf.h",
"btf_ids.h",
"btree-128.h",
"btree-type.h",
"btree.h",
"btrfs.h",
"buffer_head.h",
"bug.h",
"build-salt.h",
"build_bug.h",
"buildid.h",
"bvec.h",
"c2port.h",
"cache.h",
"cache_coherency.h",
"cacheflush.h",
"cacheinfo.h",
"call_once.h",
"capability.h",
"cb710.h",
"cc_platform.h",
"cciss_ioctl.h",
"ccp.h",
"cdev.h",
"cdrom.h",
"cfag12864b.h",
"cfi.h",
"cfi_types.h",
"cgroup-defs.h",
"cgroup.h",
"cgroup_api.h",
"cgroup_dmem.h",
"cgroup_namespace.h",
"cgroup_rdma.h",
"cgroup_refcnt.h",
"cgroup_subsys.h",
"circ_buf.h",
"cleanup.h",
"clk-provider.h",
"clk.h",
"clkdev.h",
"clockchips.h",
"clocksource.h",
"clocksource_ids.h",
"closure.h",
"cma.h",
"cmpxchg-emu.h",
"cn_proc.h",
"cnum.h",
"coda.h",
"codetag.h",
"compaction.h",
"compat.h",
"compiler-clang.h",
"compiler-context-analysis.h",
"compiler-gcc.h",
"compiler-version.h",
"compiler.h",
"compiler_attributes.h",
"compiler_types.h",
"completion.h",
"component.h",
"configfs.h",
"connector.h",
"console.h",
"console_struct.h",
"consolemap.h",
"const.h",
"container.h",
"container_of.h",
"context_tracking.h",
"context_tracking_irq.h",
"context_tracking_state.h",
"cookie.h",
"cordic.h",
"coreboot.h",
"coredump.h",
"coresight-pmu.h",
"coresight-stm.h",
"coresight.h",
"count_zeros.h",
"counter.h",
"cper.h",
"cpu.h",
"cpu_cooling.h",
"cpu_pm.h",
"cpu_rmap.h",
"cpu_smt.h",
"cpufeature.h",
"cpufreq.h",
"cpuhotplug.h",
"cpuhplock.h",
"cpuidle.h",
"cpuidle_haltpoll.h",
"cpumask.h",
"cpumask_api.h",
"cpumask_types.h",
"cpuset.h",
"crash_core.h",
"crash_dump.h",
"crash_reserve.h",
"crc-ccitt.h",
"crc-itu-t.h",
"crc-t10dif.h",
"crc16.h",
"crc32.h",
"crc32c.h",
"crc32poly.h",
"crc4.h",
"crc64.h",
"crc7.h",
"crc8.h",
"cred.h",
"crypto.h",
"cs5535.h",
"ctype.h",
"cuda.h",
"damon.h",
"dasd_mod.h",
"davinci_emac.h",
"dax.h",
"dca.h",
"dcache.h",
"dccp.h",
"debug_locks.h",
"debugfs.h",
"debugobjects.h",
"delay.h",
"delayacct.h",
"delayed_call.h",
"designware_i2c.h",
"dev_printk.h",
"devcoredump.h",
"devfreq-event.h",
"devfreq-governor.h",
"devfreq.h",
"devfreq_cooling.h",
"device-mapper.h",
"device.h",
"device_cgroup.h",
"devm-helpers.h",
"devpts_fs.h",
"dfl.h",
"dibs.h",
"digsig.h",
"dim.h",
"dio.h",
"dirent.h",
"dlm.h",
"dlm_plock.h",
"dm-bufio.h",
"dm-dirty-log.h",
"dm-io.h",
"dm-kcopyd.h",
"dm-region-hash.h",
"dm-verity-loadpin.h",
"dm9000.h",
"dma-buf-mapping.h",
"dma-buf.h",
"dma-direct.h",
"dma-direction.h",
"dma-fence-array.h",
"dma-fence-chain.h",
"dma-fence-unwrap.h",
"dma-fence.h",
"dma-heap.h",
"dma-map-ops.h",
"dma-mapping.h",
"dma-resv.h",
"dmaengine.h",
"dmapool.h",
"dmar.h",
"dmi.h",
"dnotify.h",
"dns_resolver.h",
"dpll.h",
"dqblk_qtree.h",
"dqblk_v1.h",
"dqblk_v2.h",
"ds2782_battery.h",
"dtpm.h",
"dw_apb_timer.h",
"dynamic_debug.h",
"dynamic_queue_limits.h",
"earlycpio.h",
"ecryptfs.h",
"edac.h",
"edd.h",
"eeprom_93cx6.h",
"efi-bgrt.h",
"efi.h",
"efi_embedded_fw.h",
"ehl_pse_io_aux.h",
"eisa.h",
"elf-fdpic.h",
"elf-randomize.h",
"elf.h",
"elfcore-compat.h",
"elfcore.h",
"elfnote-lto.h",
"elfnote.h",
"enclosure.h",
"energy_model.h",
"entry-common.h",
"entry-virt.h",
"err.h",
"errname.h",
"errno.h",
"error-injection.h",
"errqueue.h",
"errseq.h",
"etherdevice.h",
"ethtool.h",
"ethtool_netlink.h",
"eventfd.h",
"eventpoll.h",
"evm.h",
"execmem.h",
"export-internal.h",
"export.h",
"exportfs.h",
"exportfs_block.h",
"ext2_fs.h",
"extable.h",
"extcon-provider.h",
"extcon.h",
"f2fs_fs.h",
"f75375s.h",
"falloc.h",
"fanotify.h",
"fault-inject-usercopy.h",
"fault-inject.h",
"fb.h",
"fcdevice.h",
"fcntl.h",
"fd.h",
"fddidevice.h",
"fdtable.h",
"fec.h",
"fiemap.h",
"file.h",
"file_ref.h",
"fileattr.h",
"filelock.h",
"filter.h",
"find.h",
"fips.h",
"firewire.h",
"firmware-map.h",
"firmware.h",
"fixp-arith.h",
"flat.h",
"flex_proportions.h",
"folio_batch.h",
"folio_queue.h",
"font.h",
"fortify-string.h",
"fprobe.h",
"fpu.h",
"freezer.h",
"fs.h",
"fs_api.h",
"fs_context.h",
"fs_dirent.h",
"fs_parser.h",
"fs_pin.h",
"fs_stack.h",
"fs_struct.h",
"fscache-cache.h",
"fscache.h",
"fscrypt.h",
"fserror.h",
"fsi-occ.h",
"fsi-sbefifo.h",
"fsi.h",
"fsl-diu-fb.h",
"fsl_devices.h",
"fsl_hypervisor.h",
"fsl_ifc.h",
"fsldma.h",
"fsnotify.h",
"fsnotify_backend.h",
"fsverity.h",
"ftrace.h",
"ftrace_irq.h",
"ftrace_regs.h",
"futex.h",
"futex_types.h",
"fw_table.h",
"fwctl.h",
"fwnode.h",
"fwnode_mdio.h",
"gameport.h",
"gcd.h",
"genalloc.h",
"generic-radix-tree.h",
"gfp.h",
"gfp_api.h",
"gfp_types.h",
"glob.h",
"gnss.h",
"goldfish.h",
"gpio-pxa.h",
"gpio.h",
"gpio_keys.h",
"gpu_buddy.h",
"greybus.h",
"group_cpus.h",
"hardirq.h",
"hash.h",
"hashtable.h",
"hashtable_api.h",
"hdlc.h",
"hdmi.h",
"hex.h",
"hfs_common.h",
"hid-debug.h",
"hid-over-i2c.h",
"hid-over-spi.h",
"hid-roccat.h",
"hid-sensor-hub.h",
"hid-sensor-ids.h",
"hid.h",
"hid_bpf.h",
"hidden.h",
"hiddev.h",
"hidraw.h",
"highmem-internal.h",
"highmem.h",
"highuid.h",
"hil.h",
"hil_mlc.h",
"hisi_acc_qm.h",
"hmm-dma.h",
"hmm.h",
"host1x.h",
"host1x_context_bus.h",
"hp_sdc.h",
"hpet.h",
"hrtimer.h",
"hrtimer_api.h",
"hrtimer_bases.h",
"hrtimer_rearm.h",
"hrtimer_types.h",
"hte.h",
"huge_mm.h",
"hugetlb.h",
"hugetlb_cgroup.h",
"hugetlb_inline.h",
"hung_task.h",
"hw_bitfield.h",
"hw_breakpoint.h",
"hw_random.h",
"hwmon-sysfs.h",
"hwmon-vid.h",
"hwmon.h",
"hwspinlock.h",
"hyperv.h",
"hypervisor.h",
"i2c-algo-bit.h",
"i2c-algo-pca.h",
"i2c-algo-pcf.h",
"i2c-atr.h",
"i2c-dev.h",
"i2c-mux.h",
"i2c-of-prober.h",
"i2c-smbus.h",
"i2c.h",
"i8042.h",
"i8253.h",
"i8254.h",
"icmp.h",
"icmpv6.h",
"idle_inject.h",
"idr.h",
"ieee80211-eht.h",
"ieee80211-he.h",
"ieee80211-ht.h",
"ieee80211-mesh.h",
"ieee80211-nan.h",
"ieee80211-p2p.h",
"ieee80211-s1g.h",
"ieee80211-uhr.h",
"ieee80211-vht.h",
"ieee80211.h",
"ieee802154.h",
"if_arp.h",
"if_bridge.h",
"if_eql.h",
"if_ether.h",
"if_fddi.h",
"if_hsr.h",
"if_link.h",
"if_macvlan.h",
"if_phonet.h",
"if_pppol2tp.h",
"if_pppox.h",
"if_rmnet.h",
"if_tap.h",
"if_team.h",
"if_tun.h",
"if_tunnel.h",
"if_vlan.h",
"igmp.h",
"ihex.h",
"ima.h",
"imx-media.h",
"in.h",
"in6.h",
"indirect_call_wrapper.h",
"inet.h",
"inet_diag.h",
"inetdevice.h",
"init.h",
"init_ohci1394_dma.h",
"init_syscalls.h",
"init_task.h",
"initrd.h",
"inotify.h",
"input.h",
"instruction_pointer.h",
"instrumentation.h",
"instrumented.h",
"int_log.h",
"integrity.h",
"intel-ish-client-if.h",
"intel_dg_nvm_aux.h",
"intel_pmt_features.h",
"intel_rapl.h",
"intel_tcc.h",
"intel_th.h",
"intel_tpmi.h",
"intel_vsec.h",
"interconnect-clk.h",
"interconnect-provider.h",
"interconnect.h",
"interrupt.h",
"interrupt_rc.h",
"interval_tree.h",
"interval_tree_generic.h",
"io-64-nonatomic-hi-lo.h",
"io-64-nonatomic-lo-hi.h",
"io-mapping.h",
"io-pgtable.h",
"io.h",
"io_uring.h",
"io_uring_types.h",
"ioam6.h",
"ioam6_genl.h",
"ioam6_iptunnel.h",
"iocontext.h",
"iomap.h",
"iommu-debug-pagealloc.h",
"iommu-dma.h",
"iommu-helper.h",
"iommu.h",
"iommufd.h",
"iopoll.h",
"ioport.h",
"ioprio.h",
"ioremap.h",
"iosys-map.h",
"iov_iter.h",
"iova.h",
"iova_bitmap.h",
"ip.h",
"ipack.h",
"ipc.h",
"ipc_namespace.h",
"ipmi.h",
"ipmi_smi.h",
"ipv6.h",
"ipv6_route.h",
"irq-entry-common.h",
"irq.h",
"irq_poll.h",
"irq_sim.h",
"irq_work.h",
"irq_work_types.h",
"irqbypass.h",
"irqchip.h",
"irqdesc.h",
"irqdomain.h",
"irqdomain_defs.h",
"irqflags.h",
"irqflags_types.h",
"irqhandler.h",
"irqnr.h",
"irqreturn.h",
"isa-dma.h",
"isa.h",
"isapnp.h",
"iscsi_boot_sysfs.h",
"iscsi_ibft.h",
"ism.h",
"iversion.h",
"jbd2.h",
"jhash.h",
"jiffies.h",
"journal-head.h",
"joystick.h",
"jump_label.h",
"jump_label_ratelimit.h",
"jz4780-nemc.h",
"kallsyms.h",
"kasan-checks.h",
"kasan-enabled.h",
"kasan-tags.h",
"kasan.h",
"kbd_diacr.h",
"kbd_kern.h",
"kbuild.h",
"kconfig.h",
"kcore.h",
"kcov.h",
"kcsan-checks.h",
"kcsan.h",
"kdb.h",
"kdebug.h",
"kdev_t.h",
"kern_levels.h",
"kernel-page-flags.h",
"kernel.h",
"kernel_read_file.h",
"kernel_stat.h",
"kernfs.h",
"kexec.h",
"kexec_handover.h",
"key-type.h",
"key.h",
"keyboard.h",
"keyctl.h",
"kfence.h",
"kfifo.h",
"kgdb.h",
"kho_block.h",
"kho_radix_tree.h",
"khugepaged.h",
"klist.h",
"kmemleak.h",
"kmod.h",
"kmsan-checks.h",
"kmsan.h",
"kmsan_string.h",
"kmsan_types.h",
"kmsg_dump.h",
"kobj_map.h",
"kobject.h",
"kobject_api.h",
"kobject_ns.h",
"kprobes.h",
"kref.h",
"kref_api.h",
"ks0108.h",
"ks8842.h",
"ksm.h",
"kstack_erase.h",
"kstrtox.h",
"ksysfs.h",
"kthread.h",
"ktime.h",
"ktime_api.h",
"kvm_dirty_ring.h",
"kvm_host.h",
"kvm_irqfd.h",
"kvm_para.h",
"kvm_types.h",
"l2tp.h",
"landlock.h",
"lantiq.h",
"lapb.h",
"latencytop.h",
"lcd.h",
"lcm.h",
"leafops.h",
"led-class-flash.h",
"led-class-multicolor.h",
"led-lm3530.h",
"leds-bd2802.h",
"leds-expresswire.h",
"leds-lp3944.h",
"leds-lp3952.h",
"leds-pca9532.h",
"leds-regulator.h",
"leds-ti-lmu-common.h",
"leds.h",
"libata.h",
"libfdt.h",
"libfdt_env.h",
"libgcc.h",
"libnvdimm.h",
"libps2.h",
"license.h",
"limits.h",
"linear_range.h",
"linkage.h",
"linkmode.h",
"linux_logo.h",
"lis3lv02d.h",
"list.h",
"list_bl.h",
"list_lru.h",
"list_nulls.h",
"list_private.h",
"list_sort.h",
"litex.h",
"livepatch.h",
"livepatch_external.h",
"livepatch_helpers.h",
"livepatch_sched.h",
"liveupdate.h",
"llc.h",
"llist.h",
"llist_api.h",
"local_lock.h",
"local_lock_internal.h",
"lockdep.h",
"lockdep_api.h",
"lockdep_types.h",
"lockref.h",
"log2.h",
"logic_iomem.h",
"logic_pio.h",
"lp.h",
"lru_cache.h",
"lsm_audit.h",
"lsm_count.h",
"lsm_hook_defs.h",
"lsm_hooks.h",
"lwq.h",
"lz4.h",
"lzo.h",
"mailbox_client.h",
"mailbox_controller.h",
"maple.h",
"maple_tree.h",
"marvell_phy.h",
"math.h",
"math64.h",
"mbcache.h",
"mbus.h",
"mc146818rtc.h",
"mc33xs2410.h",
"mc6821.h",
"mcb.h",
"mdev.h",
"mdio-bitbang.h",
"mdio-mux.h",
"mdio.h",
"mei_aux.h",
"mei_cl_bus.h",
"mem_encrypt.h",
"memblock.h",
"memcontrol.h",
"memfd.h",
"memory-failure.h",
"memory-tiers.h",
"memory.h",
"memory_hotplug.h",
"mempolicy.h",
"mempool.h",
"memregion.h",
"memremap.h",
"memstick.h",
"mhi.h",
"mhi_ep.h",
"micrel_phy.h",
"microchipphy.h",
"migrate.h",
"migrate_mode.h",
"mii.h",
"mii_timestamper.h",
"min_heap.h",
"minmax.h",
"misc_cgroup.h",
"miscdevice.h",
"mm.h",
"mm_api.h",
"mm_inline.h",
"mm_types.h",
"mm_types_task.h",
"mman.h",
"mmap_lock.h",
"mmdebug.h",
"mmiotrace.h",
"mmu_context.h",
"mmu_notifier.h",
"mmzone.h",
"mnt_idmapping.h",
"mnt_namespace.h",
"mod_devicetable.h",
"module.h",
"module_signature.h",
"module_symbol.h",
"moduleloader.h",
"moduleparam.h",
"most.h",
"mount.h",
"moxtet.h",
"mpage.h",
"mpi.h",
"mpls.h",
"mpls_iptunnel.h",
"mroute.h",
"mroute6.h",
"mroute_base.h",
"msdos_fs.h",
"msdos_partition.h",
"msg.h",
"msi.h",
"msi_api.h",
"mtio.h",
"mutex.h",
"mutex_api.h",
"mutex_types.h",
"mv643xx_eth.h",
"mv643xx_i2c.h",
"mvebu-pmsu.h",
"mxm-wmi.h",
"namei.h",
"nd.h",
"ndctl.h",
"net.h",
"net_tstamp.h",
"netdev_features.h",
"netdevice.h",
"netdevice_xmit.h",
"netfilter.h",
"netfilter_bridge.h",
"netfilter_defs.h",
"netfilter_ipv4.h",
"netfilter_ipv6.h",
"netfilter_netdev.h",
"netfs.h",
"netlink.h",
"netpoll.h",
"nfs.h",
"nfs3.h",
"nfs4.h",
"nfs_common.h",
"nfs_fs.h",
"nfs_fs_i.h",
"nfs_fs_sb.h",
"nfs_iostat.h",
"nfs_page.h",
"nfs_ssc.h",
"nfs_xdr.h",
"nfsacl.h",
"nfslocalio.h",
"nitro_enclaves.h",
"nl802154.h",
"nls.h",
"nmi.h",
"node.h",
"nodemask.h",
"nodemask_types.h",
"nospec.h",
"notifier.h",
"ns_common.h",
"nsc_gpio.h",
"nsfs.h",
"nsproxy.h",
"nstree.h",
"ntb.h",
"ntb_transport.h",
"nubus.h",
"numa.h",
"numa_memblks.h",
"nvme-auth.h",
"nvme-fc-driver.h",
"nvme-fc.h",
"nvme-keyring.h",
"nvme-rdma.h",
"nvme-tcp.h",
"nvme.h",
"nvmem-consumer.h",
"nvmem-provider.h",
"nvram.h",
"oa_tc6.h",
"objagg.h",
"objpool.h",
"objtool.h",
"objtool_types.h",
"of.h",
"of_address.h",
"of_clk.h",
"of_device.h",
"of_dma.h",
"of_fdt.h",
"of_graph.h",
"of_iommu.h",
"of_irq.h",
"of_mdio.h",
"of_net.h",
"of_pci.h",
"of_pdt.h",
"of_platform.h",
"of_reserved_mem.h",
"oid_registry.h",
"olpc-ec.h",
"omap-dma.h",
"omap-gpmc.h",
"omap-iommu.h",
"omap-mailbox.h",
"omapfb.h",
"once.h",
"once_lite.h",
"oom.h",
"openvswitch.h",
"osq_lock.h",
"overflow.h",
"packing.h",
"padata.h",
"page-flags-layout.h",
"page-flags.h",
"page-isolation.h",
"page_counter.h",
"page_ext.h",
"page_frag_cache.h",
"page_idle.h",
"page_owner.h",
"page_ref.h",
"page_reporting.h",
"page_table_check.h",
"pageblock-flags.h",
"pagemap.h",
"pagewalk.h",
"panic.h",
"panic_notifier.h",
"papr_scm.h",
"parman.h",
"parport.h",
"parport_pc.h",
"parser.h",
"part_stat.h",
"pata_arasan_cf_data.h",
"patchkey.h",
"path.h",
"pch_dma.h",
"pci-acpi.h",
"pci-ats.h",
"pci-bwctrl.h",
"pci-doe.h",
"pci-ecam.h",
"pci-ep-cfs.h",
"pci-ep-msi.h",
"pci-epc.h",
"pci-epf.h",
"pci-ide.h",
"pci-p2pdma.h",
"pci-pwrctrl.h",
"pci-tph.h",
"pci-tsm.h",
"pci.h",
"pci_hotplug.h",
"pci_ids.h",
"pcie-dwc.h",
"pcs-lynx.h",
"pcs-rzn1-miic.h",
"pe.h",
"peci-cpu.h",
"peci.h",
"percpu-defs.h",
"percpu-refcount.h",
"percpu-rwsem.h",
"percpu.h",
"percpu_counter.h",
"perf_event.h",
"perf_event_api.h",
"perf_regs.h",
"personality.h",
"pfn.h",
"pgalloc.h",
"pgalloc_tag.h",
"pgtable.h",
"pgtable_api.h",
"phonet.h",
"phy.h",
"phy_fixed.h",
"phy_led_triggers.h",
"phy_link_topology.h",
"phy_port.h",
"phylib_stubs.h",
"phylink.h",
"pid.h",
"pid_namespace.h",
"pid_types.h",
"pidfs.h",
"pim.h",
"pipe_fs_i.h",
"pkeys.h",
"pl320-ipc.h",
"platform_device.h",
"platform_profile.h",
"pldmfw.h",
"plist.h",
"plist_types.h",
"pm-trace.h",
"pm.h",
"pm_clock.h",
"pm_domain.h",
"pm_opp.h",
"pm_qos.h",
"pm_runtime.h",
"pm_wakeirq.h",
"pm_wakeup.h",
"pmbus.h",
"pmu.h",
"pnp.h",
"poison.h",
"poll.h",
"polynomial.h",
"posix-clock.h",
"posix-timers.h",
"posix-timers_types.h",
"posix_acl.h",
"posix_acl_xattr.h",
"power_supply.h",
"powercap.h",
"ppp-comp.h",
"ppp_channel.h",
"ppp_defs.h",
"pps_gen_kernel.h",
"pps_kernel.h",
"pr.h",
"prandom.h",
"preempt.h",
"prefetch.h",
"prime_numbers.h",
"printk.h",
"prmt.h",
"proc_fs.h",
"proc_ns.h",
"processor.h",
"profile.h",
"projid.h",
"property.h",
"pruss_driver.h",
"psci.h",
"pseudo_fs.h",
"psi.h",
"psi_types.h",
"psp-platform-access.h",
"psp-sev.h",
"psp-tee.h",
"psp.h",
"pstore.h",
"pstore_blk.h",
"pstore_ram.h",
"pstore_zone.h",
"ptdump.h",
"pti.h",
"ptp_classify.h",
"ptp_clock_kernel.h",
"ptp_kvm.h",
"ptp_mock.h",
"ptp_pch.h",
"ptr_ring.h",
"ptrace.h",
"ptrace_api.h",
"purgatory.h",
"pvclock_gtod.h",
"pwm.h",
"pwm_backlight.h",
"pxa168_eth.h",
"pxa2xx_ssp.h",
"qnx6_fs.h",
"quota.h",
"quotaops.h",
"radix-tree.h",
"raid_class.h",
"ramfs.h",
"random.h",
"randomize_kstack.h",
"range.h",
"ras.h",
"ratelimit.h",
"ratelimit_types.h",
"rational.h",
"rbtree.h",
"rbtree_augmented.h",
"rbtree_latch.h",
"rbtree_types.h",
"rcu_node_tree.h",
"rcu_notifier.h",
"rcu_segcblist.h",
"rcu_sync.h",
"rculist.h",
"rculist_bl.h",
"rculist_nulls.h",
"rcupdate.h",
"rcupdate_trace.h",
"rcupdate_wait.h",
"rcuref.h",
"rcutiny.h",
"rcutree.h",
"rcuwait.h",
"rcuwait_api.h",
"reboot-mode.h",
"reboot.h",
"reciprocal_div.h",
"ref_tracker.h",
"refcount.h",
"refcount_api.h",
"refcount_types.h",
"regmap.h",
"regset.h",
"relay.h",
"remoteproc.h",
"resctrl.h",
"resctrl_types.h",
"reset-controller.h",
"reset.h",
"resource.h",
"resource_ext.h",
"restart_block.h",
"resume_user_mode.h",
"rethook.h",
"rfkill.h",
"rhashtable-types.h",
"rhashtable.h",
"ring_buffer.h",
"ring_buffer_types.h",
"rio.h",
"rio_drv.h",
"rio_ids.h",
"rio_regs.h",
"rmap.h",
"rmi.h",
"rndis.h",
"rodata_test.h",
"rolling_buffer.h",
"root_dev.h",
"rpmb.h",
"rpmsg.h",
"rsc_table.h",
"rseq.h",
"rseq_entry.h",
"rseq_types.h",
"rslib.h",
"rtc.h",
"rtmutex.h",
"rtnetlink.h",
"rtsx_common.h",
"rtsx_pci.h",
"rtsx_usb.h",
"rv.h",
"rw_hint.h",
"rwbase_rt.h",
"rwlock.h",
"rwlock_api_smp.h",
"rwlock_rt.h",
"rwlock_types.h",
"rwsem.h",
"sbitmap.h",
"scatterlist.h",
"sched.h",
"sched_clock.h",
"scmi_imx_protocol.h",
"scmi_protocol.h",
"scpi_protocol.h",
"screen_info.h",
"scs.h",
"sctp.h",
"scx200.h",
"scx200_gpio.h",
"seccomp.h",
"seccomp_types.h",
"secretmem.h",
"secure_boot.h",
"securebits.h",
"security.h",
"sed-opal-key.h",
"sed-opal.h",
"seg6.h",
"seg6_genl.h",
"seg6_hmac.h",
"seg6_iptunnel.h",
"seg6_local.h",
"selection.h",
"sem.h",
"sem_types.h",
"semaphore.h",
"seq_buf.h",
"seq_file.h",
"seq_file_net.h",
"seqlock.h",
"seqlock_api.h",
"seqlock_types.h",
"serdev.h",
"serial.h",
"serial_8250.h",
"serial_bcm63xx.h",
"serial_core.h",
"serial_s3c.h",
"serial_sci.h",
"serio.h",
"set_memory.h",
"sfp.h",
"sh_clk.h",
"sh_dma.h",
"sh_eth.h",
"sh_intc.h",
"sh_timer.h",
"shdma-base.h",
"shm.h",
"shmem_fs.h",
"shrinker.h",
"signal.h",
"signal_types.h",
"signalfd.h",
"simple_ring_buffer.h",
"siox.h",
"siphash.h",
"sizes.h",
"skb_array.h",
"skbuff.h",
"skbuff_ref.h",
"skmsg.h",
"slab.h",
"slimbus.h",
"sm501-regs.h",
"sm501.h",
"smbdirect.h",
"smc91x.h",
"smp.h",
"smp_types.h",
"smpboot.h",
"smsc911x.h",
"smscphy.h",
"sock_diag.h",
"socket.h",
"sockptr.h",
"softirq.h",
"sonypi.h",
"sort.h",
"sound.h",
"soundcard.h",
"spinlock.h",
"spinlock_api.h",
"spinlock_api_smp.h",
"spinlock_api_up.h",
"spinlock_rt.h",
"spinlock_types.h",
"spinlock_types_raw.h",
"spinlock_types_up.h",
"spinlock_up.h",
"splice.h",
"spmi.h",
"sprintf.h",
"sram.h",
"srcu.h",
"srcutiny.h",
"srcutree.h",
"ssbi.h",
"stackdepot.h",
"stackprotector.h",
"stacktrace.h",
"start_kernel.h",
"stat.h",
"statfs.h",
"static_call.h",
"static_call_types.h",
"static_key.h",
"stdarg.h",
"stddef.h",
"stm.h",
"stmmac.h",
"stmp3xxx_rtc_wdt.h",
"stmp_device.h",
"stop_machine.h",
"string.h",
"string_choices.h",
"string_helpers.h",
"stringhash.h",
"stringify.h",
"sungem_phy.h",
"sunserialcore.h",
"sunxi-rsb.h",
"surface_acpi_notify.h",
"suspend.h",
"svga.h",
"sw842.h",
"swab.h",
"swait.h",
"swait_api.h",
"swap.h",
"swap_ops.h",
"swapfile.h",
"swapops.h",
"swiotlb.h",
"switchtec.h",
"sxgbe_platform.h",
"sync_core.h",
"sync_file.h",
"sys.h",
"sys_info.h",
"sys_soc.h",
"syscall_user_dispatch.h",
"syscall_user_dispatch_types.h",
"syscalls.h",
"syscalls_api.h",
"syscore_ops.h",
"sysctl.h",
"sysfb.h",
"sysfs.h",
"syslog.h",
"sysrq.h",
"t10-pi.h",
"task_io_accounting.h",
"task_io_accounting_ops.h",
"task_work.h",
"taskstats_kern.h",
"tboot.h",
"tc.h",
"tcp.h",
"tee_core.h",
"tee_drv.h",
"tegra-icc.h",
"tegra-mipi-cal.h",
"termios_internal.h",
"text-patching.h",
"textsearch.h",
"textsearch_fsm.h",
"thermal.h",
"thread_info.h",
"threads.h",
"thunderbolt.h",
"ti-emif-sram.h",
"ti_wilink_st.h",
"tick.h",
"tifm.h",
"timb_dma.h",
"time.h",
"time32.h",
"time64.h",
"time_namespace.h",
"timecounter.h",
"timekeeper_internal.h",
"timekeeping.h",
"timer.h",
"timer_types.h",
"timerfd.h",
"timeriomem-rng.h",
"timerqueue.h",
"timerqueue_types.h",
"timex.h",
"tnum.h",
"topology.h",
"torture.h",
"toshiba.h",
"tpm.h",
"tpm_buf.h",
"tpm_command.h",
"tpm_eventlog.h",
"tpm_ptp.h",
"tpm_svsm.h",
"trace.h",
"trace_clock.h",
"trace_events.h",
"trace_printk.h",
"trace_recursion.h",
"trace_remote.h",
"trace_remote_event.h",
"trace_seq.h",
"tracefs.h",
"tracepoint-defs.h",
"tracepoint.h",
"transport_class.h",
"ts-nbus.h",
"tsacct_kern.h",
"tsm-mr.h",
"tsm.h",
"tty.h",
"tty_buffer.h",
"tty_driver.h",
"tty_flip.h",
"tty_ldisc.h",
"tty_port.h",
"turris-omnia-mcu-interface.h",
"turris-signing-key.h",
"typecheck.h",
"types.h",
"u64_stats_sync.h",
"u64_stats_sync_api.h",
"uacce.h",
"uaccess.h",
"ubsan.h",
"ucopysize.h",
"ucs2_string.h",
"udp.h",
"uidgid.h",
"uidgid_types.h",
"uio.h",
"uio_driver.h",
"umh.h",
"unaligned.h",
"unicode.h",
"union_find.h",
"units.h",
"unroll.h",
"unwind_deferred.h",
"unwind_deferred_types.h",
"unwind_user.h",
"unwind_user_types.h",
"uprobes.h",
"usb.h",
"usb_usual.h",
"usbdevice_fs.h",
"user-return-notifier.h",
"user.h",
"user_events.h",
"user_namespace.h",
"userfaultfd_k.h",
"util_macros.h",
"uts.h",
"uts_namespace.h",
"utsname.h",
"uuid.h",
"vbox_utils.h",
"vdpa.h",
"vdso_datastore.h",
"verification.h",
"vermagic.h",
"vexpress.h",
"vfio.h",
"vfio_pci_core.h",
"vfs.h",
"vfsdebug.h",
"vga_switcheroo.h",
"vgaarb.h",
"vhost_iotlb.h",
"via-core.h",
"via.h",
"via_i2c.h",
"videodev2.h",
"virtio.h",
"virtio_anchor.h",
"virtio_byteorder.h",
"virtio_config.h",
"virtio_dma_buf.h",
"virtio_features.h",
"virtio_net.h",
"virtio_pci_admin.h",
"virtio_pci_legacy.h",
"virtio_pci_modern.h",
"virtio_ring.h",
"virtio_vsock.h",
"vm_event_item.h",
"vmalloc.h",
"vmcore_info.h",
"vmpressure.h",
"vmstat.h",
"vmw_vmci_api.h",
"vmw_vmci_defs.h",
"vringh.h",
"vt.h",
"vt_buffer.h",
"vt_kern.h",
"vtime.h",
"w1.h",
"wait.h",
"wait_api.h",
"wait_bit.h",
"watch_queue.h",
"watchdog.h",
"win_minmax.h",
"wireless.h",
"wkup_m3_ipc.h",
"wm97xx.h",
"wmi.h",
"wordpart.h",
"workqueue.h",
"workqueue_api.h",
"workqueue_types.h",
"writeback.h",
"ww_mutex.h",
"wwan.h",
"xarray.h",
"xattr.h",
"xxhash.h",
"xz.h",
"zconf.h",
"zlib.h",
"zorro.h",
"zsmalloc.h",
"zstd.h",
"zstd_errors.h",
"zstd_lib.h",
"zswap.h",
"zutil.h"
],
"Subdirs": [
"amba",
"atomic",
"bcma",
"bnge",
"bnxt",
"bus",
"byteorder",
"can",
"cdx",
"ceph",
"clk",
"comedi",
"crush",
"decompress",
"device",
"device-id",
"dma",
"dsa",
"extcon",
"firmware",
"fpga",
"framer",
"fs",
"fsl",
"generic_pt",
"gpio",
"greybus",
"habanalabs",
"hsi",
"i3c",
"iio",
"input",
"io_uring",
"irqchip",
"kho",
"lockd",
"lsm",
"mailbox",
"mdio",
"memory",
"mfd",
"misc",
"mlx4",
"mlx5",
"mmc",
"mtd",
"mux",
"net",
"netfilter",
"netfilter_arp",
"netfilter_bridge",
"netfilter_ipv4",
"netfilter_ipv6",
"ns",
"pcs",
"pds",
"perf",
"phy",
"pinctrl",
"platform_data",
"power",
"pse-pd",
"pwrseq",
"qat",
"qed",
"raid",
"raspberrypi",
"regulator",
"remoteproc",
"reset",
"rpmsg",
"rtc",
"sched",
"soc",
"soundwire",
"spi",
"ssb",
"sunrpc",
"surface_aggregator",
"ulpi",
"unaligned",
"usb"
]
} |
| 103/3 | 2026/10/07 02:12 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 50973 output: 24 thoughts: 109 Thoughts: **Investigating the Missing DMA-BUF IO Header** Alright, hold on a second. I was just reviewing the `include/linux/` directory, specifically looking at the DMA-BUF-related headers. I see `dma-buf.h` and `dma-buf-mapping.h`, as expected. But... where's `dma-buf-io.h`? That's immediately a red flag. It feels like there should be one, given the other two. This is peculiar, because I just ran a `grep` and it showed an include of `<linux/dma-buf-io.h>` in `block/blk-merge.c`. That's not supposed to happen! It's like a phantom file. Okay, deep breath. Let's dig deeper. The first thing I need to do is to find out where `dma_buf_io_init_map` is defined. Clearly that will give a clear direction. Gotta start searching the codebase for that declaration. I need to get to the bottom of this. This feels like a build or kernel configuration anomaly. |
| 104/3 | 2026/10/07 02:12 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_init_map"
}Results: {
"Output": "drivers/nvme/host/pci-dmabuf.c=22=static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\n--\ndrivers/nvme/host/pci-dmabuf.c-65-\ndrivers/nvme/host/pci-dmabuf.c:66:\tret = dma_buf_io_init_map(ctx, \u0026map-\u003ebase, sgt);\ndrivers/nvme/host/pci-dmabuf.c-67-\tif (ret)\n"
} |
| 105/3 | 2026/10/07 02:12 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51501 output: 32 thoughts: 153 Thoughts: **Investigating the Declaration of `dma_buf_io_init_map`** Okay, so I'm trying to figure out where `dma_buf_io_init_map` is actually declared or defined. My initial instinct is to go straight for `git log` to find the commit that introduced it, a pretty standard debugging practice. But hang on, this environment isn't set up for a full `git` experience. I need to remember what tools I *do* have at my disposal – ah yes, `grepper`, `codesearch-dir-index`, and `read-file`. Wait, the `read-file include/linux/dma-buf-io.h` command failed? That's odd. Let me pivot slightly. It looks like I need to verify that file exists. Alright, let's broaden the search a bit. Let's start with a wider search for files matching a pattern related to DMA buffer I/O. I need to find something like `*dma-buf-io*` and see if anything like that surfaces. Okay, let's step back a bit and think about the broader context to find the declaration of this function. I'll need to figure out where the related structs might be defined. A quick way to find the relevant declarations would be to `grep` for `dma_buf_io_ctx` across all the header files. That should give me a good starting point. |
| 106/3 | 2026/10/07 02:12 | tool | grepper |
0mArgs:{
"Expression": "struct dma_buf_io_ctx",
"PathPrefixes": [
"include/"
]
}Results: {
"Output": "include/linux/blkdev.h=1577=struct block_device_operations {\n--\ninclude/linux/blkdev.h-1602-\tint (*init_dma_buf_io_ctx)(struct block_device *,\ninclude/linux/blkdev.h:1603:\t\t\t\t struct dma_buf_io_ctx *);\ninclude/linux/blkdev.h-1604-\tstruct module *owner;\n"
} |
| 107/3 | 2026/10/07 02:12 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 52116 output: 24 thoughts: 34 Thoughts: Here's my thought process, as if I were thinking it:
**Digging into DMA Buffer I/O Context**
Okay, hold on a second. I need to understand how the DMA buffer I/O context is structured. I need to see the definition for `struct dma_buf_io_ctx`. It's essential to understand the data members and their relationships for any real analysis. Where is it actually declared? I've used it before, I should know!
Alright, time to crack out the `grep`. Let me search the codebase directly. A simple `grep 'struct dma_buf_io_ctx {'` should do the trick. That should quickly locate the header file where this structure is defined. From there, I can move onto my analysis.
|
| 108/3 | 2026/10/07 02:13 | tool | grepper |
0mError:no matches Args: {
"Expression": "struct dma_buf_io_ctx \\{"
}Results: {
"error": "no matches"
} |
| 109/3 | 2026/10/07 02:13 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 52352 output: 24 thoughts: 263 Thoughts: **Investigating the Missing `dma_buf_io_ctx` Structure**
Okay, hold on a second. I just tried grepping for `struct dma_buf_io_ctx {`, and came up with nothing. That's strange. My immediate thought is, did I misspell something? Or maybe I'm in the wrong directory, though I'm pretty sure I checked that.
Wait a minute, does `include/linux/dma-buf-io.h` even *exist* in the working tree? Could it be something untracked, or maybe even something that was removed in a prior commit? I need to clarify what the situation is.
Aha! Hang on... I need to *actually* read the prompt. Oh, right, this is a review. It says "applied patch under review". *Let me look at the commit message*. Right, the commit is `94b94c945655f70393579916fdfa996691884372`. Okay, let's see the diff.
The prompt says it's including `#include <linux/dma-buf-io.h>` in `block/blk-merge.c`, `drivers/nvme/host/pci-dmabuf.h`, `io_uring/dma-buf.h`, and `io_uring/rsrc.c`. So why the heck wasn't that header showing up in my grep, or even in my tree? This is really odd.
Okay, is it *actually* in the kernel? I am now betting it's in a subdirectory. Let's start with the obvious and check `drivers/dma-buf/`.
|
| 110/3 | 2026/10/07 02:13 | tool | codesearch-dir-index |
0mArgs:{
"Dir": "drivers/dma-buf"
}Results: {
"Files": [
"dma-buf-mapping.c",
"dma-buf.c",
"dma-fence-array.c",
"dma-fence-chain.c",
"dma-fence-unwrap.c",
"dma-fence.c",
"dma-heap.c",
"dma-resv.c",
"st-dma-fence-chain.c",
"st-dma-fence-unwrap.c",
"st-dma-fence.c",
"st-dma-resv.c",
"sw_sync.c",
"sync_debug.c",
"sync_debug.h",
"sync_file.c",
"sync_trace.h",
"udmabuf.c"
],
"Subdirs": [
"heaps"
]
} |
| 111/3 | 2026/10/07 02:13 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53220 output: 22 thoughts: 31 Thoughts: Here's my thought process, as if I were thinking it: **Digging into `dma_buf_io_ctx`** Okay, hold on a second... where *exactly* is `dma_buf_io_ctx` defined? I need to quickly refresh my memory on the context of that structure. Time to run a quick `grep` to find its definition. I'll search for `dma_buf_io_ctx` and see what comes up. That should pinpoint the header file and, by extension, the relevant kernel subsystem. I need to understand its relationship to the broader DMA-BUF infrastructure, so I'm looking for the source that defines it. This is a common debugging technique - I can refresh my memory on the context of the struct. Let's see what the results tell us. |
| 112/3 | 2026/10/07 02:14 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_ctx"
}Results: {
"Output": "block/fops.c=959=static int blkdev_mmap_prepare(struct vm_area_desc *desc)\n--\nblock/fops.c-968-\nblock/fops.c:969:static int blkdev_init_dma_buf_io_ctx(struct file *file,\nblock/fops.c:970:\t\t\t\t struct dma_buf_io_ctx *ctx)\nblock/fops.c-971-{\n--\nblock/fops.c-976-\t\treturn -EINVAL;\nblock/fops.c:977:\tif (!disk-\u003efops-\u003einit_dma_buf_io_ctx)\nblock/fops.c-978-\t\treturn -EOPNOTSUPP;\nblock/fops.c:979:\treturn disk-\u003efops-\u003einit_dma_buf_io_ctx(bdev, ctx);\nblock/fops.c-980-}\n--\nblock/fops.c=982=const struct file_operations def_blk_fops = {\n--\nblock/fops.c-999-\t.fop_flags\t= FOP_BUFFER_RASYNC | FOP_DONTCACHE,\nblock/fops.c:1000:\t.init_dma_buf_io_ctx = blkdev_init_dma_buf_io_ctx,\nblock/fops.c-1001-};\n--\ndrivers/nvme/host/core.c=2702=static int nvme_report_zones(struct gendisk *disk, sector_t sector,\n--\ndrivers/nvme/host/core.c-2710-\ndrivers/nvme/host/core.c:2711:static int nvme_init_dma_buf_io_ctx(struct block_device *bdev,\ndrivers/nvme/host/core.c:2712:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/core.c-2713-{\n--\ndrivers/nvme/host/core.c-2716-\ndrivers/nvme/host/core.c:2717:\tif (!ctrl-\u003eops-\u003einit_dma_buf_io_ctx)\ndrivers/nvme/host/core.c-2718-\t\treturn -EINVAL;\ndrivers/nvme/host/core.c:2719:\treturn ctrl-\u003eops-\u003einit_dma_buf_io_ctx(ctrl, ctx);\ndrivers/nvme/host/core.c-2720-}\n--\ndrivers/nvme/host/core.c=2722=const struct block_device_operations nvme_bdev_ops = {\n--\ndrivers/nvme/host/core.c-2731-\t.pr_ops\t\t= \u0026nvme_pr_ops,\ndrivers/nvme/host/core.c:2732:\t.init_dma_buf_io_ctx = nvme_init_dma_buf_io_ctx,\ndrivers/nvme/host/core.c-2733-};\n--\ndrivers/nvme/host/nvme.h=651=struct nvme_ctrl_ops {\n--\ndrivers/nvme/host/nvme.h-670-\tbool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);\ndrivers/nvme/host/nvme.h:671:\tint (*init_dma_buf_io_ctx)(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/nvme.h:672:\t\t\t\t struct dma_buf_io_ctx *ctx);\ndrivers/nvme/host/nvme.h-673-\tunsigned long (*get_virt_boundary)(struct nvme_ctrl *ctrl, bool is_admin);\n--\ndrivers/nvme/host/pci-dmabuf.c=10=static void nvme_dmabuf_invalidate_mappings(struct dma_buf_attachment *attach)\ndrivers/nvme/host/pci-dmabuf.c-11-{\ndrivers/nvme/host/pci-dmabuf.c:12:\tstruct dma_buf_io_ctx *ctx = attach-\u003eimporter_priv;\ndrivers/nvme/host/pci-dmabuf.c-13-\n--\ndrivers/nvme/host/pci-dmabuf.c=17=static const struct dma_buf_attach_ops nvme_dmabuf_importer_ops = {\n--\ndrivers/nvme/host/pci-dmabuf.c-21-\ndrivers/nvme/host/pci-dmabuf.c:22:static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-23-{\ndrivers/nvme/host/pci-dmabuf.c-24-\tunsigned nr_entries = ctx-\u003edmabuf-\u003esize / NVME_CTRL_PAGE_SIZE;\ndrivers/nvme/host/pci-dmabuf.c:25:\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-26-\tstruct dma_buf_attachment *attach = nvme_ctx-\u003eattach;\n--\ndrivers/nvme/host/pci-dmabuf.c-77-\ndrivers/nvme/host/pci-dmabuf.c:78:static void nvme_dma_buf_io_unmap(struct dma_buf_io_ctx *ctx,\ndrivers/nvme/host/pci-dmabuf.c-79-\t\tstruct dma_buf_io_map *map_base)\ndrivers/nvme/host/pci-dmabuf.c-80-{\ndrivers/nvme/host/pci-dmabuf.c:81:\tstruct nvme_dma_buf_io_ctx *nvme_ctx = ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-82-\tstruct nvme_dmabuf_map *map = to_nvme_dmabuf_map(map_base);\n--\ndrivers/nvme/host/pci-dmabuf.c-89-\ndrivers/nvme/host/pci-dmabuf.c:90:static void nvme_dma_buf_io_release(struct dma_buf_io_ctx *base_ctx)\ndrivers/nvme/host/pci-dmabuf.c-91-{\ndrivers/nvme/host/pci-dmabuf.c:92:\tstruct nvme_dma_buf_io_ctx *ctx = base_ctx-\u003edev_priv;\ndrivers/nvme/host/pci-dmabuf.c-93-\tstruct nvme_dma_buf_list *buf_list = ctx-\u003ebuf_list;\n--\ndrivers/nvme/host/pci-dmabuf.c=106=void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\ndrivers/nvme/host/pci-dmabuf.c-107-{\ndrivers/nvme/host/pci-dmabuf.c:108:\tstruct nvme_dma_buf_io_ctx *ctx, *tmp;\ndrivers/nvme/host/pci-dmabuf.c-109-\n--\ndrivers/nvme/host/pci-dmabuf.c=125=static int nvme_init_io_ctx_locked(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.c-126-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.c:127:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-128-{\ndrivers/nvme/host/pci-dmabuf.c:129:\tstruct nvme_dma_buf_io_ctx *nvme_ctx;\ndrivers/nvme/host/pci-dmabuf.c-130-\tstruct dma_buf_attachment *attach;\n--\ndrivers/nvme/host/pci-dmabuf.c-153-\ndrivers/nvme/host/pci-dmabuf.c:154:int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.c-155-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.c:156:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.c-157-{\n--\ndrivers/nvme/host/pci-dmabuf.h=13=struct nvme_dma_buf_list {\n--\ndrivers/nvme/host/pci-dmabuf.h-17-\ndrivers/nvme/host/pci-dmabuf.h:18:struct nvme_dma_buf_io_ctx {\ndrivers/nvme/host/pci-dmabuf.h-19-\tstruct dma_buf_attachment *attach;\ndrivers/nvme/host/pci-dmabuf.h-20-\tstruct nvme_dma_buf_list *buf_list;\ndrivers/nvme/host/pci-dmabuf.h:21:\tstruct dma_buf_io_ctx *base;\ndrivers/nvme/host/pci-dmabuf.h-22-\tstruct nvme_ctrl *ctrl;\n--\ndrivers/nvme/host/pci-dmabuf.h=46=void __nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list);\ndrivers/nvme/host/pci-dmabuf.h:47:int __nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.h-48-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.h:49:\t\tstruct dma_buf_io_ctx *ctx);\ndrivers/nvme/host/pci-dmabuf.h-50-\ndrivers/nvme/host/pci-dmabuf.h=51=static inline void nvme_pci_remove_dmabuf(struct nvme_dma_buf_list *list)\n--\ndrivers/nvme/host/pci-dmabuf.h-56-\ndrivers/nvme/host/pci-dmabuf.h:57:static inline int nvme_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci-dmabuf.h-58-\t\tstruct nvme_dma_buf_list *buf_list,\ndrivers/nvme/host/pci-dmabuf.h:59:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci-dmabuf.h-60-{\n--\ndrivers/nvme/host/pci-dmabuf.h-62-\t\treturn -EOPNOTSUPP;\ndrivers/nvme/host/pci-dmabuf.h:63:\treturn __nvme_init_dma_buf_io_ctx(ctrl, buf_list, ctx);\ndrivers/nvme/host/pci-dmabuf.h-64-}\n--\ndrivers/nvme/host/pci.c=3783=static unsigned long nvme_pci_get_virt_boundary(struct nvme_ctrl *ctrl,\n--\ndrivers/nvme/host/pci.c-3790-\ndrivers/nvme/host/pci.c:3791:static int nvme_pci_init_dma_buf_io_ctx(struct nvme_ctrl *ctrl,\ndrivers/nvme/host/pci.c:3792:\t\tstruct dma_buf_io_ctx *ctx)\ndrivers/nvme/host/pci.c-3793-{\n--\ndrivers/nvme/host/pci.c-3795-\ndrivers/nvme/host/pci.c:3796:\treturn nvme_init_dma_buf_io_ctx(ctrl, \u0026dev-\u003edmabufs, ctx);\ndrivers/nvme/host/pci.c-3797-}\n--\ndrivers/nvme/host/pci.c=3799=static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {\n--\ndrivers/nvme/host/pci.c-3813-\t.get_virt_boundary\t= nvme_pci_get_virt_boundary,\ndrivers/nvme/host/pci.c:3814:\t.init_dma_buf_io_ctx\t= nvme_pci_init_dma_buf_io_ctx,\ndrivers/nvme/host/pci.c-3815-};\n--\ninclude/linux/blkdev.h=1577=struct block_device_operations {\n--\ninclude/linux/blkdev.h-1601-\t\t\tenum blk_unique_id id_type);\ninclude/linux/blkdev.h:1602:\tint (*init_dma_buf_io_ctx)(struct block_device *,\ninclude/linux/blkdev.h:1603:\t\t\t\t struct dma_buf_io_ctx *);\ninclude/linux/blkdev.h-1604-\tstruct module *owner;\n--\nio_uring/dma-buf.c=3=static inline void io_release_dmabuf(void *priv)\n--\nio_uring/dma-buf.c-7-\tfput(bd-\u003etarget_file);\nio_uring/dma-buf.c:8:\tdma_buf_io_ctx_release(bd-\u003ectx);\nio_uring/dma-buf.c-9-\tkfree(bd);\n--\nio_uring/dma-buf.c=12=int io_register_dmabuf(struct io_ring_ctx *ctx,\n--\nio_uring/dma-buf.c-46-\nio_uring/dma-buf.c:47:\tret = dma_buf_io_ctx_create(target_file, dmabuf, DMA_BIDIRECTIONAL,\nio_uring/dma-buf.c-48-\t\t\t\t \u0026bd-\u003ectx);\n--\nio_uring/dma-buf.h=10=struct io_buf_dma {\nio_uring/dma-buf.h:11:\tstruct dma_buf_io_ctx\t\t*ctx;\nio_uring/dma-buf.h-12-\tstruct file\t\t\t*target_file;\n"
} |
| 113/3 | 2026/10/07 02:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 57215 output: 24 thoughts: 128 Thoughts: **Investigating the `dma_buf_io_ctx` Mystery** Okay, so I'm looking at the output from a `grep` search, specifically for `dma_buf_io_ctx`, and I see `dma_buf_io_ctx_create` mentioned in `io_uring/dma-buf.c`. That's good, but hold on a second... why wasn't `grep` able to find the definition of `dma_buf_io_ctx_create` anywhere? That's definitely not what I expected. This is a bit strange, I need to understand this. Could it be defined in some file that isn't included in the current indexed Git repository? Or perhaps the way I structured the search isn't working as intended, and `grep` is missing it for some reason. The issue could also be with my understanding of where this code is expected to be. Alright, time to get a bit more aggressive. Let's try another search, perhaps using grepper to see if that turns up anything more. I need to get to the bottom of where this function is actually defined. |
| 114/3 | 2026/10/07 02:14 | tool | grepper |
0mArgs:{
"Expression": "dma_buf_io_ctx_create"
}Results: {
"Output": "io_uring/dma-buf.c=12=int io_register_dmabuf(struct io_ring_ctx *ctx,\n--\nio_uring/dma-buf.c-46-\nio_uring/dma-buf.c:47:\tret = dma_buf_io_ctx_create(target_file, dmabuf, DMA_BIDIRECTIONAL,\nio_uring/dma-buf.c-48-\t\t\t\t \u0026bd-\u003ectx);\n"
} |
| 115/3 | 2026/10/07 02:14 | llm | kmsan-evaluator |
2mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 57739 output: 25 thoughts: 685 Thoughts: **Missing Header Investigation** Okay, so I'm digging into this code and I've noticed something peculiar. The `io_uring/dma-buf.c` file references `include/linux/dma-buf-io.h`, but it's *not* present in the current set of files. That's a red flag. Where's this header? My immediate thought is that it's either in a different branch, an earlier commit, or perhaps this patch series is incomplete, or was broken into subseries. I need to get to the bottom of this. Since I can't directly run `git` commands, I need to use the information at hand. Fortunately, I know the author, Pavel Begunkov, and this was applied by `syz-cluster: applied patch under review`. This means the provided files are the ones *under review*, so it's likely part of a larger patch series. Looking at the provided file list from this commit, there are a lot of relevant files: `block/bio.c`, `block/blk-merge.c`, `drivers/nvme/*`, and `include/linux/bio.h`, `include/linux/blk-mq.h`, `include/linux/blkdev.h`, etc. Everything points to a focus on DMA buffer interaction with block/NVMe subsystems. The absence of `dma-buf-io.h` is, however, still concerning. My suspicion is that this header was meant to be included, and is either in a previous or separate patch in the series. Let's quickly refresh my memory on what `dma-buf-io.h` *probably* contains. I'm going to guess: `struct dma_buf_io_ctx`, `struct dma_buf_io_map`, along with functions like `dma_buf_io_init_map`, `dma_buf_io_detach`, `dma_buf_io_ctx_create`, `dma_buf_io_ctx_release`, `dma_buf_io_get_map`, `dma_buf_io_map_drop`, `iov_iter_is_dmabuf_map`, `iov_iter_dmabuf_map`, and `dma_buf_io_invalidate_mappings`. All of which are critical for any DMA buffer IO operations. To confirm this hypothesis, let's see if the function `iov_iter_is_dmabuf_map` is used anywhere else in the tree. This could give me a clue about where the missing header is actually defined, or if there's an issue in how the patch series was structured. |
| 116/3 | 2026/10/07 02:17 | tool | grepper |
0mArgs:{
"Expression": "iov_iter_is_dmabuf_map"
}Results: {
"Output": "block/bio.c=1209=bool bio_iov_iter_set(struct bio *bio, const struct iov_iter *iter)\nblock/bio.c-1210-{\nblock/bio.c:1211:\tif (!iov_iter_is_bvec(iter) \u0026\u0026 !iov_iter_is_dmabuf_map(iter))\nblock/bio.c-1212-\t\treturn false;\n--\nblock/bio.c-1225-\tbio_set_flag(bio, BIO_CLONED);\nblock/bio.c:1226:\tif (iov_iter_is_dmabuf_map(iter))\nblock/bio.c-1227-\t\tbio-\u003ebi_opf |= REQ_NOMERGE | REQ_DMABUF;\n--\nblock/fops.c=731=static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from)\nblock/fops.c-732-{\nblock/fops.c:733:\tif (unlikely(iov_iter_is_dmabuf_map(from)))\nblock/fops.c-734-\t\treturn -EOPNOTSUPP;\n--\nblock/fops.c=823=static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)\n--\nblock/fops.c-860-\t}\nblock/fops.c:861:\tif (unlikely(iov_iter_is_dmabuf_map(to))) {\nblock/fops.c-862-\t\tif (!ret)\n--\ninclude/linux/bio.h=445=static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)\ninclude/linux/bio.h-446-{\ninclude/linux/bio.h:447:\tif (iov_iter_is_bvec(iter) || iov_iter_is_dmabuf_map(iter))\ninclude/linux/bio.h-448-\t\treturn 0;\n"
} |
| 117/3 | 2026/10/07 02:17 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 59567 output: 36 thoughts: 926 Thoughts: **KMSAN Review: dmabuf Support Patch**
Alright, the pieces are falling into place! This patch is bringing dmabuf support to the block layer, NVMe, and io_uring. Before I dive into the code, I need to be absolutely clear on the KMSAN justification. Standard KASAN is already enabled, catching a whole host of issues: out-of-bounds accesses, use-after-free, double frees, invalid frees, locking bugs with LOCKDEP, and UB-sanitizers. The crucial distinction is that KMSAN flags uninitialized memory reads—stuff that KASAN *won't* catch. This means I only enable it if the patch itself, or changes it introduces, might expose these specific risks. KMSAN fuzzing is expensive, so it has to be justified.
My focus is on areas where uninitialized memory could be exposed to user space, or where control flow depends on it. I need to be holistic. Even if the diff itself doesn't directly add uninitialized fields, modifications in bounds checks or data calculations could change how the code handles existing buffers, and potentially leak uninitialized data. Time to dig deep. I need to use the tools available to inspect everything called from the patch, and the callers.
The guidelines are crystal clear:
1. Kernel structures sent to user space (copy_to_user, etc.) where fields might not be initialized.
2. Conditional logic based on potentially uninitialized variables.
3. Allocation of complex structures where uninitialized fields are used.
4. Modifications to bounds checks that could lead to uninitialized bytes being accessed.
If it's primarily KASAN-type bugs, or if everything is properly initialized, then it's a "NeedsKMSAN=false".
Now, let's get to the nitty-gritty. Item 1: Is this patch touching anything that gets *copied* to user space, using `copy_to_user`, `put_user`, netlink, or CQEs? Okay, so I need to check for those. I search for `copy_to_user` and `put_user` in the diff. Let's see...
Aha! In `io_uring`, `io_kiocb` completions post CQEs, but the filling of the CQEs happens in the io_uring core with `io_req_set_res` and similar. So the question is: does this patch copy structs back to the user? Let's check `io_uring/rsrc.c`.
Okay, there's `__io_sqe_buffers_update`. Here's the code:
```c
+ if (extended) {
+ if (copy_from_user(&desc, u64_to_user_ptr(user_data),
+ sizeof(desc))) {
+ err = -EFAULT;
+ break;
+ }
+ user_data += sizeof(desc);
+ } else {
...
```
Wait a second... that's `copy_from_user`, not `copy_to_user`. I need to ensure nothing *writes* to user space. Let me check the rest of `io_uring/rsrc.c`, from line 380 to 480. Time to get the bigger picture!
|
| 118/3 | 2026/10/07 02:18 | tool | read-file |
0mArgs:{
"File": "io_uring/rsrc.c",
"FirstLine": 380,
"LineCount": 90
}Results: {
"Contents": " 380:\t\t\t\t\tfput(file);\n 381:\t\t\t\t\terr = -EBADF;\n 382:\t\t\t\t\tbreak;\n 383:\t\t\t\t}\n 384:\t\t\t\tnode = io_rsrc_node_alloc(ctx, IORING_RSRC_FILE);\n 385:\t\t\t\tif (!node) {\n 386:\t\t\t\t\terr = -ENOMEM;\n 387:\t\t\t\t\tfput(file);\n 388:\t\t\t\t\tbreak;\n 389:\t\t\t\t}\n 390:\t\t\t\tctx-\u003efile_table.data.nodes[i] = node;\n 391:\t\t\t\tif (tag)\n 392:\t\t\t\t\tnode-\u003etag = tag;\n 393:\t\t\t\tio_fixed_file_set(node, file);\n 394:\t\t\t\tio_file_bitmap_set(\u0026ctx-\u003efile_table, i);\n 395:\t\t\t}\n 396:\t\t}\n 397:\t\treturn done ? done : err;\n 398:\t}\n 399:\t\n 400:\tstatic int __io_sqe_buffers_update(struct io_ring_ctx *ctx,\n 401:\t\t\t\t\t struct io_uring_rsrc_update2 *up,\n 402:\t\t\t\t\t unsigned int nr_args)\n 403:\t{\n 404:\t\tbool extended = up-\u003eflags \u0026 IORING_RSRC_UPDATE_EXTENDED;\n 405:\t\tu64 __user *tags = u64_to_user_ptr(up-\u003etags);\n 406:\t\tu64 user_data = up-\u003edata;\n 407:\t\t__u32 done;\n 408:\t\tint i, err;\n 409:\t\n 410:\t\tif (!ctx-\u003ebuf_table.nr)\n 411:\t\t\treturn -ENXIO;\n 412:\t\tif (up-\u003eoffset + nr_args \u003e ctx-\u003ebuf_table.nr)\n 413:\t\t\treturn -EINVAL;\n 414:\t\tif (up-\u003eflags \u0026 ~IORING_RSRC_UPDATE_EXTENDED)\n 415:\t\t\treturn -EINVAL;\n 416:\t\n 417:\t\tfor (done = 0; done \u003c nr_args; done++) {\n 418:\t\t\tstruct io_uring_regbuf_desc desc;\n 419:\t\t\tstruct io_rsrc_node *node;\n 420:\t\t\tu64 tag = 0;\n 421:\t\n 422:\t\t\tif (tags \u0026\u0026 copy_from_user(\u0026tag, \u0026tags[done], sizeof(tag))) {\n 423:\t\t\t\terr = -EFAULT;\n 424:\t\t\t\tbreak;\n 425:\t\t\t}\n 426:\t\n 427:\t\t\tif (extended) {\n 428:\t\t\t\tif (copy_from_user(\u0026desc, u64_to_user_ptr(user_data),\n 429:\t\t\t\t\t\t sizeof(desc))) {\n 430:\t\t\t\t\terr = -EFAULT;\n 431:\t\t\t\t\tbreak;\n 432:\t\t\t\t}\n 433:\t\t\t\tuser_data += sizeof(desc);\n 434:\t\t\t} else {\n 435:\t\t\t\tstruct iovec __user *uvec = u64_to_user_ptr(user_data);\n 436:\t\t\t\tstruct iovec fast_iov, *iov;\n 437:\t\n 438:\t\t\t\tif (io_is_compat(ctx))\n 439:\t\t\t\t\tuser_data += sizeof(struct compat_iovec);\n 440:\t\t\t\telse\n 441:\t\t\t\t\tuser_data += sizeof(struct iovec);\n 442:\t\n 443:\t\t\t\tiov = iovec_from_user(uvec, 1, 1, \u0026fast_iov, io_is_compat(ctx));\n 444:\t\t\t\tif (IS_ERR(iov)) {\n 445:\t\t\t\t\terr = PTR_ERR(iov);\n 446:\t\t\t\t\tbreak;\n 447:\t\t\t\t}\n 448:\t\t\t\tio_iov_to_regbuf_desc(iov, \u0026desc);\n 449:\t\t\t}\n 450:\t\n 451:\t\t\tnode = io_sqe_buffer_register(ctx, \u0026desc);\n 452:\t\t\tif (IS_ERR(node)) {\n 453:\t\t\t\terr = PTR_ERR(node);\n 454:\t\t\t\tbreak;\n 455:\t\t\t}\n 456:\t\n 457:\t\t\tif (tag) {\n 458:\t\t\t\tif (!node) {\n 459:\t\t\t\t\terr = -EINVAL;\n 460:\t\t\t\t\tbreak;\n 461:\t\t\t\t}\n 462:\t\t\t\tnode-\u003etag = tag;\n 463:\t\t\t}\n 464:\t\t\ti = array_index_nospec(up-\u003eoffset + done, ctx-\u003ebuf_table.nr);\n 465:\t\t\tio_reset_rsrc_node(ctx, \u0026ctx-\u003ebuf_table, i);\n 466:\t\t\tctx-\u003ebuf_table.nodes[i] = node;\n 467:\t\t}\n 468:\t\treturn done ? done : err;\n 469:\t}\n"
} |
| 119/3 | 2026/10/07 02:18 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 62573 output: 37 thoughts: 459 Thoughts: **Analyzing the io_uring Buffer Registration Logic** Okay, let's break this down. First, I see the function `io_iov_to_regbuf_desc`. It's pretty straightforward: it populates the `io_uring_regbuf_desc` structure from an `iovec`. The interesting part is that any fields of `desc` not explicitly initialized are zero-initialized. Now, considering the context of C99 designated initializers, this ensures a clean slate, particularly crucial because we'll be handling user-supplied data later. Next, I'm thinking about how the user data is actually transferred. In the `extended` path, `copy_from_user` copies the entire `sizeof(desc)` from user space into the `desc` variable, a core point for security. Now, looking at `io_sqe_buffer_register`, I notice the crucial validation steps. The code checks `desc->type` against `__IO_REGBUF_TYPE_MAX` to prevent out-of-bounds access, then, importantly, validates that the reserved and flag fields are zero, preventing unintended modification. The subsequent checks, such as those related to `dmabuf_fd` and `target_fd`, ensure that we don't inadvertently register invalid buffers. I'm satisfied that these checks are in place. These checks are absolutely vital to prevent a variety of attacks from user-space. Finally, a key point: `desc` itself is only *read* by the kernel, never copied *back* to userspace. This further minimizes the attack surface. Now, let me make sure I've got it all. I need to go over `io_sqe_buffers_register` to check for consistency. Let me see... |
| 120/3 | 2026/10/07 02:18 | tool | read-file |
0mArgs:{
"File": "io_uring/rsrc.c",
"FirstLine": 1050,
"LineCount": 50
}Results: {
"Contents": "1050:\t\t\treturn -EBUSY;\n1051:\t\tif (!nr_args || nr_args \u003e IORING_MAX_REG_BUFFERS)\n1052:\t\t\treturn -EINVAL;\n1053:\t\tret = io_rsrc_data_alloc(\u0026data, nr_args);\n1054:\t\tif (ret)\n1055:\t\t\treturn ret;\n1056:\t\n1057:\t\tif (!arg)\n1058:\t\t\tmemset(iov, 0, sizeof(*iov));\n1059:\t\n1060:\t\tfor (i = 0; i \u003c nr_args; i++) {\n1061:\t\t\tstruct io_uring_regbuf_desc desc;\n1062:\t\t\tstruct io_rsrc_node *node;\n1063:\t\t\tu64 tag = 0;\n1064:\t\n1065:\t\t\tif (arg) {\n1066:\t\t\t\tuvec = (struct iovec __user *) arg;\n1067:\t\t\t\tiov = iovec_from_user(uvec, 1, 1, \u0026fast_iov, io_is_compat(ctx));\n1068:\t\t\t\tif (IS_ERR(iov)) {\n1069:\t\t\t\t\tret = PTR_ERR(iov);\n1070:\t\t\t\t\tbreak;\n1071:\t\t\t\t}\n1072:\t\t\t\tif (io_is_compat(ctx))\n1073:\t\t\t\t\targ += sizeof(struct compat_iovec);\n1074:\t\t\t\telse\n1075:\t\t\t\t\targ += sizeof(struct iovec);\n1076:\t\t\t}\n1077:\t\n1078:\t\t\tif (tags) {\n1079:\t\t\t\tif (copy_from_user(\u0026tag, \u0026tags[i], sizeof(tag))) {\n1080:\t\t\t\t\tret = -EFAULT;\n1081:\t\t\t\t\tbreak;\n1082:\t\t\t\t}\n1083:\t\t\t}\n1084:\t\n1085:\t\t\tio_iov_to_regbuf_desc(iov, \u0026desc);\n1086:\t\t\tnode = io_sqe_buffer_register(ctx, \u0026desc);\n1087:\t\t\tif (IS_ERR(node)) {\n1088:\t\t\t\tret = PTR_ERR(node);\n1089:\t\t\t\tbreak;\n1090:\t\t\t}\n1091:\t\t\tif (tag) {\n1092:\t\t\t\tif (!node) {\n1093:\t\t\t\t\tret = -EINVAL;\n1094:\t\t\t\t\tbreak;\n1095:\t\t\t\t}\n1096:\t\t\t\tnode-\u003etag = tag;\n1097:\t\t\t}\n1098:\t\t\tdata.nodes[i] = node;\n1099:\t\t}\n"
} |
| 121/3 | 2026/10/07 02:18 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 64146 output: 18 thoughts: 2154 Thoughts: **Analyzing Memory Initialization and Allocation** Okay, let's break this down. In the `io_sqe_buffers_register` function, I see some careful initialization. If there's no argument provided, the `iov` is `memset` to zero *before* calling `io_iov_to_regbuf_desc`. If there *is* an argument, the `iov` is filled by `iovec_from_user` and then that's used. Finally, the buffer is registered. Everything seems appropriately initialized there, which is good. Now, checking `io_files_update`: The introduction of `memset(&up2, 0, sizeof(up2))` is a *very* welcome addition. That explicitly initializes the `up2` struct, preventing any potential issues with uninitialized fields, which could be a real problem. Okay, let's shift gears to memory allocation and initialization now, starting with `io_uring/dma-buf.c`. I see `bd` is allocated with `kzalloc`, which is great, guaranteeing zero initialization. The `imu` is allocated and then also `memset` to zero, so, good. Now, let's look at `drivers/nvme/host/pci-dmabuf.c`. This is where it gets interesting. I see `kvmalloc_flex` used here for `map`. The definition of `struct nvme_dmabuf_map` shows that `map` includes a dynamically sized `dma_list`. The function `kvmalloc_flex` allocates the memory, but the critical question is whether it *zeroes* the memory. That is the key concern here. The code calculates `nr_entries = ctx->dmabuf->size / NVME_CTRL_PAGE_SIZE`, and it checks the size of the DMA buffer. The interesting part is that `kvmalloc_flex` allocates memory for `map` including the `dma_list` based on `nr_entries`. The loop then populates `map->dma_list` with DMA addresses obtained from the scatterlist. **Here's where the potential bug lies:** What if the scatterlist has a *smaller* total length than `ctx->dmabuf->size`? The loop will only iterate through the scatterlist entries. The value of `nr_entries` is based on the DMA buffer size and not the number of entries in the sg table. If the sg table has fewer pages than `ctx->dmabuf->size`, then `i` will be less than `nr_entries`. This means that `map->dma_list` will contain valid DMA addresses up to the scatterlist's size, and the rest of the array will contain uninitialized, garbage values. **Furthermore, is `dma_buf_map_attachment` guarantees the size?** Where is `map->dma_list` read? Let's check. In `nvme_rq_setup_dmabuf_map`, I see that `map->dma_list` is used to construct PRP lists. This function reads `map->dma_list` sequentially. If the `dma_list` isn't fully initialized, the subsequent reads will be reading from uninitialized memory! **Important Questions**: 1. Is `kvmalloc_flex` zeroed? This is critical! If it doesn't zero, we have a significant problem. 2. Is it possible for `dma_buf_map_attachment` to return a scatterlist with *fewer* pages than `ctx->dmabuf->size`? If the DMA buffer has a fixed size, does the scatterlist also have a fixed size? 3. If `i` is less than `nr_entries`, we could be accessing uninitialized memory. We must check where this array is accessed and what is expected. I need to confirm if `kvmalloc_flex` is zeroing the allocated memory. I also need to understand the constraints and potential mismatches between the DMA buffer size and the scatterlist size. |
| 122/3 | 2026/10/07 02:19 | tool | grepper |
0mArgs:{
"Expression": "kvmalloc_flex"
}Results: {
"Output": "crypto/deflate.c=36=static void *deflate_alloc_stream(void)\n--\ncrypto/deflate.c-42-\ncrypto/deflate.c:43:\tctx = kvmalloc_flex(*ctx, workspace, size);\ncrypto/deflate.c-44-\tif (!ctx)\n--\ncrypto/zstd.c=34=static void *zstd_alloc_stream(void)\n--\ncrypto/zstd.c-46-\ncrypto/zstd.c:47:\tctx = kvmalloc_flex(*ctx, wksp, wksp_size);\ncrypto/zstd.c-48-\tif (!ctx)\n--\ndrivers/cxl/core/features.c=81=get_supported_features(struct cxl_features_state *cxlfs)\n--\ndrivers/cxl/core/features.c-96-\tstruct cxl_feat_entries *entries __free(kvfree) =\ndrivers/cxl/core/features.c:97:\t\tkvmalloc_flex(*entries, ent, count);\ndrivers/cxl/core/features.c-98-\tif (!entries)\n--\ndrivers/infiniband/core/ib_core_uverbs.c=563=__malloc void *_uverbs_alloc(struct uverbs_attr_bundle *bundle, size_t size,\n--\ndrivers/infiniband/core/ib_core_uverbs.c-576-\ndrivers/infiniband/core/ib_core_uverbs.c:577:\t\tbuf = kvmalloc_flex(*buf, data, size, flags);\ndrivers/infiniband/core/ib_core_uverbs.c-578-\t\tif (!buf)\n--\ndrivers/nvme/host/pci-dmabuf.c=22=static struct dma_buf_io_map *nvme_dma_buf_io_map(struct dma_buf_io_ctx *ctx)\n--\ndrivers/nvme/host/pci-dmabuf.c-37-\ndrivers/nvme/host/pci-dmabuf.c:38:\tmap = kvmalloc_flex(*map, dma_list, nr_entries);\ndrivers/nvme/host/pci-dmabuf.c-39-\tif (!map)\n--\nfs/btrfs/inode.c=1565=static bool run_delalloc_compressed(struct btrfs_inode *inode,\n--\nfs/btrfs/inode.c-1579-\tnofs_flag = memalloc_nofs_save();\nfs/btrfs/inode.c:1580:\tctx = kvmalloc_flex(*ctx, chunks, num_chunks);\nfs/btrfs/inode.c-1581-\tmemalloc_nofs_restore(nofs_flag);\n--\nfs/fuse/dev_uring.c=799=static int fuse_uring_set_up_zero_copy(struct fuse_ring_ent *ent,\n--\nfs/fuse/dev_uring.c-815-\nfs/fuse/dev_uring.c:816:\tzc_bvs = kvmalloc_flex(*zc_bvs, bvs, ap-\u003enum_folios,\nfs/fuse/dev_uring.c-817-\t\t\t GFP_KERNEL_ACCOUNT);\n--\ninclude/linux/slab.h=1073=void *kmalloc_nolock(size_t size, gfp_t gfp_flags, int node);\n--\ninclude/linux/slab.h-1166-\t__alloc_objs(kvmalloc, default_gfp(__VA_ARGS__), typeof(P), COUNT)\ninclude/linux/slab.h:1167:#define kvmalloc_flex(P, FAM, COUNT, ...) \\\ninclude/linux/slab.h-1168-\t__alloc_flex(kvmalloc, default_gfp(__VA_ARGS__), typeof(P), FAM, COUNT)\n--\nio_uring/rsrc.c=175=static struct io_mapped_ubuf *io_alloc_imu(struct io_ring_ctx *ctx,\n--\nio_uring/rsrc.c-179-\t\treturn io_cache_alloc(\u0026ctx-\u003eimu_cache, GFP_KERNEL);\nio_uring/rsrc.c:180:\treturn kvmalloc_flex(struct io_mapped_ubuf, bvec, nr_bvecs);\nio_uring/rsrc.c-181-}\n--\nkernel/gcov/fs.c=111=static struct gcov_iterator *gcov_iter_new(struct gcov_info *info)\n--\nkernel/gcov/fs.c-118-\nkernel/gcov/fs.c:119:\titer = kvmalloc_flex(*iter, buffer, size);\nkernel/gcov/fs.c-120-\tif (!iter)\n--\nkernel/groups.c=15=struct group_info *groups_alloc(int gidsetsize)\n--\nkernel/groups.c-17-\tstruct group_info *gi;\nkernel/groups.c:18:\tgi = kvmalloc_flex(*gi, gid, gidsetsize, GFP_KERNEL_ACCOUNT);\nkernel/groups.c-19-\tif (!gi)\n--\nnet/netfilter/xt_hashlimit.c=275=static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,\n--\nnet/netfilter/xt_hashlimit.c-296-\t}\nnet/netfilter/xt_hashlimit.c:297:\thinfo = kvmalloc_flex(*hinfo, hash, size);\nnet/netfilter/xt_hashlimit.c-298-\tif (hinfo == NULL)\n--\nnet/sched/sch_netem.c=834=static int get_dist_table(struct disttable **tbl, const struct nlattr *attr)\n--\nnet/sched/sch_netem.c-843-\nnet/sched/sch_netem.c:844:\td = kvmalloc_flex(*d, table, n);\nnet/sched/sch_netem.c-845-\tif (!d)\n--\nscripts/coccinelle/api/kmalloc_objs.cocci=127=identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex,\nscripts/coccinelle/api/kmalloc_objs.cocci-128-\t\t kzalloc_obj,kzalloc_objs,kzalloc_flex,\nscripts/coccinelle/api/kmalloc_objs.cocci:129:\t\t kvmalloc_obj,kvmalloc_objs,kvmalloc_flex,\nscripts/coccinelle/api/kmalloc_objs.cocci-130-\t\t kvzalloc_obj,kvzalloc_objs,kvzalloc_flex};\n"
} |
| 123/3 | 2026/10/07 02:19 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 68867 output: 36 thoughts: 80 Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue: **Investigating the `kvmalloc_flex` Allocation Path** Right, so `kvmalloc_flex` ultimately funnels down to `__alloc_flex`, which in turn calls `kvmalloc` with `default_gfp(... ...)` – interesting. And hey, it's *not* a `kvzalloc_flex` call, so we're talking about uninitialized memory here. Worth keeping in mind for later debugging, definitely. Now, let's just make *absolutely* sure what that `default_gfp` actually resolves to. I'm going to quickly check `include/linux/slab.h` around line 1160 to see precisely what flags that's masking. Gotta be on top of these things; especially with something that's likely the base allocation flags. Understanding exactly how the allocation is *happening* is key to understanding potential issues down the line. I always try to dive deep to be sure. |
| 124/3 | 2026/10/07 02:20 | tool | read-file |
0mArgs:{
"File": "include/linux/slab.h",
"FirstLine": 1155,
"LineCount": 30
}Results: {
"Contents": "1155:\t#define kzalloc_obj(P, ...) \\\n1156:\t\t__alloc_objs(kzalloc, default_gfp(__VA_ARGS__), typeof(P), 1)\n1157:\t#define kzalloc_objs(P, COUNT, ...) \\\n1158:\t\t__alloc_objs(kzalloc, default_gfp(__VA_ARGS__), typeof(P), COUNT)\n1159:\t#define kzalloc_flex(P, FAM, COUNT, ...)\t\t\\\n1160:\t\t__alloc_flex(kzalloc, default_gfp(__VA_ARGS__), typeof(P), FAM, COUNT)\n1161:\t\n1162:\t/* All kvmalloc aliases for kmalloc_(obj|objs|flex). */\n1163:\t#define kvmalloc_obj(P, ...) \\\n1164:\t\t__alloc_objs(kvmalloc, default_gfp(__VA_ARGS__), typeof(P), 1)\n1165:\t#define kvmalloc_objs(P, COUNT, ...) \\\n1166:\t\t__alloc_objs(kvmalloc, default_gfp(__VA_ARGS__), typeof(P), COUNT)\n1167:\t#define kvmalloc_flex(P, FAM, COUNT, ...) \\\n1168:\t\t__alloc_flex(kvmalloc, default_gfp(__VA_ARGS__), typeof(P), FAM, COUNT)\n1169:\t\n1170:\t/* All kvzalloc aliases for kmalloc_(obj|objs|flex). */\n1171:\t#define kvzalloc_obj(P, ...) \\\n1172:\t\t__alloc_objs(kvzalloc, default_gfp(__VA_ARGS__), typeof(P), 1)\n1173:\t#define kvzalloc_objs(P, COUNT, ...) \\\n1174:\t\t__alloc_objs(kvzalloc, default_gfp(__VA_ARGS__), typeof(P), COUNT)\n1175:\t#define kvzalloc_flex(P, FAM, COUNT, ...) \\\n1176:\t\t__alloc_flex(kvzalloc, default_gfp(__VA_ARGS__), typeof(P), FAM, COUNT)\n1177:\t\n1178:\t#define kmem_buckets_alloc(_b, _size, _flags)\t\\\n1179:\t\talloc_hooks(__kmalloc_node_noprof(PASS_KMALLOC_PARAMS(_size, _b, __kmalloc_token(_size)), _flags, NUMA_NO_NODE))\n1180:\t\n1181:\t#define kmem_buckets_alloc_node_track_caller(_b, _size, _flags, _node)\t\\\n1182:\t\talloc_hooks(__kmalloc_node_track_caller_noprof(PASS_KMALLOC_PARAMS(_size, _b, __kmalloc_token(_size)), _flags, _node, _RET_IP_))\n1183:\t\n1184:\t#define kmem_buckets_alloc_track_caller(_b, _size, _flags) \\\n"
} |
| 125/3 | 2026/10/07 02:20 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 69972 output: 19 thoughts: 2558 Thoughts: **Vulnerability Analysis: Uninitialized Memory in NVMe DMA Mapping** Okay, so I'm looking at this `kvmalloc_flex` allocation and immediately see that the allocated memory is uninitialized. That raises a flag. Now, let's dive into `nvme_dma_buf_io_map`. The code allocates a `map` structure, intending to populate it with DMA addresses for a `dma_buf`. It iterates through the scatterlist (`sgt`) derived from the DMA buffer's attachment to the device. The critical loop maps the DMA addresses from the scatterlist into `map->dma_list`. Here's the problem: if the scatterlist has fewer bytes than the total size of the DMA buffer, the loop might *not* populate the entire `dma_list`. The code *doesn't* check if the loop completes populating `map->dma_list` or if `i == nr_entries`. This means the tail end of `map->dma_list` can be left *uninitialized*. Crucially, I'm thinking, can an exporter provide an sg_table with less len than the full size? Now, consider the `nvme_rq_setup_dmabuf_map` function. This is where the DMA map is *used*. The function uses `map->dma_list` to build PRP (PRP: PCIe Read/Write Page) list entries for the NVMe device's DMA hardware. `map_idx` could read from uninitialized memory! The code calculates a `map_idx` based on the request's offset into the DMA buffer. A user could submit an I/O request with `addr = 0, len = dmabuf->size`, accessing `dma_list` from the beginning. This makes a condition where there's an I/O request, the exporter provides an sg_table with less total len. `map_idx` would read an uninitialized memory. The key here is that the uninitialized `dma_addr` is used to build PRP entries, ultimately given to the *hardware*. These addresses are used in the DMA process, which is a potential information leak. This is the crucial aspect of the vulnerability. Now, let's step back and consider the *rules* for flagging a vulnerability. It seems this clearly falls under rule 3: "Allocation or initialization of complex data structures where uninitialized fields could be read later in reachable code paths." We also need to consider rule 2: "Conditional logic or branching that depends on potentially uninitialized variables or struct fields." The critical point is, an `io_uring` request *can* specify the entire buffer size, leading to the read of the uninitialized data. And this may impact rule 4: "Bounds checks, lengths, or logic in a way that allows surrounding code to access uninitialized bytes of existing buffers." Further investigation needed to confirm `min_seg_shift` is initialized or not. I will check where that `struct dma_buf_io_map` in which the `min_seg_shift` comes from and how it is initialized. Based on the evidence: This is a clear case for `NeedsKMSAN=true` and an assignment for the patch. |
| 126/3 | 2026/10/07 02:22 | tool | grepper |
0mArgs:{
"Expression": "min_seg_shift"
}Results: {
"Output": "block/blk-merge.c=323=static inline int bio_split_io_at_dmabuf(struct bio *bio,\n--\nblock/blk-merge.c-328-\tunsigned bytes = min(bio-\u003ebi_iter.bi_size, max_bytes);\nblock/blk-merge.c:329:\tunsigned seg_shift = bio-\u003ebi_dmabuf_map-\u003emin_seg_shift;\nblock/blk-merge.c-330-\tunsigned offset = bio-\u003ebi_iter.bi_offset \u0026 ((1U \u003c\u003c seg_shift) - 1);\n"
} |
| 127/3 | 2026/10/07 02:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 73403 output: 27 thoughts: 1389 Thoughts: **Debugging the Absence of `dma-buf-io.h`** Okay, first things first. I noticed `min_seg_shift` is only in `block/blk-merge.c`, which is a bit odd. Then I realized that my initial search for `min_seg_shift` didn't turn up `dma-buf-io.h`, even though I expected it to. That's a red flag. Let's confirm with `grep`. Only `block/blk-merge.c` matched the search for `min_seg_shift`, so that confirms my suspicion. Could it be that `linux/dma-buf-io.h` isn't even *in* git? I need to check the status, or determine why it would be excluded. I did grep for `dma_buf_io_map` earlier, and that yielded a list of files: `block/fops.c`, `drivers/dma-buf/dma-buf.c`, `drivers/iommu/iommufd/...`, `drivers/nvme/host/core.c`, `drivers/nvme/host/nvme.h`, `drivers/nvme/host/pci-dmabuf.c`, `drivers/nvme/host/pci-dmabuf.h`, `drivers/nvme/host/pci.c`, `include/linux/blk_types.h`, `include/linux/blkdev.h`, `include/linux/io_uring_types.h`, `io_uring/dma-buf.c`, and `io_uring/dma-buf.h`. This is important context, but no `dma-buf-io.h` is mentioned. Aha! `dma-buf-io.h` wasn't in the git repo. This is probably because of a recent patch in this commit: `syz-cluster: applied patch under review`. The developer submitted a patch series, but maybe the first patch, which introduced `linux/dma-buf-io.h`, wasn't applied or is in another diff, or the file is genuinely missing from the tree. Let's check the current state of include files with the prefix `include/linux/dma-buf*`. Earlier, `codesearch-dir-index` on `include/linux` returned only `dma-buf-mapping.h` and `dma-buf.h`. So `include/linux/dma-buf-io.h` *literally* does not exist in this git tree. That explains why the `read-file` command failed! Mystery solved. That's why I'm getting "the file does not exist". Okay, now it's time to examine the patch in detail. Let's read it in full. First, I need to check `block/bio.c`. I'm seeing changes to `__bio_clone` that involve `bi_dmabuf_map` and how it interacts with the existing `bi_io_vec`. I see that `bi_dmabuf_map` and `bi_io_vec` are in a union. There's also `bio_iov_iter_set`, which is setting up the iterator. There is also a test using `if (op_is_dmabuf(bio->bi_opf))`, which tells us whether to set `bi_io_vec` or `bi_dmabuf_map`. I see that there are also assertions to check if the offsets are correct in the structure. The interesting part of this code is the conditional: `if (op_is_dmabuf(bio->bi_opf))`. I need to figure out when and how `bio->bi_opf` is set *before* `__bio_clone` is called. It's time to trace the calls. |
| 128/3 | 2026/10/07 02:22 | tool | grepper |
0mArgs:{
"Expression": "__bio_clone",
"PathPrefixes": [
"block/"
]
}Results: {
"Output": "block/bio.c=874=EXPORT_SYMBOL(bio_put);\nblock/bio.c-875-\nblock/bio.c:876:static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)\nblock/bio.c-877-{\n--\nblock/bio.c=918=struct bio *bio_alloc_clone(struct block_device *bdev, struct bio *bio_src,\n--\nblock/bio.c-926-\nblock/bio.c:927:\tif (__bio_clone(bio, bio_src, gfp) \u003c 0) {\nblock/bio.c-928-\t\tbio_put(bio);\n--\nblock/bio.c=945=int bio_init_clone(struct block_device *bdev, struct bio *bio,\n--\nblock/bio.c-950-\tbio_init(bio, bdev, NULL, 0, bio_src-\u003ebi_opf);\nblock/bio.c:951:\tret = __bio_clone(bio, bio_src, gfp);\nblock/bio.c-952-\tif (ret)\n"
} |
| 129/3 | 2026/10/07 02:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 75968 output: 33 thoughts: 55 Thoughts: Here's my summary, as the expert, taking on the persona of having these thoughts: **Dissecting the Block I/O Cloning Mechanism** Alright, let's get into this. I'm focusing on the block I/O cloning process. My immediate concern is how these cloned bios are initialized. Specifically, I'm looking at `bio_init_clone`. I see the core initialization using `bio_init(bio, bdev, NULL, 0, bio_src->bi_opf)`. That's standard, but I need to understand the implications of the NULL and 0 parameters in this cloned context. More interestingly, how does this compare to `bio_alloc_clone`? I need to check out what the differences are in the initialization process during allocation. Let's dig into `bio_alloc_clone` and see if there are any subtle differences or important optimizations employed there, as I will assume they are important. I have to understand the interplay between these two functions to fully grasp how a clone is established and managed. |
| 130/3 | 2026/10/07 02:23 | tool | read-file |
0mArgs:{
"File": "block/bio.c",
"FirstLine": 918,
"LineCount": 25
}Results: {
"Contents": " 918:\tstruct bio *bio_alloc_clone(struct block_device *bdev, struct bio *bio_src,\n 919:\t\t\tgfp_t gfp, struct bio_set *bs)\n 920:\t{\n 921:\t\tstruct bio *bio;\n 922:\t\n 923:\t\tbio = bio_alloc_bioset(bdev, 0, bio_src-\u003ebi_opf, gfp, bs);\n 924:\t\tif (!bio)\n 925:\t\t\treturn NULL;\n 926:\t\n 927:\t\tif (__bio_clone(bio, bio_src, gfp) \u003c 0) {\n 928:\t\t\tbio_put(bio);\n 929:\t\t\treturn NULL;\n 930:\t\t}\n 931:\t\treturn bio;\n 932:\t}\n 933:\tEXPORT_SYMBOL(bio_alloc_clone);\n 934:\t\n 935:\t/**\n 936:\t * bio_init_clone - clone a bio that shares the original bio's biovec\n 937:\t * @bdev: block_device to clone onto\n 938:\t * @bio: bio to clone into\n 939:\t * @bio_src: bio to clone from\n 940:\t * @gfp: allocation priority\n 941:\t *\n 942:\t * Initialize a new bio in caller provided memory that is a clone of @bio_src.\n"
} |
| 131/3 | 2026/10/07 02:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 76665 output: 35 thoughts: 676 Thoughts: **Analyzing DMA-Buf I/O Splitting** Okay, so `bio->bi_opf` has been initialized from `bio_src->bi_opf`. Now, I need to understand how the I/O is split, particularly when using DMA buffers. Let me delve into `block/blk-merge.c` and focus on `bio_split_io_at_dmabuf`. Here's the deal: `bio_split_io_at_dmabuf` is called and needs to determine if and where to split a bio that involves a DMA buffer. The initial check involves alignment. If the offset or size of the bio doesn't align with the expected boundaries defined by `len_align_mask` and `start_align_mask`, it returns `-EINVAL`. Otherwise, it's assumed to be a single contiguous range within the DMA buffer, and `*segs` is set to 1. Then comes the segment limitation. Since DMA buffers don't expose underlying segmentation directly, the code limits the split by segment size. We can't allow the number of bytes to exceed `max_segments` multiplied by the minimal segment size. So, the bytes need to be limited by `max_segs_bytes`, which ensures we don't go beyond the allowed segment count. If the calculated `bytes` is less than the original `bio->bi_iter.bi_size`, a split is required, and the function returns the split size. Otherwise, it returns 0, indicating no splitting is needed. Now, let's look at how this function is used in `bio_split_io_at`. `bio_split_io_at` first checks if the operation is a DMA-buf operation using `op_is_dmabuf(bio->bi_opf)`. If so, it calls `bio_split_io_at_dmabuf`. If `bio_split_io_at_dmabuf` returns a value less than 0, it indicates an error, and the function returns immediately. If the function returns 0, there's no need to split, and the code jumps to `out`, where `*segs = nsegs; bio->bi_bvec_gap_bit = ffs(gaps); return 0;` I see that there's a `goto out;` when `ret == 0;`. Now, what is the meaning of `gaps`? I need to understand what `gaps` represents here, because there appears to be a bitwise operation being done. I need to consult the surrounding code to determine its meaning, so let's check `bio_split_io_at` around line 346. |
| 132/3 | 2026/10/07 02:23 | tool | read-file |
0mArgs:{
"File": "block/blk-merge.c",
"FirstLine": 345,
"LineCount": 50
}Results: {
"Contents": " 345:\t\t/*\n 346:\t\t * Limit by the number of segments by using the minimal segment size.\n 347:\t\t * Any I/O consisting of N full segments should be able to cover at\n 348:\t\t * least N multiplied by the segment size. It's stricter than walking\n 349:\t\t * the segments and might cause extra splitting.\n 350:\t\t */\n 351:\t\tmax_segs_bytes = (u64)lim-\u003emax_segments \u003c\u003c seg_shift;\n 352:\t\tbytes = min_t(u64, bytes, max_segs_bytes - offset);\n 353:\t\tif (bytes != bio-\u003ebi_iter.bi_size)\n 354:\t\t\treturn bytes;\n 355:\t\treturn 0;\n 356:\t}\n 357:\t\n 358:\t/**\n 359:\t * bio_split_io_at - check if and where to split a bio\n 360:\t * @bio: [in] bio to be split\n 361:\t * @lim: [in] queue limits to split based on\n 362:\t * @segs: [out] number of segments in the bio with the first half of the sectors\n 363:\t * @max_bytes: [in] maximum number of bytes per bio\n 364:\t * @len_align_mask: [in] length alignment mask for each vector\n 365:\t *\n 366:\t * Find out if @bio needs to be split to fit the queue limits in @lim and a\n 367:\t * maximum size of @max_bytes. Returns a negative error number if @bio can't be\n 368:\t * split, 0 if the bio doesn't have to be split, or a positive sector offset if\n 369:\t * @bio needs to be split.\n 370:\t */\n 371:\tint bio_split_io_at(struct bio *bio, const struct queue_limits *lim,\n 372:\t\t\tunsigned *segs, unsigned max_bytes, unsigned len_align_mask)\n 373:\t{\n 374:\t\tstruct bio_crypt_ctx *bc = bio_crypt_ctx(bio);\n 375:\t\tstruct bio_vec bv, bvprv, *bvprvp = NULL;\n 376:\t\tunsigned nsegs = 0, bytes = 0, gaps = 0;\n 377:\t\tstruct bvec_iter iter;\n 378:\t\tunsigned start_align_mask = lim-\u003edma_alignment;\n 379:\t\n 380:\t\tif (bc) {\n 381:\t\t\tstart_align_mask |= (bc-\u003ebc_key-\u003ecrypto_cfg.data_unit_size - 1);\n 382:\t\t\tlen_align_mask |= (bc-\u003ebc_key-\u003ecrypto_cfg.data_unit_size - 1);\n 383:\t\t}\n 384:\t\n 385:\t\tif (op_is_dmabuf(bio-\u003ebi_opf)) {\n 386:\t\t\tint ret;\n 387:\t\n 388:\t\t\tret = bio_split_io_at_dmabuf(bio, lim, \u0026nsegs, max_bytes,\n 389:\t\t\t\t\t\t len_align_mask, start_align_mask);\n 390:\t\t\tif (ret \u003c 0)\n 391:\t\t\t\treturn ret;\n 392:\t\t\tif (!ret)\n 393:\t\t\t\tgoto out;\n 394:\t\t\tbytes = ret;\n"
} |
| 133/3 | 2026/10/07 02:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 78864 output: 22 thoughts: 2104 Thoughts: **Analyzing NVMe DMA Buffer Handling for Potential Issues**
Okay, so I'm diving into the NVMe driver code, specifically the DMA buffer handling with an eye towards potential vulnerabilities or inefficiencies. I've started by tracking the initialization of `gaps` to zero, which seems straightforward enough.
Now, I'm checking the interaction between `dm_bio_rewind_iter` and `bio_advance_iter`. These functions are adjusting the `bi_offset` and `bi_size` fields within the iterator when dealing with dmabuf (where the `bio_no_advance_iter(bio)` is true). This seems like standard iterator adjustment behavior, but I'll keep this in mind.
Now let's move on to the NVMe PCIe DMABUF setup:
I'm inspecting `nvme_rq_setup_dmabuf`, which decides how to manage scatter-gather lists (SGLs) based on certain conditions. Specifically, I'm trying to see under what conditions the `nvme_rq_setup_dmabuf_sgl` function gets called. The function `nvme_pci_dmabuf_sgl_nents` appears to be a crucial component in this process.
`nvme_pci_dmabuf_sgl_nents` seems to calculate the number of scatterlist entries (`nents`) for the request. I see a loop iterating through the scatterlist entries (`sg`). It calculates how many entries are used for a particular request by checking the remaining payload bytes (`remaining`) and comparing against the DMA length of each scatterlist entry.
The critical bit, the one I'm interested in, is the `nvme_rq_setup_dmabuf_sgl` function. This is where the DMA buffer is actually set up for SGL use. The logic begins by checking if entries exist and uses a `dma_pool_alloc` call to allocate memory for the SGL descriptors. Now, here's where my alarm bells start ringing. The call to `dma_pool_alloc` does *not* zero the allocated memory. However, the subsequent loop only initializes entries up to the number of used descriptors (`mapped`).
I see that `nvme_pci_sgl_set_data` is used to populate the `nvme_sgl_desc` structure for each segment, so the `addr`, `len` and `type` fields are properly set, but there is no explicit zeroing. This means the allocated SGL memory may contain stale data.
Let's quickly check the struct definition:
`struct nvme_sgl_desc`
```c
struct nvme_sgl_desc {
__le64 addr;
__le32 length;
u8 type;
u8 reserved[3];
};
```
This is important because `nvme_pci_sgl_set_data` only populates the `addr`, `length` and `type` fields. The `reserved` field *isn't* explicitly initialized or set to zero. This could be a potential issue if the NVMe controller is sensitive to the contents of that field.
|
| 134/3 | 2026/10/07 02:23 | tool | grepper |
0mArgs:{
"Expression": "struct nvme_sgl_desc"
}Results: {
"Output": "drivers/nvme/host/pci.c-51-#define NVME_MAX_SEGS \\\ndrivers/nvme/host/pci.c:52:\t(NVME_CTRL_PAGE_SIZE / sizeof(struct nvme_sgl_desc))\ndrivers/nvme/host/pci.c-53-\n--\ndrivers/nvme/host/pci.c-58-#define NVME_MAX_META_SEGS \\\ndrivers/nvme/host/pci.c:59:\t((NVME_SMALL_POOL_SIZE / sizeof(struct nvme_sgl_desc)) - 1)\ndrivers/nvme/host/pci.c-60-\n--\ndrivers/nvme/host/pci.c=437=struct nvme_iod {\n--\ndrivers/nvme/host/pci.c-451-\tstruct dma_iova_state meta_dma_state;\ndrivers/nvme/host/pci.c:452:\tstruct nvme_sgl_desc *meta_descriptor;\ndrivers/nvme/host/pci.c-453-};\n--\ndrivers/nvme/host/pci.c=940=static void nvme_free_prps(struct request *req, unsigned int attrs)\n--\ndrivers/nvme/host/pci.c-951-\ndrivers/nvme/host/pci.c:952:static void nvme_free_sgls(struct request *req, struct nvme_sgl_desc *sge,\ndrivers/nvme/host/pci.c:953:\t\tstruct nvme_sgl_desc *sg_list, unsigned int attrs)\ndrivers/nvme/host/pci.c-954-{\n--\ndrivers/nvme/host/pci.c=972=static void nvme_unmap_metadata(struct request *req)\n--\ndrivers/nvme/host/pci.c-978-\tstruct device *dma_dev = nvmeq-\u003edev-\u003edev;\ndrivers/nvme/host/pci.c:979:\tstruct nvme_sgl_desc *sge = iod-\u003emeta_descriptor;\ndrivers/nvme/host/pci.c-980-\tunsigned int attrs = 0;\n--\ndrivers/nvme/host/pci.c=1104=static blk_status_t nvme_pci_setup_data_prp(struct request *req,\n--\ndrivers/nvme/host/pci.c-1225-\ndrivers/nvme/host/pci.c:1226:static void nvme_pci_sgl_set_data(struct nvme_sgl_desc *sge,\ndrivers/nvme/host/pci.c-1227-\t\tdma_addr_t addr, u32 len)\n--\ndrivers/nvme/host/pci.c-1233-\ndrivers/nvme/host/pci.c:1234:static void nvme_pci_dma_iter_set_sgl(struct nvme_sgl_desc *sge,\ndrivers/nvme/host/pci.c-1235-\t\tstruct blk_dma_iter *iter)\n--\ndrivers/nvme/host/pci.c-1239-\ndrivers/nvme/host/pci.c:1240:static void nvme_pci_sgl_set_seg(struct nvme_sgl_desc *sge,\ndrivers/nvme/host/pci.c-1241-\t\tdma_addr_t dma_addr, int entries)\n--\ndrivers/nvme/host/pci.c=1286=static blk_status_t nvme_rq_setup_dmabuf_sgl(struct request *req,\n--\ndrivers/nvme/host/pci.c-1291-\tsize_t length = blk_rq_payload_bytes(req);\ndrivers/nvme/host/pci.c:1292:\tstruct nvme_sgl_desc *sg_list = \u0026iod-\u003ecmd.common.dptr.sgl;\ndrivers/nvme/host/pci.c-1293-\tsize_t offset = req-\u003ebio-\u003ebi_iter.bi_offset;\n--\ndrivers/nvme/host/pci.c=1384=static blk_status_t nvme_pci_setup_data_sgl(struct request *req,\n--\ndrivers/nvme/host/pci.c-1389-\tunsigned int entries = blk_rq_nr_phys_segments(req);\ndrivers/nvme/host/pci.c:1390:\tstruct nvme_sgl_desc *sg_list;\ndrivers/nvme/host/pci.c-1391-\tdma_addr_t sgl_dma;\n--\ndrivers/nvme/host/pci.c=1514=static blk_status_t nvme_pci_setup_meta_iter(struct request *req)\n--\ndrivers/nvme/host/pci.c-1519-\tstruct nvme_dev *dev = nvmeq-\u003edev;\ndrivers/nvme/host/pci.c:1520:\tstruct nvme_sgl_desc *sg_list;\ndrivers/nvme/host/pci.c-1521-\tstruct blk_dma_iter iter;\n--\ndrivers/nvme/host/rdma.c=1299=static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue,\n--\ndrivers/nvme/host/rdma.c-1302-{\ndrivers/nvme/host/rdma.c:1303:\tstruct nvme_sgl_desc *sg = \u0026c-\u003ecommon.dptr.sgl;\ndrivers/nvme/host/rdma.c-1304-\tstruct ib_sge *sge = \u0026req-\u003esge[1];\n--\ndrivers/nvme/host/tcp.c=2644=static void nvme_tcp_set_sg_null(struct nvme_command *c)\ndrivers/nvme/host/tcp.c-2645-{\ndrivers/nvme/host/tcp.c:2646:\tstruct nvme_sgl_desc *sg = \u0026c-\u003ecommon.dptr.sgl;\ndrivers/nvme/host/tcp.c-2647-\n--\ndrivers/nvme/host/tcp.c=2654=static void nvme_tcp_set_sg_inline(struct nvme_tcp_queue *queue,\n--\ndrivers/nvme/host/tcp.c-2656-{\ndrivers/nvme/host/tcp.c:2657:\tstruct nvme_sgl_desc *sg = \u0026c-\u003ecommon.dptr.sgl;\ndrivers/nvme/host/tcp.c-2658-\n--\ndrivers/nvme/host/tcp.c=2664=static void nvme_tcp_set_sg_host_data(struct nvme_command *c,\n--\ndrivers/nvme/host/tcp.c-2666-{\ndrivers/nvme/host/tcp.c:2667:\tstruct nvme_sgl_desc *sg = \u0026c-\u003ecommon.dptr.sgl;\ndrivers/nvme/host/tcp.c-2668-\n--\ndrivers/nvme/target/pci-epf.c=949=static int nvmet_pci_epf_iod_parse_prps(struct nvmet_pci_epf_iod *iod)\n--\ndrivers/nvme/target/pci-epf.c-971- */\ndrivers/nvme/target/pci-epf.c:972:static struct nvme_sgl_desc *\ndrivers/nvme/target/pci-epf.c-973-nvmet_pci_epf_get_sgl_segment(struct nvmet_pci_epf_ctrl *ctrl,\ndrivers/nvme/target/pci-epf.c:974:\t\t\t struct nvme_sgl_desc *desc, unsigned int *nr_sgls)\ndrivers/nvme/target/pci-epf.c-975-{\ndrivers/nvme/target/pci-epf.c:976:\tstruct nvme_sgl_desc *sgls;\ndrivers/nvme/target/pci-epf.c-977-\tu32 length = le32_to_cpu(desc-\u003elength);\n--\ndrivers/nvme/target/pci-epf.c-980-\ndrivers/nvme/target/pci-epf.c:981:\tif (length \u003c sizeof(struct nvme_sgl_desc))\ndrivers/nvme/target/pci-epf.c-982-\t\treturn NULL;\n--\ndrivers/nvme/target/pci-epf.c-995-\tsgls = buf;\ndrivers/nvme/target/pci-epf.c:996:\tnr_descs = length / sizeof(struct nvme_sgl_desc);\ndrivers/nvme/target/pci-epf.c-997-\tif (sgls[nr_descs - 1].type == (NVME_SGL_FMT_SEG_DESC \u003c\u003c 4) ||\n--\ndrivers/nvme/target/pci-epf.c=1016=static int nvmet_pci_epf_iod_parse_sgl_segments(struct nvmet_pci_epf_ctrl *ctrl,\n--\ndrivers/nvme/target/pci-epf.c-1019-\tstruct nvme_command *cmd = \u0026iod-\u003ecmd;\ndrivers/nvme/target/pci-epf.c:1020:\tstruct nvme_sgl_desc seg = cmd-\u003ecommon.dptr.sgl;\ndrivers/nvme/target/pci-epf.c:1021:\tstruct nvme_sgl_desc *sgls = NULL;\ndrivers/nvme/target/pci-epf.c-1022-\tint n = 0, i, nr_sgls;\n--\ndrivers/nvme/target/pci-epf.c=1076=static int nvmet_pci_epf_iod_parse_sgls(struct nvmet_pci_epf_iod *iod)\n--\ndrivers/nvme/target/pci-epf.c-1078-\tstruct nvmet_pci_epf_ctrl *ctrl = iod-\u003ectrl;\ndrivers/nvme/target/pci-epf.c:1079:\tstruct nvme_sgl_desc *sgl = \u0026iod-\u003ecmd.common.dptr.sgl;\ndrivers/nvme/target/pci-epf.c-1080-\n--\ndrivers/nvme/target/rdma.c=855=static u16 nvmet_rdma_map_sgl_inline(struct nvmet_rdma_rsp *rsp)\ndrivers/nvme/target/rdma.c-856-{\ndrivers/nvme/target/rdma.c:857:\tstruct nvme_sgl_desc *sgl = \u0026rsp-\u003ereq.cmd-\u003ecommon.dptr.sgl;\ndrivers/nvme/target/rdma.c-858-\tu64 off = le64_to_cpu(sgl-\u003eaddr);\n--\ndrivers/nvme/target/tcp.c=418=static int nvmet_tcp_map_data(struct nvmet_tcp_cmd *cmd)\ndrivers/nvme/target/tcp.c-419-{\ndrivers/nvme/target/tcp.c:420:\tstruct nvme_sgl_desc *sgl = \u0026cmd-\u003ereq.cmd-\u003ecommon.dptr.sgl;\ndrivers/nvme/target/tcp.c-421-\tu32 len = le32_to_cpu(sgl-\u003elength);\n--\ndrivers/nvme/target/tcp.c=603=static void nvmet_tcp_queue_response(struct nvmet_req *req)\n--\ndrivers/nvme/target/tcp.c-609-\tstruct nvmet_tcp_cmd *queue_cmd;\ndrivers/nvme/target/tcp.c:610:\tstruct nvme_sgl_desc *sgl;\ndrivers/nvme/target/tcp.c-611-\tu32 len;\n--\ninclude/linux/nvme.h=1007=enum {\n--\ninclude/linux/nvme.h-1016- *\ninclude/linux/nvme.h:1017: * For struct nvme_sgl_desc:\ninclude/linux/nvme.h-1018- * @NVME_SGL_FMT_DATA_DESC:\t\tdata block descriptor\n--\ninclude/linux/nvme.h=1028=enum {\n--\ninclude/linux/nvme.h-1035-\ninclude/linux/nvme.h:1036:struct nvme_sgl_desc {\ninclude/linux/nvme.h-1037-\t__le64\taddr;\n--\ninclude/linux/nvme.h=1050=union nvme_data_ptr {\n--\ninclude/linux/nvme.h-1054-\t};\ninclude/linux/nvme.h:1055:\tstruct nvme_sgl_desc\tsgl;\ninclude/linux/nvme.h-1056-\tstruct nvme_keyed_sgl_desc ksgl;\n"
} |
| 135/3 | 2026/10/07 02:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 85081 output: 37 thoughts: 26 Thoughts: Here's my thought process, as if I were considering this myself: **Diving into the NVMe SGL Descriptor** Alright, time to get my hands dirty. I need to take a look at the definition of `struct nvme_sgl_desc`. My initial instinct is to go directly to the source, so I'll check `include/linux/nvme.h`. That's where the core NVMe structures and definitions should reside within the kernel headers, so I'll find what I need there. This SGL descriptor is crucial, as it will describe scatter-gather lists. I know that I will need to understand this to have a handle on how this block driver handles memory. Let's see what's in there. |
| 136/3 | 2026/10/07 02:24 | tool | read-file |
0mArgs:{
"File": "include/linux/nvme.h",
"FirstLine": 1036,
"LineCount": 15
}Results: {
"Contents": "1036:\tstruct nvme_sgl_desc {\n1037:\t\t__le64\taddr;\n1038:\t\t__le32\tlength;\n1039:\t\t__u8\trsvd[3];\n1040:\t\t__u8\ttype;\n1041:\t};\n1042:\t\n1043:\tstruct nvme_keyed_sgl_desc {\n1044:\t\t__le64\taddr;\n1045:\t\t__u8\tlength[3];\n1046:\t\t__u8\tkey[4];\n1047:\t\t__u8\ttype;\n1048:\t};\n1049:\t\n1050:\tunion nvme_data_ptr {\n"
} |
| 137/3 | 2026/10/07 02:24 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 85510 output: 40 thoughts: 1420 Thoughts: **Analyzing NVMe SGL and PRP Handling** Okay, let's break this down. First, I was looking at the `nvme_sgl_desc` structure and the `nvme_pci_sgl_set_data` function, trying to understand how data descriptors are set up for Single-Gather List (SGL) transfers over PCIe. The `nvme_sgl_desc` structure clearly defines fields for address, length, reserved bytes (`rsvd`), and type. The `nvme_pci_sgl_set_data` function populates the address, length, and type fields of the SGL descriptor. My initial thought was, "Hey, does `nvme_pci_sgl_set_data` touch the `rsvd` field?" It doesn't, which is expected. Then I wanted to confirm if this code was recently changed, but the diff shows that the function signature was actually refactored to take dma parameters. Since this structure is used to communicate with the NVMe device over PCIe, the reserved fields are ignored by hardware. Now, let's shift gears to how PRP lists are handled. I need to understand how the driver manages Physical Region Page (PRP) lists, which are crucial for data transfer. I'm looking at `nvme_rq_setup_dmabuf_map` and how it sets up these PRP lists. This function seems to handle the mapping of DMA buffers to PRP entries. It checks if the data fits into a single PRP entry, or if multiple PRP entries are needed. When multiple entries are required, it allocates a PRP list, which contains the DMA addresses for the data. If the data exceeds the small pool size, it moves to the large pool. Then, the function populates the PRP list with DMA addresses, handling the cases where it needs to allocate additional PRP lists. Ultimately it populates `iod->cmd.common.dptr.prp1` and `iod->cmd.common.dptr.prp2` with the PRP addresses. So far, it seems like standard PRP handling, and a good way to handle DMA. Now, I should continue the analysis. |
| 138/3 | 2026/10/07 02:25 | tool | read-file |
0mArgs:{
"File": "drivers/nvme/host/pci.c",
"FirstLine": 1150,
"LineCount": 70
}Results: {
"Contents": "1150:\t\n1151:\t\tif (DIV_ROUND_UP(length, NVME_CTRL_PAGE_SIZE) \u003c=\n1152:\t\t NVME_SMALL_POOL_SIZE / sizeof(__le64))\n1153:\t\t\tiod-\u003eflags |= IOD_SMALL_DESCRIPTOR;\n1154:\t\n1155:\t\tprp_list = dma_pool_alloc(nvme_dma_pool(nvmeq, iod), GFP_ATOMIC,\n1156:\t\t\t\t\u0026prp2_dma);\n1157:\t\tif (!prp_list) {\n1158:\t\t\titer-\u003estatus = BLK_STS_RESOURCE;\n1159:\t\t\tgoto done;\n1160:\t\t}\n1161:\t\tiod-\u003edescriptors[iod-\u003enr_descriptors++] = prp_list;\n1162:\t\n1163:\t\ti = 0;\n1164:\t\tfor (;;) {\n1165:\t\t\tprp_list[i++] = cpu_to_le64(iter-\u003eaddr);\n1166:\t\t\tprp_len = min(length, NVME_CTRL_PAGE_SIZE);\n1167:\t\t\tif (WARN_ON_ONCE(iter-\u003elen \u003c prp_len))\n1168:\t\t\t\tgoto bad_sgl;\n1169:\t\n1170:\t\t\tiod-\u003etotal_len += prp_len;\n1171:\t\t\titer-\u003eaddr += prp_len;\n1172:\t\t\titer-\u003elen -= prp_len;\n1173:\t\t\tlength -= prp_len;\n1174:\t\t\tif (!length)\n1175:\t\t\t\tbreak;\n1176:\t\n1177:\t\t\tif (!nvme_pci_prp_iter_next(req, nvmeq-\u003edev-\u003edev, iter)) {\n1178:\t\t\t\tif (WARN_ON_ONCE(!iter-\u003estatus))\n1179:\t\t\t\t\tgoto bad_sgl;\n1180:\t\t\t\tgoto done;\n1181:\t\t\t}\n1182:\t\n1183:\t\t\t/*\n1184:\t\t\t * If we've filled the entire descriptor, allocate a new that is\n1185:\t\t\t * pointed to be the last entry in the previous PRP list. To\n1186:\t\t\t * accommodate for that move the last actual entry to the new\n1187:\t\t\t * descriptor.\n1188:\t\t\t */\n1189:\t\t\tif (i == NVME_CTRL_PAGE_SIZE \u003e\u003e 3) {\n1190:\t\t\t\t__le64 *old_prp_list = prp_list;\n1191:\t\t\t\tdma_addr_t prp_list_dma;\n1192:\t\n1193:\t\t\t\tprp_list = dma_pool_alloc(nvmeq-\u003edescriptor_pools.large,\n1194:\t\t\t\t\t\tGFP_ATOMIC, \u0026prp_list_dma);\n1195:\t\t\t\tif (!prp_list) {\n1196:\t\t\t\t\titer-\u003estatus = BLK_STS_RESOURCE;\n1197:\t\t\t\t\tgoto done;\n1198:\t\t\t\t}\n1199:\t\t\t\tiod-\u003edescriptors[iod-\u003enr_descriptors++] = prp_list;\n1200:\t\n1201:\t\t\t\tprp_list[0] = old_prp_list[i - 1];\n1202:\t\t\t\told_prp_list[i - 1] = cpu_to_le64(prp_list_dma);\n1203:\t\t\t\ti = 1;\n1204:\t\t\t}\n1205:\t\t}\n1206:\t\n1207:\tdone:\n1208:\t\t/*\n1209:\t\t * nvme_unmap_data uses the DPT field in the SQE to tear down the\n1210:\t\t * mapping, so initialize it even for failures.\n1211:\t\t */\n1212:\t\tiod-\u003ecmd.common.dptr.prp1 = cpu_to_le64(prp1_dma);\n1213:\t\tiod-\u003ecmd.common.dptr.prp2 = cpu_to_le64(prp2_dma);\n1214:\t\tif (unlikely(iter-\u003estatus))\n1215:\t\t\tnvme_unmap_data(req);\n1216:\t\treturn iter-\u003estatus;\n1217:\t\n1218:\tbad_sgl:\n1219:\t\tdev_err_once(nvmeq-\u003edev-\u003edev,\n"
} |
| 139/3 | 2026/10/07 02:25 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 88584 output: 34 thoughts: 6526 Thoughts: **io_uring dmabuf Integration Analysis** Alright, let's break down this io_uring dmabuf integration. The basic idea is to adapt the existing PRP list logic for dmabuf, creating a path for zero-copy I/O with block devices, specifically NVMe drives. My focus here is on understanding how this is implemented, and critically, if there's any risk of information leakage to userspace. First, I looked at how dmabufs are registered with io_uring. The kernel uses `IORING_REGISTER_BUFFERS2` and `IORING_REGISTER_BUFFERS_UPDATE` with the `IORING_RSRC_UPDATE_EXTENDED` flag, along with a `struct io_uring_regbuf_desc`. When the type is `IO_REGBUF_TYPE_DMABUF`, `io_register_dmabuf` is called. It validates the setup, retrieves the dmabuf file descriptor, and links the target file with the dmabuf via `dma_buf_io_ctx_create`. This looks solid, and I see a check for `CONFIG_DMA_SHARED_BUFFER` which is important. The use of `imu->release = io_release_dmabuf` is good, that's what I expect. Then, during I/O submission via `io_read_fixed` or `io_write_fixed`, `io_init_rw_fixed` gets called, which in turn calls `io_import_reg_buf`. If the registered buffer is a dmabuf (`IO_REGBUF_F_DMABUF`), `io_import_dmabuf_map` is used to hook this into the request and then `io_attach_dmabuf_map` is responsible for attaching the dmabuf map. The `iov_iter_dmabuf_map` is where it sets up the dmabuf-based scatter-gather list and attaches it to the request. The block layer functions are then used and they ultimately use the dmabuf map in the `bio` structure. So it's all making sense so far. Now the critical part – info leaks. The main concern is that the block device reads data into the DMABUF, which the user can then `mmap` or read directly. The question is: is any kernel data being copied to userspace via `copy_to_user`, `put_user`, socket, or netlink? I checked the code paths carefully, including `io_uring_rsrc_update2`, which has a `copy_from_user` but doesn't copy anything *back*. The important point: No kernel structures are being *directly* copied to userspace. That’s good! Next, I looked at the NVMe driver's side to understand the `nvme_dma_buf_io_map`. This is where the mapping of dmabuf to a scatter-gather list (sgt) happens. This is a critical area. `kvmalloc_flex` is used to allocate the `nvme_dmabuf_map`. I see the `dma_list` is populated from the scatter-gather table. The size calculations are the important part. Here's the problem: The code allocates `nr_entries` based on `ctx->dmabuf->size`. But if the `sgt` has fewer entries than `nr_entries`, then `map->dma_list` would contain uninitialized memory and we could have a memory disclosure vulnerability. Worse, If the sgt has MORE entries than `nr_entries`, we have an out-of-bounds write to `map->dma_list` and we have a heap-buffer-overflow. This is where KASAN (Kernel AddressSanitizer) comes in. It would catch such an out-of-bounds write. However, if `sgt` has fewer entries then `remaining` can be non-zero and we hit an `if (unlikely(remaining)) return 0;` which would return `BLK_STS_IOERR`. Further, the `bvec_done` and `map_idx` which is calculated using `bvec_done` could also lead to an out-of-bounds read if the index exceeds the number of entries if `map->sgt` has fewer bytes. To double-check for safety, I re-examined the KMSAN criteria. Does any of the code involve copying kernel structures to userspace, or branching on uninitialized data, or allocating complex structures with uninitialized fields, or allowing access to uninitialized bytes? I reviewed all the files, including io_uring code, and confirmed that the main data flows are through dmabufs or control structures (like `io_uring_rsrc_update |
| 140/3 | 2026/10/07 02:26 | tool | grepper |
0mArgs:{
"Expression": "io_uring_rsrc_update2",
"PathPrefixes": [
"io_uring/"
]
}Results: {
"Output": "io_uring/io_uring.c=3285=static int __init io_uring_init(void)\n--\nio_uring/io_uring.c-3353-\tBUILD_BUG_ON(sizeof(struct io_uring_rsrc_update) \u003e\nio_uring/io_uring.c:3354:\t\t sizeof(struct io_uring_rsrc_update2));\nio_uring/io_uring.c-3355-\n--\nio_uring/rsrc.c=330=static int __io_sqe_files_update(struct io_ring_ctx *ctx,\nio_uring/rsrc.c:331:\t\t\t\t struct io_uring_rsrc_update2 *up,\nio_uring/rsrc.c-332-\t\t\t\t unsigned nr_args)\n--\nio_uring/rsrc.c=400=static int __io_sqe_buffers_update(struct io_ring_ctx *ctx,\nio_uring/rsrc.c:401:\t\t\t\t struct io_uring_rsrc_update2 *up,\nio_uring/rsrc.c-402-\t\t\t\t unsigned int nr_args)\n--\nio_uring/rsrc.c=471=static int __io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned type,\nio_uring/rsrc.c:472:\t\t\t\t struct io_uring_rsrc_update2 *up,\nio_uring/rsrc.c-473-\t\t\t\t unsigned nr_args)\n--\nio_uring/rsrc.c=491=int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,\n--\nio_uring/rsrc.c-493-{\nio_uring/rsrc.c:494:\tstruct io_uring_rsrc_update2 up;\nio_uring/rsrc.c-495-\n--\nio_uring/rsrc.c=506=int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg,\n--\nio_uring/rsrc.c-508-{\nio_uring/rsrc.c:509:\tstruct io_uring_rsrc_update2 up;\nio_uring/rsrc.c-510-\n--\nio_uring/rsrc.c=608=int io_files_update(struct io_kiocb *req, unsigned int issue_flags)\n--\nio_uring/rsrc.c-611-\tstruct io_ring_ctx *ctx = req-\u003ectx;\nio_uring/rsrc.c:612:\tstruct io_uring_rsrc_update2 up2;\nio_uring/rsrc.c-613-\tint ret;\n"
} |
| 141/3 | 2026/10/07 02:26 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 96866 output: 477 thoughts: 3944 Thoughts: **Analysis of Potential Uninitialized Memory Issues in DMA-BUF Integration** Okay, so I've gone through this patch with a fine-tooth comb, focusing specifically on the potential for uninitialized memory usage. The core functionality seems to involve integrating DMA-BUF with the block layer, NVMe host driver, and io_uring, and the crucial point is that data is primarily flowing from userspace *to* kernel space. `io_register_rsrc_update` and `io_files_update` only copy *from* user space. This is a key starting point: no direct avenues for info leaks via uninitialized memory to user space. I carefully scrutinized all conditional logic introduced or modified. Every branch condition I looked at checks variables that are either initialized within the same scope, initialized during data structure creation, or cloned from an already initialized structure. There are no "if" statements that hinge on potentially uninitialized values. Specifically, the checks within the `block/bio.c`, `block/blk-merge.c`, `block/fops.c`, `drivers/md/dm-io-rewind.c`, `drivers/nvme/host/core.c`, `drivers/nvme/host/pci-dmabuf.c`, `drivers/nvme/host/pci.c`, `io_uring/dma-buf.c`, `io_uring/rsrc.c`, and `io_uring/rw.c` all look safe. The next concern was data structure initialization. I double-checked the allocation and initialization of every data structure touched by the patch. All allocations, including `nvme_ctx`, `bd`, `imu`, `up2`, and `map` are either zeroed during allocation via `kzalloc`, `kzalloc_obj`, or `memset` or are fully initialized through the use of compound literals or a `copy_from_user` operation that ensures every field is populated. The `map` structure, which involves `sgt` and `dma_list`, is carefully populated after allocation, and I traced its use to ensure all reads are from initialized fields. Critically, there's no scenario where uninitialized fields of `map` are read before being written. Finally, I checked for cases where bounds checks or logic might allow access to uninitialized bytes in existing buffers. The block device is doing DMA directly to/from the memory backing the DMA-BUF. This is an important consideration as it bypasses the CPU for data transfer. My focus shifted to potential issues in how DMA buffers are mapped, requests are split, and offsets and lengths are calculated. For example, in `bio_split_io_at_dmabuf`, and the various `nvme_` functions, alignment checks and index calculations are crucial. My thinking here is: if an alignment or index calculation is wrong, the kernel is likely to try to read or write beyond the bounds of a buffer, rather than accessing the buffer's uninitialized portion. Here’s the rub: those kinds of problems (out-of-bounds array access, use-after-free, double-free, concurrency bugs, and NULL dereferences) are *exactly* what KASAN, LOCKDEP, and standard kernel crash detection are designed to catch! The potential for a real issue here is more about memory safety, and less about uninitialized values. `map->dma_list` or `sg_list` indexing out of bounds, reference counting or locking bugs, and invalid pointers fall squarely into KASAN's domain. Since the patch doesn't introduce uninitialized memory risks that *only* KMSAN could detect and since the primary risks are memory safety issues that are well covered by KASAN, LOCKDEP, and standard debugging tools, `NeedsKMSAN` should be `false`. |
| 142/3 | 2026/10/07 02:28 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series adds support for direct I/O to/from DMA-BUF memory in io_uring, the block layer, and the NVMe PCIe driver.\n\nEvaluating KMSAN applicability:\n1. Kernel-to-user info-leaks: No kernel structures are copied or leaked to user space (no copy_to_user, put_user, netlink skbs, etc.). The new UAPI structs (such as struct io_uring_regbuf_desc and io_uring_rsrc_update2) are only copied from user space to kernel space.\n2. Uninitialized memory reads/branches: All newly introduced or modified kernel structures on the stack and heap are fully initialized or zeroed:\n - io_files_update zeroes `up2` via memset(\u0026up2, 0, sizeof(up2)).\n - io_iov_to_regbuf_desc zeroes unspecified fields via C99 compound literal initialization.\n - io_register_dmabuf allocates `bd` via kzalloc.\n - io_register_dmabuf_desc zeroes `imu` via memset(imu, 0, sizeof(*imu)).\n - nvme_init_io_ctx_locked allocates `nvme_ctx` via kzalloc_obj.\n - In nvme_dma_buf_io_map, struct nvme_dmabuf_map has all struct fields initialized before use.\n - No conditional branches or control flow rely on uninitialized memory.\n\nEvaluating KASAN / LOCKDEP applicability:\nThe primary failure modes introduced by this patch series involve DMA buffer lifetime management (dma_buf attachment/detachment, refcounts, use-after-free), scatterlist and segment index calculations (potential out-of-bounds accesses in map-\u003edma_list or sg_list descriptors), and lock ordering (buf_list-\u003elock and dma-resv locks). These issues are thoroughly covered by standard KASAN, LOCKDEP, and standard bug detectors.\n\nTherefore, there is no risk of uninitialized memory use that would justify spawning an expensive dedicated KMSAN fuzzing session.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series adds support for direct I/O to/from DMA-BUF memory in io_uring, the block layer, and the NVMe PCIe driver.\n\nEvaluating KMSAN applicability:\n1. Kernel-to-user info-leaks: No kernel structures are copied or leaked to user space (no copy_to_user, put_user, netlink skbs, etc.). The new UAPI structs (such as struct io_uring_regbuf_desc and io_uring_rsrc_update2) are only copied from user space to kernel space.\n2. Uninitialized memory reads/branches: All newly introduced or modified kernel structures on the stack and heap are fully initialized or zeroed:\n - io_files_update zeroes `up2` via memset(\u0026up2, 0, sizeof(up2)).\n - io_iov_to_regbuf_desc zeroes unspecified fields via C99 compound literal initialization.\n - io_register_dmabuf allocates `bd` via kzalloc.\n - io_register_dmabuf_desc zeroes `imu` via memset(imu, 0, sizeof(*imu)).\n - nvme_init_io_ctx_locked allocates `nvme_ctx` via kzalloc_obj.\n - In nvme_dma_buf_io_map, struct nvme_dmabuf_map has all struct fields initialized before use.\n - No conditional branches or control flow rely on uninitialized memory.\n\nEvaluating KASAN / LOCKDEP applicability:\nThe primary failure modes introduced by this patch series involve DMA buffer lifetime management (dma_buf attachment/detachment, refcounts, use-after-free), scatterlist and segment index calculations (potential out-of-bounds accesses in map-\u003edma_list or sg_list descriptors), and lock ordering (buf_list-\u003elock and dma-resv locks). These issues are thoroughly covered by standard KASAN, LOCKDEP, and standard bug detectors.\n\nTherefore, there is no risk of uninitialized memory use that would justify spawning an expensive dedicated KMSAN fuzzing session.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|