Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [tip:objtool/core 8/12] vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation
@ 2023-06-06 20:57 kernel test robot
  2023-06-06 21:52 ` Josh Poimboeuf
  0 siblings, 1 reply; 5+ messages in thread
From: kernel test robot @ 2023-06-06 20:57 UTC (permalink / raw)
  To: Josh Poimboeuf; +Cc: llvm, oe-kbuild-all, linux-kernel, x86, Miroslav Benes

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git objtool/core
head:   ff9a6459bbec06df7da2545020d7383aba13b3fb
commit: fedb724c3db5490234ddde0103811c28c2fedae0 [8/12] objtool: Detect missing __noreturn annotations
config: x86_64-randconfig-a012-20230606 (https://download.01.org/0day-ci/archive/20230607/202306070408.EFxuDoRs-lkp@intel.com/config)
compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
reproduce (this is a W=1 build):
        mkdir -p ~/bin
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=fedb724c3db5490234ddde0103811c28c2fedae0
        git remote add tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
        git fetch --no-tags tip objtool/core
        git checkout fedb724c3db5490234ddde0103811c28c2fedae0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306070408.EFxuDoRs-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation


objdump-func vmlinux.o rust_begin_unwind:
0000 00000000000b9e69 <rust_begin_unwind>:
0000    b9e69:	48 83 ec 48          	sub    $0x48,%rsp
0004    b9e6d:	48 89 e0             	mov    %rsp,%rax
0007    b9e70:	48 89 38             	mov    %rdi,(%rax)
000a    b9e73:	48 8d 4c 24 08       	lea    0x8(%rsp),%rcx
000f    b9e78:	48 89 01             	mov    %rax,(%rcx)
0012    b9e7b:	48 c7 41 08 00 00 00 00 	movq   $0x0,0x8(%rcx)	b9e7f: R_X86_64_32S	_RNvXsR_NtCs3yuwAp0waWO_4core3fmtRNtNtNtB7_5panic10panic_info9PanicInfoNtB5_7Display3fmtCsfATHBUcknU9_6kernel
001a    b9e83:	48 8d 54 24 18       	lea    0x18(%rsp),%rdx
001f    b9e88:	48 c7 02 00 00 00 00 	movq   $0x0,(%rdx)	b9e8b: R_X86_64_32S	.rodata+0x137d8
0026    b9e8f:	48 c7 42 08 02 00 00 00 	movq   $0x2,0x8(%rdx)
002e    b9e97:	48 c7 42 10 00 00 00 00 	movq   $0x0,0x10(%rdx)
0036    b9e9f:	48 89 4a 20          	mov    %rcx,0x20(%rdx)
003a    b9ea3:	48 c7 42 28 01 00 00 00 	movq   $0x1,0x28(%rdx)
0042    b9eab:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi	b9eae: R_X86_64_32S	_RNvNtNtCsfATHBUcknU9_6kernel5print14format_strings5EMERG
0049    b9eb2:	48 c7 c6 00 00 00 00 	mov    $0x0,%rsi	b9eb5: R_X86_64_32S	.rodata+0x13568
0050    b9eb9:	31 c0                	xor    %eax,%eax
0052    b9ebb:	e8 00 00 00 00       	call   b9ec0 <rust_begin_unwind+0x57>	b9ebc: R_X86_64_PLT32	_printk-0x4
0057    b9ec0:	e8 00 00 00 00       	call   b9ec5 <rust_begin_unwind+0x5c>	b9ec1: R_X86_64_PLT32	rust_helper_BUG-0x4
005c    b9ec5:	eb fe                	jmp    b9ec5 <rust_begin_unwind+0x5c>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [tip:objtool/core 8/12] vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation
  2023-06-06 20:57 [tip:objtool/core 8/12] vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation kernel test robot
@ 2023-06-06 21:52 ` Josh Poimboeuf
  2023-06-06 21:56   ` Alex Gaynor
  2023-06-06 22:22   ` Miguel Ojeda
  0 siblings, 2 replies; 5+ messages in thread
From: Josh Poimboeuf @ 2023-06-06 21:52 UTC (permalink / raw)
  To: Miguel Ojeda, Wedson Almeida Filho
  Cc: llvm, oe-kbuild-all, linux-kernel, x86, Miroslav Benes,
	kernel test robot, Peter Zijlstra, Alex Gaynor, rust-for-linux

