Re: [Patch v1] x86: Fix the logical destination mode test

Nitesh Narayan Lal
2020-03-09T23:25:21Z

On 3/9/20 7:15 PM, Nitesh Narayan Lal wrote:
> There are following issues with the ioapic logical destination mode test:
>
> - A race condition that is triggered when the interrupt handler
>   ioapic_isr_86() is called at the same time by multiple vCPUs. Due to this
> the g_isr_86 is not correctly incremented. To prevent this a spinlock is
> added around ‘g_isr_86++’.
>
> - On older QEMU versions initial x2APIC ID is not set, that is why
>   the local APIC IDs of each vCPUs are not configured. Hence the logical
>   destination mode test fails/hangs. Adding ‘+x2apic’ to the qemu -cpu params
>   ensures that the local APICs are configured every time, irrespective of the
>   QEMU version.
>
> - With ‘-machine kernel_irqchip=split’ included in the ioapic test
>   test_ioapic_self_reconfigure() always fails and somehow leads to a state where
>   after submitting IOAPIC fixed delivery - logical destination mode request we
>   never receive an interrupt back. For now, the physical and logical destination
>   mode tests are moved above test_ioapic_self_reconfigure().

The above were the reasons which were causing the ioapic logical destination
mode test to fail/hang.

The previous discussion can be found at:
https://lore.kernel.org/kvm/20191205151610.19299-1-thuth@redhat.com/

Following is a test run with smp = 4 and -machine kernel_irqchip=split.

[root@virtlab420 kvm-unit-tests]# git diff
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index d658bc8..348953b 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -46,7 +46,7 @@ timeout = 30
[ioapic]
file = ioapic.flat
smp = 4
-extra_params = -cpu qemu64,+x2apic
+extra_params = -cpu qemu64,+x2apic -machine kernel_irqchip=split
arch = x86_64

[cmpxchg8b]
[root@virtlab420 kvm-unit-tests]# ./tests/ioapic
BUILD_HEAD=83a3b429
timeout -k 1s --foreground 90s /usr/libexec/qemu-kvm -nodefaults -device
pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4 -vnc none -serial stdio
-device pci-testdev -machine accel=kvm -kernel /tmp/tmp.cS40xFvt0U -smp 4 -cpu
qemu64,+x2apic -machine kernel_irqchip=split # -initrd /tmp/tmp.69rw56TppH
enabling apic
enabling apic
enabling apic
enabling apic
paging enabled
cr0 = 80010011
cr3 = 61d000
cr4 = 20
x2apic enabled
PASS: version register read only test
PASS: id register only bits [24:27] writable
PASS: arbitration register set by id
PASS: arbtration register read only
PASS: edge triggered intr
PASS: level triggered intr
PASS: ioapic simultaneous edge interrupts
PASS: coalesce simultaneous level interrupts
PASS: sequential level interrupts
PASS: retriggered level interrupts without masking
PASS: masked level interrupt
PASS: unmasked level interrupt
PASS: masked level interrupt
PASS: unmasked level interrupt
PASS: retriggered level interrupts with mask
PASS: TMR for ioapic edge interrupts (expected false)
PASS: TMR for ioapic level interrupts (expected false)
PASS: TMR for ioapic level interrupts (expected true)
PASS: TMR for ioapic edge interrupts (expected true)
PASS: ioapic physical destination mode
PASS: ioapic logical destination mode
1012375 iterations before interrupt received
PASS: TMR for ioapic edge interrupts (expected false)
832021 iterations before interrupt received
PASS: TMR for ioapic level interrupts (expected false)
1009498 iterations before interrupt received
PASS: TMR for ioapic level interrupts (expected true)
994532 iterations before interrupt received
PASS: TMR for ioapic edge interrupts (expected true)
FAIL: Reconfigure self
SUMMARY: 26 tests, 1 unexpected failures
FAIL ioapic (26 tests, 1 unexpected failures)

Please let me know if there are any more suggestions/comments.

[...]

--
Nitesh