From: sashiko-bot@kernel.org
To: "Vipin Sharma" <vipinsh@google.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 16/16] vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Date: Wed, 13 May 2026 23:22:13 +0000 [thread overview]
Message-ID: <20260513232213.C318FC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260511234802.2280368-17-vipinsh@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Missing PROT_READ flag in mmap() causes segmentation fault on read.
- [Low] Incorrect memset size in dma_memcpy_start() leaves half of the transfer buffer uninitialized.
--
commit 4781683698837fa3bf4dcf765b9c536579e8545a
Author: David Matlack <dmatlack@google.com>
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
This commit adds a long-running DMA memcpy operation to the Live Update kexec
test to ensure continuous DMAs do not lead to system instability.
> diff --git a/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c b/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
> index 65c48196e44e7..36bddfbb88ed2 100644
> --- a/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
> +++ b/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
[ ... ]
> +static void dma_memcpy_start(struct vfio_pci_device *device)
> +{
> + void *src = memcpy_region.vaddr, *dst;
> + u64 count, size;
> +
> + size = min_t(u64, memcpy_region.size / 2, device->driver.max_memcpy_size);
> + dst = src + size;
> +
> + /*
> + * Rough Math: If we assume the device will perform memcpy at a rate of
> + * 30GB/s then 7200GB of transfers will run for about 4 minutes.
> + */
> + count = (u64)7200 * SZ_1G / size;
> + count = min_t(u64, count, device->driver.max_memcpy_count);
> +
> + memset(src, 1, size / 2);
> + memset(dst, 0, size / 2);
Does this leave half of the transfer buffer uninitialized?
The transfer size is calculated as size, but the initialization loop
only covers size / 2 bytes. When vfio_pci_driver_memcpy_start() initiates
the DMA transfer of size bytes, the device will read from the uninitialized
second half of the buffer.
> +
> + printf("Kicking off %lu DMA memcpy operations of size 0x%lx...\n", count, size);
> + vfio_pci_driver_memcpy_start(device,
> + to_iova(device, src),
> + to_iova(device, dst),
> + size, count);
> +}
> +
> +static void dma_memfd_map(struct vfio_pci_device *device, int fd)
> +{
> + void *vaddr;
> +
> + vaddr = mmap(NULL, MEMFD_SIZE, PROT_WRITE, MAP_SHARED, fd, 0);
Does this mmap() call need the PROT_READ flag?
The DMA buffer is mapped with only PROT_WRITE, but the test subsequently
performs read operations on this mapped memory:
dma_memcpy_one()
VFIO_ASSERT_EQ(memcmp(src, dst, size), 0);
On architectures that enforce strict memory permissions and do not
implicitly grant read access for write-only mappings, this will cause a
segmentation fault.
> + VFIO_ASSERT_NE(vaddr, MAP_FAILED);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511234802.2280368-1-vipinsh@google.com?part=16
prev parent reply other threads:[~2026-05-13 23:22 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 23:47 [PATCH v4 00/16] vfio/pci: Base Live Update support for VFIO Vipin Sharma
2026-05-11 23:47 ` [PATCH v4 01/16] vfio/pci: Register a file handler with Live Update Orchestrator Vipin Sharma
2026-05-13 2:44 ` sashiko-bot
2026-05-11 23:47 ` [PATCH v4 02/16] vfio/pci: Preserve vfio-pci device files across Live Update Vipin Sharma
2026-05-12 20:59 ` David Matlack
2026-05-12 21:29 ` Vipin Sharma
2026-05-13 22:42 ` Samiullah Khawaja
2026-05-13 3:24 ` sashiko-bot
2026-05-11 23:47 ` [PATCH v4 03/16] vfio/pci: Retrieve preserved device files after " Vipin Sharma
2026-05-13 4:23 ` sashiko-bot
2026-05-11 23:47 ` [PATCH v4 04/16] vfio/pci: Notify PCI subsystem about devices preserved across " Vipin Sharma
2026-05-11 23:47 ` [PATCH v4 05/16] vfio: Enforce preserved devices are retrieved via LIVEUPDATE_SESSION_RETRIEVE_FD Vipin Sharma
2026-05-13 19:16 ` sashiko-bot
2026-05-11 23:47 ` [PATCH v4 06/16] vfio/pci: Store incoming Live Update state in struct vfio_pci_core_device Vipin Sharma
2026-05-13 20:13 ` sashiko-bot
2026-05-11 23:47 ` [PATCH v4 07/16] docs: liveupdate: Add documentation for VFIO PCI Vipin Sharma
2026-05-11 23:47 ` [PATCH v4 08/16] vfio: selftests: Build liveupdate library in VFIO selftests Vipin Sharma
2026-05-13 20:28 ` sashiko-bot
2026-05-11 23:47 ` [PATCH v4 09/16] vfio: selftests: Add vfio_pci_liveupdate_uapi_test Vipin Sharma
2026-05-13 21:12 ` sashiko-bot
2026-05-11 23:47 ` [PATCH v4 10/16] vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD Vipin Sharma
2026-05-11 23:47 ` [PATCH v4 11/16] vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED Vipin Sharma
2026-05-11 23:47 ` [PATCH v4 12/16] vfio: selftests: Add vfio_pci_liveupdate_kexec_test Vipin Sharma
2026-05-11 23:47 ` [PATCH v4 13/16] vfio: selftests: Expose iommu_modes to tests Vipin Sharma
2026-05-11 23:48 ` [PATCH v4 14/16] vfio: selftests: Expose low-level helper routines for setting up struct vfio_pci_device Vipin Sharma
2026-05-11 23:48 ` [PATCH v4 15/16] vfio: selftests: Verify that opening VFIO device fails during Live Update Vipin Sharma
2026-05-13 23:33 ` sashiko-bot
2026-05-11 23:48 ` [PATCH v4 16/16] vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test Vipin Sharma
2026-05-13 23:22 ` sashiko-bot [this message]
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=20260513232213.C318FC19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vipinsh@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox