Skip to contentSkip to conversation

Minor regression with kvm ioapic, gsi >= 16

Qemu-devel Avi Kivity 2 participants 2 messages Feb 16, 2012

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

kvm-unit-tests.git x86/apic.flat is failing ioapic tests with

qemu-system-x86_64 -vnc :99 -device testdev,chardev=x -chardev null,id=x -smp 2 -kernel ./x86/apic.flat -serial stdio
...
ioapic interrupt: FAIL
ioapic simultaneous interrupt: FAIL

This happens because the test is invoking gsi 16, which is handled by the non-kvm ioapic instead of the kvm ioapic.

Introduced by

commit c3388c9bd8d4f4fd841b521feed20993185d9be4

Author: Jan Kiszka <[email protected]>
Date:   Mon Feb 6 12:20:53 2012 +0100

qemu-kvm: Fix GSI handling with in-kernel irqchip

Interrupt routing with in-kernel irqchip was always a mess. Now this increased after latest upstream merge: we started to call ioapic_set_irq also for kernel-handled interrupts.

Reduce this mess again by using the upstream kvm_piix3_gsi_handler. It is aware of the PIIX3-specific routing in KVM mode and won't call into the user space APIC model (as we do not raise IRQs >= ISA_NUM_IRQS with the PIIX3).

The obvious fix would be to start using upstream's kvm-ioapic, but you haven't, why?

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#1 lore raw
Quoted 10 lines · Avi Kivity

kvm-unit-tests.git x86/apic.flat is failing ioapic tests with

qemu-system-x86_64 -vnc :99 -device testdev,chardev=x -chardev null,id=x -smp 2 -kernel ./x86/apic.flat -serial stdio
...
ioapic interrupt: FAIL
ioapic simultaneous interrupt: FAIL

This happens because the test is invoking gsi 16, which is handled by the non-kvm ioapic instead of the kvm ioapic.

That test should be changed anyway as the hack that allowed it so far will break finally when we move to upstream logic. Moreover, it is testing unused path with our current chipset. When this may change, I'm sure we will also have better IRQ injection mechanisms by that time.

Find a patch below.

Quoted 18 lines

Introduced by

commit c3388c9bd8d4f4fd841b521feed20993185d9be4

Author: Jan Kiszka <[email protected]>
Date:   Mon Feb 6 12:20:53 2012 +0100

qemu-kvm: Fix GSI handling with in-kernel irqchip

Interrupt routing with in-kernel irqchip was always a mess. Now this increased after latest upstream merge: we started to call ioapic_set_irq also for kernel-handled interrupts.

Reduce this mess again by using the upstream kvm_piix3_gsi_handler. It is aware of the PIIX3-specific routing in KVM mode and won't call into the user space APIC model (as we do not raise IRQs >= ISA_NUM_IRQS with the PIIX3).

Quoted 7 lines

The obvious fix would be to start using upstream's kvm-ioapic, but you haven't, why?

I did this in a separate series, see your inbox.

Jan

--------8<--------

From: Jan Kiszka <[email protected]>

Do not use unsupported IRQ numbers

The testdev is not able to trigger IRQs outside the ISA range (without fragile hacks). But we can use lower pins as well without losing information as the PIC is masked during the test.

---
 x86/apic.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
x86/apic.c +6 -6
index 2725b9a..9e6bff9 100644
@@ -139,8 +139,8 @@ static void ioapic_isr_77(isr_regs_t *regs)
 static void test_ioapic_intr(void)
 {
     handle_irq(0x77, ioapic_isr_77);
-    set_ioapic_redir(0x10, 0x77);
-    toggle_irq_line(0x10);
+    set_ioapic_redir(0x0f, 0x77);
+    toggle_irq_line(0x0f);
     asm volatile ("nop");
     report("ioapic interrupt", g_isr_77 == 1);
 }
@@ -168,11 +168,11 @@ static void test_ioapic_simultaneous(void)
 {
     handle_irq(0x78, ioapic_isr_78);
     handle_irq(0x66, ioapic_isr_66);
-    set_ioapic_redir(0x10, 0x78);
-    set_ioapic_redir(0x11, 0x66);
+    set_ioapic_redir(0x0e, 0x78);
+    set_ioapic_redir(0x0f, 0x66);
     irq_disable();
-    toggle_irq_line(0x11);
-    toggle_irq_line(0x10);
+    toggle_irq_line(0x0e);
+    toggle_irq_line(0x0f);
     irq_enable();
     asm volatile ("nop");
     report("ioapic simultaneous interrupt",
Signature · 1 line
1.7.3.4