From: Catalin Marinas <catalin.marinas@arm.com>
To: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com,
Andrew Morton <akpm@linux-foundation.org>,
Will Deacon <will@kernel.org>, Dmitry Vyukov <dvyukov@google.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Alexander Potapenko <glider@google.com>,
Marco Elver <elver@google.com>,
Evgenii Stepanov <eugenis@google.com>,
Branislav Rankov <Branislav.Rankov@arm.com>,
Andrey Konovalov <andreyknvl@google.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Subject: Re: [PATCH v15 5/8] arm64: mte: Enable TCO in functions that can read beyond buffer limits
Date: Fri, 12 Mar 2021 15:13:00 +0000 [thread overview]
Message-ID: <20210312151259.GB24210@arm.com> (raw)
In-Reply-To: <20210312142210.21326-6-vincenzo.frascino@arm.com>
On Fri, Mar 12, 2021 at 02:22:07PM +0000, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/include/asm/mte.h b/arch/arm64/include/asm/mte.h
> index 9b557a457f24..8603c6636a7d 100644
> --- a/arch/arm64/include/asm/mte.h
> +++ b/arch/arm64/include/asm/mte.h
> @@ -90,5 +90,20 @@ static inline void mte_assign_mem_tag_range(void *addr, size_t size)
>
> #endif /* CONFIG_ARM64_MTE */
>
> +#ifdef CONFIG_KASAN_HW_TAGS
> +/* Whether the MTE asynchronous mode is enabled. */
> +DECLARE_STATIC_KEY_FALSE(mte_async_mode);
> +
> +static inline bool system_uses_mte_async_mode(void)
> +{
> + return static_branch_unlikely(&mte_async_mode);
> +}
> +#else
> +static inline bool system_uses_mte_async_mode(void)
> +{
> + return false;
> +}
> +#endif /* CONFIG_KASAN_HW_TAGS */
You can write this with fewer lines:
DECLARE_STATIC_KEY_FALSE(mte_async_mode);
static inline bool system_uses_mte_async_mode(void)
{
return IS_ENABLED(CONFIG_KASAN_HW_TAGS) &&
static_branch_unlikely(&mte_async_mode);
}
The compiler will ensure that mte_async_mode is not referred when
!CONFIG_KASAN_HW_TAGS and therefore doesn't need to be defined.
> diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
> index fa755cf94e01..9362928ba0d5 100644
> --- a/arch/arm64/kernel/mte.c
> +++ b/arch/arm64/kernel/mte.c
> @@ -26,6 +26,10 @@ u64 gcr_kernel_excl __ro_after_init;
>
> static bool report_fault_once = true;
>
> +/* Whether the MTE asynchronous mode is enabled. */
> +DEFINE_STATIC_KEY_FALSE(mte_async_mode);
> +EXPORT_SYMBOL_GPL(mte_async_mode);
Maybe keep these bracketed by #ifdef CONFIG_KASAN_HW_TAGS. I think the
mte_enable_kernel_*() aren't needed either if KASAN_HW is disabled (you
can do it with an additional patch).
With these, you can add:
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
next prev parent reply other threads:[~2021-03-12 15:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 14:22 [PATCH v15 0/8] arm64: ARMv8.5-A: MTE: Add async mode support Vincenzo Frascino
2021-03-12 14:22 ` [PATCH v15 1/8] arm64: mte: Add asynchronous " Vincenzo Frascino
2021-03-12 14:22 ` [PATCH v15 2/8] kasan: Add KASAN mode kernel parameter Vincenzo Frascino
2021-03-12 14:22 ` [PATCH v15 3/8] arm64: mte: Drop arch_enable_tagging() Vincenzo Frascino
2021-03-12 14:22 ` [PATCH v15 4/8] kasan: Add report for async mode Vincenzo Frascino
2021-03-12 14:22 ` [PATCH v15 5/8] arm64: mte: Enable TCO in functions that can read beyond buffer limits Vincenzo Frascino
2021-03-12 15:13 ` Catalin Marinas [this message]
2021-03-12 15:23 ` Vincenzo Frascino
2021-03-12 15:29 ` Catalin Marinas
2021-03-12 15:44 ` Vincenzo Frascino
2021-03-12 14:22 ` [PATCH v15 6/8] arm64: mte: Enable async tag check fault Vincenzo Frascino
2021-03-12 14:22 ` [PATCH v15 7/8] arm64: mte: Report async tag faults before suspend Vincenzo Frascino
2021-03-12 14:22 ` [PATCH v15 8/8] kasan, arm64: tests supports for HW_TAGS async mode Vincenzo Frascino
2021-03-12 14:49 ` Andrey Konovalov
2021-03-12 14:56 ` Vincenzo Frascino
2021-03-12 14:50 ` [PATCH v15 0/8] arm64: ARMv8.5-A: MTE: Add async mode support Andrey Konovalov
2021-03-12 14:56 ` Vincenzo Frascino
2021-03-12 15:14 ` 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=20210312151259.GB24210@arm.com \
--to=catalin.marinas@arm.com \
--cc=Branislav.Rankov@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@google.com \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=eugenis@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.pieralisi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®