Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a77600cd authored by Borislav Petkov's avatar Borislav Petkov
Browse files

x86/lib/memmove_64.S: Convert memmove() to ALTERNATIVE macro



Make it execute the ERMS version if support is present and we're in the
forward memmove() part and remove the unfolded alternatives section
definition.

Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
parent 84d95ad4
Loading
Loading
Loading
Loading
+2 −17
Original line number Original line Diff line number Diff line
@@ -5,7 +5,6 @@
 * This assembly file is re-written from memmove_64.c file.
 * This assembly file is re-written from memmove_64.c file.
 *	- Copyright 2011 Fenghua Yu <fenghua.yu@intel.com>
 *	- Copyright 2011 Fenghua Yu <fenghua.yu@intel.com>
 */
 */
#define _STRING_C
#include <linux/linkage.h>
#include <linux/linkage.h>
#include <asm/dwarf2.h>
#include <asm/dwarf2.h>
#include <asm/cpufeature.h>
#include <asm/cpufeature.h>
@@ -44,6 +43,8 @@ ENTRY(__memmove)
	jg 2f
	jg 2f


.Lmemmove_begin_forward:
.Lmemmove_begin_forward:
	ALTERNATIVE "", "movq %rdx, %rcx; rep movsb; retq", X86_FEATURE_ERMS

	/*
	/*
	 * movsq instruction have many startup latency
	 * movsq instruction have many startup latency
	 * so we handle small size by general register.
	 * so we handle small size by general register.
@@ -207,21 +208,5 @@ ENTRY(__memmove)
13:
13:
	retq
	retq
	CFI_ENDPROC
	CFI_ENDPROC

	.section .altinstr_replacement,"ax"
.Lmemmove_begin_forward_efs:
	/* Forward moving data. */
	movq %rdx, %rcx
	rep movsb
	retq
.Lmemmove_end_forward_efs:
	.previous

	.section .altinstructions,"a"
	altinstruction_entry .Lmemmove_begin_forward,		\
		.Lmemmove_begin_forward_efs,X86_FEATURE_ERMS,	\
		.Lmemmove_end_forward-.Lmemmove_begin_forward,	\
		.Lmemmove_end_forward_efs-.Lmemmove_begin_forward_efs,0
	.previous
ENDPROC(__memmove)
ENDPROC(__memmove)
ENDPROC(memmove)
ENDPROC(memmove)