From: chengang.beijing@outlook.com (chengang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 1/1] ARM : missing corrupted reg in __div64_32
Date: Fri, 1 Apr 2016 12:22:11 +0800 [thread overview]
Message-ID: <BLU436-SMTP267D09D3249FC3AAF122B999A0@phx.gbl> (raw)
In-Reply-To: <20160331114106.GI3701@e103592.cambridge.arm.com>
__xl(R0 in little endian system, or R1 in big endian system) is corrupted
after calling __do_div64 and compiler is not informed about this.
If n is used again afterwards, __xl won't be reloaded and n will
contain incorrect value.
Signed-off-by: Chen Gang <gangchen@rdamicro.com>
Signed-off-by: Chen Gang <changeang.beijing@outlook.com>
---
arch/arm/include/asm/div64.h | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/arch/arm/include/asm/div64.h b/arch/arm/include/asm/div64.h
index e1f0776..8d1b49a 100644
--- a/arch/arm/include/asm/div64.h
+++ b/arch/arm/include/asm/div64.h
@@ -21,30 +21,24 @@
* for arguments and results (beware).
*/
-#ifdef __ARMEB__
-#define __xh "r0"
-#define __xl "r1"
-#else
-#define __xl "r0"
-#define __xh "r1"
-#endif
static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
{
register unsigned int __base asm("r4") = base;
register unsigned long long __n asm("r0") = *n;
register unsigned long long __res asm("r2");
- register unsigned int __rem asm(__xh);
- asm( __asmeq("%0", __xh)
+ asm( __asmeq("%0", "r0")
__asmeq("%1", "r2")
- __asmeq("%2", "r0")
- __asmeq("%3", "r4")
+ __asmeq("%2", "r4")
"bl __do_div64"
- : "=r" (__rem), "=r" (__res)
- : "r" (__n), "r" (__base)
+ : "+r" (__n), "=r" (__res)
+ : "r" (__base)
: "ip", "lr", "cc");
*n = __res;
- return __rem;
+ /*
+ * rem is saved at the up half of __n, see __do_div64 for more
+ */
+ return __n >> 32;
}
#define __div64_32 __div64_32
--
2.4.3
next prev parent reply other threads:[~2016-04-01 4:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-28 4:19 [PATCH 1/1] ARM : missing corrupted reg in __do_div_asm Chen Gang
2016-03-29 10:19 ` Arnd Bergmann
2016-03-29 10:26 ` Dave Martin
2016-03-29 10:34 ` Russell King - ARM Linux
2016-03-29 10:56 ` Dave Martin
2016-03-30 3:27 ` 陈刚(Gangchen)
2016-03-30 14:07 ` Dave Martin
2016-03-31 7:56 ` 陈刚(Gangchen)
2016-03-31 10:30 ` Dave Martin
2016-03-31 11:20 ` 陈刚(Gangchen)
2016-03-31 11:41 ` Dave Martin
2016-04-01 4:22 ` chengang [this message]
2016-04-01 8:56 ` [PATCH V3 1/1] ARM : missing corrupted reg in __div64_32 Dave Martin
2016-04-01 10:28 ` [PATCH V4 " chengang
2016-04-01 11:03 ` Dave Martin
2016-04-01 11:25 ` [PATCH V5 " chengang
2016-04-01 11:34 ` Dave P Martin
2016-04-01 11:35 ` [PATCH V4 " 陈刚(Gangchen)
2016-03-31 11:41 ` [PATCH v2 " Chen Gang
2016-03-29 10:58 ` [PATCH 1/1] ARM : missing corrupted reg in __do_div_asm 陈刚(Gangchen)
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=BLU436-SMTP267D09D3249FC3AAF122B999A0@phx.gbl \
--to=chengang.beijing@outlook.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.