Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/smap: Use ALTERNATIVE macro

... and drop unfolded version. No need for ASM_NOP3 anymore either as
the alternatives do the proper padding at build time and insert proper
NOPs at boot time.

There should be no apparent operational change from this patch.

Signed-off-by: Borislav Petkov <bp@suse.de>

+8 -20
+8 -20
arch/x86/include/asm/smap.h
··· 27 27 28 28 #ifdef CONFIG_X86_SMAP 29 29 30 - #define ASM_CLAC \ 31 - 661: ASM_NOP3 ; \ 32 - .pushsection .altinstr_replacement, "ax" ; \ 33 - 662: __ASM_CLAC ; \ 34 - .popsection ; \ 35 - .pushsection .altinstructions, "a" ; \ 36 - altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3, 0 ; \ 37 - .popsection 30 + #define ASM_CLAC \ 31 + ALTERNATIVE "", __stringify(__ASM_CLAC), X86_FEATURE_SMAP 38 32 39 - #define ASM_STAC \ 40 - 661: ASM_NOP3 ; \ 41 - .pushsection .altinstr_replacement, "ax" ; \ 42 - 662: __ASM_STAC ; \ 43 - .popsection ; \ 44 - .pushsection .altinstructions, "a" ; \ 45 - altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3, 0 ; \ 46 - .popsection 33 + #define ASM_STAC \ 34 + ALTERNATIVE "", __stringify(__ASM_STAC), X86_FEATURE_SMAP 47 35 48 36 #else /* CONFIG_X86_SMAP */ 49 37 ··· 49 61 static __always_inline void clac(void) 50 62 { 51 63 /* Note: a barrier is implicit in alternative() */ 52 - alternative(ASM_NOP3, __stringify(__ASM_CLAC), X86_FEATURE_SMAP); 64 + alternative("", __stringify(__ASM_CLAC), X86_FEATURE_SMAP); 53 65 } 54 66 55 67 static __always_inline void stac(void) 56 68 { 57 69 /* Note: a barrier is implicit in alternative() */ 58 - alternative(ASM_NOP3, __stringify(__ASM_STAC), X86_FEATURE_SMAP); 70 + alternative("", __stringify(__ASM_STAC), X86_FEATURE_SMAP); 59 71 } 60 72 61 73 /* These macros can be used in asm() statements */ 62 74 #define ASM_CLAC \ 63 - ALTERNATIVE(ASM_NOP3, __stringify(__ASM_CLAC), X86_FEATURE_SMAP) 75 + ALTERNATIVE("", __stringify(__ASM_CLAC), X86_FEATURE_SMAP) 64 76 #define ASM_STAC \ 65 - ALTERNATIVE(ASM_NOP3, __stringify(__ASM_STAC), X86_FEATURE_SMAP) 77 + ALTERNATIVE("", __stringify(__ASM_STAC), X86_FEATURE_SMAP) 66 78 67 79 #else /* CONFIG_X86_SMAP */ 68 80