aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/setup.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2021-10-17 17:23:47 +0200
committerArd Biesheuvel <ardb@kernel.org>2021-12-03 15:11:33 +0100
commitae5cc07da8f8e4c9802894c05f1d96802b9de5f2 (patch)
tree21066f35c5fbc0716918d40eb353576819dba285 /arch/arm/kernel/setup.c
parentARM: switch_to: clean up Thumb2 code path (diff)
downloadlinux-dev-ae5cc07da8f8e4c9802894c05f1d96802b9de5f2.tar.xz
linux-dev-ae5cc07da8f8e4c9802894c05f1d96802b9de5f2.zip
ARM: entry: rework stack realignment code in svc_entry
The original Thumb-2 enablement patches updated the stack realignment code in svc_entry to work around the lack of a STMIB instruction in Thumb-2, by subtracting 4 from the frame size, inverting the sense of the misaligment check, and changing to a STMIA instruction and a final stack push of a 4 byte quantity that results in the stack becoming aligned at the end of the sequence. It also pushes and pops R0 to the stack in order to have a temp register that Thumb-2 allows in general purpose ALU instructions, as TST using SP is not permitted. Both are a bit problematic for vmap'ed stacks, as using the stack is only permitted after we decide that we did not overflow the stack, or have already switched to the overflow stack. As for the alignment check: the current approach creates a corner case where, if the initial SUB of SP ends up right at the start of the stack, we will end up subtracting another 8 bytes and overflowing it. This means we would need to add the overflow check *after* the SUB that deliberately misaligns the stack. However, this would require us to keep local state (i.e., whether we performed the subtract or not) across the overflow check, but without any GPRs or stack available. So let's switch to an approach where we don't use the stack, and where the alignment check of the stack pointer occurs in the usual way, as this is guaranteed not to result in overflow. This means we will be able to do the overflow check first. While at it, switch to R1 so the mode stack pointer in R0 remains accessible. Acked-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Tested-by: Marc Zyngier <maz@kernel.org> Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
Diffstat (limited to 'arch/arm/kernel/setup.c')
0 files changed, 0 insertions, 0 deletions