Re: [PATCH] x86/mm: fix objtool failure with KMSAN enabled
From: Dmitry Voytik
Date: Wed Jul 01 2026 - 10:47:56 EST
Hi Alexander,
On Wed, Jul 1, 2026 at 3:18 PM Alexander Potapenko <glider@xxxxxxxxxx> wrote:
>
> On Wed, Jul 1, 2026 at 2:51 PM Dmitry Voytik <voytikd@xxxxxxxxx> wrote:
> >
> > This patch fixes broken builds with defconfig + CONFIG_KMSAN +
> > CONFIG_DEBUG_INFO_*.
> >
> > To reproduce the issue before the fix:
> > make mrproper
> > make LLVM=1 defconfig
> > ./scripts/config -e CONFIG_KMSAN \
> > -e CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
> > make LLVM=1 olddefconfig
> > make LLVM=1 -j(nproc) vmlinux
> > ...
> > LD vmlinux.o
> > vmlinux.o: warning: objtool: folio_zero_user+0x801: undefined stack state
> > vmlinux.o: error: objtool: folio_zero_user+0x801: unknown CFA base reg -1
> > make[2]: *** [scripts/Makefile.vmlinux_o:76: vmlinux.o] Error 255
> >
> > objtool in verbose mode shows how the frame pointer is omitted:
> > make LLVM=1 OBJTOOL_VERBOSE=1 -j(nproc) vmlinux
> > ...
> > b15a2c: folio_zero_user+0x7fc xor %eax,%eax
> > b15a2e: folio_zero_user+0x7fe mov %rcx,%rsp
> > b15a31: folio_zero_user+0x801 mov %r14,%rdi
> > b15a34: folio_zero_user+0x804 mov %rbx,%rcx
> > b15a37: folio_zero_user+0x807 call 0xb15a3c <__clear_pages_unrol
> >
> > After the fix, the frame pointer is back:
> > b15a37: 31 c0 xor %eax,%eax
> > b15a39: 48 89 ec mov %rbp,%rsp
> > b15a3c: 4c 89 f7 mov %r14,%rdi
> > b15a3f: 48 89 d9 mov %rbx,%rcx
> > b15a42: e8 00 00 00 00 call b15a47 <folio_zero_user+0x817>
> >
> > It seems the issue was introduced by
> > commit 54a6b89a3db2 ("x86/mm: simplify clear_page_*")
> >
> > The actual fix is to revert the change how ASM_CALL_CONSTRAINT is
> > positioned.
> > Additionally, reintroduce asm_inline to prevent potential compiler
> > rejection of inlining.
> >
> > Link: https://lore.kernel.org/CAAX90H2_RPnZL_dFYN7cQF6yt-wAweKKSx2=6e2aZ0kv+Pm+NQ@xxxxxxxxxxxxxx
> > Signed-off-by: Dmitry Voytik <voytikd@xxxxxxxxx>
> Have you tried running KMSAN with this fix?
>
> I tried running with the config that Thomas posted at
> https://lore.kernel.org/all/87tsqjq3i3.ffs@fw13/
> (https://tglx.de/~tglx/config.fail), and it still hangs for me.
I only tested the fix with defconfig + CONFIG_KMSAN +
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT + olddefconfig.
qemu-system-x86_64 \
-kernel arch/x86/boot/bzImage \
-append "console=ttyS0" \
-nographic \
-m 8G -smp 4 \
-serial file:serial_output.log
Booting from ROM..
[ 0.000000] Linux version 7.1.0-14280-g3dd2bc904bda
(voyt@voyt-laptop-dell) (clang version 22.1.6, LLD 22.1.6) #2 SMP
PREEMPT_DYNAMIC Wed Jul 1 16:25:28 CEST 2026
...
[ 2.274314] Starting KernelMemorySanitizer
[ 2.274356] ATTENTION: KMSAN is a debugging tool! Do not use it on
production machines!
[ 2.357699] Dynamic Preempt: lazy
[ 2.390793] rcu: Preemptible hierarchical RCU implementation.
[ 2.391032] rcu: RCU event tracing is enabled.
[ 2.391256] rcu: RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=4.
...
[ 53.009112] /dev/root: Can't open blockdev
[ 53.012357] VFS: Cannot open root device "" or unknown-block(0,0): error -6
[ 53.013186] Please append a correct "root=" boot option; here are
the available partitions:
...