Hi Miguel, Wedson,

Objtool detected that rust_helper_BUG() doesn't return, and seems to be
missing a __noreturn.  But it actually *does* have __noreturn.  The
problem is actually that its rust callees don't seem to know that, i.e.
they assume it returns.

After a little digging I found this comment in rust panic():

    unsafe { bindings::BUG() };
    // Bindgen currently does not recognize `__noreturn` so `BUG` returns `()`
    // instead of `!`. See <https://github.com/rust-lang/rust-bindgen/issues/2094>.
    loop {}

So it seems to be an issue with bindgen, though that github issue has
been resolved.  Any idea when this will show up in a toolchain?

In the meantime we may have to get objtool to manually silence the
warning, unless you have any better ideas.

On Wed, Jun 07, 2023 at 04:57:42AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git objtool/core
> head:   ff9a6459bbec06df7da2545020d7383aba13b3fb
> commit: fedb724c3db5490234ddde0103811c28c2fedae0 [8/12] objtool: Detect missing __noreturn annotations
> config: x86_64-randconfig-a012-20230606 (https://download.01.org/0day-ci/archive/20230607/202306070408.EFxuDoRs-lkp@intel.com/config)
> compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
> reproduce (this is a W=1 build):
>         mkdir -p ~/bin
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=fedb724c3db5490234ddde0103811c28c2fedae0
>         git remote add tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
>         git fetch --no-tags tip objtool/core
>         git checkout fedb724c3db5490234ddde0103811c28c2fedae0
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202306070408.EFxuDoRs-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
> >> vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation
> 
> 
> objdump-func vmlinux.o rust_begin_unwind:
> 0000 00000000000b9e69 <rust_begin_unwind>:
> 0000    b9e69:	48 83 ec 48          	sub    $0x48,%rsp
> 0004    b9e6d:	48 89 e0             	mov    %rsp,%rax
> 0007    b9e70:	48 89 38             	mov    %rdi,(%rax)
> 000a    b9e73:	48 8d 4c 24 08       	lea    0x8(%rsp),%rcx
> 000f    b9e78:	48 89 01             	mov    %rax,(%rcx)
> 0012    b9e7b:	48 c7 41 08 00 00 00 00 	movq   $0x0,0x8(%rcx)	b9e7f: R_X86_64_32S	_RNvXsR_NtCs3yuwAp0waWO_4core3fmtRNtNtNtB7_5panic10panic_info9PanicInfoNtB5_7Display3fmtCsfATHBUcknU9_6kernel
> 001a    b9e83:	48 8d 54 24 18       	lea    0x18(%rsp),%rdx
> 001f    b9e88:	48 c7 02 00 00 00 00 	movq   $0x0,(%rdx)	b9e8b: R_X86_64_32S	.rodata+0x137d8
> 0026    b9e8f:	48 c7 42 08 02 00 00 00 	movq   $0x2,0x8(%rdx)
> 002e    b9e97:	48 c7 42 10 00 00 00 00 	movq   $0x0,0x10(%rdx)
> 0036    b9e9f:	48 89 4a 20          	mov    %rcx,0x20(%rdx)
> 003a    b9ea3:	48 c7 42 28 01 00 00 00 	movq   $0x1,0x28(%rdx)
> 0042    b9eab:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi	b9eae: R_X86_64_32S	_RNvNtNtCsfATHBUcknU9_6kernel5print14format_strings5EMERG
> 0049    b9eb2:	48 c7 c6 00 00 00 00 	mov    $0x0,%rsi	b9eb5: R_X86_64_32S	.rodata+0x13568
> 0050    b9eb9:	31 c0                	xor    %eax,%eax
> 0052    b9ebb:	e8 00 00 00 00       	call   b9ec0 <rust_begin_unwind+0x57>	b9ebc: R_X86_64_PLT32	_printk-0x4
> 0057    b9ec0:	e8 00 00 00 00       	call   b9ec5 <rust_begin_unwind+0x5c>	b9ec1: R_X86_64_PLT32	rust_helper_BUG-0x4
> 005c    b9ec5:	eb fe                	jmp    b9ec5 <rust_begin_unwind+0x5c>
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

-- 
Josh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [tip:objtool/core 8/12] vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation
  2023-06-06 21:52 ` Josh Poimboeuf
@ 2023-06-06 21:56   ` Alex Gaynor
  2023-06-06 22:22   ` Miguel Ojeda
  1 sibling, 0 replies; 5+ messages in thread
From: Alex Gaynor @ 2023-06-06 21:56 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: Miguel Ojeda, Wedson Almeida Filho, llvm, oe-kbuild-all,
	linux-kernel, x86, Miroslav Benes, kernel test robot,
	Peter Zijlstra, rust-for-linux

The fix to properly handle noreturn is present in bindgen > 0.61.0.
Per min-tool-version.sh, we currently only require bindgen 0.56.0 or
newer.

I'm not sure if there are obstacles to requiring a newer bindgen
version, at which point the loop {} would not be required.

Cheers,
Alex

On Tue, Jun 6, 2023 at 5:52 PM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
>
> Hi Miguel, Wedson,
>
> Objtool detected that rust_helper_BUG() doesn't return, and seems to be
> missing a __noreturn.  But it actually *does* have __noreturn.  The
> problem is actually that its rust callees don't seem to know that, i.e.
> they assume it returns.
>
> After a little digging I found this comment in rust panic():
>
>     unsafe { bindings::BUG() };
>     // Bindgen currently does not recognize `__noreturn` so `BUG` returns `()`
>     // instead of `!`. See <https://github.com/rust-lang/rust-bindgen/issues/2094>.
>     loop {}
>
> So it seems to be an issue with bindgen, though that github issue has
> been resolved.  Any idea when this will show up in a toolchain?
>
> In the meantime we may have to get objtool to manually silence the
> warning, unless you have any better ideas.
>
> On Wed, Jun 07, 2023 at 04:57:42AM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git objtool/core
> > head:   ff9a6459bbec06df7da2545020d7383aba13b3fb
> > commit: fedb724c3db5490234ddde0103811c28c2fedae0 [8/12] objtool: Detect missing __noreturn annotations
> > config: x86_64-randconfig-a012-20230606 (https://download.01.org/0day-ci/archive/20230607/202306070408.EFxuDoRs-lkp@intel.com/config)
> > compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
> > reproduce (this is a W=1 build):
> >         mkdir -p ~/bin
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=fedb724c3db5490234ddde0103811c28c2fedae0
> >         git remote add tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
> >         git fetch --no-tags tip objtool/core
> >         git checkout fedb724c3db5490234ddde0103811c28c2fedae0
> >         # save the config file
> >         mkdir build_dir && cp config build_dir/.config
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> >
> > If you fix the issue, kindly add following tag where applicable
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202306070408.EFxuDoRs-lkp@intel.com/
> >
> > All warnings (new ones prefixed by >>):
> >
> > >> vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation
> >
> >
> > objdump-func vmlinux.o rust_begin_unwind:
> > 0000 00000000000b9e69 <rust_begin_unwind>:
> > 0000    b9e69:        48 83 ec 48             sub    $0x48,%rsp
> > 0004    b9e6d:        48 89 e0                mov    %rsp,%rax
> > 0007    b9e70:        48 89 38                mov    %rdi,(%rax)
> > 000a    b9e73:        48 8d 4c 24 08          lea    0x8(%rsp),%rcx
> > 000f    b9e78:        48 89 01                mov    %rax,(%rcx)
> > 0012    b9e7b:        48 c7 41 08 00 00 00 00         movq   $0x0,0x8(%rcx)   b9e7f: R_X86_64_32S     _RNvXsR_NtCs3yuwAp0waWO_4core3fmtRNtNtNtB7_5panic10panic_info9PanicInfoNtB5_7Display3fmtCsfATHBUcknU9_6kernel
> > 001a    b9e83:        48 8d 54 24 18          lea    0x18(%rsp),%rdx
> > 001f    b9e88:        48 c7 02 00 00 00 00    movq   $0x0,(%rdx)      b9e8b: R_X86_64_32S     .rodata+0x137d8
> > 0026    b9e8f:        48 c7 42 08 02 00 00 00         movq   $0x2,0x8(%rdx)
> > 002e    b9e97:        48 c7 42 10 00 00 00 00         movq   $0x0,0x10(%rdx)
> > 0036    b9e9f:        48 89 4a 20             mov    %rcx,0x20(%rdx)
> > 003a    b9ea3:        48 c7 42 28 01 00 00 00         movq   $0x1,0x28(%rdx)
> > 0042    b9eab:        48 c7 c7 00 00 00 00    mov    $0x0,%rdi        b9eae: R_X86_64_32S     _RNvNtNtCsfATHBUcknU9_6kernel5print14format_strings5EMERG
> > 0049    b9eb2:        48 c7 c6 00 00 00 00    mov    $0x0,%rsi        b9eb5: R_X86_64_32S     .rodata+0x13568
> > 0050    b9eb9:        31 c0                   xor    %eax,%eax
> > 0052    b9ebb:        e8 00 00 00 00          call   b9ec0 <rust_begin_unwind+0x57>   b9ebc: R_X86_64_PLT32   _printk-0x4
> > 0057    b9ec0:        e8 00 00 00 00          call   b9ec5 <rust_begin_unwind+0x5c>   b9ec1: R_X86_64_PLT32   rust_helper_BUG-0x4
> > 005c    b9ec5:        eb fe                   jmp    b9ec5 <rust_begin_unwind+0x5c>
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wiki
>
> --
> Josh



-- 
All that is necessary for evil to succeed is for good people to do nothing.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [tip:objtool/core 8/12] vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation
  2023-06-06 21:52 ` Josh Poimboeuf
  2023-06-06 21:56   ` Alex Gaynor
@ 2023-06-06 22:22   ` Miguel Ojeda
  2023-06-06 22:29     ` Josh Poimboeuf
  1 sibling, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2023-06-06 22:22 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: Miguel Ojeda, Wedson Almeida Filho, llvm, oe-kbuild-all,
	linux-kernel, x86, Miroslav Benes, kernel test robot,
	Peter Zijlstra, Alex Gaynor, rust-for-linux

On Tue, Jun 6, 2023 at 11:52 PM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
>
> So it seems to be an issue with bindgen, though that github issue has
> been resolved.  Any idea when this will show up in a toolchain?
>
> In the meantime we may have to get objtool to manually silence the
> warning, unless you have any better ideas.

We were going to update `bindgen`, so we can just do that -- one more
reason to do so! :)

If the update goes into the upcoming merge window, would that be fine
with you? Or do you need it for this current cycle?

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [tip:objtool/core 8/12] vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation
  2023-06-06 22:22   ` Miguel Ojeda
@ 2023-06-06 22:29     ` Josh Poimboeuf
  0 siblings, 0 replies; 5+ messages in thread
From: Josh Poimboeuf @ 2023-06-06 22:29 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, Wedson Almeida Filho, llvm, oe-kbuild-all,
	linux-kernel, x86, Miroslav Benes, kernel test robot,
	Peter Zijlstra, Alex Gaynor, rust-for-linux

On Wed, Jun 07, 2023 at 12:22:45AM +0200, Miguel Ojeda wrote:
> On Tue, Jun 6, 2023 at 11:52 PM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
> >
> > So it seems to be an issue with bindgen, though that github issue has
> > been resolved.  Any idea when this will show up in a toolchain?
> >
> > In the meantime we may have to get objtool to manually silence the
> > warning, unless you have any better ideas.
> 
> We were going to update `bindgen`, so we can just do that -- one more
> reason to do so! :)
> 
> If the update goes into the upcoming merge window, would that be fine
> with you? Or do you need it for this current cycle?

The next merge window would be good.  Eventually I want to get objtool
to zero warnings so we can do -Werror, but we're not there yet :-)

Thanks!

-- 
Josh

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-06 22:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-06 20:57 [tip:objtool/core 8/12] vmlinux.o: warning: objtool: rust_begin_unwind+0x5c: rust_helper_BUG() is missing a __noreturn annotation kernel test robot
2023-06-06 21:52 ` Josh Poimboeuf
2023-06-06 21:56   ` Alex Gaynor
2023-06-06 22:22   ` Miguel Ojeda
2023-06-06 22:29     ` Josh Poimboeuf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox