From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Nathan Chancellor <nathan@kernel.org>,
Kees Cook <kees@kernel.org>,
Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: Simon Horman <horms@kernel.org>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
Sami Tolvanen <samitolvanen@google.com>,
Russell King <linux@armlinux.org.uk>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Michal Kubiak <michal.kubiak@intel.com>,
<linux-kernel@vger.kernel.org>, <llvm@lists.linux.dev>,
<linux-arm-kernel@lists.infradead.org>, <netdev@vger.kernel.org>,
<intel-wired-lan@lists.osuosl.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>
Subject: Re: [Intel-wired-lan] [PATCH 3/3] libeth: xdp: Disable generic kCFI pass for libeth_xdp_tx_xmit_bulk()
Date: Mon, 27 Oct 2025 12:09:47 +0100 [thread overview]
Message-ID: <fa4487d0-a077-4582-80aa-2deeccee6270@intel.com> (raw)
In-Reply-To: <20251025-idpf-fix-arm-kcfi-build-error-v1-3-ec57221153ae@kernel.org>
On 10/25/25 22:53, Nathan Chancellor wrote:
> When building drivers/net/ethernet/intel/idpf/xsk.c for ARCH=arm with
> CONFIG_CFI=y using a version of LLVM prior to 22.0.0, there is a
> BUILD_BUG_ON failure:
>
> $ cat arch/arm/configs/repro.config
> CONFIG_BPF_SYSCALL=y
> CONFIG_CFI=y
> CONFIG_IDPF=y
> CONFIG_XDP_SOCKETS=y
>
> $ make -skj"$(nproc)" ARCH=arm LLVM=1 clean defconfig repro.config drivers/net/ethernet/intel/idpf/xsk.o
> In file included from drivers/net/ethernet/intel/idpf/xsk.c:4:
> include/net/libeth/xsk.h:205:2: error: call to '__compiletime_assert_728' declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(tmo == libeth_xsktmo)
> 205 | BUILD_BUG_ON(!__builtin_constant_p(tmo == libeth_xsktmo));
> | ^
> ...
>
> libeth_xdp_tx_xmit_bulk() indirectly calls libeth_xsk_xmit_fill_buf()
> but these functions are marked as __always_inline so that the compiler
> can turn these indirect calls into direct ones and see that the tmo
> parameter to __libeth_xsk_xmit_fill_buf_md() is ultimately libeth_xsktmo
> from idpf_xsk_xmit().
>
> Unfortunately, the generic kCFI pass in LLVM expands the kCFI bundles
> from the indirect calls in libeth_xdp_tx_xmit_bulk() in such a way that
> later optimizations cannot turn these calls into direct ones, making the
> BUILD_BUG_ON fail because it cannot be proved at compile time that tmo
> is libeth_xsktmo.
>
sorry, but from regular driver developer perspective, just after reading
your commit messages, I'm unable to tell what the fix is about, and from
that follows a bigger issue: how to write code in the future to avoid
such issues (it would be infeasible to always wait for a LLVM specialist
to come up with a fix ;))
was the tricky case to call __always_inline func from another that was
marked the same? Would it be also the case if one of the functions would
not be marked with __always_inline attribute, but still end up inlined?
what would be the cost of the alternative naive solution, to always add
__nocfi_generic to functions marked __always_inline?
(technically you would redefine __always_inline to have also
__nocfi_generic for the config combinations that require that)
sorry for my ignorance of not reading any of the attached URLs
> Disable the generic kCFI pass for libeth_xdp_tx_xmit_bulk() to ensure
> these indirect calls can always be turned into direct calls to avoid
> this error.
>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2124
> Fixes: 9705d6552f58 ("idpf: implement Rx path for AF_XDP")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> include/net/libeth/xdp.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
> index bc3507edd589..898723ab62e8 100644
> --- a/include/net/libeth/xdp.h
> +++ b/include/net/libeth/xdp.h
> @@ -513,7 +513,7 @@ struct libeth_xdp_tx_desc {
> * can't fail, but can send less frames if there's no enough free descriptors
> * available. The actual free space is returned by @prep from the driver.
> */
> -static __always_inline u32
> +static __always_inline __nocfi_generic u32
> libeth_xdp_tx_xmit_bulk(const struct libeth_xdp_tx_frame *bulk, void *xdpsq,
> u32 n, bool unroll, u64 priv,
> u32 (*prep)(void *xdpsq, struct libeth_xdpsq *sq),
>
WARNING: multiple messages have this Message-ID (diff)
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Nathan Chancellor <nathan@kernel.org>,
Kees Cook <kees@kernel.org>,
Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: Simon Horman <horms@kernel.org>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
Sami Tolvanen <samitolvanen@google.com>,
Russell King <linux@armlinux.org.uk>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Michal Kubiak <michal.kubiak@intel.com>,
<linux-kernel@vger.kernel.org>, <llvm@lists.linux.dev>,
<linux-arm-kernel@lists.infradead.org>, <netdev@vger.kernel.org>,
<intel-wired-lan@lists.osuosl.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>
Subject: Re: [PATCH 3/3] libeth: xdp: Disable generic kCFI pass for libeth_xdp_tx_xmit_bulk()
Date: Mon, 27 Oct 2025 12:09:47 +0100 [thread overview]
Message-ID: <fa4487d0-a077-4582-80aa-2deeccee6270@intel.com> (raw)
In-Reply-To: <20251025-idpf-fix-arm-kcfi-build-error-v1-3-ec57221153ae@kernel.org>
On 10/25/25 22:53, Nathan Chancellor wrote:
> When building drivers/net/ethernet/intel/idpf/xsk.c for ARCH=arm with
> CONFIG_CFI=y using a version of LLVM prior to 22.0.0, there is a
> BUILD_BUG_ON failure:
>
> $ cat arch/arm/configs/repro.config
> CONFIG_BPF_SYSCALL=y
> CONFIG_CFI=y
> CONFIG_IDPF=y
> CONFIG_XDP_SOCKETS=y
>
> $ make -skj"$(nproc)" ARCH=arm LLVM=1 clean defconfig repro.config drivers/net/ethernet/intel/idpf/xsk.o
> In file included from drivers/net/ethernet/intel/idpf/xsk.c:4:
> include/net/libeth/xsk.h:205:2: error: call to '__compiletime_assert_728' declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(tmo == libeth_xsktmo)
> 205 | BUILD_BUG_ON(!__builtin_constant_p(tmo == libeth_xsktmo));
> | ^
> ...
>
> libeth_xdp_tx_xmit_bulk() indirectly calls libeth_xsk_xmit_fill_buf()
> but these functions are marked as __always_inline so that the compiler
> can turn these indirect calls into direct ones and see that the tmo
> parameter to __libeth_xsk_xmit_fill_buf_md() is ultimately libeth_xsktmo
> from idpf_xsk_xmit().
>
> Unfortunately, the generic kCFI pass in LLVM expands the kCFI bundles
> from the indirect calls in libeth_xdp_tx_xmit_bulk() in such a way that
> later optimizations cannot turn these calls into direct ones, making the
> BUILD_BUG_ON fail because it cannot be proved at compile time that tmo
> is libeth_xsktmo.
>
sorry, but from regular driver developer perspective, just after reading
your commit messages, I'm unable to tell what the fix is about, and from
that follows a bigger issue: how to write code in the future to avoid
such issues (it would be infeasible to always wait for a LLVM specialist
to come up with a fix ;))
was the tricky case to call __always_inline func from another that was
marked the same? Would it be also the case if one of the functions would
not be marked with __always_inline attribute, but still end up inlined?
what would be the cost of the alternative naive solution, to always add
__nocfi_generic to functions marked __always_inline?
(technically you would redefine __always_inline to have also
__nocfi_generic for the config combinations that require that)
sorry for my ignorance of not reading any of the attached URLs
> Disable the generic kCFI pass for libeth_xdp_tx_xmit_bulk() to ensure
> these indirect calls can always be turned into direct calls to avoid
> this error.
>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2124
> Fixes: 9705d6552f58 ("idpf: implement Rx path for AF_XDP")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> include/net/libeth/xdp.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
> index bc3507edd589..898723ab62e8 100644
> --- a/include/net/libeth/xdp.h
> +++ b/include/net/libeth/xdp.h
> @@ -513,7 +513,7 @@ struct libeth_xdp_tx_desc {
> * can't fail, but can send less frames if there's no enough free descriptors
> * available. The actual free space is returned by @prep from the driver.
> */
> -static __always_inline u32
> +static __always_inline __nocfi_generic u32
> libeth_xdp_tx_xmit_bulk(const struct libeth_xdp_tx_frame *bulk, void *xdpsq,
> u32 n, bool unroll, u64 priv,
> u32 (*prep)(void *xdpsq, struct libeth_xdpsq *sq),
>
next prev parent reply other threads:[~2025-10-27 11:10 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-25 20:53 [Intel-wired-lan] [PATCH 0/3] Resolve ARM kCFI build failure in idpf xsk.c Nathan Chancellor
2025-10-25 20:53 ` Nathan Chancellor
2025-10-25 20:53 ` [Intel-wired-lan] [PATCH 1/3] compiler_types: Introduce __nocfi_generic Nathan Chancellor
2025-10-25 20:53 ` Nathan Chancellor
2025-10-25 20:53 ` [Intel-wired-lan] [PATCH 2/3] ARM: Select ARCH_USES_CFI_GENERIC_LLVM_PASS Nathan Chancellor
2025-10-25 20:53 ` Nathan Chancellor
2025-10-27 15:53 ` [Intel-wired-lan] " Sami Tolvanen
2025-10-27 15:53 ` Sami Tolvanen
2025-10-27 20:59 ` [Intel-wired-lan] " Nathan Chancellor
2025-10-27 20:59 ` Nathan Chancellor
2025-10-27 22:56 ` [Intel-wired-lan] " Linus Walleij
2025-10-27 22:56 ` Linus Walleij
2025-10-28 17:52 ` [Intel-wired-lan] " Nathan Chancellor
2025-10-28 17:52 ` Nathan Chancellor
2025-10-28 18:14 ` [Intel-wired-lan] " Sami Tolvanen
2025-10-28 18:14 ` Sami Tolvanen
2025-10-30 3:04 ` [Intel-wired-lan] " Kees Cook
2025-10-30 3:04 ` Kees Cook
2025-10-25 20:53 ` [Intel-wired-lan] [PATCH 3/3] libeth: xdp: Disable generic kCFI pass for libeth_xdp_tx_xmit_bulk() Nathan Chancellor
2025-10-25 20:53 ` Nathan Chancellor
2025-10-27 11:09 ` Przemek Kitszel [this message]
2025-10-27 11:09 ` Przemek Kitszel
2025-10-27 20:36 ` [Intel-wired-lan] " Nathan Chancellor
2025-10-27 20:36 ` Nathan Chancellor
2025-10-27 14:59 ` [Intel-wired-lan] " Alexander Lobakin
2025-10-27 14:59 ` Alexander Lobakin
2025-10-27 20:54 ` [Intel-wired-lan] " Nathan Chancellor
2025-10-27 20:54 ` Nathan Chancellor
2025-10-28 16:29 ` [Intel-wired-lan] " Alexander Lobakin
2025-10-28 16:29 ` Alexander Lobakin
2025-10-28 22:01 ` [Intel-wired-lan] " Nathan Chancellor
2025-10-28 22:01 ` Nathan Chancellor
2025-10-28 7:31 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-10-28 7:31 ` Loktionov, Aleksandr
2025-10-30 3:06 ` [Intel-wired-lan] [PATCH 0/3] Resolve ARM kCFI build failure in idpf xsk.c Kees Cook
2025-10-30 3:06 ` Kees Cook
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=fa4487d0-a077-4582-80aa-2deeccee6270@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=aleksander.lobakin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=llvm@lists.linux.dev \
--cc=michal.kubiak@intel.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=pabeni@redhat.com \
--cc=samitolvanen@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.