Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: David Matlack <dmatlack@google.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org,
	Alex Williamson <alex@shazbot.org>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH 3/3] KVM: selftests: Use VFIO selftests library to pick IOMMU mode in IRQ test
Date: Mon, 2 Nov 2026 07:35:46 -0800	[thread overview]
Message-ID: <auit0kVkAaWcNUvk@google.com> (raw)
In-Reply-To: <auinpIEk6FdGwDS8@google.com>

On Mon, Nov 02, 2026, Sean Christopherson wrote:
> On Thu, Oct 29, 2026, David Matlack wrote:
> >  static void help(const char *name)
> >  {
> >  	printf("Usage: %s [-a] [-d <segment:bus:device.function>] [-e] [-h] [-i nr_irqs] [-m] [-n] [-t iommu_type] [-v nr_vcpus] [-x]\n", name);
> > @@ -266,8 +250,7 @@ int main(int argc, char **argv)
> >  	}
> >  
> >  	if (device_bdf) {
> > -		if (!iommu_type)
> > -			iommu_type = probe_iommu_type();
> > +		TEST_REQUIRE(iommu_mode_is_available(iommu_type));
> 
> This is very unhelpful when neither IOMMUFD nor VFIO is available, especially
> why the user doesn't explicitly provide the desired mode:
> 
>   # ./irq_test -d 0000:6f:01.0 -i 10000
>   Random seed: 0x79d386bd
>   1..0 # SKIP - Requirement not met: iommu_mode_is_available(iommu_type)
> 
> I helped write the test and I had to go read the code to figure out what iommu_type
> would be, and then read the VFIO library to see how it reacted to a NULL pointer.
> 
> How about something like this as fixup:
> 
> diff --git a/tools/testing/selftests/kvm/irq_test.c b/tools/testing/selftests/kvm/irq_test.c
> index f9c11d80a306..63205afc04d1 100644
> --- a/tools/testing/selftests/kvm/irq_test.c
> +++ b/tools/testing/selftests/kvm/irq_test.c
> @@ -250,7 +250,9 @@ int main(int argc, char **argv)
>  	}
>  
>  	if (device_bdf) {
> -		TEST_REQUIRE(iommu_mode_is_available(iommu_type));
> +		__TEST_REQUIRE(iommu_mode_is_available(iommu_type),
> +			       "IOMMU mode(s) '%s' not available",
> +			       iommu_type ? iommu_type : "IOMMU and/or VFIO");
>  		iommu = iommu_init(iommu_type);
>  		device = vfio_pci_device_init(device_bdf, iommu);
>  		msix = vfio_setup_msi(device);
> 
> to yield:
> 
>   # ./irq_test -d 0000:6f:01.0 -i 10000 -t vfio_type1_iommu
>   Random seed: 0x14e21328
>   1..0 # SKIP - IOMMU mode(s) 'vfio_type1_iommu' not available
>   # ./irq_test -d 0000:6f:01.0 -i 10000
>   Random seed: 0x160225ae
>   1..0 # SKIP - IOMMU mode(s) 'IOMMU and/or VFIO' not available

Side topic, it would be nice if iommu_mode_lookup() printed out the known modes
when this is hit:

	VFIO_FAIL("Unrecognized IOMMU mode: %s\n", iommu_mode);

  reply	other threads:[~2026-11-02 15:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 22:17 [PATCH 0/3] vfio: selftests: Automatically detect the IOMMU mode David Matlack
2026-10-29 22:17 ` [PATCH 1/3] vfio: selftests: Automatically detect the IOMMU mode in iommu_init() David Matlack
2026-10-29 22:17 ` [PATCH 2/3] vfio: selftests: Skip tests when the IOMMU mode is not available David Matlack
2026-10-29 22:17 ` [PATCH 3/3] KVM: selftests: Use VFIO selftests library to pick IOMMU mode in IRQ test David Matlack
2026-11-02 15:09   ` Sean Christopherson
2026-11-02 15:35     ` Sean Christopherson [this message]
2026-11-02 18:59       ` 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=auit0kVkAaWcNUvk@google.com \
    --to=seanjc@google.com \
    --cc=alex@shazbot.org \
    --cc=dmatlack@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    /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