david/ipxe
Archived
1
0

[string] Use 64-bit registers in assembly memswap() on x86_64

An assembly version of memswap() is in an x86 word-length-agnostic
header file, but it used 32-bit registers to store pointers, leading
to memory errors responding to ARP queries on 64-bit systems.

Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Joshua Oreman 2010-07-30 09:52:03 -07:00 committed by Michael Brown
parent 73aea88a62
commit 79e05875d3

View File

@ -198,12 +198,12 @@ return s;
#define __HAVE_ARCH_MEMSWAP #define __HAVE_ARCH_MEMSWAP
static inline void * memswap(void *dest, void *src, size_t n) static inline void * memswap(void *dest, void *src, size_t n)
{ {
int d0, d1, d2, d3; long d0, d1, d2, d3;
__asm__ __volatile__( __asm__ __volatile__(
"\n1:\t" "\n1:\t"
"movb (%%edi),%%al\n\t" "movb (%2),%%al\n\t"
"xchgb (%%esi),%%al\n\t" "xchgb (%1),%%al\n\t"
"incl %%esi\n\t" "inc %1\n\t"
"stosb\n\t" "stosb\n\t"
"loop 1b" "loop 1b"
: "=&c" (d0), "=&S" (d1), "=&D" (d2), "=&a" (d3) : "=&c" (d0), "=&S" (d1), "=&D" (d2), "=&a" (d3)