* [PATCH] csky: Fix ABIv2 memcmp() s1 alignment check
@ 2026-06-23 11:24 Hanlin Song
0 siblings, 0 replies; only message in thread
From: Hanlin Song @ 2026-06-23 11:24 UTC (permalink / raw)
To: guoren; +Cc: linux-csky, linux-kernel, Hanlin Song
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@gmail.com>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-23 11:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 11:24 [PATCH] csky: Fix ABIv2 memcmp() s1 alignment check Hanlin Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox