ppt: Fix panic when configuring unavailable MSI-X vector

In some cases VM may have different idea about number
of available MSI-X vectors then PPT driver. Return
an error when VM requests setup for more vectors
than expected.

It was observed while using SR-IOV on an Intel E810 Ethernet adapter.
VF driver in a VM sees a correct number of available MSI-X vectors,
which depends on num-queues assigned in iovctl.conf, while
pci_msix_count in the PPT driver always returns 1.

Signed-off-by: Krzysztof Galazka <kgalazka@FreeBSD.org>
Reviewed By:	#bhyve, jhb
Approved by:	erj (mentor), kbowling (mentor)
MFC after:	1 week
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D48812
This commit is contained in:
Krzysztof Galazka 2025-05-16 13:29:08 +02:00
parent 91ef8c3e13
commit 413197cef9

View file

@ -750,6 +750,9 @@ ppt_setup_msix(struct vm *vm, int bus, int slot, int func,
}
}
if (idx >= ppt->msix.num_msgs)
return (EINVAL);
if ((vector_control & PCIM_MSIX_VCTRL_MASK) == 0) {
/* Tear down the IRQ if it's already set up */
ppt_teardown_msix_intr(ppt, idx);