[PATCH 00/10] arm64/entry:

Mark Rutland posted 10 patches 2 months, 2 weeks ago
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(-)
[PATCH 00/10] arm64/entry:
Posted by Mark Rutland 2 months, 2 weeks ago
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
Re: [PATCH 00/10] arm64/entry:
Posted by Thomas Gleixner 2 months, 2 weeks ago
On Tue, Apr 07 2026 at 14:16, Mark Rutland wrote:
> 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.

I looked through them and I can't find any problem with them. I queued
them localy and added the missing kernel doc as I promised you on IRC.

As I have quite a conflict pending in the tip tree with other changes
related to the generic entry code, I suggest that I queue 1-5, tag them
for arm64 consumption and merge them into the conflicting branch to
avoid trouble with pull request ordering and headaches for the -next
people.

Does that work for you?

Thanks,

        tglx
Re: [PATCH 00/10] arm64/entry:
Posted by Peter Zijlstra 2 months, 1 week ago
On Tue, Apr 07, 2026 at 11:08:36PM +0200, Thomas Gleixner wrote:
> On Tue, Apr 07 2026 at 14:16, Mark Rutland wrote:
> > 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.
> 
> I looked through them and I can't find any problem with them. I queued
> them localy and added the missing kernel doc as I promised you on IRC.
> 
> As I have quite a conflict pending in the tip tree with other changes
> related to the generic entry code, I suggest that I queue 1-5, tag them
> for arm64 consumption and merge them into the conflicting branch to
> avoid trouble with pull request ordering and headaches for the -next
> people.

FWIW, for those 1-5

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Re: [PATCH 00/10] arm64/entry:
Posted by Mark Rutland 2 months, 1 week ago
On Tue, Apr 07, 2026 at 11:08:36PM +0200, Thomas Gleixner wrote:
> On Tue, Apr 07 2026 at 14:16, Mark Rutland wrote:
> > 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.
> 
> I looked through them and I can't find any problem with them. I queued
> them localy and added the missing kernel doc as I promised you on IRC.

Thanks! Much appreciated!

> As I have quite a conflict pending in the tip tree with other changes
> related to the generic entry code, I suggest that I queue 1-5, tag them
> for arm64 consumption and merge them into the conflicting branch to
> avoid trouble with pull request ordering and headaches for the -next
> people.
> 
> Does that work for you?

That sounds good to me.

Catalin, Will, does that work for you?

Mark.
Re: [PATCH 00/10] arm64/entry:
Posted by Catalin Marinas 2 months, 1 week ago
On Wed, Apr 08, 2026 at 10:02:28AM +0100, Mark Rutland wrote:
> On Tue, Apr 07, 2026 at 11:08:36PM +0200, Thomas Gleixner wrote:
> > On Tue, Apr 07 2026 at 14:16, Mark Rutland wrote:
> > > 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.
> > 
> > I looked through them and I can't find any problem with them. I queued
> > them localy and added the missing kernel doc as I promised you on IRC.
> 
> Thanks! Much appreciated!
> 
> > As I have quite a conflict pending in the tip tree with other changes
> > related to the generic entry code, I suggest that I queue 1-5, tag them
> > for arm64 consumption and merge them into the conflicting branch to
> > avoid trouble with pull request ordering and headaches for the -next
> > people.
> > 
> > Does that work for you?
> 
> That sounds good to me.
> 
> Catalin, Will, does that work for you?

Yes, it does. Thanks!

-- 
Catalin
Re: [PATCH 00/10] arm64/entry:
Posted by Thomas Gleixner 2 months, 1 week ago
On Wed, Apr 08 2026 at 10:06, Catalin Marinas wrote:
> On Wed, Apr 08, 2026 at 10:02:28AM +0100, Mark Rutland wrote:
>> > Does that work for you?
>> 
>> That sounds good to me.
>> 
>> Catalin, Will, does that work for you?
>
> Yes, it does. Thanks!

Here you go:

  git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git entry-for-arm64-26-04-08

Thanks,

        tglx
Re: (subset) [PATCH 00/10] arm64/entry:
Posted by Catalin Marinas 2 months, 1 week ago
On Tue, 07 Apr 2026 14:16:40 +0100, Mark Rutland wrote:
> 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:
> 
> [...]

Applied to arm64 (for-next/generic-entry) on top of Thomas' tip branch.
Thanks Mark for the patches and Thomas for providing the entry branch.

[06/10] arm64: entry: Don't preempt with SError or Debug masked
        https://git.kernel.org/arm64/c/2371bd83b3df
[07/10] arm64: entry: Consistently prefix arm64-specific wrappers
        https://git.kernel.org/arm64/c/6879ef130223
[08/10] arm64: entry: Use irqentry_{enter_from,exit_to}_kernel_mode()
        https://git.kernel.org/arm64/c/a07b7b214240
[09/10] arm64: entry: Use split preemption logic
        https://git.kernel.org/arm64/c/ae654112eac0
[10/10] arm64: Check DAIF (and PMR) at task-switch time
        https://git.kernel.org/arm64/c/8d13386c7624