Skip to contentSkip to conversation

ARM : missing corrupted reg in __do_div_asm

PATCH Superseded Chen Gang 1 participant 1 message Jun 10, 2015 Arm (32-bit)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH v2 1/1 ARM : missing corrupted reg in __do_div_asm

__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 in macro __do_div_asm. If n is used again afterwards, __xl won't be reloaded and n will contain incorrect value.

---
 arch/arm/include/asm/div64.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/include/asm/div64.h +6 -4
index 662c7bd..fa9489e 100644
@@ -34,12 +34,14 @@
 	register unsigned long long __n   asm("r0") = n;	\
 	register unsigned long long __res asm("r2");		\
 	register unsigned int __rem       asm(__xh);		\
+	register unsigned int __clobber   asm(__xl);		\
 	asm(	__asmeq("%0", __xh)				\
-		__asmeq("%1", "r2")				\
-		__asmeq("%2", "r0")				\
-		__asmeq("%3", "r4")				\
+		__asmeq("%1", __xl)				\
+		__asmeq("%2", "r2")				\
+		__asmeq("%3", "r0")				\
+		__asmeq("%4", "r4")				\
 		"bl	__do_div64"				\
-		: "=r" (__rem), "=r" (__res)			\
+		: "=r" (__rem), "=r" (__clobber), "=r" (__res)  \
 		: "r" (__n), "r" (__base)			\
 		: "ip", "lr", "cc");				\
 	n = __res;						\
Signature · 1 line
2.4.2