arm: Make arch specific memcpy thumb-safe.
authorKlaus Goger <klaus.goger@theobroma-systems.com>
Thu, 26 Apr 2018 18:18:10 +0000 (20:18 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 16 Nov 2018 21:51:57 +0000 (16:51 -0500)
The current arch implementation of memcpy cannot be called
from thumb code, because it does not use bx instructions on return.
This patch addresses that. Note, that this patch does not touch
the hot loop of memcpy, so performance is not affected.

Tested on MXS (arm926ejs) with and without thumb-mode enabled.

Signed-off-by: Klaus Goger <klaus.goger@theobroma-systems.com>
Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
arch/arm/lib/memcpy.S

index 0ca61210da7ed04a2d099e056d5c855cd3a4a1e5..f7fb77235cd642b734fdb17c60f0a4e1b2c9cd64 100644 (file)
@@ -59,7 +59,7 @@
 #endif
 ENTRY(memcpy)
                cmp     r0, r1
-               moveq   pc, lr
+               bxeq    lr
 
                enter   r4, lr
 
@@ -147,7 +147,8 @@ ENTRY(memcpy)
                str1b   r0, r4, cs, abort=21f
                str1b   r0, ip, cs, abort=21f
 
-               exit    r4, pc
+               exit    r4, lr
+               bx      lr
 
 9:             rsb     ip, ip, #4
                cmp     ip, #2
@@ -256,7 +257,8 @@ ENTRY(memcpy)
        .endm
 
        .macro  copy_abort_end
-       ldmfd   sp!, {r4, pc}
+       ldmfd   sp!, {r4, lr}
+       bx      lr
        .endm
 
 ENDPROC(memcpy)