]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
avr32/lib: fix unaligned memcpy()
authorSebastian Andrzej Siewior <bigeasy@breakpoint.cc>
Sun, 26 Jul 2009 12:57:54 +0000 (14:57 +0200)
committerHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
Mon, 27 Jul 2009 10:37:27 +0000 (12:37 +0200)
memcpy(p, unaligned, 4..) returns (p + num_of_unaligned_by_copied)
instead of p because p is not preserved in the unaligned case.

Noticed by Herbert Xu's superior parameter recycling coding technique
which let the md4 self-test fail on avr32.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
arch/avr32/lib/memcpy.S

index 0abb26142b64689ae717f97be7f173a95e92861f..93e74b6fcdb6ab140ebbb12ef627a21563a231e7 100644 (file)
@@ -24,8 +24,8 @@ memcpy:
        brne    1f
 
        /* At this point, "from" is word-aligned */
-2:     sub     r10, 4
-       mov     r9, r12
+2:     mov     r9, r12
+5:     sub     r10, 4
        brlt    4f
 
 3:     ld.w    r8, r11++
@@ -59,4 +59,13 @@ memcpy:
        st.b    r12++, r8
        ld.ub   r8, r11++
        st.b    r12++, r8
-       rjmp    2b
+       mov     r8, r12
+       add     pc, pc, r9
+       sub     r8, 1
+       nop
+       sub     r8, 1
+       nop
+       sub     r8, 1
+       nop
+       mov     r9, r8
+       rjmp    5b