> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index afa566e0fa86..cad2bdf3456f 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -282,11 +282,16 @@ config CC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION > # https://github.com/llvm/llvm-project/pull/131230 > def_bool > $(cc-option,-fpatchable-function-entry=1$(comma)1$(comma).discard.patchable_function_entries) > > +config RUSTC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION > + # The section argument needs Rust 1.98.0 or later: > + # https://github.com/rust-lang/rust/pull/157445 > + def_bool > $(rustc-option,-Zpatchable-function-entry=1$(comma)1$(comma).discard.patchable_function_entries) > + > config ARM64_CFI_PERMITS_CALL_OPS > def_bool y > depends on CFI > depends on CC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION > - depends on !RUST > + depends on !RUST || RUSTC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION > > config ARM64_FUNCTION_PREFIX_NOPS > int > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > index 653c1ed6ef38..b23430e2b856 100644 > --- a/arch/arm64/Makefile > +++ b/arch/arm64/Makefile > @@ -152,6 +152,9 @@ ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS),y) > -DCC_USING_PATCHABLE_FUNCTION_PREFIX=$(prefix_nops) > KBUILD_CFLAGS += $(CFI_PREFIX_CFLAGS) > export CFI_PREFIX_CFLAGS > + # Rust functions are not patched by ftrace, but they are called > indirectly > + # from C and make indirect calls themselves, so they need the same > prefix. > + KBUILD_RUSTFLAGS += > -Zpatchable-function-entry=$(prefix_nops),$(prefix_nops),.discard.patchable_function_entries > endif > else ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_ARGS),y) > KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY > diff --git a/rust/Makefile b/rust/Makefile > index da1a7409d984..b402ab768f72 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -511,7 +511,12 @@ endif > # prototypes for functions like `memcpy` -- if this flag is not passed, > # `bindgen`-generated prototypes use `c_ulong` or `c_uint` depending on > # architecture instead of generating `usize`. > -bindgen_c_flags_final = $(bindgen_c_flags_lto) -fno-builtin -D__BINDGEN__ > +# > +# Do not pass -fpatchable-function-entry to bindgen: its libclang may not > +# support the section argument (Clang >= 21), and removing the flag does not > +# change the ABI. > +bindgen_c_flags_final = $(filter-out -fpatchable-function-entry=%, \ > + $(bindgen_c_flags_lto)) -fno-builtin -D__BINDGEN__ ^^^^
This isn't a bug, but could the commit message mention that bindgen's C flags now drop -fpatchable-function-entry on all architectures, not just arm64 with CFI? The change applies whenever any architecture passes -fpatchable-function-entry in CFLAGS (x86 CALL_PADDING, riscv, powerpc, loongarch, parisc, and arm64 ftrace). The reason for filtering it out (bindgen's libclang may be older than the kernel's Clang and may reject the section argument) is documented in the code comment, but the commit message only describes the arm64 kCFI pieces. --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/36069841267
