[PATCH 1/2] arm64: mte-kasan: Use IS_ENABLED() rather than ALTERNATIVE() 'cfg' parameter
Mark Rutland
mark.rutland at arm.com
Wed Sep 2 04:32:31 PDT 2026
The ALTERNATIVE() macro accepts an optional 'cfg' parameter, which
accepts a CONFIG_* symbol. Where a CONFIG_* symbol is provided, but is
not selected, the ALTERNATIVE() macro will expand to nothing.
It would be nicer overall to remove the 'cfg' parameter and to have an
explicit check for 'cfg' outside of the asm() block. This is clearer to
a reader, and permits the compiler to elide the asm() block when 'cfg'
is not selected.
In the mte-kasan code, replace the usage of the 'cfg' parameter with an
explicit IS_ENABLED() check.
Signed-off-by: Mark Rutland <mark.rutland at arm.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: James Morse <james.morse at arm.com>
Cc: Marc Zyngier <maz at kernel.org>
Cc: Will Deacon <will at kernel.org>
---
arch/arm64/include/asm/mte-kasan.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/include/asm/mte-kasan.h b/arch/arm64/include/asm/mte-kasan.h
index 3521392719189..de910f1c19e1b 100644
--- a/arch/arm64/include/asm/mte-kasan.h
+++ b/arch/arm64/include/asm/mte-kasan.h
@@ -53,14 +53,16 @@ static inline bool system_uses_mte_async_or_asymm_mode(void)
*/
static inline void mte_disable_tco(void)
{
- asm volatile(ALTERNATIVE("nop", SET_PSTATE_TCO(0),
- ARM64_MTE, CONFIG_KASAN_HW_TAGS));
+ if (!IS_ENABLED(CONFIG_KASAN_HW_TAGS))
+ return;
+ asm volatile(ALTERNATIVE("nop", SET_PSTATE_TCO(0), ARM64_MTE));
}
static inline void mte_enable_tco(void)
{
- asm volatile(ALTERNATIVE("nop", SET_PSTATE_TCO(1),
- ARM64_MTE, CONFIG_KASAN_HW_TAGS));
+ if (!IS_ENABLED(CONFIG_KASAN_HW_TAGS))
+ return;
+ asm volatile(ALTERNATIVE("nop", SET_PSTATE_TCO(1), ARM64_MTE));
}
/*
--
2.30.2
More information about the linux-arm-kernel
mailing list