Skip to content

ARM: add support for IRQ stacks

Ard Biesheuvel linux-arm-kernel 4 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest9 patches 0 repliesNew
  2. v310 patches 5 repliesSuperseded
  3. v29 patches 15 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v110 patches3 repliesSuperseded

Changes in v4 from the cover letter

- rebase onto v5.16-rc1
- dropped patch abstracting the call to (*handle_arch_irq)() from entry.S, which is no longer needed due to cross-arch rework that landed during the merge window
- add some acks from Nick

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9ARM: remove some dead codearch/arm/include/asm/entry-macro-multi.S arch/arm/include/asm/smp.h arch/arm/kernel/smp.c+0 -340 replies
2/9ARM: assembler: introduce bl_r macroarch/arm/include/asm/assembler.h+15 -00 replies
3/9ARM: unwind: support unwinding across multiple stacksarch/arm/kernel/unwind.c+16 -90 replies
4/9ARM: export dump_mem() to other objectsarch/arm/include/asm/stacktrace.h arch/arm/kernel/traps.c+5 -40 replies
5/9ARM: unwind: dump exception stack from calling framearch/arm/include/asm/stacktrace.h arch/arm/kernel/traps.c arch/arm/kernel/unwind.c+19 -20 replies
6/9ARM: backtrace-clang: avoid crash on bogus frame pointerarch/arm/lib/backtrace-clang.S+3 -30 replies
7/9ARM: implement IRQ stacksarch/arm/Kconfig arch/arm/include/asm/assembler.h arch/arm/kernel/entry-armv.S +4 more+112 -40 replies
8/9ARM: call_with_stack: add unwind supportarch/arm/lib/call_with_stack.S+25 -80 replies
9/9ARM: run softirqs on the per-CPU IRQ stackarch/arm/Kconfig arch/arm/kernel/irq.c+16 -00 replies

Reviews trailers per patch

All 9 patches have a Reviewed-by or Acked-by.

PatchArnd BergmannLinus WalleijKeith PackardNick Desaulniers
1/9R-b A-b T-b
2/9R-b A-b T-b
3/9R-b A-b T-b
4/9R-b A-b T-b
5/9R-b A-b T-b
6/9R-b
7/9A-b T-b A-b
8/9A-b T-b R-b
9/9R-b A-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v4 thread

Cover letter [PATCH v4 0/9] ARM: add support for IRQ stacks

Compared to user space, the kernel's task stacks are tiny and inflexible, as we don't grow them dynamically using demand paging. This is the reason we tend to obsess about functions with disproportionately large stack frames, given that it is hard to predict statically how calls to those functions may combine at runtime, and exhaust the stack and crash the kernel.

This becomes even less predictable when taking interrupt handling into account, as their handlers are normally executed on the stack of the task that was interrupted, regardless of how deep its call stack was at the time of the interruption. To decouple these, and reduce the risk of hitting a pathological worst case where IRQ handling and the task below it happen to exhaust the available stack space when combined, we can switch to a different stack when taking interrupts, similar to how this is done already on some other architectures. This series implements this approach for ARM.

Note that a good chunk of the changes below are related to supporting non-contiguous call stacks, which is also relevant in the context of vmap'ed stacks, which use a separate overflow stack to handle stack overflows. The changes preserve all functionality related to walking the call stack and dumping exception stacks and register contents.

Changes since v3:
- rebase onto v5.16-rc1
- dropped patch abstracting the call to (*handle_arch_irq)() from entry.S, which is no longer needed due to cross-arch rework that landed during the merge window
- add some acks from Nick

Changes since v2:
- improve Clang support, by emitting code that is compatible with its frame pointer unwinder if that is the unwinder being used;
- add acks from Arnd and Linus (thanks!)

Changes since v1:
- drop the first bugfix patch, which has been queued as a fix in the meantime;
- preserve/restore FP in the irq_handler entry code;
- add missing include to arch/arm/kernel/irq.c to silence warnings about missing prototypes.

Patch #1 removes some code that I spotted that is no longer used.

Patch #2 introduces a macro that will be used later in the series to emit the optimal indirect call sequence for older and newer cores.

Patch #3 updates the unwind info based unwinder so it can deal with call stacks that are non-contiguous.

Patch #4 exports dump_mem() to other compilation units so the ARM unwinder can call it directly. This is needed by the next patch.

Patch #5 refactors the ARM unwinder to dump the exception stack from a context where it is able to figure out if it lives on the current stack or on the task stack.

Patch #6 fixes an issue in the Clang frame pointer unwinder, which may get into an endless recursive fault if any of the stack frames have a bogus value for the link register.

Patch #7 implements the actual IRQ stacks support, by allocating one for each CPU, and adding the code to switch to it in the IRQ entry path. It also contains some related changes to allow the frame pointer based unwinder to deal with the new situation.

Patch #8 modifies call_with_stack() so both the frame pointer unwinder as well as the ARM unwinder know how to deal with it.

Patch #9 adds the IRQ stack switching for softIRQ handling initiated from task context.

Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Kees Cook <[email protected]>
Cc Keith Packard <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Nicolas Pitre <[email protected]>

Ard Biesheuvel (9):
ARM: remove some dead code
ARM: assembler: introduce bl_r macro
ARM: unwind: support unwinding across multiple stacks
ARM: export dump_mem() to other objects
ARM: unwind: dump exception stack from calling frame
ARM: backtrace-clang: avoid crash on bogus frame pointer
ARM: implement IRQ stacks
ARM: call_with_stack: add unwind support
ARM: run softirqs on the per-CPU IRQ stack

 arch/arm/Kconfig                         |  6 +++
 arch/arm/include/asm/assembler.h         | 19 +++++++
 arch/arm/include/asm/entry-macro-multi.S | 24 ---------
 arch/arm/include/asm/smp.h               |  5 --
 arch/arm/include/asm/stacktrace.h        | 12 +++++
 arch/arm/kernel/entry-armv.S             | 54 ++++++++++++++++++--
 arch/arm/kernel/irq.c                    | 37 ++++++++++++++
 arch/arm/kernel/smp.c                    |  5 --
 arch/arm/kernel/traps.c                  | 25 ++++++---
 arch/arm/kernel/unwind.c                 | 33 ++++++++----
 arch/arm/lib/backtrace-clang.S           | 14 +++--
 arch/arm/lib/backtrace.S                 |  8 +++
 arch/arm/lib/call_with_stack.S           | 33 +++++++++---
 13 files changed, 211 insertions(+), 64 deletions(-)
Signature · 7 lines
2.30.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel