From: Catalin Marinas <catalin.marinas@arm.com>
To: Peter Collingbourne <pcc@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>,
Will Deacon <will@kernel.org>,
Andrey Konovalov <andreyknvl@gmail.com>,
Evgenii Stepanov <eugenis@google.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 2/2] arm64: kasan: mte: move GCR_EL1 switch to task switch when KASAN disabled
Date: Tue, 21 Sep 2021 13:39:58 +0100 [thread overview]
Message-ID: <YUnSnoqcR+u6npsI@arm.com> (raw)
In-Reply-To: <20210915190336.398390-2-pcc@google.com>
On Wed, Sep 15, 2021 at 12:03:36PM -0700, Peter Collingbourne wrote:
> -static void mte_update_sctlr_user(struct task_struct *task)
> +static void mte_update_sctlr_user_and_gcr_excl(struct task_struct *task)
> {
> /*
> * This must be called with preemption disabled and can only be called
> @@ -177,6 +177,24 @@ static void mte_update_sctlr_user(struct task_struct *task)
> else if (resolved_mte_tcf & MTE_CTRL_TCF_SYNC)
> sctlr |= SCTLR_EL1_TCF0_SYNC;
> task->thread.sctlr_user = sctlr;
> +
> + /*
> + * SYS_GCR_EL1 will be set to current->thread.mte_ctrl value by
> + * mte_set_user_gcr() in kernel_exit, but only if KASAN is enabled.
> + */
> + if (!kasan_hw_tags_enabled())
> + write_sysreg_s(((mte_ctrl >> MTE_CTRL_GCR_USER_EXCL_SHIFT) &
> + SYS_GCR_EL1_EXCL_MASK) | SYS_GCR_EL1_RRND,
> + SYS_GCR_EL1);
> +}
The only nitpick I have is that I'd like to keep the GCR_EL1 updating in
a separate function, mte_update_gcr_user() or something (it can be
static inline) that you'd explicitly call from mte_thread_switch() and
set_mte_ctrl(). The original mte_update_sctlr_user() was not writing any
system registers.
Maybe a better alternative would be to move the update_sctlr_el1() call
in mte_update_sctlr_user() as well (and rename it more generically to
mte_update_user_ctrl()) but with a new bool update_sctlr argument that's
false on the thread switch path.
Either way:
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-09-21 12:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 19:03 [PATCH v3 1/2] arm64: add an MTE support check to the top of mte_thread_switch() Peter Collingbourne
2021-09-15 19:03 ` [PATCH v3 2/2] arm64: kasan: mte: move GCR_EL1 switch to task switch when KASAN disabled Peter Collingbourne
2021-09-21 12:39 ` Catalin Marinas [this message]
2021-09-24 1:08 ` Peter Collingbourne
2021-09-21 12:45 ` (subset) [PATCH v3 1/2] arm64: add an MTE support check to the top of mte_thread_switch() Catalin Marinas
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=YUnSnoqcR+u6npsI@arm.com \
--to=catalin.marinas@arm.com \
--cc=andreyknvl@gmail.com \
--cc=eugenis@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=pcc@google.com \
--cc=vincenzo.frascino@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 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.