Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aaron Lewis" <aaronlewis@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/4] vfio: selftests: Introduce vfio_dma_mapping_perf_test
Date: Wed, 01 Jul 2026 20:44:06 +0000	[thread overview]
Message-ID: <20260701204407.30F9A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260701203311.326798-2-aaronlewis@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Format String Mismatch (Undefined Behavior) for 64-bit `u64` values.
- [Low] Unused struct `iommu_mapping` definition.
--

commit ed41e119412fd95d65a62de77183ae8dfc8f2449
Author: Aaron Lewis <aaronlewis@google.com>

vfio: selftests: Introduce vfio_dma_mapping_perf_test

Introduce a tool to aid in latency testing rather than a traditional
pass/fail test. Start with a basic test that performs a simple DMA
map/unmap and reports the duration of each operation.

> diff --git a/tools/testing/selftests/vfio/vfio_dma_mapping_perf_test.c b/tools/testing/selftests/vfio/vfio_dma_mapping_perf_test.c
> new file mode 100644
> index 0000000000000..87d84450fc47e
> --- /dev/null
> +++ b/tools/testing/selftests/vfio/vfio_dma_mapping_perf_test.c
> @@ -0,0 +1,124 @@
> +// SPDX-License-Identifier: GPL-2.0-only
[ ... ]
> +static const char *device_bdf;
> +
> +struct iommu_mapping {
> +	u64 pgd;
> +	u64 p4d;
> +	u64 pud;
> +	u64 pmd;
> +	u64 pte;
> +};

[Severity: Low]
This isn't a bug, but struct iommu_mapping is defined and never used in this
file. Is it needed, or is it left over from earlier iterations?

[ ... ]
> +TEST_F(vfio_dma_mapping_perf_test, dma_map_unmap)
> +{
> +	const u64 size = SZ_1G;
> +	const int flags = variant->mmap_flags;
> +	struct dma_region region;
> +	struct timespec start;
> +	u64 unmapped;
> +	int rc;
[ ... ]
> +	timer_start(&start);
> +	iommu_map(self->iommu, &region);
> +	printf("Mapped HVA %p (size %luG) at IOVA 0x%lx in %.2lfms\n",
> +	       region.vaddr, size / SZ_1G, region.iova, timer_elapsed_ms(start));

[Severity: Medium]
Does this printf format string mismatch cause stack misalignment on 32-bit
platforms?

Because size / SZ_1G and region.iova are 64-bit u64 values, using %lu and %lx
instead of %llu and %llx can misalign the variadic arguments. On 32-bit
systems, %lu expects a 32-bit value, so printf will misread the 64-bit integer,
corrupting the subsequent double argument and producing garbage output for
timer_elapsed_ms().

> +	ASSERT_EQ(region.iova, to_iova(self->device, region.vaddr));
> +
> +	timer_start(&start);
> +	rc = __iommu_unmap(self->iommu, &region, &unmapped);
> +	printf("Unmapped IOVA 0x%lx in %.2lfms\n", region.iova, timer_elapsed_ms(start));

[Severity: Medium]
Similarly here, does region.iova need %llx to avoid stack misalignment issues
with the subsequent double on 32-bit platforms?

> +	ASSERT_EQ(rc, 0);
> +	ASSERT_EQ(unmapped, region.size);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260701203311.326798-1-aaronlewis@google.com?part=1

  reply	other threads:[~2026-07-01 20:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 20:33 [PATCH 0/4] Introduce vfio_dma_mapping_perf_test Aaron Lewis
2026-07-01 20:33 ` [PATCH 1/4] vfio: selftests: " Aaron Lewis
2026-07-01 20:44   ` sashiko-bot [this message]
2026-07-01 20:33 ` [PATCH 2/4] vfio: selftests: Add memfd test to vfio_dma_mapping_perf_test Aaron Lewis
2026-07-01 20:43   ` sashiko-bot
2026-07-01 20:33 ` [PATCH 3/4] vfio: selftests: Allow a size for vfio_dma_mapping_perf_test Aaron Lewis
2026-07-01 20:44   ` sashiko-bot
2026-07-01 20:33 ` [PATCH 4/4] vfio: selftests: Allow the flag MAP_POPULATE to be set on the cmdline Aaron Lewis

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=20260701204407.30F9A1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aaronlewis@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox