summaryrefslogtreecommitdiffstats
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/core/x86_string.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/arch/x86/core/x86_string.c b/src/arch/x86/core/x86_string.c
index 7d5e4a5f1..1a1e79dac 100644
--- a/src/arch/x86/core/x86_string.c
+++ b/src/arch/x86/core/x86_string.c
@@ -30,6 +30,14 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <string.h>
+#include <config/defaults.h>
+
+/* Use generic_memcpy_reverse() if we cannot safely set the direction flag */
+#ifdef UNSAFE_STD
+#define USE_GENERIC_MEMCPY_REVERSE 1
+#else
+#define USE_GENERIC_MEMCPY_REVERSE 0
+#endif
/**
* Copy memory area
@@ -77,6 +85,12 @@ void * __attribute__ (( noinline )) __memcpy_reverse ( void *dest,
const void *esi = ( src + len - 1 );
int discard_ecx;
+ /* Use unoptimised version if we are not permitted to modify
+ * the direction flag.
+ */
+ if ( USE_GENERIC_MEMCPY_REVERSE )
+ return generic_memcpy_reverse ( dest, src, len );
+
/* Assume memmove() is not performance-critical, and perform a
* bytewise copy for simplicity.
*/