]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec
authorPhil Dennis-Jordan <phil@philjordan.eu>
Fri, 13 Dec 2024 16:06:14 +0000 (17:06 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 18 Jan 2025 10:43:32 +0000 (13:43 +0300)
commit98f7a50d4c86e4ef197e51b20da325b141c5e769
tree42e91c529cfde64c4eea5653832002d8134c43e6
parent34a2b679c552d3c14573f01e6a5ef3a1d021dd22
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec

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>
hw/usb/hcd-xhci-pci.c