Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] x86: checksum_32: allow memory/immediate operands in csum_ipv6_magic
@ 2026-09-04  0:08 Rosen Penev
  0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-09-04  0:08 UTC (permalink / raw)
  To: x86
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt,
	open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 arch/x86/include/asm/checksum_32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
index 17da95387997..f74873a5e351 100644
--- a/arch/x86/include/asm/checksum_32.h
+++ b/arch/x86/include/asm/checksum_32.h
@@ -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);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-04  0:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  0:08 [PATCH] x86: checksum_32: allow memory/immediate operands in csum_ipv6_magic Rosen Penev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox