* [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* Re: [PATCH] csky: Fix ABIv2 memcmp() s1 alignment check
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
0 siblings, 1 reply; 4+ messages in thread
From: Hanlin Song @ 2026-07-06 10:39 UTC (permalink / raw)
To: guoren; +Cc: Hanlin Song, linux-csky, linux-kernel
Hi Guo Ren and C-SKY maintainers,
Gentle ping on this patch.
My understanding is that r3 holds the original s1 pointer after r0 is
cleared, so the alignment check should use r3 instead of r0. I also
tested this on a CK860f chip, and the patched version was faster in my
unaligned memcmp test.
I may be missing some C-SKY ABIv2 detail, so any feedback would be
appreciated.
Thanks,
Hanlin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] csky: Fix ABIv2 memcmp() s1 alignment check
2026-07-06 10:39 ` Hanlin Song
@ 2026-07-07 3:15 ` Guo Ren
2026-07-07 3:47 ` Hanlin Song
0 siblings, 1 reply; 4+ messages in thread
From: Guo Ren @ 2026-07-07 3:15 UTC (permalink / raw)
To: Hanlin Song; +Cc: linux-csky, linux-kernel
Hi Song,
On Mon, Jul 6, 2026 at 6:40 PM Hanlin Song <pgeorge8929@gmail.com> wrote:
>
> Hi Guo Ren and C-SKY maintainers,
>
> Gentle ping on this patch.
>
> My understanding is that r3 holds the original s1 pointer after r0 is
> cleared, so the alignment check should use r3 instead of r0. I also
> tested this on a CK860f chip, and the patched version was faster in my
> unaligned memcmp test.
>
> I may be missing some C-SKY ABIv2 detail, so any feedback would be
> appreciated.
>
Thanks for the patch, but this code is intentional. The CK810 and
CK860 support misaligned load/store in their microarchitecture, so the
alignment-check path is effectively dead code that exists only to keep
this asm code. It has been carried over unchanged from the very first.
--
Best Regards
Guo Ren
^ permalink raw reply [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