From: Borislav Petkov <bp@alien8.de>
To: Rosen Penev <rosenp@gmail.com>
Cc: Sasha Levin <sashal@kernel.org>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Florian Westphal <fw@strlen.de>, Julian Anastasov <ja@ssi.bg>,
Jeff Johnson <jeff.johnson@oss.qualcomm.com>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] x86/csum: Relax the len and proto constraints in 32-bit csum_ipv6_magic()
Date: Mon, 19 Oct 2026 18:11:40 -0700 [thread overview]
Message-ID: <20261020011140.GCata_zHOTeTXLdlr2@fat_crate.local> (raw)
In-Reply-To: <CAKxU2N9paXhCuNknUzKx5dYxhXitLZ=OVVY7Sym1HV8Mow6cSQ@mail.gmail.com>
On Mon, Oct 19, 2026 at 05:56:44PM -0700, Rosen Penev wrote:
> On Mon, Oct 19, 2026 at 5:32 PM Sasha Levin <sashal@kernel.org> wrote:
> >
> > Building an i386 allmodconfig kernel with clang fails since allmodconfig
> > started building netfilter with GCOV profiling:
> >
> > In file included from net/netfilter/nf_synproxy_core.c:7:
> > In file included from ./include/linux/skbuff.h:26:
> > In file included from ./include/net/checksum.h:21:
> > In file included from ./arch/x86/include/asm/checksum.h:9:
> > ./arch/x86/include/asm/checksum_32.h:149:6: error: inline assembly requires more registers than available
> >
> > The csum_ipv6_magic() asm needs five registers at once: the early-clobber
> > sum plus register-only inputs for saddr, daddr, htonl(len) and
> > htonl(proto). With frame pointers enabled, six general purpose registers
> > are left to choose from.
> >
> > In synproxy_send_tcp_ipv6(), the GCOV instrumentation lets clang's
> > machine scheduler move the copies of two incoming register arguments,
> > EDX and ECX, below the asm. Both registers then stay live across the
> > asm, which leaves four registers for its five operands. This is LLVM
> > issue #206307. The error goes away without either GCOV or frame
> > pointers, and it reproduces with clang 19, 21 and 22.
> >
> > Neither len nor proto has to be in a register: adcl also takes a 32-bit
> > memory or immediate source operand. Use "g" for both, so the asm needs
> > at most three registers whatever the caller looks like.
> >
> > ASM_INPUT_G, which normally replaces "g" to avoid clang's poor handling
> > of it, is not enough here. It expands to "ir" for clang, so callers that
> > pass a variable protocol, like nf_ip6_checksum(), would still need five
> > registers. With "g", clang passes a non-constant len or proto through
> > the stack and still turns constants into immediates.
> >
> > Fixes: 403cec8ab6d0 ("netfilter: add option for GCOV profiling")
> > Reported-by: kernelci.org bot <bot@kernelci.org>
> > Closes: https://dashboard.kernelci.org/build/maestro:6ad55fe255fda507603d2651
> > Reported-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
> > Closes: https://lore.kernel.org/a28df759-d0e9-41c0-97c7-5f89a18d54e2@oss.qualcomm.com
> > Assisted-by: LLM
> > Signed-off-by: Sasha Levin <sashal@kernel.org>
> > Cc: stable@vger.kernel.org
> > Link: https://github.com/llvm/llvm-project/issues/206307
> > ---
> > KernelCI's kbuild-clang-21-i386-allmodconfig job has failed on mainline
> > with this error since the 7.2 merge window, v7.3 included.
This'll tell you how much people including us care about 32-bit...
> > Tested on i386 with KernelCI's allmodconfig-based .config: with clang
> > 19.1.7, 21.1.8 and 22.1.8, nf_synproxy_core.o fails before this change
> > and builds after it, and net/{netfilter,ipv4,ipv6,bridge}/ and
> > arch/x86/lib/ build without errors or warnings. The same directories
> > also build cleanly with GCC 16.2 (i386 allmodconfig). A 32-bit userspace
> > harness comparing the asm against a C reference over 2M random and
> > carry-edge inputs shows no mismatches with either compiler. No full
> > allmodconfig build or boot test.
> >
> > 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 17da953879976..f74873a5e3510 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");
> Same as https://lore.kernel.org/all/20260904000833.2058186-1-rosenp@gmail.com/
Except that Sasha's commit message explains it perfectly clear how this
happens while for yours I would've asked how you're reproducing this.
OTOH, I'm not sure I care about Sasha's AI's blurb about what params should've
been in what registers and so on... :)
If only you guys would agree on how to merge the two, assign authorship and
drop the unnecessary blurb...
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2026-10-20 1:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 0:32 Sasha Levin
2026-10-20 0:56 ` Rosen Penev
2026-10-20 1:11 ` Borislav Petkov [this message]
2026-10-20 1:17 ` Sasha Levin
2026-10-20 1:28 ` Borislav Petkov
2026-10-20 3:04 ` Rosen Penev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261020011140.GCata_zHOTeTXLdlr2@fat_crate.local \
--to=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=fw@strlen.de \
--cc=hpa@zytor.com \
--cc=ja@ssi.bg \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=rosenp@gmail.com \
--cc=sashal@kernel.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®