native_sim: IRQ handling: dont swap if kernel is uninitialized

After an interrupt, do not attempt to swap
if the kernel is not yet initialized.

Otherwise, if an interrupt is raised with interrupts
unlocked while the kernel is not yet fully initialized,
a swap would lead to a crash.
(This could happen if a PREKERNEK1/2 driver enables interrupts
and an interrupt fires before the kernel has swapped to
main)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-08-09 09:23:33 +02:00 committed by Alberto Escolar
commit e543fbdf9a

View file

@ -106,7 +106,7 @@ void posix_irq_handler(void)
*/
if (may_swap
&& (hw_irq_ctrl_get_cur_prio() == 256)
&& (_kernel.ready_q.cache != _current)) {
&& (_kernel.ready_q.cache) && (_kernel.ready_q.cache != _current)) {
(void)z_swap_irqlock(irq_lock);
}