Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Brad Hawthorne" <brad@sim.vu>,
	"Russell King" <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org
Cc: "Vladimir Murzin" <vladimir.murzin@arm.com>,
	"Linus Walleij" <linusw@kernel.org>,
	envzhu@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] ARM: v7m: clear CONTROL.FPCA before the boot SVC
Date: Wed, 25 Nov 2026 08:41:28 +0100	[thread overview]
Message-ID: <a1b6d899-b392-45c2-85f2-67bb07fcaf5d@app.fastmail.com> (raw)
In-Reply-To: <20261125025852.1160075-2-brad@sim.vu>

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


  reply	other threads:[~2026-11-25  7:42 UTC|newest]

Thread overview: 5+ 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 ` [PATCH 1/2] ARM: v7m: clear CONTROL.FPCA before the boot SVC Brad Hawthorne
2026-11-25  7:41   ` Arnd Bergmann [this message]
2026-11-25  2:58 ` [PATCH 2/2] ARM: v7m: clear the Cortex-M33's ACTLR.EXTEXCLALL at boot Brad Hawthorne
2026-11-25  7:35   ` Arnd Bergmann

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=a1b6d899-b392-45c2-85f2-67bb07fcaf5d@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=brad@sim.vu \
    --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