Skip to content

Commit 244122b

Browse files
aeglsuryasaimadhu
authored andcommitted
x86/lib: Add fast-short-rep-movs check to copy_user_enhanced_fast_string()
Commit f444a5f ("x86/cpufeatures: Add support for fast short REP; MOVSB") fixed memmove() with an ALTERNATIVE that will use REP MOVSB for all string lengths. copy_user_enhanced_fast_string() has a similar run time check to avoid using REP MOVSB for copies less that 64 bytes. Add an ALTERNATIVE to patch out the short length check and always use REP MOVSB on X86_FEATURE_FSRM CPUs. Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9c7e263 commit 244122b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/lib/copy_user_64.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ EXPORT_SYMBOL(copy_user_generic_string)
200200
*/
201201
SYM_FUNC_START(copy_user_enhanced_fast_string)
202202
ASM_STAC
203-
cmpl $64,%edx
204-
jb .L_copy_short_string /* less then 64 bytes, avoid the costly 'rep' */
203+
/* CPUs without FSRM should avoid rep movsb for short copies */
204+
ALTERNATIVE "cmpl $64, %edx; jb .L_copy_short_string", "", X86_FEATURE_FSRM
205205
movl %edx,%ecx
206206
1: rep
207207
movsb

0 commit comments

Comments
 (0)