Fix off-by-one in the MSI-X interrupt establish loop that always tried to
authorpatrick <patrick@openbsd.org>
Wed, 5 Jul 2023 18:11:08 +0000 (18:11 +0000)
committerpatrick <patrick@openbsd.org>
Wed, 5 Jul 2023 18:11:08 +0000 (18:11 +0000)
establish one more interrupt than would be needed for per-VQ IRQs. This
meant even though there were enough MSI-X vectors available this path could
fail, roll back previously established interrupts and switch to shared IRQs
as a fallback.

ok dv@

sys/dev/pci/virtio_pci.c

index 1e54398..28087f1 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: virtio_pci.c,v 1.33 2023/05/29 08:13:35 sf Exp $      */
+/*     $OpenBSD: virtio_pci.c,v 1.34 2023/07/05 18:11:08 patrick Exp $ */
 /*     $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
 
 /*
@@ -976,7 +976,7 @@ virtio_pci_setup_msix(struct virtio_pci_softc *sc, struct pci_attach_args *pa,
                for (i = 0; i < vsc->sc_nvqs; i++)
                        virtio_pci_set_msix_queue_vector(sc, i, 1);
        } else {
-               for (i = 0; i <= vsc->sc_nvqs; i++) {
+               for (i = 0; i < vsc->sc_nvqs; i++) {
                        if (virtio_pci_msix_establish(sc, pa, i + 1,
                            virtio_pci_queue_intr, &vsc->sc_vqs[i])) {
                                goto fail;