From 8c777547f451a6d93ae258bbc794be6752af05c4 Mon Sep 17 00:00:00 2001 From: Auger Eric Date: Mon, 6 Nov 2017 17:08:45 +0100 Subject: [PATCH 9/9] hw/pci-host/gpex: Improve INTX to gsi routing error checking RH-Author: Auger Eric Message-id: <1509988125-30275-5-git-send-email-eric.auger@redhat.com> Patchwork-id: 77511 O-Subject: [RHV7.5 qemu-kvm-ma PATCH 4/4] hw/pci-host/gpex: Improve INTX to gsi routing error checking Bugzilla: 1460957 RH-Acked-by: Alex Williamson RH-Acked-by: Laurent Vivier RH-Acked-by: Miroslav Rezanina We exposed gpex_set_irq_num() for machines to set the INTx to GSI routing. However if the machine forgets to call that function we currently do not check the association was properly done. Let's initialize gsi values to -1 and if this value is found in gpex_route_intx_pin_to_irq, set the routing mode as disabled. Signed-off-by: Eric Auger Message-id: 1508776211-22175-1-git-send-email-eric.auger@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 168df2dea701bbf3118bdfea7794369dfa694d3d) Signed-off-by: Eric Auger Signed-off-by: Miroslav Rezanina --- hw/pci-host/gpex.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c index 4090793..edf305b 100644 --- a/hw/pci-host/gpex.c +++ b/hw/pci-host/gpex.c @@ -57,9 +57,14 @@ static PCIINTxRoute gpex_route_intx_pin_to_irq(void *opaque, int pin) { PCIINTxRoute route; GPEXHost *s = opaque; + int gsi = s->irq_num[pin]; - route.mode = PCI_INTX_ENABLED; - route.irq = s->irq_num[pin]; + route.irq = gsi; + if (gsi < 0) { + route.mode = PCI_INTX_DISABLED; + } else { + route.mode = PCI_INTX_ENABLED; + } return route; } @@ -81,6 +86,7 @@ static void gpex_host_realize(DeviceState *dev, Error **errp) sysbus_init_mmio(sbd, &s->io_ioport); for (i = 0; i < GPEX_NUM_IRQS; i++) { sysbus_init_irq(sbd, &s->irq[i]); + s->irq_num[i] = -1; } pci->bus = pci_register_bus(dev, "pcie.0", gpex_set_irq, -- 1.8.3.1