From: Catalin Marinas <catalin.marinas@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64/gcs: Don't call gcs_free() during flush_gcs()
Date: Wed, 11 Jun 2025 18:34:15 +0100 [thread overview]
Message-ID: <aEm-F04k0sC1tOCp@arm.com> (raw)
In-Reply-To: <20250611-arm64-gcs-flush-thread-v1-1-cc26feeddabd@kernel.org>
On Wed, Jun 11, 2025 at 05:28:13PM +0100, Mark Brown wrote:
> Currently we call gcs_free() during flush_gcs() to reset the thread state
> for GCS. This includes unmapping any kernel allocated GCS, but this is
> redundant when doing a flush_thread() since we are reinitialisng the thread
> memory too. Inline the reinitialisaton of the thread struct.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> arch/arm64/kernel/process.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
> index a5ca15daeb8a..5954cec19660 100644
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
> @@ -288,7 +288,9 @@ static void flush_gcs(void)
> if (!system_supports_gcs())
> return;
>
> - gcs_free(current);
> + current->thread.gcspr_el0 = 0;
> + current->thread.gcs_base = 0;
> + current->thread.gcs_size = 0;
> current->thread.gcs_el0_mode = 0;
> write_sysreg_s(GCSCRE0_EL1_nTR, SYS_GCSCRE0_EL1);
> write_sysreg_s(0, SYS_GCSPR_EL0);
I think this makes sense.
However, I thought there was another slightly misplaced call to
gcs_free() via arch_release_task_struct(). I wouldn't touch the user
memory with vm_munmap() when releasing a task structure. Is this needed
because the shadow stack is allocated automatically on thread creation,
so we need something to free it when the thread died?
Another caller of gcs_free() is deactivate_mm(). It's not clear to me
when we need to free the shadow stack on this path. On the exit_mm()
path for example we have mmput() -> exit_mmap() that takes care of
unmapping everything. Similarly on the exec_mmap() path.
--
Catalin
next prev parent reply other threads:[~2025-06-11 20:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 16:28 [PATCH] arm64/gcs: Don't call gcs_free() during flush_gcs() Mark Brown
2025-06-11 17:34 ` Catalin Marinas [this message]
2025-06-12 11:40 ` Mark Brown
2025-06-12 14:47 ` Catalin Marinas
2025-06-12 14:51 ` Mark Brown
2025-06-12 16:20 ` Will Deacon
2025-06-12 16:44 ` Mark Brown
2025-06-12 17:27 ` Will Deacon
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=aEm-F04k0sC1tOCp@arm.com \
--to=catalin.marinas@arm.com \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.