All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: mhonap@nvidia.com
Cc: kvm@vger.kernel.org, virtualization@lists.linux.dev,
	dri-devel@lists.freedesktop.org, linux-cxl@vger.kernel.org,
	media-ci@linuxtv.org, "Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH 1/5] vfio/pci: Move the excluded windows out of vfio_pci_core_do_io_rw()
Date: Wed, 02 Dec 2026 09:44:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-245348@kernel.org> (raw)
In-Reply-To: <20261202093250.1683744-2-mhonap@nvidia.com>

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 <mhonap@nvidia.com>

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/20261202093250.1683744-1-mhonap@nvidia.com?part=1

  reply	other threads:[~2026-12-02  9:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:32 [PATCH 0/5] vfio/pci: Per-BAR excluded ranges mhonap
2026-12-02  9:32 ` [PATCH 1/5] vfio/pci: Move the excluded windows out of vfio_pci_core_do_io_rw() mhonap
2026-12-02  9:44   ` sashiko-bot [this message]
2026-12-02  9:32 ` [PATCH 2/5] vfio/virtio: Release vfio-pci-core state when legacy I/O setup fails mhonap
2026-12-02  9:32 ` [PATCH 3/5] vfio/pci: Add per-BAR excluded ranges and put the MSI-X table on them mhonap
2026-12-02  9:32 ` [PATCH 4/5] vfio/pci: Advertise the mmap areas around excluded ranges mhonap
2026-12-02  9:32 ` [PATCH 5/5] vfio/pci: Refuse ioeventfds and dma-buf exports over " mhonap
2026-12-02  9:42   ` sashiko-bot
2026-12-02  9:47 ` [PATCH 0/5] vfio/pci: Per-BAR " sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-245348@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eperezma@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=mhonap@nvidia.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.