[PATCH] csky: Fix ABIv2 memcmp() s1 alignment check

From: Hanlin Song

Date: Tue Jun 23 2026 - 07:25:46 EST


memcmp() saves the original s1 pointer in r3 and then clears r0 for the
return value. The following alignment check tests r0 instead of r3:

mov r3, r0
movi r0, 0
...
andi r13, r0, 3

As a result, the path for an unaligned s1 address is never taken, and
memcmp() may issue word loads from an unaligned s1 address.

Test r3 instead, which still holds the original s1 pointer.

Signed-off-by: Hanlin Song <pgeorge8929@xxxxxxxxx>
---
arch/csky/abiv2/memcmp.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/csky/abiv2/memcmp.S b/arch/csky/abiv2/memcmp.S
index bf0d809f0..1c6ced74d 100644
--- a/arch/csky/abiv2/memcmp.S
+++ b/arch/csky/abiv2/memcmp.S
@@ -12,7 +12,7 @@ ENTRY(memcmp)
cmplti r2, 4
bt .L_compare_by_byte

- andi r13, r0, 3
+ andi r13, r3, 3
movi r19, 4

/* Test if s1 is not 4 bytes aligned. */
--
2.25.1