[PATCH 00/10] arm64/entry:

Mark Rutland
2026-04-07T13:17:09Z

Since the move to generic IRQ entry, arm64's involuntary kernel
preemption logic has been subtly broken, and preemption can lead to
tasks running with some exceptions masked unexpectedly.

The gory details were discussed in the thread for my earlier attempt to
fix this:

https://lore.kernel.org/linux-arm-kernel/20260320113026.3219620-1-mark.rutland@arm.com/
https://lore.kernel.org/linux-arm-kernel/ab1prenkP-tFgUzK@J2N7QTR9R3.cambridge.arm.com/
https://lore.kernel.org/linux-arm-kernel/ab2EZAXvL6bYcuKt@J2N7QTR9R3.cambridge.arm.com/
https://lore.kernel.org/linux-arm-kernel/acPAzdtjK5w-rNqC@J2N7QTR9R3/

In summary, due to the way arm64's exceptions work architecturally, and
due to some constraints on sequencing during entry/exit, fixing this
properly requires tha arm64 handles more of the sequencing and
(architectural) state management itself.

This series attempts to make that possible by refactoring the generic
irqentry kernel mode entry/exit paths to look more like the user mode
entry/exit paths, with a separate 'prepare' step prior to return. The
refactoring also allows more of the generic irqentry code to be inlined
into architectural entry code, which can result in slightly better code
generation.

I've split the series into a prefix of changes for generic irqentry,
followed by changes to the arm64 code. I'm hoping that we can queue the
generic irqentry patches onto a stable branch, or take those via arm64.
The patches are as follows:

* Patches 1 and 2 are cleanup to the generic irqentry code. These have no
functional impact, and I think these can be taken regardless of the
rest of the series.

* Patches 3 to 5 refactor the generic irqentry code as described above,
providing separate irqentry_{enter,exit}() functions and providing a
split form of irqentry_exit_to_kernel_mode() similar to what exists
for irqentry_exit_to_user_mode(). These patches alone should have no
functional impact.

* Patch 6 is a minimal fix for the arm64 exception masking issues. This
DOES NOT depend on the generic irqentry patches, and can be backported
to stable.

* Patches 7 to 9 refactor the arm64 entry code and provide a more
optimal fix (which permits preemption in more cases). These are split
into separate patches to aid bisection.

* Patch 10 is a test which can detect exceptions being masked
unexpectedly. I don't know whether we want to take this as-is, but
I've included it here to aid testing and so that it gets archived for
future reference.

The series is based on v7.0-rc3.

Thanks,
Mark.

Mark Rutland (10):
entry: Fix stale comment for irqentry_enter()
entry: Remove local_irq_{enable,disable}_exit_to_user()
entry: Move irqentry_enter() prototype later
entry: Split kernel mode logic from irqentry_{enter,exit}()
entry: Split preemption from irqentry_exit_to_kernel_mode()
arm64: entry: Don't preempt with SError or Debug masked
arm64: entry: Consistently prefix arm64-specific wrappers
arm64: entry: Use irqentry_{enter_from,exit_to}_kernel_mode()
arm64: entry: Use split preemption logic
arm64: Check DAIF (and PMR) at task-switch time

arch/arm64/kernel/entry-common.c | 52 ++++----
arch/arm64/kernel/process.c | 25 ++++
include/linux/entry-common.h | 2 +-
include/linux/irq-entry-common.h | 196 ++++++++++++++++++++++---------
kernel/entry/common.c | 107 ++---------------
5 files changed, 202 insertions(+), 180 deletions(-)

--
2.30.2