From 97c16bd1f44287f95f1be82185631d654a6022d8 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 3 Apr 2024 10:33:12 -0700 Subject: [PATCH] Avoid alternative assembler noise for common ops Just hardcode the ones I have for SMP and LFENCE --- arch/x86/include/asm/alternative.h | 7 +------ arch/x86/include/asm/barrier.h | 2 +- arch/x86/include/asm/smap.h | 18 ++++++------------ arch/x86/lib/getuser.S | 2 +- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 15bc07a5ebb3..281c823a869e 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -42,12 +42,7 @@ */ #ifdef CONFIG_SMP -#define LOCK_PREFIX_HERE \ - ".pushsection .smp_locks,\"a\"\n" \ - ".balign 4\n" \ - ".long 671f - .\n" /* offset */ \ - ".popsection\n" \ - "671:" +#define LOCK_PREFIX_HERE #define LOCK_PREFIX LOCK_PREFIX_HERE "\n\tlock " diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h index db70832232d4..2b911c88467b 100644 --- a/arch/x86/include/asm/barrier.h +++ b/arch/x86/include/asm/barrier.h @@ -45,7 +45,7 @@ __mask; }) /* Prevent speculative execution past this barrier. */ -#define barrier_nospec() alternative("", "lfence", X86_FEATURE_LFENCE_RDTSC) +#define barrier_nospec() asm volatile("lfence":::"memory") #define __dma_rmb() barrier() #define __dma_wmb() barrier() diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h index 4f84d421d1cf..613b24a58b26 100644 --- a/arch/x86/include/asm/smap.h +++ b/arch/x86/include/asm/smap.h @@ -15,24 +15,20 @@ #ifdef __ASSEMBLER__ -#define ASM_CLAC \ - ALTERNATIVE "", "clac", X86_FEATURE_SMAP +#define ASM_CLAC "clac" -#define ASM_STAC \ - ALTERNATIVE "", "stac", X86_FEATURE_SMAP +#define ASM_STAC "stac" #else /* __ASSEMBLER__ */ static __always_inline void clac(void) { - /* Note: a barrier is implicit in alternative() */ - alternative("", "clac", X86_FEATURE_SMAP); + asm volatile("clac": : :"memory"); } static __always_inline void stac(void) { - /* Note: a barrier is implicit in alternative() */ - alternative("", "stac", X86_FEATURE_SMAP); + asm volatile("stac": : :"memory"); } static __always_inline unsigned long smap_save(void) @@ -58,10 +54,8 @@ static __always_inline void smap_restore(unsigned long flags) } /* These macros can be used in asm() statements */ -#define ASM_CLAC \ - ALTERNATIVE("", "clac", X86_FEATURE_SMAP) -#define ASM_STAC \ - ALTERNATIVE("", "stac", X86_FEATURE_SMAP) +#define ASM_CLAC "clac" +#define ASM_STAC "stac" #define ASM_CLAC_UNSAFE \ ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "clac", X86_FEATURE_SMAP) diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S index 9d5654b8a72a..1c5952c637ce 100644 --- a/arch/x86/lib/getuser.S +++ b/arch/x86/lib/getuser.S @@ -37,7 +37,7 @@ #include #include -#define ASM_BARRIER_NOSPEC ALTERNATIVE "", "lfence", X86_FEATURE_LFENCE_RDTSC +#define ASM_BARRIER_NOSPEC lfence .macro check_range size:req .if IS_ENABLED(CONFIG_X86_64) -- 2.51.1.534.g6d2b4bf2f4