Re: [linus:master] [rust] b7b8b4ccda: CFI_failure_at_do_one_initcall

From: Gary Guo

Date: Thu Aug 20 2026 - 09:31:19 EST


(Cc Clang/LLVM folks)

On Thu Aug 20, 2026 at 4:16 AM BST, kernel test robot wrote:
>
>
> Hello,
>
> kernel test robot noticed "CFI_failure_at_do_one_initcall" on:
>
> commit: b7b8b4ccdad45a59aafa5cfc32a51fe1ee5cb680 ("rust: extract `bitfield!` macro from `register!`") https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master
>
> [test still failed on linus/master 8d3ae59288f1e7d58d76558a6ee96d533bc5019]
>
> in testcase: rcutorture
> with following parameters:
>
> runtime: 300s
> test: cpuhotplug
> torture_type: tasks-tracing
>
>
>
> config: x86_64-randconfig-015-20260715
> compiler: clang-22
> test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 32G
>
> (please refer to attached dmesg/kmsg for entire log/backtrace)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <yi1.lai@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-lkp/202608201017.100a4511-lkp@xxxxxxxxx

The issue looks like that LLVM is trying to merge functions by creating alias
with different KCFI types.

See this minimized example: https://godbolt.org/z/PhhcGh4W5

Note that a and b have different !kcfi_types annotation, but they're merged
regardless.

This causes the merge of `__module_firmware_test_init` with `Flags::zeroed`
which ABI-wise are compatible as they all return just an integer, but have
different KCFI signature.

I think we need to disable function merging pass when KCFI is enabled, until
this has been fixed by LLVM. Clang disables this pass by default. We can also
workaround the issue by disable the test that generates
`__module_firmware_test_init` (perhaps we should do this regardless, it's
strange that a module is produced from doc tests!)

So that commit is just a trigger and isn't buggy itself; it only introduces a
new function which happens to be mergeable with the empty
__module_firmware_test_init.

Best,
Gary

>
>
> [ 16.811904][ T1] CFI failure at do_one_initcall+0x12e/0x478 (target: _RINvCsdamrQDJyPhn_8pin_init6zeroedNtNvNvNvCsdPKRummocL6_25doctests_kernel_generated33rust_doctest_kernel_bitfield_rs_04main43__doctest_main_rust_kernel_bitfield_rs_118_05FlagsEBE_+0x0/0x4; expected type: 0x6fbb3035)
> [ 16.820524][ T1] WARNING: at do_one_initcall+0x12e/0x478, CPU#0: swapper/0/1
> [ 16.823875][ T1] Modules linked in:
> [ 16.825674][ T1] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.1.0-rc4-00055-gb7b8b4ccdad4 #1 PREEMPT 79da7d58e576708b28b47c0dd4cca3fe34a229fd
> [ 16.831720][ T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
> [ 16.836267][ T1] RIP: 0010:do_one_initcall+0x12e/0x478
> [ 16.838287][ T1] Code: d2 31 c9 e8 74 04 49 00 45 84 f6 75 0c 48 8d 3d 90 03 a1 0c 67 48 0f b9 3a 4c 8b 5c 24 08 41 ba cb cf 44 90 45 03 53 fc 74 02 <0f> 0b 2e e8 42 96 f8 06 41 89 c6 0f 1f 44 00 00 41 81 e5 ff ff ff
> [ 16.843506][ T1] RSP: 0018:ffffc9000001fb80 EFLAGS: 00010a13
> [ 16.845121][ T1] RAX: 0000000000000000 RBX: dffffc0000000000 RCX: 0000000000000000
> [ 16.847279][ T1] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
> [ 16.849427][ T1] RBP: ffffc9000001fe70 R08: 0000000000000000 R09: 0000000b8a3be5a2
> [ 16.851619][ T1] R10: 000000006c292bb6 R11: ffffffff81407458 R12: ffffffff8f899850
> [ 16.853771][ T1] R13: 0000000080000000 R14: 0000000000000001 R15: 1ffffffff1edab41
> [ 16.855915][ T1] FS: 0000000000000000(0000) GS:0000000000000000(0000) knlGS:0000000000000000
> [ 16.858307][ T1] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 16.860091][ T1] CR2: 00007fd1104620ac CR3: 000000000ba86000 CR4: 00000000000406b0
> [ 16.862236][ T1] Call Trace:
> [ 16.863144][ T1] <TASK>
> [ 16.863961][ T1] ? __cfi__RINvCsdamrQDJyPhn_8pin_init6zeroedNtNvNvNvCsdPKRummocL6_25doctests_kernel_generated33rust_doctest_kernel_bitfield_rs_04main43__doctest_main_rust_kernel_bitfield_rs_118_05FlagsEBE_+0x8/0x8
> [ 16.869044][ T1] ? stack_depot_save_flags+0x40f/0xab8
> [ 16.870574][ T1] ? irqentry_exit+0x1b8/0x638
> [ 16.871878][ T1] ? trace_irq_disable+0x25/0x100
> [ 16.873243][ T1] ? __cfi_ignore_unknown_bootoption+0x8/0x8
> [ 16.874861][ T1] ? strlen+0x32/0x78
> [ 16.875952][ T1] ? parameq+0x1a/0xf8
> [ 16.877070][ T1] ? __cfi_ignore_unknown_bootoption+0x8/0x8
> [ 16.878666][ T1] ? parse_args+0x17e/0x538
> [ 16.879902][ T1] do_initcall_level+0x10e/0x1c0
> [ 16.881314][ T1] do_initcalls+0x59/0xc0
> [ 16.882501][ T1] kernel_init_freeable+0x11e/0x1c0
> [ 16.883889][ T1] ? __cfi_kernel_init+0x8/0x8
> [ 16.885175][ T1] kernel_init+0x16/0x138
> [ 16.886357][ T1] ret_from_fork+0x266/0x5f8
> [ 16.887598][ T1] ? __cfi_kernel_init+0x8/0x8
> [ 16.888884][ T1] ret_from_fork_asm+0x11/0x20
> [ 16.890220][ T1] </TASK>
> [ 16.891058][ T1] irq event stamp: 306141
> [ 16.892233][ T1] hardirqs last enabled at (306157): [<ffffffff81749821>] __console_unlock+0x61/0xc0
> [ 16.894765][ T1] hardirqs last disabled at (306170): [<ffffffff81749806>] __console_unlock+0x46/0xc0
> [ 16.897303][ T1] softirqs last enabled at (305714): [<ffffffff81618b94>] handle_softirqs+0x614/0x780
> [ 16.899859][ T1] softirqs last disabled at (305705): [<ffffffff81618ec5>] __irq_exit_rcu+0x45/0x140
> [ 16.902401][ T1] ---[ end trace 0000000000000000 ]---
>
>
> The kernel config and materials to reproduce are available at:
> https://download.01.org/0day-ci/archive/20260820/202608201017.100a4511-lkp@xxxxxxxxx
>
>
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki