]> git.baikalelectronics.ru Git - kernel.git/commit
ARM: 8926/1: v7m: remove register save to stack before svc
authorafzal mohammed <afzal.mohd.ma@gmail.com>
Mon, 21 Oct 2019 05:06:14 +0000 (06:06 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Mon, 21 Oct 2019 17:40:13 +0000 (18:40 +0100)
commite81579595e428a89f2e08e589c1e55a0e89f8507
tree7e4c86997cbb4bc517ed533a91c11a482e296bfb
parentadf041889c37f47eb3e0289e39efa5ad6578fd31
ARM: 8926/1: v7m: remove register save to stack before svc

r0-r3 & r12 registers are saved & restored, before & after svc
respectively. Intention was to preserve those registers across thread to
handler mode switch.

On v7-M, hardware saves the register context upon exception in AAPCS
complaint way. Restoring r0-r3 & r12 is done from stack location where
hardware saves it, not from the location on stack where these registers
were saved.

To clarify, on stm32f429 discovery board:

1. before svc, sp - 0x90009ff8
2. r0-r3,r12 saved to 0x90009ff8 - 0x9000a00b
3. upon svc, h/w decrements sp by 32 & pushes registers onto stack
4. after svc,  sp - 0x90009fd8
5. r0-r3,r12 restored from 0x90009fd8 - 0x90009feb

Above means r0-r3,r12 is not restored from the location where they are
saved, but since hardware pushes the registers onto stack, the registers
are restored correctly.

Note that during register saving to stack (step 2), it goes past
0x9000a000. And it seems, based on objdump, there are global symbols
residing there, and it perhaps can cause issues on a non-XIP Kernel
(on XIP, data section is setup later).

Based on the analysis above, manually saving registers onto stack is at
best no-op and at worst can cause data section corruption. Hence remove
storing of registers onto stack before svc.

Fixes: ac3f487b8f7c ("ARM: 8671/1: V7M: Preserve registers across switch from Thread to Handler mode")
Signed-off-by: afzal mohammed <afzal.mohd.ma@gmail.com>
Acked-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/mm/proc-v7m.S