Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Arm32: correct string.h functions for "int" -> "unsigned char" conversion
@ 2026-05-19  6:44 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2026-05-19  6:44 UTC (permalink / raw)
  To: linux-arm-kernel@lists.infradead.org; +Cc: Russell King

While Arm64 does so uniformly, for Arm32 only strchr() currently handles
this properly. Add the necessary conversion also to strrchr(), memchr(),
and memset().

As to the placement in memset(): Putting the new insn at the beginning
of the function could perhaps be deemed more "obvious", but the code
reachable without ever making it to the "1" label only ever does byte
stores.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/arch/arm/lib/memchr.S
+++ b/arch/arm/lib/memchr.S
@@ -12,6 +12,7 @@
 	.text
 	.align	5
 ENTRY(memchr)
+	and	r1, r1, #0xff
 1:	subs	r2, r2, #1
 	bmi	2f
 	ldrb	r3, [r0], #1
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -24,7 +24,8 @@ UNWIND( .fnstart         )
 /*
  * we know that the pointer in ip is aligned to a word boundary.
  */
-1:	orr	r1, r1, r1, lsl #8
+1:	and	r1, r1, #0xff
+	orr	r1, r1, r1, lsl #8
 	orr	r1, r1, r1, lsl #16
 	mov	r3, r1
 7:	cmp	r2, #16
--- a/arch/arm/lib/strrchr.S
+++ b/arch/arm/lib/strrchr.S
@@ -12,6 +12,7 @@
 		.text
 		.align	5
 ENTRY(strrchr)
+		and	r1, r1, #0xff
 		mov	r3, #0
 1:		ldrb	r2, [r0], #1
 		teq	r2, r1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-19  6:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19  6:44 Arm32: correct string.h functions for "int" -> "unsigned char" conversion Jan Beulich

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