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

x86/lib/copy_user_64.S: Convert to ALTERNATIVE_2

Use the asm macro and drop the locally grown version.

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

+10 -30
+10 -30
arch/x86/lib/copy_user_64.S
··· 16 16 #include <asm/asm.h> 17 17 #include <asm/smap.h> 18 18 19 - /* 20 - * By placing feature2 after feature1 in altinstructions section, we logically 21 - * implement: 22 - * If CPU has feature2, jmp to alt2 is used 23 - * else if CPU has feature1, jmp to alt1 is used 24 - * else jmp to orig is used. 25 - */ 26 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2 27 - 0: 28 - jmp \orig 29 - 1: 30 - .section .altinstr_replacement,"ax" 31 - 2: 32 - jmp \alt1 33 - 3: 34 - jmp \alt2 35 - .previous 36 - 37 - .section .altinstructions,"a" 38 - altinstruction_entry 0b,2b,\feature1,5,5,0 39 - altinstruction_entry 0b,3b,\feature2,5,5,0 40 - .previous 41 - .endm 42 - 43 19 .macro ALIGN_DESTINATION 44 20 /* check for bad alignment of destination */ 45 21 movl %edi,%ecx ··· 49 73 jc bad_to_user 50 74 cmpq TI_addr_limit(%rax),%rcx 51 75 ja bad_to_user 52 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \ 53 - copy_user_generic_unrolled,copy_user_generic_string, \ 54 - copy_user_enhanced_fast_string 76 + ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \ 77 + "jmp copy_user_generic_string", \ 78 + X86_FEATURE_REP_GOOD, \ 79 + "jmp copy_user_enhanced_fast_string", \ 80 + X86_FEATURE_ERMS 55 81 CFI_ENDPROC 56 82 ENDPROC(_copy_to_user) 57 83 ··· 66 88 jc bad_from_user 67 89 cmpq TI_addr_limit(%rax),%rcx 68 90 ja bad_from_user 69 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \ 70 - copy_user_generic_unrolled,copy_user_generic_string, \ 71 - copy_user_enhanced_fast_string 91 + ALTERNATIVE_2 "jmp copy_user_generic_unrolled", \ 92 + "jmp copy_user_generic_string", \ 93 + X86_FEATURE_REP_GOOD, \ 94 + "jmp copy_user_enhanced_fast_string", \ 95 + X86_FEATURE_ERMS 72 96 CFI_ENDPROC 73 97 ENDPROC(_copy_from_user) 74 98