XDMA: proper write-read selection for get_user_pages_fast
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- c
- Domain
- operating-systems
Research direction
Start in XDMA/linux-kernel/xdma/cdev_sgdma.c at char_sgdma_map_user_buf_to_sgl and inspect how the write argument maps to H2C and C2H transfers. Verify get_user_pages_fast requests writable pages only when DMA writes to user memory, then validate the driver or kernel build; done means read-only H2C buffers can be pinned without requesting write access.
Written by the indexing model from the issue text.
Description
diff --git a/XDMA/linux-kernel/xdma/cdev_sgdma.c b/XDMA/linux-kernel/xdma/cdev_sgdma.c
index 4271173..0333c27 100755
--- a/XDMA/linux-kernel/xdma/cdev_sgdma.c
+++ b/XDMA/linux-kernel/xdma/cdev_sgdma.c
@@ -319,7 +319,9 @@ static int char_sgdma_map_user_buf_to_sgl(struct xdma_io_cb *cb, bool write)
goto err_out;
}
- rv = get_user_pages_fast((unsigned long)buf, pages_nr, 1/* write */,
+ /* write=true means H2C (DMA reads user pages): pin read-only.
+ * write=false means C2H (DMA writes user pages): pin writable. */
+ rv = get_user_pages_fast((unsigned long)buf, pages_nr, !write,
cb->pages);
/* No pages were pinned */
if (rv < 0) {
With the hardcoded 1, H2C always pins writable. That's overly broad — if your H2C source buffer is a read-only mmap() (e.g., a mapped file opened O_RDONLY), the kernel refuses the pin because you're requesting write access to a read-only VMA, even though you only need to read from it.
- Dominant language
- C
- Stars
- 856
- Forks
- 570
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Xilinx/dma_ip_drivers
-
QDMA: libqdma fails to build on RHEL/AlmaLinux/Rocky 9.8+ and 10.1+ (from_timer removed by backport) Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Xilinx/dma_ip_drivers#391 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Xilinx/dma_ip_drivers#387 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Xilinx/dma_ip_drivers#283 ·
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
Xilinx/dma_ip_drivers#401 · 1 comment ·
-
帮我翻译 Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
Xilinx/dma_ip_drivers#400 ·
All issues in Xilinx/dma_ip_drivers
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·