Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] vfio/nvgrace-gpu: vfio_pci_core_do_io_rw() byte count treated as error [1] --
commit 483fcda0dfc229fdf013b0a4d4193d8e61dc59ac Author: Manish Honap <[email protected]> vfio/pci: Move the excluded windows out of vfio_pci_core_do_io_rw() This commit moves the excluded range handling out of vfio_pci_core_do_io_rw() into a new vfio_pci_excluded_range_rw() helper in vfio_pci_bar_rw() and removes the window arguments from vfio_pci_core_do_io_rw() and its callers. > diff --git a/drivers/vfio/pci/nvgrace-gpu/main.c > b/drivers/vfio/pci/nvgrace-gpu/main.c > index 5ddec340b73ba..432f6b9c2842b 100644 > --- a/drivers/vfio/pci/nvgrace-gpu/main.c > +++ b/drivers/vfio/pci/nvgrace-gpu/main.c > @@ -787,7 +787,7 @@ nvgrace_gpu_map_and_read(struct > nvgrace_gpu_pci_core_device *nvdev, > ret = vfio_pci_core_do_io_rw(&nvdev->core_device, false, > nvdev->resmem.ioaddr, > buf, offset, mem_count, > - 0, 0, false, VFIO_PCI_IO_WIDTH_8); > + false, VFIO_PCI_IO_WIDTH_8); > } > > return ret; > @@ -925,7 +925,7 @@ nvgrace_gpu_map_and_write(struct > nvgrace_gpu_pci_core_device *nvdev, > ret = vfio_pci_core_do_io_rw(&nvdev->core_device, false, > nvdev->resmem.ioaddr, > (char __user *)buf, pos, mem_count, > - 0, 0, true, VFIO_PCI_IO_WIDTH_8); > + true, VFIO_PCI_IO_WIDTH_8); > } > > return ret; [Severity: High] This problem wasn't introduced by this patch, but do nvgrace_gpu_map_and_read() and nvgrace_gpu_map_and_write() cause their callers to treat a successful vfio_pci_core_do_io_rw() transfer as an error [1]? vfio_pci_core_do_io_rw() returns the positive byte count transferred on success (or a negative errno on failure), whereas the USEMEM_REGION_INDEX branch returns 0 on success. Both nvgrace_gpu_read_mem() and nvgrace_gpu_write_mem() check "if (ret) return ret;", so any non-zero transfer on RESMEM_REGION_INDEX returns early without advancing *ppos, truncates the ssize_t byte count through int ret, and on reads straddling memregion->memlength skips filling the unmapped tail [mem_count, count) with 0xff and returns mem_count instead of count: drivers/vfio/pci/nvgrace-gpu/main.c:nvgrace_gpu_read_mem() { ... scoped_guard(rwsem_read, &vdev->memory_lock) { ... ret = nvgrace_gpu_map_and_read(nvdev, buf, mem_count, ppos); if (ret) return ret; } for (i = mem_count; i < count; i++) { ret = put_user(val, (unsigned char __user *)(buf + i)); if (ret) return ret; } *ppos += count; return count; } [1] https://sashiko.dev/#/bug/linux-1d672947-b9c7-46b6-896d-b4214a0879d3 -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
