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

x86/alternative: Merge include files

Merge arch/x86/include/asm/alternative-asm.h into
arch/x86/include/asm/alternative.h in order to make it easier to use
common definitions later.

Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210311142319.4723-2-jgross@suse.com

authored by

Juergen Gross and committed by
Borislav Petkov
5e21a3ec db16e072

+120 -132
+1 -1
arch/x86/entry/entry_32.S
··· 40 40 #include <asm/processor-flags.h> 41 41 #include <asm/irq_vectors.h> 42 42 #include <asm/cpufeatures.h> 43 - #include <asm/alternative-asm.h> 43 + #include <asm/alternative.h> 44 44 #include <asm/asm.h> 45 45 #include <asm/smap.h> 46 46 #include <asm/frame.h>
+1 -1
arch/x86/entry/vdso/vdso32/system_call.S
··· 6 6 #include <linux/linkage.h> 7 7 #include <asm/dwarf2.h> 8 8 #include <asm/cpufeatures.h> 9 - #include <asm/alternative-asm.h> 9 + #include <asm/alternative.h> 10 10 11 11 .text 12 12 .globl __kernel_vsyscall
-114
arch/x86/include/asm/alternative-asm.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ASM_X86_ALTERNATIVE_ASM_H 3 - #define _ASM_X86_ALTERNATIVE_ASM_H 4 - 5 - #ifdef __ASSEMBLY__ 6 - 7 - #include <asm/asm.h> 8 - 9 - #ifdef CONFIG_SMP 10 - .macro LOCK_PREFIX 11 - 672: lock 12 - .pushsection .smp_locks,"a" 13 - .balign 4 14 - .long 672b - . 15 - .popsection 16 - .endm 17 - #else 18 - .macro LOCK_PREFIX 19 - .endm 20 - #endif 21 - 22 - /* 23 - * objtool annotation to ignore the alternatives and only consider the original 24 - * instruction(s). 25 - */ 26 - .macro ANNOTATE_IGNORE_ALTERNATIVE 27 - .Lannotate_\@: 28 - .pushsection .discard.ignore_alts 29 - .long .Lannotate_\@ - . 30 - .popsection 31 - .endm 32 - 33 - /* 34 - * Issue one struct alt_instr descriptor entry (need to put it into 35 - * the section .altinstructions, see below). This entry contains 36 - * enough information for the alternatives patching code to patch an 37 - * instruction. See apply_alternatives(). 38 - */ 39 - .macro altinstruction_entry orig alt feature orig_len alt_len pad_len 40 - .long \orig - . 41 - .long \alt - . 42 - .word \feature 43 - .byte \orig_len 44 - .byte \alt_len 45 - .byte \pad_len 46 - .endm 47 - 48 - /* 49 - * Define an alternative between two instructions. If @feature is 50 - * present, early code in apply_alternatives() replaces @oldinstr with 51 - * @newinstr. ".skip" directive takes care of proper instruction padding 52 - * in case @newinstr is longer than @oldinstr. 53 - */ 54 - .macro ALTERNATIVE oldinstr, newinstr, feature 55 - 140: 56 - \oldinstr 57 - 141: 58 - .skip -(((144f-143f)-(141b-140b)) > 0) * ((144f-143f)-(141b-140b)),0x90 59 - 142: 60 - 61 - .pushsection .altinstructions,"a" 62 - altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f,142b-141b 63 - .popsection 64 - 65 - .pushsection .altinstr_replacement,"ax" 66 - 143: 67 - \newinstr 68 - 144: 69 - .popsection 70 - .endm 71 - 72 - #define old_len 141b-140b 73 - #define new_len1 144f-143f 74 - #define new_len2 145f-144f 75 - 76 - /* 77 - * gas compatible max based on the idea from: 78 - * http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax 79 - * 80 - * The additional "-" is needed because gas uses a "true" value of -1. 81 - */ 82 - #define alt_max_short(a, b) ((a) ^ (((a) ^ (b)) & -(-((a) < (b))))) 83 - 84 - 85 - /* 86 - * Same as ALTERNATIVE macro above but for two alternatives. If CPU 87 - * has @feature1, it replaces @oldinstr with @newinstr1. If CPU has 88 - * @feature2, it replaces @oldinstr with @feature2. 89 - */ 90 - .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2 91 - 140: 92 - \oldinstr 93 - 141: 94 - .skip -((alt_max_short(new_len1, new_len2) - (old_len)) > 0) * \ 95 - (alt_max_short(new_len1, new_len2) - (old_len)),0x90 96 - 142: 97 - 98 - .pushsection .altinstructions,"a" 99 - altinstruction_entry 140b,143f,\feature1,142b-140b,144f-143f,142b-141b 100 - altinstruction_entry 140b,144f,\feature2,142b-140b,145f-144f,142b-141b 101 - .popsection 102 - 103 - .pushsection .altinstr_replacement,"ax" 104 - 143: 105 - \newinstr1 106 - 144: 107 - \newinstr2 108 - 145: 109 - .popsection 110 - .endm 111 - 112 - #endif /* __ASSEMBLY__ */ 113 - 114 - #endif /* _ASM_X86_ALTERNATIVE_ASM_H */
+109 -3
arch/x86/include/asm/alternative.h
··· 2 2 #ifndef _ASM_X86_ALTERNATIVE_H 3 3 #define _ASM_X86_ALTERNATIVE_H 4 4 5 - #ifndef __ASSEMBLY__ 6 - 7 5 #include <linux/types.h> 8 - #include <linux/stddef.h> 9 6 #include <linux/stringify.h> 10 7 #include <asm/asm.h> 8 + 9 + #ifndef __ASSEMBLY__ 10 + 11 + #include <linux/stddef.h> 11 12 12 13 /* 13 14 * Alternative inline assembly for SMP. ··· 271 270 * alternative_{input,io,call}() 272 271 */ 273 272 #define ASM_NO_INPUT_CLOBBER(clbr...) "i" (0) : clbr 273 + 274 + #else /* __ASSEMBLY__ */ 275 + 276 + #ifdef CONFIG_SMP 277 + .macro LOCK_PREFIX 278 + 672: lock 279 + .pushsection .smp_locks,"a" 280 + .balign 4 281 + .long 672b - . 282 + .popsection 283 + .endm 284 + #else 285 + .macro LOCK_PREFIX 286 + .endm 287 + #endif 288 + 289 + /* 290 + * objtool annotation to ignore the alternatives and only consider the original 291 + * instruction(s). 292 + */ 293 + .macro ANNOTATE_IGNORE_ALTERNATIVE 294 + .Lannotate_\@: 295 + .pushsection .discard.ignore_alts 296 + .long .Lannotate_\@ - . 297 + .popsection 298 + .endm 299 + 300 + /* 301 + * Issue one struct alt_instr descriptor entry (need to put it into 302 + * the section .altinstructions, see below). This entry contains 303 + * enough information for the alternatives patching code to patch an 304 + * instruction. See apply_alternatives(). 305 + */ 306 + .macro altinstruction_entry orig alt feature orig_len alt_len pad_len 307 + .long \orig - . 308 + .long \alt - . 309 + .word \feature 310 + .byte \orig_len 311 + .byte \alt_len 312 + .byte \pad_len 313 + .endm 314 + 315 + /* 316 + * Define an alternative between two instructions. If @feature is 317 + * present, early code in apply_alternatives() replaces @oldinstr with 318 + * @newinstr. ".skip" directive takes care of proper instruction padding 319 + * in case @newinstr is longer than @oldinstr. 320 + */ 321 + .macro ALTERNATIVE oldinstr, newinstr, feature 322 + 140: 323 + \oldinstr 324 + 141: 325 + .skip -(((144f-143f)-(141b-140b)) > 0) * ((144f-143f)-(141b-140b)),0x90 326 + 142: 327 + 328 + .pushsection .altinstructions,"a" 329 + altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f,142b-141b 330 + .popsection 331 + 332 + .pushsection .altinstr_replacement,"ax" 333 + 143: 334 + \newinstr 335 + 144: 336 + .popsection 337 + .endm 338 + 339 + #define old_len 141b-140b 340 + #define new_len1 144f-143f 341 + #define new_len2 145f-144f 342 + 343 + /* 344 + * gas compatible max based on the idea from: 345 + * http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax 346 + * 347 + * The additional "-" is needed because gas uses a "true" value of -1. 348 + */ 349 + #define alt_max_short(a, b) ((a) ^ (((a) ^ (b)) & -(-((a) < (b))))) 350 + 351 + 352 + /* 353 + * Same as ALTERNATIVE macro above but for two alternatives. If CPU 354 + * has @feature1, it replaces @oldinstr with @newinstr1. If CPU has 355 + * @feature2, it replaces @oldinstr with @feature2. 356 + */ 357 + .macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2 358 + 140: 359 + \oldinstr 360 + 141: 361 + .skip -((alt_max_short(new_len1, new_len2) - (old_len)) > 0) * \ 362 + (alt_max_short(new_len1, new_len2) - (old_len)),0x90 363 + 142: 364 + 365 + .pushsection .altinstructions,"a" 366 + altinstruction_entry 140b,143f,\feature1,142b-140b,144f-143f,142b-141b 367 + altinstruction_entry 140b,144f,\feature2,142b-140b,145f-144f,142b-141b 368 + .popsection 369 + 370 + .pushsection .altinstr_replacement,"ax" 371 + 143: 372 + \newinstr1 373 + 144: 374 + \newinstr2 375 + 145: 376 + .popsection 377 + .endm 274 378 275 379 #endif /* __ASSEMBLY__ */ 276 380
-1
arch/x86/include/asm/nospec-branch.h
··· 7 7 #include <linux/objtool.h> 8 8 9 9 #include <asm/alternative.h> 10 - #include <asm/alternative-asm.h> 11 10 #include <asm/cpufeatures.h> 12 11 #include <asm/msr-index.h> 13 12 #include <asm/unwind_hints.h>
+1 -4
arch/x86/include/asm/smap.h
··· 11 11 12 12 #include <asm/nops.h> 13 13 #include <asm/cpufeatures.h> 14 + #include <asm/alternative.h> 14 15 15 16 /* "Raw" instruction opcodes */ 16 17 #define __ASM_CLAC ".byte 0x0f,0x01,0xca" 17 18 #define __ASM_STAC ".byte 0x0f,0x01,0xcb" 18 19 19 20 #ifdef __ASSEMBLY__ 20 - 21 - #include <asm/alternative-asm.h> 22 21 23 22 #ifdef CONFIG_X86_SMAP 24 23 ··· 35 36 #endif /* CONFIG_X86_SMAP */ 36 37 37 38 #else /* __ASSEMBLY__ */ 38 - 39 - #include <asm/alternative.h> 40 39 41 40 #ifdef CONFIG_X86_SMAP 42 41
+1 -1
arch/x86/lib/atomic64_386_32.S
··· 6 6 */ 7 7 8 8 #include <linux/linkage.h> 9 - #include <asm/alternative-asm.h> 9 + #include <asm/alternative.h> 10 10 11 11 /* if you want SMP support, implement these with real spinlocks */ 12 12 .macro LOCK reg
+1 -1
arch/x86/lib/atomic64_cx8_32.S
··· 6 6 */ 7 7 8 8 #include <linux/linkage.h> 9 - #include <asm/alternative-asm.h> 9 + #include <asm/alternative.h> 10 10 11 11 .macro read64 reg 12 12 movl %ebx, %eax
+1 -1
arch/x86/lib/copy_page_64.S
··· 3 3 4 4 #include <linux/linkage.h> 5 5 #include <asm/cpufeatures.h> 6 - #include <asm/alternative-asm.h> 6 + #include <asm/alternative.h> 7 7 #include <asm/export.h> 8 8 9 9 /*
+1 -1
arch/x86/lib/copy_user_64.S
··· 11 11 #include <asm/asm-offsets.h> 12 12 #include <asm/thread_info.h> 13 13 #include <asm/cpufeatures.h> 14 - #include <asm/alternative-asm.h> 14 + #include <asm/alternative.h> 15 15 #include <asm/asm.h> 16 16 #include <asm/smap.h> 17 17 #include <asm/export.h>
+1 -1
arch/x86/lib/memcpy_64.S
··· 4 4 #include <linux/linkage.h> 5 5 #include <asm/errno.h> 6 6 #include <asm/cpufeatures.h> 7 - #include <asm/alternative-asm.h> 7 + #include <asm/alternative.h> 8 8 #include <asm/export.h> 9 9 10 10 .pushsection .noinstr.text, "ax"
+1 -1
arch/x86/lib/memmove_64.S
··· 8 8 */ 9 9 #include <linux/linkage.h> 10 10 #include <asm/cpufeatures.h> 11 - #include <asm/alternative-asm.h> 11 + #include <asm/alternative.h> 12 12 #include <asm/export.h> 13 13 14 14 #undef memmove
+1 -1
arch/x86/lib/memset_64.S
··· 3 3 4 4 #include <linux/linkage.h> 5 5 #include <asm/cpufeatures.h> 6 - #include <asm/alternative-asm.h> 6 + #include <asm/alternative.h> 7 7 #include <asm/export.h> 8 8 9 9 /*
+1 -1
arch/x86/lib/retpoline.S
··· 4 4 #include <linux/linkage.h> 5 5 #include <asm/dwarf2.h> 6 6 #include <asm/cpufeatures.h> 7 - #include <asm/alternative-asm.h> 7 + #include <asm/alternative.h> 8 8 #include <asm/export.h> 9 9 #include <asm/nospec-branch.h> 10 10 #include <asm/unwind_hints.h>