Patchwork [v2,15/21] q35: Fix non-PCI IRQ processing in ich9_lpc_update_apic

login
register
mail settings
Submitter Jason Baron
Date Oct. 9, 2012, 3:30 a.m.
Message ID <7ea11a735259819620b49c3e0f127f9fe6c89248.1349749915.git.jbaron@redhat.com>
Download mbox | patch
Permalink /patch/190206/
State New
Headers show

Comments

Jason Baron - Oct. 9, 2012, 3:30 a.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

Avoid passing a non-PCI IRQ to ich9_gsi_to_pirq. It's wrong and triggers
an assertion.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Jason Baron <jbaron@redhat.com>
---
 hw/q35.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Paolo Bonzini - Oct. 9, 2012, 7:53 a.m.
Il 09/10/2012 05:30, Jason Baron ha scritto:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> Avoid passing a non-PCI IRQ to ich9_gsi_to_pirq. It's wrong and triggers
> an assertion.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> ---
>  hw/q35.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/q35.c b/hw/q35.c
> index ff570ce..5d256cb 100644
> --- a/hw/q35.c
> +++ b/hw/q35.c
> @@ -663,9 +663,11 @@ static void ich9_lpc_update_apic(ICH9LPCIrqState *irq_state, int gsi)
>  {
>      GMCHPCIHost *s = container_of(irq_state, GMCHPCIHost, irq_state);
>      ICH9LPCState *lpc = irq_state->lpc;
> -    int level;
> +    int level = 0;
>  
> -    level = pci_bus_get_irq_level(s->host.pci.bus, ich9_gsi_to_pirq(gsi));
> +    if (gsi >= ICH9_LPC_PIC_NUM_PINS) {
> +        level |= pci_bus_get_irq_level(s->host.pci.bus, ich9_gsi_to_pirq(gsi));
> +    }
>      if (gsi == ich9_lpc_sci_irq(lpc)) {
>          level |= lpc->sci_level;
>      }
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Patch

diff --git a/hw/q35.c b/hw/q35.c
index ff570ce..5d256cb 100644
--- a/hw/q35.c
+++ b/hw/q35.c
@@ -663,9 +663,11 @@  static void ich9_lpc_update_apic(ICH9LPCIrqState *irq_state, int gsi)
 {
     GMCHPCIHost *s = container_of(irq_state, GMCHPCIHost, irq_state);
     ICH9LPCState *lpc = irq_state->lpc;
-    int level;
+    int level = 0;
 
-    level = pci_bus_get_irq_level(s->host.pci.bus, ich9_gsi_to_pirq(gsi));
+    if (gsi >= ICH9_LPC_PIC_NUM_PINS) {
+        level |= pci_bus_get_irq_level(s->host.pci.bus, ich9_gsi_to_pirq(gsi));
+    }
     if (gsi == ich9_lpc_sci_irq(lpc)) {
         level |= lpc->sci_level;
     }