From: Mark Rutland <mark.rutland@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Subject: Re: [BOOT-WRAPPER PATCH 3/3] aarch64: Enable use of GCS for EL2 and below
Date: Wed, 27 Nov 2024 10:25:54 +0000 [thread overview]
Message-ID: <Z0bzmYuVweIT-5L5@J2N7QTR9R3> (raw)
In-Reply-To: <287e6fab-e858-4a7b-bc21-687c36742e24@sirena.org.uk>
On Tue, Nov 26, 2024 at 06:53:03PM +0000, Mark Brown wrote:
> On Tue, Nov 26, 2024 at 06:01:56PM +0000, Mark Rutland wrote:
>
> > GCSCR_EL3.PCRSEL resets to 0, so the HW won't push to the GCS for BL/BLR
> > and won't pop from the GCS for a RET. That menas there's no GCS value
> > for a return value check to compare with...
>
> Oh, good point - I'd trusted that the initialisations were required and
> misremembered which of PCRSEL and RVCHKEN was which. Sorry about that.
> The values on reset follow the same pattern in all the GCS control
> registers down to GCSCRE0_EL1 so the initialisations of the other
> control registers are equally redundant. We should be consistent here,
> either initialising all the GCS control registers or relying on the
> architecture defaults for all of them, and the note in the changelog
> about them needs an update if the initialisation is there.
Hmm... that's somewhat unusual, usually the architecture has a "minimal
reset policy", where _ELx register fields are only reset when ELx is the
highest EL after the reset, leaving it to SW to initialise lower ELs.
It's not clear to me if not following that here was deliberate or an
oversight.
I can drop those for now. In future the boot-wrapper will probably need
to poke those (and many other register fields) to properly handle PSCI
CPU_OFF -> CPU_ON sequences, as we currently don't reset anything, and
that should really involve a true reset.
> > That does raise the question of what specifically happens for a return
> > at EL3 when GCSCR_EL3.{PCRSEL,RVCHKEN} == {1,0}. Can you enlighten me?
>
> RET will attempt to load and use a GCS record, the pseudocode is in
> LoadCheckGCSRecord() which isn't EL dependent other than the selection
> of which GCSPR and GCSCR to use and setting the access as privileged if
> we're not at EL0.
Sorry, I got the bits backwards, and had meant the case where:
GCSCR_EL3.{PCRSEL,RVCHKEN} == {0,1}
... where I assume the RVCHKEN bit has no effect given we don't have a
GCS return value to compare against, but wanted to confirm that there
wasn't an architectural edge-case that we might need to feed back to
architects.
It *seems* like RVCHKEN has no effect for RET when PCRSEL is clear.
In ARM DDI 0487K.a, C6.2.291, the pseudocode for RET starts with:
| if (IsFeatureImplemented(FEAT_GCS) && GCSPCREnabled(PSTATE.EL)) then
| target = LoadCheckGCSRecord(target, GCSInstType_PRET);
| SetCurrentGCSPointer(GetCurrentGCSPointer() + 8);
... and RVCHKEN is consumed under LoadCheckGCSRecord(), which has:
| if GCSReturnValueCheckEnabled(PSTATE.EL) && (recorded_va != vaddress) then
| GCSDataCheckException(gcsinst_type);
... where GCSReturnValueCheckEnabled() is:
| boolean GCSReturnValueCheckEnabled(bits(2) el)
| if UsingAArch32() then
| return FALSE;
| case el of
| when EL0 return GCSCRE0_EL1.RVCHKEN == '1';
| when EL1 return GCSCR_EL1.RVCHKEN == '1';
| when EL2 return GCSCR_EL2.RVCHKEN == '1';
| when EL3 return GCSCR_EL3.RVCHKEN == '1';
AFAICT GCSReturnValueCheckEnabled() is only used by
LoadCheckGCSRecord(), and that's only used by the pseudocode for
RET/RETAA/RETAB, so it looks like we're good.
Mark.
next prev parent reply other threads:[~2024-11-27 10:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 15:39 [BOOT-WRAPPER PATCH 0/3] Add support for FEAT_FPMR and FEAT_GCS Mark Rutland
2024-11-26 15:39 ` [BOOT-WRAPPER PATCH 1/3] aarch64: shuffle ID_AA64PFR{0,1}_EL1 definitions Mark Rutland
2024-11-26 15:39 ` [BOOT-WRAPPER PATCH 2/3] aarch64: Enable use of FPMR for EL2 and below Mark Rutland
2024-11-26 17:05 ` Mark Brown
2024-11-26 15:39 ` [BOOT-WRAPPER PATCH 3/3] aarch64: Enable use of GCS " Mark Rutland
2024-11-26 17:20 ` Mark Brown
2024-11-26 18:01 ` Mark Rutland
2024-11-26 18:53 ` Mark Brown
2024-11-27 10:25 ` Mark Rutland [this message]
2024-11-27 11:22 ` 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=Z0bzmYuVweIT-5L5@J2N7QTR9R3 \
--to=mark.rutland@arm.com \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.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