From 413197cef9ccbf22831eb914c2ef469880468d97 Mon Sep 17 00:00:00 2001 From: Krzysztof Galazka Date: Fri, 16 May 2025 13:29:08 +0200 Subject: [PATCH] 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 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 --- sys/amd64/vmm/io/ppt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/amd64/vmm/io/ppt.c b/sys/amd64/vmm/io/ppt.c index c3b2b57da98..2cb459fb848 100644 --- a/sys/amd64/vmm/io/ppt.c +++ b/sys/amd64/vmm/io/ppt.c @@ -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);