From: Dave Martin <Dave.Martin@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/6] arm64/signal: Consistently invalidate the in register FP state in restore
Date: Tue, 3 Dec 2024 17:06:34 +0000 [thread overview]
Message-ID: <Z086mm/qzNCRB2jH@e133380.arm.com> (raw)
In-Reply-To: <f9e297ab-8325-4b48-b8fc-21486ff48cd2@sirena.org.uk>
Hi,
On Tue, Dec 03, 2024 at 04:53:11PM +0000, Mark Brown wrote:
> On Tue, Dec 03, 2024 at 03:34:01PM +0000, Dave Martin wrote:
> > On Tue, Dec 03, 2024 at 12:45:56PM +0000, Mark Brown wrote:
> > > When restoring the SVE and SME specific floating point register states we
> > > flush the task floating point state, marking the hardware state as stale so
> > > that preemption does not result in us saving register state from the signal
>
> Now I think about it again this should probably be dropped from the
> series, or at least ordered after the reenablement.
>
> > > + * thread floating point state with preemption enabled, so
> > > + * protection is needed to prevent a racing context switch
> > > + * from writing stale registers back over the new data. Mark
> > > + * the register floating point state as invalid and unbind the
> > > + * task from the CPU to force a reload before we return to
> > > + * userspace. fpsimd_flush_task_state() has a check for FP
> > > + * support.
> > > + */
>
> > Maybe add a comment in fpsimd_flush_task_state() about why the
> > system_supports_fpsimd() check is important? It's not obvious there
> > why we should ever be calling that function on non-FPSIMD systems.
>
> There already is a comment in there about it?
There's a comment, but it's not clear that calling that function is
considered correct / useful if there is no FPSIMD.
Not a big deal, anyhow.
> > But would it be a good idea to stick a
> > WARN_ON(!test_thread_flag(TIF_FOREIGN_FPSTATE)) at the start of the
> > functions that rely on this?
>
> As I mentioned in reply to one of your other messages I want to just gut
> the whole API here and replace it with get/put functions for the state
> which would include the get/put functions making sure they're paired
> with each other.
No argument from me on that, but it would be good to have a way to
check that functions that expect to be called with the FP context held,
actually are (similar to lockdep_assert_held() etc.)
If the number of affected functions is low, I guess comments may be
enough, though.
>
> Please delete unneeded context from mails when replying. Doing this
> makes it much easier to find your reply in the message, helping ensure
> it won't be missed by people scrolling through the irrelevant quoted
> material.
Ack, but opinions can differ about what context is unneeded.
I'll try to keep the noise down on these threads.
Cheers
---Dave
next prev parent reply other threads:[~2024-12-03 17:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 12:45 [PATCH 0/6] arm64/sme: Collected SME fixes Mark Brown
2024-12-03 12:45 ` [PATCH 1/6] arm64/sme: Flush foreign register state in do_sme_acc() Mark Brown
2024-12-03 15:32 ` Dave Martin
2024-12-03 16:00 ` Mark Brown
2024-12-03 17:00 ` Dave Martin
2024-12-03 17:24 ` Mark Brown
2024-12-04 11:33 ` Dave Martin
2024-12-03 12:45 ` [PATCH 2/6] arm64/fp: Don't corrupt FPMR when streaming mode changes Mark Brown
2024-12-03 12:45 ` [PATCH 3/6] arm64/ptrace: Zero FPMR on streaming mode entry/exit Mark Brown
2024-12-03 12:45 ` [PATCH 4/6] arm64/signal: Consistently invalidate the in register FP state in restore Mark Brown
2024-12-03 15:34 ` Dave Martin
2024-12-03 16:53 ` Mark Brown
2024-12-03 17:06 ` Dave Martin [this message]
2024-12-03 12:45 ` [PATCH 5/6] arm64/signal: Avoid corruption of SME state when entering signal handler Mark Brown
2024-12-03 15:33 ` Dave Martin
2024-12-03 16:12 ` Mark Brown
2024-12-03 17:10 ` Dave Martin
2024-12-03 12:45 ` [PATCH 6/6] arm64/sme: Reenable SME Mark Brown
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=Z086mm/qzNCRB2jH@e133380.arm.com \
--to=dave.martin@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=will@kernel.org \
/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