[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v17 01/11] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector a
From: |
Phil Dennis-Jordan |
Subject: |
[PATCH v17 01/11] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec |
Date: |
Sun, 12 Jan 2025 22:00:46 +0100 |
QEMU would crash with a failed assertion if the XHCI controller
attempted to raise the interrupt on an interrupter corresponding
to a MSI vector with a higher index than the highest configured
for the device by the guest driver.
This behaviour is correct on the MSI/PCI side: per PCI 3.0 spec,
devices must ensure they do not send MSI notifications for
vectors beyond the range of those allocated by the system/driver
software. Unlike MSI-X, there is no generic way for handling
aliasing in the case of fewer allocated vectors than requested,
so the specifics are up to device implementors. (Section
6.8.3.4. "Sending Messages")
It turns out the XHCI spec (Implementation Note in section 4.17,
"Interrupters") requires that the host controller signal the MSI
vector with the number computed by taking the interrupter number
modulo the number of enabled MSI vectors.
This change introduces that modulo calculation, fixing the
failed assertion. This makes the device work correctly in MSI mode
with macOS's XHCI driver, which only allocates a single vector.
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
v2:
* Switch to modulo arithmetic for MSI vector number rather than dropping,
as per spec.
hw/usb/hcd-xhci-pci.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index a069b42338..49642aab58 100644
--- a/hw/usb/hcd-xhci-pci.c
+++ b/hw/usb/hcd-xhci-pci.c
@@ -74,6 +74,7 @@ static bool xhci_pci_intr_raise(XHCIState *xhci, int n, bool
level)
}
if (msi_enabled(pci_dev) && level) {
+ n %= msi_nr_vectors_allocated(pci_dev);
msi_notify(pci_dev, n);
return true;
}
--
2.39.5 (Apple Git-154)
- [PATCH v17 00/11] New vmapple machine type and xhci fixes, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 01/11] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec,
Phil Dennis-Jordan <=
- [PATCH v17 03/11] hw: Add vmapple subdir, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 02/11] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 04/11] hw/misc/pvpanic: Add MMIO interface, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 06/11] hw/vmapple/bdif: Introduce vmapple backdoor interface, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 07/11] hw/vmapple/cfg: Introduce vmapple cfg region, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 05/11] hw/vmapple/aes: Introduce aes engine, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 10/11] hw/intc: Remove TCG dependency on ARM_GICV3, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 09/11] hw/usb/hcd-xhci-pci: Adds property for disabling mapping in IRQ mode, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 08/11] hw/vmapple/virtio-blk: Add support for apple virtio-blk, Phil Dennis-Jordan, 2025/01/12
- [PATCH v17 11/11] hw/vmapple/vmapple: Add vmapple machine type, Phil Dennis-Jordan, 2025/01/12