Re: [PATCH] x86/mm: fix objtool failure with KMSAN enabled
From: Dmitry Voytik
Date: Fri Jul 03 2026 - 06:43:42 EST
Hi Thomas,
On Thu, Jul 2, 2026 at 10:05 PM Thomas Gleixner <tglx@xxxxxxxxxx> wrote:
>
> On Thu, Jul 02 2026 at 21:46, Thomas Gleixner wrote:
> > On Thu, Jul 02 2026 at 13:15, Peter Zijlstra wrote:
> >> A quick test with folio_zero_user() seems to suggest the
> >> ASM_CALL_CONSTRAINT movement (your patch) generates the same code for
> >> defconfg as does the unmodified code. The change from the thread linked
> >> above (input constraint on __builtin_frame_address(0)) generates
> >> different code.
> >>
> >> A third option is to force FRAME_POINTER=y for KMSAN builds -- for now,
> >> until clang is taught to be less insane.
> >
> > With FRAME_POINTER=y I get now with clang-22
> >
> > vmlinux.o: warning: objtool: folio_zero_user+0xa7b: stack state mismatch: reg1[4]=-1+0 reg2[4]=-2-336
> > vmlinux.o: warning: objtool: set_ftrace_ops_ro+0x64: relocation to !ENDBR: machine_kexec_prepare+0x8f0
> >
> > That's with your objtool patch applied. When I remove that then the
> > folio_zero_user one goes away. The relocation to !ENDBR stays.
> >
> > Oh well...
>
> And none of this boots when KMSAN=y ....
Thanks for checking this!
I wonder if we are debugging clang here because I just retested the patch with
CONFIG_FRAME_POINTER on the current Linus' tree and it works in my env:
clang --version
clang version 22.1.6
git pull -r
git show -s --oneline -2
21f3d2b2069e (HEAD -> master) x86/mm: fix objtool failure with KMSAN enabled
d2c9a99135da (origin/master, origin/HEAD) Merge tag 'device-id-rework'
of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux
make mrproper
make LLVM=1 defconfig
./scripts/config \
-e CONFIG_KMSAN \
-e CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT \
-e UNWINDER_FRAME_POINTER
make LLVM=1 olddefconfig
make LLVM=1 W=ce -j(nproc) bzImage
grep -e CONFIG_KMSAN= -e CONFIG_FRAME_POINTER \
-e CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT .config
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
CONFIG_FRAME_POINTER=y
CONFIG_KMSAN=y
qemu-system-x86_64 \
-kernel arch/x86/boot/bzImage \
-accel kvm \
-append "console=ttyS0" \
-nographic \
-m 8G -smp 4 \
-serial file:serial_out.log
grep -e 'Linux version' -A1 -e KernelMemorySanitizer -e 'append a
correct' serial_out.log
[ 0.000000] Linux version 7.2.0-rc1-00009-gb0b29f0286be
(voyt@voyt-laptop-dell) (clang version 22.1.6, LLD 22.1.6) #1 SMP
PREEMPT_DYNAMIC Fri Jul 3 11:55:02 CEST 2026
[ 0.000000] Command line: console=ttyS0
--
[ 0.218380] Starting KernelMemorySanitizer
[ 0.218382] ATTENTION: KMSAN is a debugging tool! Do not use it on
production machines!
--
[ 4.037384] Please append a correct "root=" boot option; here are
the available partitions:
[ 4.037772] 0b00 1048575 sr0
Could another CONFIG_ be the culprit on your side? Or, has your clang
version some different (buggy?) behaviour?