Linux C-SKY architecture development
 help / color / mirror / Atom feed
* [PATCH] csky: Fix ABIv2 memcmp() s1 alignment check
@ 2026-06-23 11:24 Hanlin Song
  2026-07-06 10:39 ` Hanlin Song
  0 siblings, 1 reply; 4+ messages 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] 4+ messages in thread

end of thread, other threads:[~2026-07-07  3:47 UTC | newest]

Thread overview: 4+ messages (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
2026-07-06 10:39 ` Hanlin Song
2026-07-07  3:15   ` Guo Ren
2026-07-07  3:47     ` Hanlin Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox