Skip to contentSkip to conversation

m68k: libgcc: Fix lvalue abuse in umul_ppmm()

PATCH In review Geert Uytterhoeven 2 participants 2 messages Jan 8, 2025 m68k architecture

lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

PATCH 1/1 m68k: libgcc: Fix lvalue abuse in umul_ppmm()

lib/muldi3.c:53:28: warning: asm output is not an lvalue lib/muldi3.c:53:28: warning: asm output is not an lvalue lib/muldi3.c:53:28: error: not addressable lib/muldi3.c:53:28: warning: generating address of non-lvalue (11) lib/muldi3.c:53:28: warning: generating address of non-lvalue (11)

Fix the lvalue warnings by replacing the casts on the output operands by intermediate variables of the right type.

Fix the "not addressable" error by replacing the cast on the second input operand by an intermediate variable, too. Treat the other input operand the same for consistency.

---
To be queued in the m68k for-v6.14 branch.
Not folding into commit e96424b86d5098f4 ("m68k: Use kernel's generic muldi3 libgcc function"), as the issue was pre-existing.

---
 arch/m68k/include/asm/libgcc.h | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
arch/m68k/include/asm/libgcc.h +12 -5
index 1cce6d130d805368..27e17195bd7be41c 100644
@@ -10,11 +10,18 @@
  * will fallback to using the C-coded version of umul_ppmm().
  */
 #define umul_ppmm(w1, w0, u, v)				\
-	__asm__ ("mulu%.l %3,%1:%0"			\
-		 : "=d" ((unsigned long)(w0)),		\
-		   "=d" ((unsigned long)(w1))		\
-		 : "%0" ((unsigned long)(u)),		\
-		   "dmi" ((unsigned long)(v)))
+	do {						\
+		unsigned long __u = (u), __v = (v);	\
+		unsigned long __w0, __w1;		\
+							\
+		__asm__ ("mulu%.l %3,%1:%0"		\
+			 : "=d" (__w0),			\
+			   "=d" (__w1)			\
+			 : "%0" (__u),			\
+			   "dmi" (__v));		\
+							\
+		(w0) = __w0; (w1) = __w1;		\
+	} while (0)
 #endif /* !CONFIG_CPU_HAS_NO_MULDIV64 */
 
 #endif /* __ASM_M68K_LIBGCC_H */
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw

Hi Geert,

Quoted 9 lines · Geert Uytterhoeven

lib/muldi3.c:53:28: warning: asm output is not an lvalue lib/muldi3.c:53:28: warning: asm output is not an lvalue lib/muldi3.c:53:28: error: not addressable lib/muldi3.c:53:28: warning: generating address of non-lvalue (11) lib/muldi3.c:53:28: warning: generating address of non-lvalue (11)

Fix the lvalue warnings by replacing the casts on the output operands by intermediate variables of the right type.

Quoted 8 lines

Fix the "not addressable" error by replacing the cast on the second input operand by an intermediate variable, too. Treat the other input operand the same for consistency.

Thanks for cleaning this up.

Regards
Greg

Quoted 36 lines

---
To be queued in the m68k for-v6.14 branch.
Not folding into commit e96424b86d5098f4 ("m68k: Use kernel's generic muldi3 libgcc function"), as the issue was pre-existing.

---
  arch/m68k/include/asm/libgcc.h | 17 ++++++++++++-----
  1 file changed, 12 insertions(+), 5 deletions(-)
arch/m68k/include/asm/libgcc.h +12 -5
index 1cce6d130d805368..27e17195bd7be41c 100644
@@ -10,11 +10,18 @@
   * will fallback to using the C-coded version of umul_ppmm().
   */
  #define umul_ppmm(w1, w0, u, v)				\
-	__asm__ ("mulu%.l %3,%1:%0"			\
-		 : "=d" ((unsigned long)(w0)),		\
-		   "=d" ((unsigned long)(w1))		\
-		 : "%0" ((unsigned long)(u)),		\
-		   "dmi" ((unsigned long)(v)))
+	do {						\
+		unsigned long __u = (u), __v = (v);	\
+		unsigned long __w0, __w1;		\
+							\
+		__asm__ ("mulu%.l %3,%1:%0"		\
+			 : "=d" (__w0),			\
+			   "=d" (__w1)			\
+			 : "%0" (__u),			\
+			   "dmi" (__v));		\
+							\
+		(w0) = __w0; (w1) = __w1;		\
+	} while (0)
  #endif /* !CONFIG_CPU_HAS_NO_MULDIV64 */
 
  #endif /* __ASM_M68K_LIBGCC_H */