From: Catalin Marinas <catalin.marinas@arm.com>
To: Peter Collingbourne <pcc@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Andrey Konovalov <andreyknvl@google.com>,
Mark Brown <broonie@kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
Evgenii Stepanov <eugenis@google.com>
Subject: Re: [PATCH v3 3/3] kasan: arm64: support specialized outlined tag mismatch checks
Date: Tue, 8 Dec 2020 17:49:07 +0000 [thread overview]
Message-ID: <20201208174906.GD13960@gaia> (raw)
In-Reply-To: <e45282aa6bd5495abc71314cb929c85827fa15cc.1606972188.git.pcc@google.com>
On Wed, Dec 02, 2020 at 09:12:24PM -0800, Peter Collingbourne wrote:
> By using outlined checks we can achieve a significant code size
> improvement by moving the tag-based ASAN checks into separate
> functions. Unlike the existing CONFIG_KASAN_OUTLINE mode these
> functions have a custom calling convention that preserves most
> registers and is specialized to the register containing the address
> and the type of access, and as a result we can eliminate the code
> size and performance overhead of a standard calling convention such
> as AAPCS for these functions.
>
> This change depends on a separate series of changes to Clang [1] to
> support outlined checks in the kernel, although the change works fine
> without them (we just don't get outlined checks). This is because the
> flag -mllvm -hwasan-inline-all-checks=0 has no effect until the Clang
> changes land. The flag was introduced in the Clang 9.0 timeframe as
> part of the support for outlined checks in userspace and because our
> minimum Clang version is 10.0 we can pass it unconditionally.
>
> Outlined checks require a new runtime function with a custom calling
> convention. Add this function to arch/arm64/lib.
>
> I measured the code size of defconfig + tag-based KASAN, as well
> as boot time (i.e. time to init launch) on a DragonBoard 845c with
> an Android arm64 GKI kernel. The results are below:
>
> code size boot time
> CONFIG_KASAN_INLINE=y before 92824064 6.18s
> CONFIG_KASAN_INLINE=y after 38822400 6.65s
> CONFIG_KASAN_OUTLINE=y 39215616 11.48s
>
> We can see straight away that specialized outlined checks beat the
> existing CONFIG_KASAN_OUTLINE=y on both code size and boot time
> for tag-based ASAN.
>
> As for the comparison between CONFIG_KASAN_INLINE=y before and after
> we saw similar performance numbers in userspace [2] and decided
> that since the performance overhead is minimal compared to the
> overhead of tag-based ASAN itself as well as compared to the code
> size improvements we would just replace the inlined checks with the
> specialized outlined checks without the option to select between them,
> and that is what I have implemented in this patch. But we may make a
> different decision for the kernel such as having CONFIG_KASAN_OUTLINE=y
> turn on specialized outlined checks if Clang is new enough.
>
> Signed-off-by: Peter Collingbourne <pcc@google.com>
> Link: https://linux-review.googlesource.com/id/I1a30036c70ab3c3ee78d75ed9b87ef7cdc3fdb76
> Link: [1] https://reviews.llvm.org/D90426
> Link: [2] https://reviews.llvm.org/D56954
> ---
> v3:
> - adopt Mark Rutland's suggested changes
> - move frame record alignment patches behind this one
>
> v2:
> - use calculations in the stack spills and restores
> - improve the comment at the top of the function
> - add a BTI instruction
>
> arch/arm64/include/asm/asm-prototypes.h | 6 ++
> arch/arm64/include/asm/module.lds.h | 17 +++++-
> arch/arm64/lib/Makefile | 2 +
> arch/arm64/lib/kasan_sw_tags.S | 76 +++++++++++++++++++++++++
> mm/kasan/tags.c | 7 +++
> scripts/Makefile.kasan | 1 +
I can try to queue the series but this patch would need an ack on the
kasan changes.
(also, it may conflict with linux-next which renames tags.c to sw_tags.c
but that's trivial)
--
Catalin
_______________________________________________
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:[~2020-12-08 17:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 5:12 [PATCH v3 1/3] arm64: Change the on_*stack functions to take a size argument Peter Collingbourne
2020-12-03 5:12 ` [PATCH v3 2/3] arm64: stacktrace: Relax frame record alignment requirement to 8 bytes Peter Collingbourne
2020-12-03 5:12 ` [PATCH v3 3/3] kasan: arm64: support specialized outlined tag mismatch checks Peter Collingbourne
2020-12-08 17:49 ` Catalin Marinas [this message]
2021-01-20 12:41 ` Will Deacon
2021-05-13 2:30 ` Peter Collingbourne
2021-01-07 15:20 ` Andrey Konovalov
2020-12-08 10:20 ` [PATCH v3 1/3] arm64: Change the on_*stack functions to take a size argument Mark Rutland
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=20201208174906.GD13960@gaia \
--to=catalin.marinas@arm.com \
--cc=andreyknvl@google.com \
--cc=ardb@kernel.org \
--cc=broonie@kernel.org \
--cc=eugenis@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=pcc@google.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.