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>,
Szabolcs Nagy <szabolcs.nagy@arm.com>,
Tejas Belagod <Tejas.Belagod@arm.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] arm64: mte: switch GCR_EL1 on task switch rather than entry/exit
Date: Mon, 5 Jul 2021 15:17:35 +0100 [thread overview]
Message-ID: <20210705141735.GB4799@arm.com> (raw)
In-Reply-To: <CAMn1gO5=cMZT8d9sMu+EjoYU9UEkTAAhbPqzascZ0RWqL44=Cg@mail.gmail.com>
On Fri, Jul 02, 2021 at 11:39:33AM -0700, Peter Collingbourne wrote:
> On Fri, Jul 2, 2021 at 10:44 AM Catalin Marinas <catalin.marinas@arm.com> wrote:
> > On Thu, Jul 01, 2021 at 08:19:22PM -0700, Peter Collingbourne wrote:
> > > Accessing GCR_EL1 and issuing an ISB can be expensive on some
> > > microarchitectures. To avoid taking this performance hit on every
> > > kernel entry/exit, switch GCR_EL1 on task switch rather than
> > > entry/exit.
> >
> > Is it the ISB that's causing issues or the MRS/MSR as well? I think we
> > can avoid the ISB when PtrAuth is enabled by shuffling the entry code a
> > bit. We can also simplify the mte_set_gcr macro to avoid an MRS.
>
> This was the first thing that I tried on our hardware:
>
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index 7312eafec946..8699ab28a924 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -204,7 +204,6 @@ alternative_else_nop_endif
> ldr_l \tmp, gcr_kernel_excl
>
> mte_set_gcr \tmp, \tmp2
> - isb
> 1:
> #endif
> .endm
> @@ -277,13 +276,13 @@ alternative_if ARM64_HAS_ADDRESS_AUTH
> orr x0, x0, SCTLR_ELx_ENIA
> msr sctlr_el1, x0
> 2:
> - isb
> alternative_else_nop_endif
> #endif
>
> apply_ssbd 1, x22, x23
>
> mte_set_kernel_gcr x22, x23
> + isb
>
> scs_load tsk, x20
> .else
>
> However, on most of the cores this led to only around half of the
> performance improvement of the patch that I sent. Which is somewhat
> surprising, but it is what it is.
BTW, can you also modify mte_set_kernel_gcr to only do a write to the
GCR_EL1 register rather than a read-modify-write?
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2021-07-05 14:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-02 3:19 [PATCH] arm64: mte: switch GCR_EL1 on task switch rather than entry/exit Peter Collingbourne
2021-07-02 17:44 ` Catalin Marinas
2021-07-02 18:39 ` Peter Collingbourne
2021-07-05 14:17 ` Catalin Marinas [this message]
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=20210705141735.GB4799@arm.com \
--to=catalin.marinas@arm.com \
--cc=Tejas.Belagod@arm.com \
--cc=andreyknvl@gmail.com \
--cc=eugenis@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=pcc@google.com \
--cc=szabolcs.nagy@arm.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.