From: Brad Hawthorne <brad@sim.vu>
To: linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org
Cc: vladimir.murzin@arm.com, linusw@kernel.org, arnd@arndb.de,
envzhu@gmail.com, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] ARM: v7m: clear CONTROL.FPCA before the boot SVC
Date: Tue, 24 Nov 2026 20:58:51 -0600 [thread overview]
Message-ID: <20261125025852.1160075-2-brad@sim.vu> (raw)
In-Reply-To: <20261125025852.1160075-1-brad@sim.vu>
__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@arm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Brad Hawthorne <brad@sim.vu>
---
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
next prev parent reply other threads:[~2026-11-25 2:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 2:58 [PATCH 0/2] ARM: v7m: reset loader-set CONTROL and M33 ACTLR at boot Brad Hawthorne
2026-11-25 2:58 ` Brad Hawthorne [this message]
2026-11-25 2:58 ` [PATCH 2/2] ARM: v7m: clear the Cortex-M33's ACTLR.EXTEXCLALL " Brad Hawthorne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125025852.1160075-2-brad@sim.vu \
--to=brad@sim.vu \
--cc=arnd@arndb.de \
--cc=envzhu@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=vladimir.murzin@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox