[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.2.1 32/41] hw/usb/hcd-xhci-pci: Use modulo to select MSI vecto
From: |
Michael Tokarev |
Subject: |
[Stable-9.2.1 32/41] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec |
Date: |
Mon, 27 Jan 2025 17:17:46 +0300 |
From: Phil Dennis-Jordan <phil@philjordan.eu>
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>
Message-ID: <20250112210056.16658-2-phil@philjordan.eu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit bb5b7fced6b5d3334ab20702fc846e47bb1fb731)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
index a039f5778a..516e6909d2 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
- [Stable-9.2.1 06/41] pc-bios: add missing riscv64 descriptor, (continued)
- [Stable-9.2.1 06/41] pc-bios: add missing riscv64 descriptor, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 05/41] roms: re-add edk2-basetools target, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 29/41] hw/ufs: Adjust value to match CPU's endian format, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 31/41] backends/cryptodev-vhost-user: Fix local_error leaks, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 35/41] tests: acpi: whitelist expected blobs, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 34/41] pci/msix: Fix msix pba read vector poll end calculation, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 09/41] target/i386: Reset TSCs of parked vCPUs too on VM reset, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 03/41] tcg/riscv: Fix StoreStore barrier generation, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 04/41] x86/loader: only patch linux kernels, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 30/41] tests/qtest/boot-serial-test: Correct HPPA machine name, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 32/41] hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec,
Michael Tokarev <=
- [Stable-9.2.1 33/41] pci: ensure valid link status bits for downstream ports, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 14/41] docs: Correct release of TCG trace-events removal, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 10/41] hw/intc/riscv_aplic: Fix APLIC in_clrip and clripnum write emulation, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 07/41] hw/intc/arm_gicv3_its: Zero initialize local DTEntry etc structs, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 13/41] docs: Correct '-runas' and '-fsdev/-virtfs proxy' indentation, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 15/41] target/i386/cpu: Fix notes for CPU models, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 12/41] target/loongarch: Use actual operand size with vbsrl check, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 17/41] migration/multifd: Fix compat with QEMU < 9.0, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 22/41] migration: Rename vmstate_info_nullptr, Michael Tokarev, 2025/01/27
- [Stable-9.2.1 16/41] migration/multifd: Fix compile error caused by page_size usage, Michael Tokarev, 2025/01/27