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, stable@vger.kernel.org
Subject: Re: [PATCH 1/6] arm64/sme: Flush foreign register state in do_sme_acc()
Date: Wed, 4 Dec 2024 11:33:02 +0000 [thread overview]
Message-ID: <Z1A97pR+un1Trtyg@e133380.arm.com> (raw)
In-Reply-To: <44d67835-1e43-47cc-9a18-c279c885dcec@sirena.org.uk>
On Tue, Dec 03, 2024 at 05:24:39PM +0000, Mark Brown wrote:
> On Tue, Dec 03, 2024 at 05:00:08PM +0000, Dave Martin wrote:
> > On Tue, Dec 03, 2024 at 04:00:45PM +0000, Mark Brown wrote:
[...]
> We know that the only bit of register state which is not up to date at
> this point is the SME vector length, we don't configure that for tasks
> that do not have SME. SVCR is always configured since we have to exit
> streaming mode for FPSIMD and SVE to work properly so we know it's
> already 0, all the other SME specific state is gated by controls in
> SVCR.
>
> > fpsimd_flush_task_state() means that we do the necessary work when re-
> > entering userspace, but is there a problem with simply marking all the
> > FPSIMD/vector state as stale? If FPSR or FPCR is dirty for example, it
> > now looks like they won't get written back to thread struct if there is
> > a context switch before current re-enters userspace?
>
> > Maybe the other flags distinguish these cases -- I haven't fully got my
> > head around it.
>
> We are doing fpsimd_flush_task_state() in the TIF_FOREIGN_FPSTATE case
> so we know there is no dirty state in the registers.
Ah, that wasn't obvious from the diff context, but you're right.
I was confused by the fpsimd_bind_task_to_cpu() call; I forgot that
there are reasons to call this even when TIF_FOREIGN_FPSTATE is clear.
Perhaps it would be worth splitting some of those uses up, but it would
need some thinking about. Doesn't really belong in this series anyway.
> > (Actually, the ARM ARM says (IMHTLZ) that toggling PSTATE.SM by any
> > means causes FPSR to become 0x800009f. I'm not sure where that fits in
> > -- do we handle that anywhere? I guess the "soft" SM toggling via
>
> Urgh, not seen that one - that needs handling in the signal entry path
> and ptrace. That will have been defined while the feature was being
> implemented. It's not relevant here though since we are in the SME
> access trap, we might be trapping due to a SMSTART or equivalent
> operation but that SMSTART has not yet run at the point where we return
> to userspace.
>
> > ptrace, signal delivery or maybe exec, ought to set this? Not sure how
> > that interacts with the expected behaviour of the fenv(3) API... Hmm.
> > I see no corresponding statement about FPCR.)
>
> Fun. I'm not sure how the ABI is defined there by libc.
I guess this should be left as-is, for now. There's an argument for
sanitising FPCR/FPSR on signal delivery, but neither signal(7) nor
fenv(3) give any clue about the expected behaviour...
For ptrace, the user has the opportunity to specify exactly what they
want to happen to all the registers, so I suppose it's best to stick to
the current model and require the tracer to specify all changes
explicitly rather than add new magic ptrace behaviour.
Not relevant for this series, in any case.
Cheers
---Dave
next prev parent reply other threads:[~2024-12-04 11:34 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 [this message]
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
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=Z1A97pR+un1Trtyg@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=stable@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).