Re: [PATCH 1/2] ARM: v7m: clear CONTROL.FPCA before the boot SVC
From: Arnd Bergmann
Date: Wed Nov 25 2026 - 02:42:04 EST
On Wed, Nov 25, 2026, at 03:58, Brad Hawthorne wrote:
> __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.
Should this perhaps be addressed by documenting the state of
the CPU core in Documentation/arch/arm/booting.rst?
We already have similar requirements for normal CPUs there, in
particular about errata workarounds and the state of MMU, cache,
privilege level, instruction set etc, so this seems like something
that should be handled by the loader as well.
Arnd