Skip to content

Commit 1234ad6

Browse files
Julien Thierryctmarinas
authored andcommitted
arm64: Skip preemption when exiting an NMI
Handling of an NMI should not set any TIF flags. For NMIs received from EL0 the current exit path is safe to use. However, an NMI received at EL1 could have interrupted some task context that has set the TIF_NEED_RESCHED flag. Preempting a task should not happen as a result of an NMI. Skip preemption after handling an NMI from EL1. Signed-off-by: Julien Thierry <julien.thierry@arm.com> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 7d31464 commit 1234ad6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/arm64/kernel/entry.S

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,15 @@ el1_irq:
624624

625625
#ifdef CONFIG_PREEMPT
626626
ldr x24, [tsk, #TSK_TI_PREEMPT] // get preempt count
627-
cbnz x24, 1f // preempt count != 0
627+
alternative_if ARM64_HAS_IRQ_PRIO_MASKING
628+
/*
629+
* DA_F were cleared at start of handling. If anything is set in DAIF,
630+
* we come back from an NMI, so skip preemption
631+
*/
632+
mrs x0, daif
633+
orr x24, x24, x0
634+
alternative_else_nop_endif
635+
cbnz x24, 1f // preempt count != 0 || NMI return path
628636
bl preempt_schedule_irq // irq en/disable is done inside
629637
1:
630638
#endif

0 commit comments

Comments
 (0)