Skip to contentSkip to conversation

fix bug of isa_bus irq

PATCH In review Wanpeng Li 2 participants 4 messages Mar 11, 2012 – Mar 12, 2012

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 1/1 fix bug of isa_bus irq

ISA bus only use IRQ 0~15, so don't need to give an array qemu_irq 0~23, just array qemu_irq i8259 is ok.

---
 hw/pc_piix.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/pc_piix.c +2 -1
index 63dba4e..52f7cf8 100644
@@ -210,7 +210,6 @@ static void pc_init1(MemoryRegion *system_memory,
         isa_bus = isa_bus_new(NULL, system_io);
         no_hpet = 1;
     }
-    isa_bus_irqs(isa_bus, gsi);
 
     if (kvm_irqchip_in_kernel()) {
         i8259 = kvm_i8259_init(isa_bus);
@@ -221,6 +220,8 @@ static void pc_init1(MemoryRegion *system_memory,
         i8259 = i8259_init(isa_bus, cpu_irq[0]);
     }
 
+    isa_bus_irqs(isa_bus, i8259);
+
     for (i = 0; i < ISA_NUM_IRQS; i++) {
         gsi_state->i8259_irq[i] = i8259[i];
     }
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 21 lines · Wanpeng Li

ISA bus only use IRQ 0~15, so don't need to give an array qemu_irq 0~23, just array qemu_irq i8259 is ok.

---
 hw/pc_piix.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/pc_piix.c +0 -1
index 63dba4e..52f7cf8 100644
@@ -210,7 +210,6 @@ static void pc_init1(MemoryRegion *system_memory,
         isa_bus = isa_bus_new(NULL, system_io);
         no_hpet = 1;
     }
-    isa_bus_irqs(isa_bus, gsi);
 
     if (kvm_irqchip_in_kernel()) {
         i8259 = kvm_i8259_init(isa_bus);

hw/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 227

Quoted 8 lines
hw/pc_piix.c +2 -0
@@ -221,6 +220,8 @@ static void pc_init1(MemoryRegion *system_memory,
         i8259 = i8259_init(isa_bus, cpu_irq[0]);
     }
 
+    isa_bus_irqs(isa_bus, i8259);
+
     for (i = 0; i < ISA_NUM_IRQS; i++) {
         gsi_state->i8259_irq[i] = i8259[i];
     }

This is bogus. isa_bus_irqs sets the output IRQs of the ISA bus. And those are not only delivered to the PIC on the PIIX2, but also the IOAPIC. Thus we have to pass in the GSI input lines which dispatch to both. Of those lines, only the first 16 will be used by the ISA bus (there is even an assert to ensure this).

Did you see any concrete bug in the context of this logic?

Jan

author
#2 lore raw
Quoted 37 lines · Jan Kiszka
Quoted 21 lines · Wanpeng Li

ISA bus only use IRQ 0~15, so don't need to give an array qemu_irq 0~23, just array qemu_irq i8259 is ok.

---
 hw/pc_piix.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/pc_piix.c +0 -1
index 63dba4e..52f7cf8 100644
@@ -210,7 +210,6 @@ static void pc_init1(MemoryRegion *system_memory,
         isa_bus = isa_bus_new(NULL, system_io);
         no_hpet = 1;
     }
-    isa_bus_irqs(isa_bus, gsi);
 
     if (kvm_irqchip_in_kernel()) {
         i8259 = kvm_i8259_init(isa_bus);

hw/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 227

Quoted 8 lines
hw/pc_piix.c +2 -0
@@ -221,6 +220,8 @@ static void pc_init1(MemoryRegion *system_memory,
         i8259 = i8259_init(isa_bus, cpu_irq[0]);
     }
 
+    isa_bus_irqs(isa_bus, i8259);
+
     for (i = 0; i < ISA_NUM_IRQS; i++) {
         gsi_state->i8259_irq[i] = i8259[i];
     }

This is bogus. isa_bus_irqs sets the output IRQs of the ISA bus. And those are not only delivered to the PIC on the PIIX2, but also the IOAPIC. Thus we have to pass in the GSI input lines which dispatch to both. Of those lines, only the first 16 will be used by the ISA bus (there is even an assert to ensure this).

Quoted 4 lines

Did you see any concrete bug in the context of this logic?

Jan

Yes, but actually PIC is being used at present, whether passing qemu_irq 0~23 to isa_bus is not safe or not.

Wanpeng Li

#3 lore raw
Quoted 38 lines · Wanpeng Li
Quoted 37 lines · Jan Kiszka
Quoted 21 lines · Wanpeng Li

ISA bus only use IRQ 0~15, so don't need to give an array qemu_irq 0~23, just array qemu_irq i8259 is ok.

---
 hw/pc_piix.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
hw/pc_piix.c +0 -1
index 63dba4e..52f7cf8 100644
@@ -210,7 +210,6 @@ static void pc_init1(MemoryRegion *system_memory,
         isa_bus = isa_bus_new(NULL, system_io);
         no_hpet = 1;
     }
-    isa_bus_irqs(isa_bus, gsi);
 
     if (kvm_irqchip_in_kernel()) {
         i8259 = kvm_i8259_init(isa_bus);

hw/pc_piix.c static void pc_init1(MemoryRegion *system_memory, · line 227

Quoted 8 lines
hw/pc_piix.c +2 -0
@@ -221,6 +220,8 @@ static void pc_init1(MemoryRegion *system_memory,
         i8259 = i8259_init(isa_bus, cpu_irq[0]);
     }
 
+    isa_bus_irqs(isa_bus, i8259);
+
     for (i = 0; i < ISA_NUM_IRQS; i++) {
         gsi_state->i8259_irq[i] = i8259[i];
     }

This is bogus. isa_bus_irqs sets the output IRQs of the ISA bus. And those are not only delivered to the PIC on the PIIX2, but also the IOAPIC. Thus we have to pass in the GSI input lines which dispatch to both. Of those lines, only the first 16 will be used by the ISA bus (there is even an assert to ensure this).

Quoted 7 lines
Quoted 4 lines

Did you see any concrete bug in the context of this logic?

Jan

Yes, but actually PIC is being used at present, whether passing qemu_irq 0~23 to isa_bus is not safe or not.

Sorry, IRQ routing to PIC and IOAPIC is actually not a property of the PIIX3 but the board we emulate. And here we follow the Multiprocessor Specification of Intel and route ISA bus IRQs to both interrupt controllers. Thus the bus must be connected to the GSIs. And, again, GSI[16..13] aren't referenced by the ISA bus at any time.

Jan