Re: [PATCH v2 10/14] KVM: selftests: Add support for NMI delivery

Josh Hilke
2026-04-02T05:27:19Z

On Wed, Apr 01, 2026 at 01:29:42PM -0700, Sean Christopherson wrote:
> On Tue, Mar 31, 2026, Josh Hilke wrote:
> > From: David Matlack <dmatlack@google.com>
> >
> > Add the '-n' flag to vfio_pci_irq_test to route device interrupts
> > to be delivered as NMIs (Non-Maskable Interrupts) into the guest.
> > This expands test coverage to include KVM's NMI injection and
> > delivery logic for assigned devices.
>
> The original motivation for sending NMIs wasn't to validate NMI delivery, it was
> to validate KVM's handling of delivery types that _can't_ be posted, and more
> specifically KVM's handling of transitions between posted and remapped mode.
>
> NMI just so happens to be the easy choice (SMI support isn't guaranteed, INIT is
> too destructive). I.e. any NMI testing is largely a bonus.
>

Got it. I'll update the commit body to reflect this.

> > @@ -125,7 +132,7 @@ static void send_msi(struct vfio_pci_device *device, bool use_device_msi, int ms
> >
> > static void help(const char *name)
> > {
> > - printf("Usage: %s [-a] [-b] [-d] [-e] [-h] [-i nr_irqs] segment:bus:device.function\n",
> > + printf("Usage: %s [-a] [-b] [-d] [-e] [-h] [-i nr_irqs] [-n] segment:bus:device.function\n",
> > name);
> > printf("\n");
> > printf(" -a: Randomly affinitize the device IRQ to different CPUs\n"
> > @@ -136,6 +143,8 @@ static void help(const char *name)
> > printf(" -e: Destroy and recreate KVM's GSI routing table in between\n"
> > " some interrupts.\n");
> > printf(" -i: The number of IRQs to generate during the test.\n");
> > + printf(" -n: Route some of the device interrupts to be delivered as\n"
>
> How much is some?
>

Every 4th interrupt is an NMI. I'll update the help text in v3.

> > + " an NMI into the guest.\n");
> > printf("\n");
> > exit(KSFT_FAIL);
> > }