[PATCH v2 3/6] kasan: Always inline kasan_hw_tags_enabled()
From: Jisheng Zhang
Date: Mon Nov 09 2026 - 07:08:22 EST
The arm64 MTE entry and exit helpers call kasan_hw_tags_enabled()
from noinstr code. Although kasan_enabled() is __always_inline, its
wrapper kasan_hw_tags_enabled() uses plain inline.
With CONFIG_KASAN_HW_TAGS=y and CONFIG_CC_OPTIMIZE_FOR_SIZE=y, GCC
emits kasan_hw_tags_enabled() in .text and calls it from .noinstr.text.
Mark both definitions __always_inline so the runtime check inherits
its callers' instrumentation restrictions.
Verified that the out-of-line symbol and calls disappear from the
arm64 entry-common.o object after rebuilding.
Signed-off-by: Jisheng Zhang <jszhang@xxxxxxxxxx>
Assisted-by: LLM
---
include/linux/kasan-enabled.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/kasan-enabled.h b/include/linux/kasan-enabled.h
index 9eca967d8526..14a9e9fd6c6b 100644
--- a/include/linux/kasan-enabled.h
+++ b/include/linux/kasan-enabled.h
@@ -35,12 +35,12 @@ static inline void kasan_enable(void) {}
#endif /* CONFIG_ARCH_DEFER_KASAN || CONFIG_KASAN_HW_TAGS */
#ifdef CONFIG_KASAN_HW_TAGS
-static inline bool kasan_hw_tags_enabled(void)
+static __always_inline bool kasan_hw_tags_enabled(void)
{
return kasan_enabled();
}
#else
-static inline bool kasan_hw_tags_enabled(void)
+static __always_inline bool kasan_hw_tags_enabled(void)
{
return false;
}
--
2.55.0