Thread (3 messages) flat view 3 messages, 1 author, 5d ago
COOLING5d

[PATCH 1/2] arm64: mte-kasan: Use IS_ENABLED() rather than ALTERNATIVE() 'cfg' parameter

From: Mark Rutland <mark.rutland@arm.com>
Date: 2026-09-02 11:32:56
Subsystem: arm64 port (aarch64 architecture), kasan, the rest · Maintainers: Catalin Marinas, Will Deacon, Andrey Ryabinin, Linus Torvalds

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@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Will Deacon <will@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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help