arch/x86/memcpy: Fix undefined behaviour
Clear DF flag before invoking MOVS instruction to make sure it increments %esi/%edi on each mov. Change-Id: I209f50dec2003ea9846e5958d3e77b8979f338df Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/88796 Reviewed-by: Shuo Liu <shuo.liu@intel.com> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
7c0f7e0b3f
commit
e37a53a2fc
1 changed files with 2 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ void *memcpy(void *dest, const void *src, size_t n)
|
|||
|
||||
#if ENV_X86_64
|
||||
asm volatile(
|
||||
"cld\n\t"
|
||||
"rep ; movsq\n\t"
|
||||
"mov %4,%%rcx\n\t"
|
||||
"rep ; movsb\n\t"
|
||||
|
|
@ -25,6 +26,7 @@ void *memcpy(void *dest, const void *src, size_t n)
|
|||
);
|
||||
#else
|
||||
asm volatile(
|
||||
"cld\n\t"
|
||||
"rep ; movsl\n\t"
|
||||
"movl %4,%%ecx\n\t"
|
||||
"rep ; movsb\n\t"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue