linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND,PATCH] ARM: fix __div64_32() error when compiling with clang
@ 2020-11-23  7:36 Antony Yu
  2020-11-23 18:16 ` Nathan Chancellor
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Antony Yu @ 2020-11-23  7:36 UTC (permalink / raw)
  Cc: swpenim, Russell King, Nathan Chancellor, Nick Desaulniers,
	linux-arm-kernel, linux-kernel, clang-built-linux

__do_div64 clobbers the input register r0 in little endian system.
According to the inline assembly document, if an input operand is
modified, it should be tied to a output operand. This patch can
prevent compilers from reusing r0 register after asm statements.

Signed-off-by: Antony Yu <swpenim@gmail.com>
---
 arch/arm/include/asm/div64.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/div64.h b/arch/arm/include/asm/div64.h
index 898e9c78a7e7..809efc51e90f 100644
--- a/arch/arm/include/asm/div64.h
+++ b/arch/arm/include/asm/div64.h
@@ -39,9 +39,10 @@ static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
 	asm(	__asmeq("%0", __xh)
 		__asmeq("%1", "r2")
 		__asmeq("%2", "r0")
-		__asmeq("%3", "r4")
+		__asmeq("%3", "r0")
+		__asmeq("%4", "r4")
 		"bl	__do_div64"
-		: "=r" (__rem), "=r" (__res)
+		: "=r" (__rem), "=r" (__res), "=r" (__n)
 		: "r" (__n), "r" (__base)
 		: "ip", "lr", "cc");
 	*n = __res;
-- 
2.23.0


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

end of thread, other threads:[~2020-11-30 18:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-23  7:36 [RESEND,PATCH] ARM: fix __div64_32() error when compiling with clang Antony Yu
2020-11-23 18:16 ` Nathan Chancellor
2020-11-24  7:42   ` Antony Yu
2020-11-24 10:14     ` Antony Yu
2020-11-24 21:06       ` Nick Desaulniers
2020-11-30  8:20         ` [PATCH v2] " Antony Yu
2020-11-24 23:16 ` [RESEND,PATCH] " kernel test robot
2020-11-30 10:11 ` Ard Biesheuvel
2020-11-30 10:12   ` Ard Biesheuvel
2020-11-30 10:21     ` Russell King - ARM Linux admin
2020-11-30 10:40       ` Ard Biesheuvel
2020-11-30 13:58         ` David Laight
2020-11-30 14:18           ` Russell King - ARM Linux admin
2020-11-30 15:50     ` Nicolas Pitre
2020-11-30 17:18       ` Ard Biesheuvel
2020-11-30 17:52         ` Nicolas Pitre
2020-11-30 18:08           ` Ard Biesheuvel

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).