]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86: use proper 'clac' and 'stac' opcode names
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 29 Dec 2024 21:07:51 +0000 (13:07 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 20 Jan 2025 16:39:29 +0000 (08:39 -0800)
Back when we added SMAP support, all versions of binutils didn't
necessarily understand the 'clac' and 'stac' instructions.  So we
implemented those instructions manually as ".byte" sequences.

But we've since upgraded the minimum version of binutils to version
2.25, and that included proper support for the SMAP instructions, and
there's no reason for us to use some line noise to express them any
more.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/x86/include/asm/smap.h

index bab490379c65f6b29b4ffa110c627790bd126de3..2de1e5a75c5735985f0428e85d4165ba2f29b008 100644 (file)
 #include <asm/cpufeatures.h>
 #include <asm/alternative.h>
 
-/* "Raw" instruction opcodes */
-#define __ASM_CLAC     ".byte 0x0f,0x01,0xca"
-#define __ASM_STAC     ".byte 0x0f,0x01,0xcb"
-
 #ifdef __ASSEMBLY__
 
 #define ASM_CLAC \
-       ALTERNATIVE "", __ASM_CLAC, X86_FEATURE_SMAP
+       ALTERNATIVE "", "clac", X86_FEATURE_SMAP
 
 #define ASM_STAC \
-       ALTERNATIVE "", __ASM_STAC, X86_FEATURE_SMAP
+       ALTERNATIVE "", "stac", X86_FEATURE_SMAP
 
 #else /* __ASSEMBLY__ */
 
 static __always_inline void clac(void)
 {
        /* Note: a barrier is implicit in alternative() */
-       alternative("", __ASM_CLAC, X86_FEATURE_SMAP);
+       alternative("", "clac", X86_FEATURE_SMAP);
 }
 
 static __always_inline void stac(void)
 {
        /* Note: a barrier is implicit in alternative() */
-       alternative("", __ASM_STAC, X86_FEATURE_SMAP);
+       alternative("", "stac", X86_FEATURE_SMAP);
 }
 
 static __always_inline unsigned long smap_save(void)
@@ -44,7 +40,7 @@ static __always_inline unsigned long smap_save(void)
        unsigned long flags;
 
        asm volatile ("# smap_save\n\t"
-                     ALTERNATIVE("", "pushf; pop %0; " __ASM_CLAC "\n\t",
+                     ALTERNATIVE("", "pushf; pop %0; " "clac" "\n\t",
                                  X86_FEATURE_SMAP)
                      : "=rm" (flags) : : "memory", "cc");
 
@@ -61,9 +57,9 @@ static __always_inline void smap_restore(unsigned long flags)
 
 /* These macros can be used in asm() statements */
 #define ASM_CLAC \
-       ALTERNATIVE("", __ASM_CLAC, X86_FEATURE_SMAP)
+       ALTERNATIVE("", "clac", X86_FEATURE_SMAP)
 #define ASM_STAC \
-       ALTERNATIVE("", __ASM_STAC, X86_FEATURE_SMAP)
+       ALTERNATIVE("", "stac", X86_FEATURE_SMAP)
 
 #endif /* __ASSEMBLY__ */