From: afzal.mohd.ma@gmail.com (Afzal Mohammed)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: memset: zero out upper bytes in r1
Date: Thu, 8 May 2014 05:12:56 +0530 [thread overview]
Message-ID: <20140507234255.GA2050@afzal-ThinkPad-R50e> (raw)
In-Reply-To: <1399273875-8403-1-git-send-email-a.ryabinin@samsung.com>
Hi Andrey,
On Mon, May 05, 2014 at 11:11:13AM +0400, Andrey Ryabinin wrote:
> 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.
> --- 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
int is to be converted to unsigned char in memset, would having above
change immediately upon entry to memset rather than at a place where it
won't always execute make intention clearer ? (although it doesn't make
difference)
ubfx r1, r1, #0, #8 would have given the needed typecasting, but seems
it is available only on ARMv6T2 & above.
Regards
Afzal
next prev parent reply other threads:[~2014-05-07 23:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-05 7:11 [PATCH] arm: memset: zero out upper bytes in r1 Andrey Ryabinin
2014-05-07 23:42 ` Afzal Mohammed [this message]
2014-05-08 7:59 ` Andrey Ryabinin
2014-05-08 14:40 ` Andrey Ryabinin
[not found] ` <loom.20140508T095105-952@post.gmane.org>
[not found] ` <loom.20140508T103032-725@post.gmane.org>
2014-05-12 6:58 ` Andrey Ryabinin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140507234255.GA2050@afzal-ThinkPad-R50e \
--to=afzal.mohd.ma@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).