From: Mark Brown <broonie@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: 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 2/2] arm64: gcs: Store GCSCRE0_EL1 values instead of userspace mode
Date: Wed, 14 Oct 2026 19:28:08 +0100 [thread overview]
Message-ID: <c39b2cc4-832f-49cb-8a59-e5b7a8bd9317@sirena.org.uk> (raw)
In-Reply-To: <as-8IqsbMbOBo5Oq@arm.com>
[-- Attachment #1: Type: text/plain, Size: 2224 bytes --]
On Wed, Oct 14, 2026 at 06:30:10PM +0100, Catalin Marinas wrote:
> On Thu, Sep 17, 2026 at 11:14:17PM +0100, Mark Brown wrote:
> > u64 por_el0;
> > #ifdef CONFIG_ARM64_GCS
> > - unsigned int gcs_el0_mode;
> > + unsigned int gcscre0_el1;
> u64?
Sure, I always find the decision about which to use in a given situation
confusing.
> > - current->thread.gcs_el0_mode = enabled;
> > + gcs_set_el0_mode(current, enabled);
>
> I think we have an existing bug here and it's more serious without this
> patch. restore_gcs_context() does not update the actual register and,
> with current mainline, we may even skip the hardware write in
> gcs_thread_switch(). Basically one task can disable GCS for another
Right, that's an existing bug.
> task. Can we get gcs_set_el0_mode() to actually update the register as
> well?
We also set the mode from ptrace at which point it's being set for a
different thread.
> On the sigreturn bug, do you recall why we thought we needed to update
> the gcs_el0_mode in the signal handler (or even expose it)? Wouldn't it
> be better if the signal handler did a prctl() directly if it needed to
> change the mode for the current thread?
In theory you could have tasks with a mix of GCS and non-GCS threads
doing green thread stuff, especially if the clone3() stuff had gone in
so that the GCS wasn't so tied to the thread. You could also have mixed
push or write permissions in that case. I am not sure that any of this
is a realistic use case though, I'm certainly not aware of any current
users.
The case where a signal handler tries to handle a GCS fault by disabling
GCS could be handled using prctl() if someone wants it. I'm not aware
of anyone doing that yet, there was some talk about implementing it in
glibc at LPC but it's not been implemented.
> I don't think we have any precedent for allowing sigreturn to update an
> EL1 sysreg. In hindsight, we shouldn't have exposed it at all but that's
> ABI now. The next best thing we can do now is check the field hasn't
> been modified and fault otherwise (assuming no-one does anything with
> this field).
I don't think userspace is doing anything with it at present.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-10-14 18:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 22:14 [PATCH 0/2] arm64/gcs: Store the GCSCRE0_EL1 register value not " Mark Brown
2026-09-17 22:14 ` [PATCH 1/2] arm64/gcs: Move gcs_check_locked() out of the header Mark Brown
2026-09-17 22:14 ` [PATCH 2/2] arm64: gcs: Store GCSCRE0_EL1 values instead of userspace mode Mark Brown
2026-10-14 17:30 ` Catalin Marinas
2026-10-14 18:28 ` Mark Brown [this message]
2026-10-15 12:04 ` Catalin Marinas
2026-10-15 13:02 ` 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=c39b2cc4-832f-49cb-8a59-e5b7a8bd9317@sirena.org.uk \
--to=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
all inboxes | Powered by JetHome®