Skip to contentSkip to conversation

x86: checksum_32: allow memory/immediate operands in csum_ipv6_magic

PATCH New Rosen Penev 1 participant 1 message Sep 4 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: checksum_32: allow memory/immediate operands in csum_ipv6_magic

Building nf_synproxy_core.c for i386 with LLVM/Clang fails with "inline assembly requires more registers than available". The csum_ipv6_magic() inline asm demands five registers at once: an early-clobber output for sum plus four "r" inputs (saddr, daddr, htonl(len), htonl(proto)). i386 only has six GPRs, so under register pressure at inlined call sites Clang cannot satisfy the constraints.

Relax the register-only "r" constraints on the len and proto operands to "g" (register, memory, or immediate). Since the asm uses adcl, which accepts memory and immediate sources for these operands, the generated checksum is unchanged; the compiler can now fold the constants to immediates/memory and only three hard registers are needed.

Assisted-by opencode:big-pickle
---
 arch/x86/include/asm/checksum_32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/checksum_32.h +1 -1
index 17da95387997..f74873a5e351 100644
@@ -159,7 +159,7 @@ static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 	    "adcl $0, %0	;\n"
 	    : "=&r" (sum)
 	    : "r" (saddr), "r" (daddr),
-	      "r" (htonl(len)), "r" (htonl(proto)), "0" (sum)
+	      "g" (htonl(len)), "g" (htonl(proto)), "0" (sum)
 	    : "memory");
 
 	return csum_fold(sum);
Signature · 1 line
2.55.0