public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm: memset: zero out upper bytes in r1
@ 2014-05-05  7:11 Andrey Ryabinin
  2014-05-07 23:42 ` Afzal Mohammed
  2014-05-08  8:04 ` Vladimir Murzin
  0 siblings, 2 replies; 7+ messages in thread
From: Andrey Ryabinin @ 2014-05-05  7:11 UTC (permalink / raw)
  To: linux; +Cc: Andrey Ryabinin, moderated list:ARM PORT, open list

memset doesn't work right for following example:

	signed char c = 0xF0;
	memset(addr, c, size);

Variable c is signed, so after typcasting to int the value will be 0xFFFFFFF0.
This value will be passed through r1 regitster to memset function.
memset doesn't zero out upper bytes in r1, so memory will be filled
with 0xFFFFFFF0 instead of expected 0xF0F0F0F0.

Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
---
 arch/arm/lib/memset.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index 94b0650..a010f76 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -22,7 +22,8 @@ ENTRY(memset)
 /*
  * 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
 	cmp	r2, #16
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-12  7:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-05  7:11 [PATCH] arm: memset: zero out upper bytes in r1 Andrey Ryabinin
2014-05-07 23:42 ` Afzal Mohammed
2014-05-08  7:59   ` Andrey Ryabinin
2014-05-08 14:40     ` Andrey Ryabinin
2014-05-08  8:04 ` Vladimir Murzin
2014-05-08  8:38   ` Vladimir Murzin
2014-05-12  6:58     ` Andrey Ryabinin

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