Re: [PATCH] vfio/pci: Guard accel_irqchip_begin_route_changes() calls
Cédric Le Goater <[email protected]>
| Newsgroups | gmane.comp.emulators.qemu |
|---|---|
| Message-ID | <[email protected]> |
This is a regression with TCG.
VFIO needs these changes to correctly fall back to userspace interrupt
routing, as before without aborting.
Thanks,
C.
On 7/21/26 12:50, Cédric Le Goater wrote:
> Since commit 49b2dcbd2422 ("accel/accel-irq: add generic
> begin_route_changes"), accel_irqchip_begin_route_changes() aborts when
> no accelerator irqchip is available. This causes a fatal error when
> running VFIO passthrough devices under TCG emulation:
>
> qemu-system-aarch64: can't initiate route change, no accel irqchip available
>
> The previous kvm_irqchip_begin_route_changes() was a simple inline
> that did not have a fatal path. The VFIO code already handles the
> absence of KVM MSI routing gracefully by falling back to userspace
> handling, but the new generic function aborts before that fallback
> can take effect.
>
> Guard the call sites in hw/vfio/pci.c with
> accel_msi_via_irqfd_enabled() so that route changes are only
> initiated when an accelerator irqchip is actually present.
>
> Fixes: 49b2dcbd2422 ("accel/accel-irq: add generic begin_route_changes")
> Cc: Magnus Kulke <[email protected]>
> Signed-off-by: Cédric Le Goater <[email protected]>
> ---
> hw/vfio/pci.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 380dd8c15f8d5bb98b725075978eef2e4e1e6c2d..a3147d28665abd29fd804bd08bdffc3c7440033c 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -699,7 +699,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
> if (msg) {
> if (vdev->defer_kvm_irq_routing) {
> vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true);
> - } else {
> + } else if (accel_msi_via_irqfd_enabled()) {
> vfio_route_change = accel_irqchip_begin_route_changes();
> vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true);
> accel_irqchip_commit_route_changes(&vfio_route_change);
> @@ -801,7 +801,9 @@ void vfio_pci_prepare_kvm_msi_virq_batch(VFIOPCIDevice *vdev)
> {
> assert(!vdev->defer_kvm_irq_routing);
> vdev->defer_kvm_irq_routing = true;
> - vfio_route_change = accel_irqchip_begin_route_changes();
> + if (accel_msi_via_irqfd_enabled()) {
> + vfio_route_change = accel_irqchip_begin_route_changes();
> + }
> }
>
> void vfio_pci_commit_kvm_msi_virq_batch(VFIOPCIDevice *vdev)