ARM: v7m: enable support for IRQ stacks
authorArd Biesheuvel <ardb@kernel.org>
Thu, 2 Dec 2021 08:36:59 +0000 (09:36 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Mon, 6 Dec 2021 11:49:17 +0000 (12:49 +0100)
Enable support for IRQ stacks on !MMU, and add the code to the IRQ entry
path to switch to the IRQ stack if not running from it already.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
arch/arm/Kconfig
arch/arm/kernel/entry-v7m.S

index 50ae5286f59b5096c13ece1dd6dce191bdb0dd1a..359a3b85c8b37b9e864a3671ae9c7365db365855 100644 (file)
@@ -1158,7 +1158,6 @@ config CURRENT_POINTER_IN_TPIDRURO
 
 config IRQSTACKS
        def_bool y
-       depends on MMU
        select HAVE_IRQ_EXIT_ON_IRQ_STACK
        select HAVE_SOFTIRQ_ON_OWN_STACK
 
index 4e0d318b67c6c92ebadb76ce3b140f33ec49d697..de8a60363c8597769d0d3b5d8bbe28208c724bdd 100644 (file)
@@ -40,11 +40,24 @@ __irq_entry:
        @ Invoke the IRQ handler
        @
        mov     r0, sp
-       stmdb   sp!, {lr}
+       ldr_this_cpu sp, irq_stack_ptr, r1, r2
+
+       @
+       @ If we took the interrupt while running in the kernel, we may already
+       @ be using the IRQ stack, so revert to the original value in that case.
+       @
+       subs    r2, sp, r0              @ SP above bottom of IRQ stack?
+       rsbscs  r2, r2, #THREAD_SIZE    @ ... and below the top?
+       movcs   sp, r0
+
+       push    {r0, lr}                @ preserve LR and original SP
+
        @ routine called with r0 = struct pt_regs *
        bl      generic_handle_arch_irq
 
-       pop     {lr}
+       pop     {r0, lr}
+       mov     sp, r0
+
        @
        @ Check for any pending work if returning to user
        @