Commit 1c8f1cd5 authored by Kumar Gala's avatar Kumar Gala Committed by Anas Nashif
Browse files

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: default avatarKumar Gala <kumar.gala@intel.com>
parent 4e13e6ad
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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,