tests: kernel: interrupt: workaround qemu_x86 interrupt issue

qemu_x86 seems to take an extra instruction after the sti instruction
(irq_unlock) happens before it posts the interrupts.  This can issues
if the instruction after the sti ends up reading the state that is
suppose to be updated by the ISR handler.

We see this behavior when building with LLVM.  To workaround this issue
we add an arch_nop() to provide an extra instruction to allow the
interrupts to post.

Opened zephyrproject-rtos/sdk-ng#629 to track qemu issue.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
This commit is contained in:
Kumar Gala 2023-02-03 17:42:39 +00:00 committed by Anas Nashif
parent 4e13e6ada7
commit 1c8f1cd590

View file

@ -92,6 +92,21 @@ ZTEST(interrupt_feature, test_isr_regular)
irq_unlock(key);
#ifdef CONFIG_BOARD_QEMU_X86
/* QEMU seems to have an issue in that interrupts seem to post on
* the instruction after the 'sti' that is part of irq_unlock(). This
* can cause an issue if the instruction after the 'sti' ends up looking
* at the state that the ISR is suppose to update. This has been shown
* to happen when building this test for LLVM.
*
* Adding a nop instruction allows QEMU to post the ISR before any state
* gets examined as a workaround.
*
* See GitHub issue zephyrproject-rtos/sdk-ng#629 for the qemu bug.
*/
arch_nop();
#endif
/* interrupt serve after irq unlocked */
zassert_true(reg_int_executed[0] == 2 &&
reg_int_executed[1] == 2,