Re: [PATCH v15 5/8] arm64: mte: Enable TCO in functions that can read beyond buffer limits
From: Catalin Marinas <catalin.marinas@arm.com>
Date: 2021-03-12 15:30:36
Also in:
lkml
On Fri, Mar 12, 2021 at 03:23:44PM +0000, Vincenzo Frascino wrote:
On 3/12/21 3:13 PM, Catalin Marinas wrote:quoted
On Fri, Mar 12, 2021 at 02:22:07PM +0000, Vincenzo Frascino wrote:quoted
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.Yes, I agree, but I introduce "#ifdef CONFIG_KASAN_HW_TAGS" in the successive patch anyway, according to me the overall code looks more uniform like this. But I do not have a strong opinion or preference on this.
Ah, yes, I didn't look at patch 6 again as it was already reviewed and I forgot the context. Leave it as it is then, my reviewed-by still stands. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel