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

Sean Christopherson
2026-04-01T20:29:44Z

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.

> @@ -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?

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