[PATCH] arm64: kasan: mte: move GCR_EL1 switch to task switch when KASAN disabled

Peter Collingbourne pcc at google.com
Tue Sep 7 16:20:41 PDT 2021


On Mon, Sep 6, 2021 at 10:58 AM Catalin Marinas <catalin.marinas at arm.com> wrote:
>
> On Thu, Aug 26, 2021 at 08:07:48PM -0700, Peter Collingbourne wrote:
> > It is not necessary to write to GCR_EL1 on every kernel entry and
> > exit when HW tag-based KASAN is disabled because the kernel will not
> > execute any IRG instructions in that mode. Since accessing GCR_EL1
> > can be expensive on some microarchitectures, avoid doing so by moving
> > the access to task switch when HW tag-based KASAN is disabled.
>
> I haven't got a chance to look at this patch yet as it was posted pretty
> close to the merging window, so it wasn't on my urgent list (not a fix).
>
> What's the use-case exactly? Do you expect production kernels to have
> KASAN_HW built in but disabled on the command line?

Yes, KASAN_HW_TAGS will be enabled in the GKI, but we would still like
the flexibility of allowing vendors to disable it via the command
line. If they choose to do so, the overhead should be as small as
possible.

> I thought there's an
> overhead already from kasan even without MTE.

I believe that the intent is that KASAN_HW_TAGS on its own (with
kasan=off or on unsupported hardware) should not introduce any
significant overhead.

Peter



More information about the linux-arm-kernel mailing list