[PATCH 1/2] ARM: v7m: clear CONTROL.FPCA before the boot SVC
From: Brad Hawthorne
Date: Tue Nov 24 2026 - 21:59:23 EST
__v7m_setup writes CONTROL only after the SVC it uses to enter Handler
mode. If the boot loader ran FP code, CONTROL.FPCA can still be set,
so the SVC stacks an extended frame, and its EXC_RETURN has FType
clear. Since commit 72cd4064fcca ("ARM: 8830/1: NOMMU: Toggle only
bits in EXC_RETURN we are really care of"), that EXC_RETURN is saved in
exc_ret, which every return to user space uses, so each return expects
an extended frame that ret_to_user never builds. init then starts with
a corrupted stack.
Write CONTROL to its reset value, 0, before the SVC. That clears FPCA,
and also selects the main stack, which the code after the SVC reads.
Tested under QEMU (mps2-an505) with a boot shim that runs a VMOV
before jumping to the kernel: without this patch init loses its
arguments; with it init starts with them. It also boots on an RP2350
board.
This patch was written with an AI coding assistant (Claude Opus 5.5,
Anthropic): it wrote the change, the boot shim and this changelog, and
ran the QEMU and board tests; I reviewed the reasoning and the test
results.
Fixes: 72cd4064fcca ("ARM: 8830/1: NOMMU: Toggle only bits in EXC_RETURN we are really care of")
Cc: Vladimir Murzin <vladimir.murzin@xxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Brad Hawthorne <brad@xxxxxx>
---
arch/arm/mm/proc-v7m.S | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/mm/proc-v7m.S b/arch/arm/mm/proc-v7m.S
index d4675603593b..6d0532abc086 100644
--- a/arch/arm/mm/proc-v7m.S
+++ b/arch/arm/mm/proc-v7m.S
@@ -124,6 +124,11 @@ __v7m_setup_cont:
mov r5, #0x00800000
str r5, [r0, V7M_SCB_SHPR3] @ set PendSV priority
+ @ Clear CONTROL: a boot loader may leave FPCA or SPSEL set
+ mov r5, #0
+ msr control, r5
+ isb
+
@ SVC to switch to handler mode. Notice that this requires sp to
@ point to writeable memory because the processor saves
@ some registers to the stack.
--
2.43.0