From: David Matlack <dmatlack@google.com>
To: Sairaj Kodilkar <sarunkod@amd.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
Aaron Lewis <aaronlewis@google.com>,
Adhemerval Zanella <adhemerval.zanella@linaro.org>,
Adithya Jayachandran <ajayachandra@nvidia.com>,
Andrew Jones <ajones@ventanamicro.com>,
Ard Biesheuvel <ardb@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Bibo Mao <maobibo@loongson.cn>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Dan Williams <dan.j.williams@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
dmaengine@vger.kernel.org, Huacai Chen <chenhuacai@kernel.org>,
James Houghton <jthoughton@google.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Joel Granados <joel.granados@kernel.org>,
Josh Hilke <jrhilke@google.com>,
Kevin Tian <kevin.tian@intel.com>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
"Pratik R. Sampat" <prsampat@amd.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Sean Christopherson <seanjc@google.com>,
Shuah Khan <shuah@kernel.org>,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Vipin Sharma <vipinsh@google.com>,
Wei Yang <richard.weiyang@gmail.com>,
"Yury Norov [NVIDIA]" <yury.norov@gmail.com>,
Santosh Shukla <santosh.shukla@amd.com>,
Vasant Hegde <vasant.hegde@amd.com>
Subject: Re: [PATCH 03/33] vfio: selftests: Introduce vfio_pci_device_test
Date: Fri, 27 Jun 2025 16:08:02 -0700 [thread overview]
Message-ID: <CALzav=eYD85ydnpAwYsTArDHbxOLd+D-BtYWaiYQxeJ1tGGp7A@mail.gmail.com> (raw)
In-Reply-To: <62734f4d-8883-4145-a483-5bf2c462fad5@amd.com>
On Thu, Jun 26, 2025 at 9:57 PM Sairaj Kodilkar <sarunkod@amd.com> wrote:
>
>
>
> On 6/26/2025 9:59 PM, David Matlack wrote:
> > On Thu, Jun 26, 2025 at 4:44 AM Sairaj Kodilkar <sarunkod@amd.com> wrote:
> >> On 6/26/2025 4:57 PM, Sairaj Kodilkar wrote:
> >>> On 6/21/2025 4:50 AM, David Matlack wrote:
> >>>> +/*
> >>>> + * Limit the number of MSIs enabled/disabled by the test regardless
> >>>> of the
> >>>> + * number of MSIs the device itself supports, e.g. to avoid hitting
> >>>> IRTE limits.
> >>>> + */
> >>>> +#define MAX_TEST_MSI 16U
> >>>> +
> >>>
> >>> Now that AMD IOMMU supports upto 2048 IRTEs per device, I wonder if we
> >>> can include a test with max MSIs 2048.
> >
> > That sounds worth doing. I originally added this because I was hitting
> > IRTE limits on an Intel host and a ~6.6 kernel.
> >
> > Is there some way the test can detect from userspace that the IOMMU
> > supports 2048 IRTEs that we could key off to decide what value of
> > MAX_TEST_MSI to use?
> >
>
> The feature is published to userspace through
>
> $ cat /sys/class/iommu/ivhd0/amd-iommu/features
> 25bf732fa2295afe:53d
>
> The output is in format "efr1:efr2". The Bit 9-8 of efr2 shows the
> support for 2048 interrupts (efr2 & 0x300).
>
> Please refer 3.4.13 Extended Feature 2 Register of IOMMU specs [1] for
> more details.
>
> [1]
> https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/specifications/48882_IOMMU.pdf
>
> Note that, when device is behind PCIe-PCI bridge the IOMMU may hit IRTE
> limit early as multiple devices share same IRTE table. (But this is a
> corner case and I doubt that 2K capable device is kept behind the
> bridge).
Thanks. We could definitely read that and allow up to 2048 MSIs in
this test. Would you be ok if we defer that to a future commit though?
This series is already quite big :)
>
> >>>> +
> >>>> + vfio_pci_dma_map(self->device, iova, size, mem);
> >>>> + printf("Mapped HVA %p (size 0x%lx) at IOVA 0x%lx\n", mem, size,
> >>>> iova);
> >>>> + vfio_pci_dma_unmap(self->device, iova, size);
> >>>
> >>>
> >>> I am slightly confused here. Because You are having an assert on munmap
> >>> and not on any of the vfio_pci_dma_(map/unmap). This test case is not
> >>> testing VFIO.
> >>
> >> I missed to see ioctl_assert. Please ignore this :) Sorry about that.
> >
> > No worries, it's not very obvious :)
> >
> > vfio_pci_dma_map() and vfio_pci_dma_unmap() both return void right now
> > and perform internal asserts since all current users of those
> > functions want to assert success.
> >
> > If and when we have a use-case to assert that map or unmap fails
> > (which I think we'll definitely have) we can add __vfio_pci_dma_map()
> > and __vfio_pci_dma_unmap() variants that return int instead of void.
>
> Yep we can. Another question, why do we need assert on mmunmap ? If
> mmunmap fails then its not really a fault of VFIO.
You're right, it's very unlikely (almost impossible) to be VFIO's
fault if munmap() fails. But it would be a sign of a bug in the test,
so it is still good to detect so we can fix it.
next prev parent reply other threads:[~2025-06-27 23:08 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 23:19 [PATCH 00/33] vfio: Introduce selftests for VFIO David Matlack
2025-06-20 23:19 ` [PATCH 01/33] selftests: Create tools/testing/selftests/vfio David Matlack
2025-06-20 23:20 ` [PATCH 02/33] vfio: selftests: Add a helper library for VFIO selftests David Matlack
2025-06-20 23:20 ` [PATCH 03/33] vfio: selftests: Introduce vfio_pci_device_test David Matlack
2025-06-26 11:27 ` Sairaj Kodilkar
2025-06-26 11:44 ` Sairaj Kodilkar
2025-06-26 16:29 ` David Matlack
2025-06-27 4:57 ` Sairaj Kodilkar
2025-06-27 23:08 ` David Matlack [this message]
2025-06-30 6:18 ` Sairaj Kodilkar
2025-06-20 23:20 ` [PATCH 04/33] vfio: selftests: Test basic VFIO and IOMMUFD integration David Matlack
2025-06-20 23:20 ` [PATCH 05/33] vfio: selftests: Move vfio dma mapping test to their own file David Matlack
2025-06-20 23:20 ` [PATCH 06/33] vfio: selftests: Add test to reset vfio device David Matlack
2025-06-20 23:20 ` [PATCH 07/33] vfio: selftests: Add DMA mapping tests for 2M and 1G HugeTLB David Matlack
2025-06-20 23:20 ` [PATCH 08/33] vfio: selftests: Validate 2M/1G HugeTLB are mapped as 2M/1G in IOMMU David Matlack
2025-06-20 23:20 ` [PATCH 09/33] tools headers: Add stub definition for __iomem David Matlack
2025-06-20 23:20 ` [PATCH 10/33] tools headers: Import asm-generic MMIO helpers David Matlack
2025-06-20 23:20 ` [PATCH 11/33] tools headers: Import x86 MMIO helper overrides David Matlack
2025-06-20 23:20 ` [PATCH 12/33] tools headers: Import iosubmit_cmds512() David Matlack
2025-08-18 23:25 ` Vinicius Costa Gomes
2025-08-18 23:46 ` David Matlack
2025-06-20 23:20 ` [PATCH 13/33] tools headers: Add symlink to linux/pci_ids.h David Matlack
2025-06-20 23:20 ` [PATCH 14/33] vfio: selftests: Keep track of DMA regions mapped into the device David Matlack
2025-06-20 23:20 ` [PATCH 15/33] vfio: selftests: Enable asserting MSI eventfds not firing David Matlack
2025-06-20 23:20 ` [PATCH 16/33] vfio: selftests: Add a helper for matching vendor+device IDs David Matlack
2025-06-20 23:20 ` [PATCH 17/33] vfio: selftests: Add driver framework David Matlack
2025-06-20 23:20 ` [PATCH 18/33] vfio: sefltests: Add vfio_pci_driver_test David Matlack
2025-06-20 23:20 ` [PATCH 19/33] dmaengine: ioat: Move system_has_dca_enabled() to dma.h David Matlack
2025-08-19 22:07 ` Dave Jiang
2025-06-20 23:20 ` [PATCH 20/33] vfio: selftests: Add driver for Intel CBDMA David Matlack
2025-08-19 22:07 ` Dave Jiang
2025-06-20 23:20 ` [PATCH 21/33] dmaengine: idxd: Allow registers.h to be included from tools/ David Matlack
2025-08-18 23:26 ` Vinicius Costa Gomes
2025-06-20 23:20 ` [PATCH 22/33] vfio: selftests: Add driver for Intel DSA David Matlack
2025-08-18 23:41 ` Vinicius Costa Gomes
2025-08-19 16:31 ` David Matlack
2025-08-19 18:52 ` Vinicius Costa Gomes
2025-06-20 23:20 ` [PATCH 23/33] vfio: selftests: Move helper to get cdev path to libvfio David Matlack
2025-06-20 23:20 ` [PATCH 24/33] vfio: selftests: Encapsulate IOMMU mode David Matlack
2025-06-20 23:20 ` [PATCH 25/33] vfio: selftests: Replicate tests across all iommu_modes David Matlack
2025-06-20 23:20 ` [PATCH 26/33] vfio: selftests: Add vfio_type1v2_mode David Matlack
2025-06-20 23:20 ` [PATCH 27/33] vfio: selftests: Add iommufd_compat_type1{,v2} modes David Matlack
2025-06-20 23:20 ` [PATCH 28/33] vfio: selftests: Add iommufd mode David Matlack
2025-06-20 23:20 ` [PATCH 29/33] vfio: selftests: Make iommufd the default iommu_mode David Matlack
2025-06-20 23:20 ` [PATCH 30/33] vfio: selftests: Add a script to help with running VFIO selftests David Matlack
2025-06-20 23:20 ` [PATCH 31/33] KVM: selftests: Build and link sefltests/vfio/lib into KVM selftests David Matlack
2025-06-20 23:20 ` [PATCH 32/33] KVM: selftests: Test sending a vfio-pci device IRQ to a VM David Matlack
2025-06-20 23:20 ` [PATCH 33/33] KVM: selftests: Add -d option to vfio_pci_device_irq_test for device-sent MSIs David Matlack
2025-07-25 16:47 ` [PATCH 00/33] vfio: Introduce selftests for VFIO David Matlack
2025-07-28 16:27 ` Alex Williamson
2025-07-29 22:26 ` Jason Gunthorpe
2025-07-31 20:55 ` David Matlack
2025-08-18 18:59 ` David Matlack
2025-08-18 19:37 ` Alex Williamson
2025-08-18 20:33 ` David Matlack
2025-08-21 20:10 ` Alex Williamson
2025-08-21 21:03 ` David Matlack
2025-08-19 14:50 ` Shuah Khan
2025-08-05 15:08 ` Joel Granados
2025-08-12 15:04 ` David Matlack
2025-08-19 17:48 ` David Matlack
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='CALzav=eYD85ydnpAwYsTArDHbxOLd+D-BtYWaiYQxeJ1tGGp7A@mail.gmail.com' \
--to=dmatlack@google.com \
--cc=aaronlewis@google.com \
--cc=acme@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=ajayachandra@nvidia.com \
--cc=ajones@ventanamicro.com \
--cc=alex.williamson@redhat.com \
--cc=ardb@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=imbrenda@linux.ibm.com \
--cc=jgg@nvidia.com \
--cc=joel.granados@kernel.org \
--cc=jrhilke@google.com \
--cc=jthoughton@google.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maobibo@loongson.cn \
--cc=pasha.tatashin@soleen.com \
--cc=pbonzini@redhat.com \
--cc=prsampat@amd.com \
--cc=richard.weiyang@gmail.com \
--cc=rppt@kernel.org \
--cc=saeedm@nvidia.com \
--cc=santosh.shukla@amd.com \
--cc=sarunkod@amd.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=vasant.hegde@amd.com \
--cc=vinicius.gomes@intel.com \
--cc=vipinsh@google.com \
--cc=yury.norov@gmail.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;
as well as URLs for NNTP newsgroup(s).