[PATCH 18/20] x86/smap: Use alternative_io() in smap_{save,restore}()
From: Josh Poimboeuf
Date: Fri Mar 14 2025 - 17:51:38 EST
Use the standard alternative_io() interface.
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
arch/x86/include/asm/smap.h | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
index 60ea21b4c8b7..8b77ddcb37e7 100644
--- a/arch/x86/include/asm/smap.h
+++ b/arch/x86/include/asm/smap.h
@@ -39,20 +39,22 @@ static __always_inline unsigned long smap_save(void)
{
unsigned long flags;
- asm volatile ("# smap_save\n\t"
- ALTERNATIVE("",
- "pushf; pop %[flags]; clac\n\t", X86_FEATURE_SMAP)
- : [flags] "=rm" (flags) : : "memory", "cc");
+ alternative_io("",
+ "pushf; pop %[flags]; clac\n\t", X86_FEATURE_SMAP,
+ ARG([flags] "=rm" (flags)),
+ ARG(),
+ ARG("memory", "cc"));
return flags;
}
static __always_inline void smap_restore(unsigned long flags)
{
- asm volatile ("# smap_restore\n\t"
- ALTERNATIVE("",
- "push %[flags]; popf\n\t", X86_FEATURE_SMAP)
- : : [flags] "g" (flags) : "memory", "cc");
+ alternative_io("",
+ "push %[flags]; popf\n\t", X86_FEATURE_SMAP,
+ ARG(),
+ ARG([flags] "g" (flags)),
+ ARG("memory", "cc"));
}
/* These macros can be used in asm() statements */
--
2.48.1