[PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0

Miguel Ojeda posted 5 patches 9 months, 1 week ago
[PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Miguel Ojeda 9 months, 1 week ago
Starting with Rust 1.87.0 (expected 2025-05-15), `objtool` may report:

    rust/core.o: warning: objtool: _R..._4core9panicking9panic_fmt() falls
    through to next function _R..._4core9panicking18panic_nounwind_fmt()

    rust/core.o: warning: objtool: _R..._4core9panicking18panic_nounwind_fmt()
    falls through to next function _R..._4core9panicking5panic()

The reason is that `rust_begin_unwind` is now mangled:

    _R..._7___rustc17rust_begin_unwind

Thus add the mangled one to the list so that `objtool` knows it is
actually `noreturn`.

See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
for more details.

Alternatively, we could remove the fixed one in `noreturn.h` and relax
this test to cover both, but it seems best to be strict as long as we can.

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 tools/objtool/check.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 3a411064fa34..b21b12ec88d9 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -227,6 +227,7 @@ static bool is_rust_noreturn(const struct symbol *func)
 	       str_ends_with(func->name, "_4core9panicking19assert_failed_inner")			||
 	       str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference")		||
 	       str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference")	||
+	       str_ends_with(func->name, "_7___rustc17rust_begin_unwind")				||
 	       strstr(func->name, "_4core9panicking13assert_failed")					||
 	       strstr(func->name, "_4core9panicking11panic_const24panic_const_")			||
 	       (strstr(func->name, "_4core5slice5index24slice_") &&
--
2.49.0
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Joel Fernandes 8 months, 4 weeks ago
Hello Miguel,

On Fri, May 02, 2025 at 04:02:33PM +0200, Miguel Ojeda wrote:
> Starting with Rust 1.87.0 (expected 2025-05-15), `objtool` may report:
> 
>     rust/core.o: warning: objtool: _R..._4core9panicking9panic_fmt() falls
>     through to next function _R..._4core9panicking18panic_nounwind_fmt()
> 
>     rust/core.o: warning: objtool: _R..._4core9panicking18panic_nounwind_fmt()
>     falls through to next function _R..._4core9panicking5panic()

We are seeing a similar issue with the patch [1]:

  RUSTC [M] drivers/gpu/nova-core/nova_core.o
drivers/gpu/nova-core/nova_core.o: warning: objtool:
<nova_core::vbios::PciAtBiosImage as
core::convert::TryFrom<nova_core::vbios::BiosImageBase>>::try_from() falls
through to next function <nova_core::vbios::FwSecBiosImage>::fwsec_header()

The code in concern is implementing try_from():
+
+impl TryFrom<BiosImageBase> for PciAtBiosImage {
+    type Error = Error;
+
+    fn try_from(base: BiosImageBase) -> Result<Self> {

I dumped the codegen [2] for this function and at the end of the codegen, there
is a call instruction to to the fwsec_header() function.

Any thoughts on how to fix the warning?

thanks,

 - Joel

[1] https://lore.kernel.org/all/20250420-nova-frts-v1-13-ecd1cca23963@nvidia.com/
[2] https://paste.debian.net/1374516/


> The reason is that `rust_begin_unwind` is now mangled:
> 
>     _R..._7___rustc17rust_begin_unwind
> 
> Thus add the mangled one to the list so that `objtool` knows it is
> actually `noreturn`.
> 
> See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> for more details.
> 
> Alternatively, we could remove the fixed one in `noreturn.h` and relax
> this test to cover both, but it seems best to be strict as long as we can.
> 
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Cc: Josh Poimboeuf <jpoimboe@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
>  tools/objtool/check.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 3a411064fa34..b21b12ec88d9 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -227,6 +227,7 @@ static bool is_rust_noreturn(const struct symbol *func)
>  	       str_ends_with(func->name, "_4core9panicking19assert_failed_inner")			||
>  	       str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference")		||
>  	       str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference")	||
> +	       str_ends_with(func->name, "_7___rustc17rust_begin_unwind")				||
>  	       strstr(func->name, "_4core9panicking13assert_failed")					||
>  	       strstr(func->name, "_4core9panicking11panic_const24panic_const_")			||
>  	       (strstr(func->name, "_4core5slice5index24slice_") &&
> --
> 2.49.0
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Miguel Ojeda 8 months, 3 weeks ago
On Tue, May 13, 2025 at 8:08 PM Joel Fernandes <joelagnelf@nvidia.com> wrote:
>
> Any thoughts on how to fix the warning?

For future reference, this gets fixed with
https://lore.kernel.org/rust-for-linux/20250520185555.825242-1-ojeda@kernel.org/

I hope that helps (and apologies for the delay, a bunch of us were in
RustWeek :)

Cheers,
Miguel
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Joel Fernandes 8 months, 4 weeks ago
On Tue, May 13, 2025 at 02:07:57PM -0400, Joel Fernandes wrote:
> Hello Miguel,
> 
> On Fri, May 02, 2025 at 04:02:33PM +0200, Miguel Ojeda wrote:
> > Starting with Rust 1.87.0 (expected 2025-05-15), `objtool` may report:
> > 
> >     rust/core.o: warning: objtool: _R..._4core9panicking9panic_fmt() falls
> >     through to next function _R..._4core9panicking18panic_nounwind_fmt()
> > 
> >     rust/core.o: warning: objtool: _R..._4core9panicking18panic_nounwind_fmt()
> >     falls through to next function _R..._4core9panicking5panic()
> 
> We are seeing a similar issue with the patch [1]:
> 
>   RUSTC [M] drivers/gpu/nova-core/nova_core.o
> drivers/gpu/nova-core/nova_core.o: warning: objtool:
> <nova_core::vbios::PciAtBiosImage as
> core::convert::TryFrom<nova_core::vbios::BiosImageBase>>::try_from() falls
> through to next function <nova_core::vbios::FwSecBiosImage>::fwsec_header()
> 
> The code in concern is implementing try_from():
> +
> +impl TryFrom<BiosImageBase> for PciAtBiosImage {
> +    type Error = Error;
> +
> +    fn try_from(base: BiosImageBase) -> Result<Self> {
> 
> I dumped the codegen [2] for this function and at the end of the codegen, there
> is a call instruction to to the fwsec_header() function.
> 
> Any thoughts on how to fix the warning?

Btw, Danilo mentioned to me the latest Rust compiler (1.86?) does not give
this warning for that patch.

Mine is on 1.85. So if anyone else other than me is suffering from this
warning, do upgrade. :-)

thanks,

 - Joel
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by John Hubbard 8 months, 4 weeks ago
On 5/13/25 2:58 PM, Joel Fernandes wrote:
> On Tue, May 13, 2025 at 02:07:57PM -0400, Joel Fernandes wrote:
>> On Fri, May 02, 2025 at 04:02:33PM +0200, Miguel Ojeda wrote:
>>> Starting with Rust 1.87.0 (expected 2025-05-15), `objtool` may report:
...
> Btw, Danilo mentioned to me the latest Rust compiler (1.86?) does not give
> this warning for that patch.

I'm sorry to burst this happy bubble, but I just upgraded to rustc 1.86 and did
a clean build, and I *am* setting these warnings:

$ rustc --version
rustc 1.86.0 (05f9846f8 2025-03-31) (Arch Linux rust 1:1.86.0-1)

...
  RUSTC L rust/kernel.o
rust/kernel.o: warning: objtool: _RNvMNtCsbA27Kl4nY2_6kernel6deviceNtB2_6Device10get_device() falls through to next function _RNvXs4_NtCsbA27Kl4nY2_6kernel9auxiliaryNtB5_6DeviceNtNtB7_5types16AlwaysRefCounted7inc_ref()
rust/kernel.o: warning: objtool: _RNvMs2_NtNtCsbA27Kl4nY2_6kernel2fs4fileNtB5_9LocalFile4cred() falls through to next function _RNvXs8_NtNtCsbA27Kl4nY2_6kernel2fs4fileNtB5_10BadFdErrorNtNtCs8y00iZOEpTQ_4core3fmt5Debug3fmt()

...followed by 10 or 12 more of the same "falls through" type.


> 
> Mine is on 1.85. So if anyone else other than me is suffering from this
> warning, do upgrade. :-)
> 

Looks like that might not suffice!

thanks,
-- 
John Hubbard
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Timur Tabi 8 months, 4 weeks ago
On Tue, 2025-05-13 at 17:22 -0700, John Hubbard wrote:
> On 5/13/25 2:58 PM, Joel Fernandes wrote:
> > On Tue, May 13, 2025 at 02:07:57PM -0400, Joel Fernandes wrote:
> > > On Fri, May 02, 2025 at 04:02:33PM +0200, Miguel Ojeda wrote:
> > > > Starting with Rust 1.87.0 (expected 2025-05-15), `objtool` may report:
> ...
> > Btw, Danilo mentioned to me the latest Rust compiler (1.86?) does not give
> > this warning for that patch.
> 
> I'm sorry to burst this happy bubble, but I just upgraded to rustc 1.86 and did
> a clean build, and I *am* setting these warnings:

I see these warnings with .c code also:

  CHK     kernel/kheaders_data.tar.xz
drivers/media/pci/solo6x10/solo6x10-tw28.o: error: objtool: tw28_set_ctrl_val() falls through to
next function tw28_get_ctrl_val()
make[9]: *** [scripts/Makefile.build:203: drivers/media/pci/solo6x10/solo6x10-tw28.o] Error 1

I think it's an objtool bug and not a rustc bug.
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Joel Fernandes 8 months, 4 weeks ago

On 5/13/2025 8:43 PM, Timur Tabi wrote:
> On Tue, 2025-05-13 at 17:22 -0700, John Hubbard wrote:
>> On 5/13/25 2:58 PM, Joel Fernandes wrote:
>>> On Tue, May 13, 2025 at 02:07:57PM -0400, Joel Fernandes wrote:
>>>> On Fri, May 02, 2025 at 04:02:33PM +0200, Miguel Ojeda wrote:
>>>>> Starting with Rust 1.87.0 (expected 2025-05-15), `objtool` may report:
>> ...
>>> Btw, Danilo mentioned to me the latest Rust compiler (1.86?) does not give
>>> this warning for that patch.
>>
>> I'm sorry to burst this happy bubble, but I just upgraded to rustc 1.86 and did
>> a clean build, and I *am* setting these warnings:
> 
> I see these warnings with .c code also:
> 
>   CHK     kernel/kheaders_data.tar.xz
> drivers/media/pci/solo6x10/solo6x10-tw28.o: error: objtool: tw28_set_ctrl_val() falls through to
> next function tw28_get_ctrl_val()
> make[9]: *** [scripts/Makefile.build:203: drivers/media/pci/solo6x10/solo6x10-tw28.o] Error 1
> 
> I think it's an objtool bug and not a rustc bug.

Thanks John and Timur.
And sigh, fwiw I pulled the latest rust nightly build and I see the warning as well:

rustc --version
rustc 1.89.0-nightly (414482f6a 2025-05-13)

I am leaning more towards Timur's opinion that this is more than likely an
objtool issue.

 - Joel
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Josh Poimboeuf 8 months, 4 weeks ago
On Wed, May 14, 2025 at 10:52:17AM -0400, Joel Fernandes wrote:
> On 5/13/2025 8:43 PM, Timur Tabi wrote:
> > On Tue, 2025-05-13 at 17:22 -0700, John Hubbard wrote:
> >> On 5/13/25 2:58 PM, Joel Fernandes wrote:
> >>> On Tue, May 13, 2025 at 02:07:57PM -0400, Joel Fernandes wrote:
> >>>> On Fri, May 02, 2025 at 04:02:33PM +0200, Miguel Ojeda wrote:
> >>>>> Starting with Rust 1.87.0 (expected 2025-05-15), `objtool` may report:
> >> ...
> >>> Btw, Danilo mentioned to me the latest Rust compiler (1.86?) does not give
> >>> this warning for that patch.
> >>
> >> I'm sorry to burst this happy bubble, but I just upgraded to rustc 1.86 and did
> >> a clean build, and I *am* setting these warnings:
> > 
> > I see these warnings with .c code also:
> > 
> >   CHK     kernel/kheaders_data.tar.xz
> > drivers/media/pci/solo6x10/solo6x10-tw28.o: error: objtool: tw28_set_ctrl_val() falls through to
> > next function tw28_get_ctrl_val()
> > make[9]: *** [scripts/Makefile.build:203: drivers/media/pci/solo6x10/solo6x10-tw28.o] Error 1
> > 
> > I think it's an objtool bug and not a rustc bug.
> 
> Thanks John and Timur.
> And sigh, fwiw I pulled the latest rust nightly build and I see the warning as well:
> 
> rustc --version
> rustc 1.89.0-nightly (414482f6a 2025-05-13)
> 
> I am leaning more towards Timur's opinion that this is more than likely an
> objtool issue.

The above warning is in completely different code from the Rust one, so
they're likely unrelated.

The fallthrough warnings are typically caused by either Clang undefined
behavior (usually potential divide by zero or negative shift), or a call
to an unannotated noreturn function.

Timur, can you share your .config and compiler version?

-- 
Josh
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Timur Tabi 8 months, 4 weeks ago
On Wed, 2025-05-14 at 12:14 -0700, Josh Poimboeuf wrote:
> The above warning is in completely different code from the Rust one, so
> they're likely unrelated.

True, but the fall-through is bogus in the C code as well.

> The fallthrough warnings are typically caused by either Clang undefined
> behavior (usually potential divide by zero or negative shift), or a call
> to an unannotated noreturn function.
> 
> Timur, can you share your .config and compiler version?

.config: https://pastebin.com/inDHfmbG

ttabi@ttabi:~$ llvm-config --version
18.1.3
ttabi@ttabi:~$ gcc --version
gcc (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0

Since I build with LLVM=1, I'm assuming the answer is 18.1.3
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Josh Poimboeuf 8 months, 4 weeks ago
On Wed, May 14, 2025 at 07:46:49PM +0000, Timur Tabi wrote:
> On Wed, 2025-05-14 at 12:14 -0700, Josh Poimboeuf wrote:
> > The above warning is in completely different code from the Rust one, so
> > they're likely unrelated.
> 
> True, but the fall-through is bogus in the C code as well.
> 
> > The fallthrough warnings are typically caused by either Clang undefined
> > behavior (usually potential divide by zero or negative shift), or a call
> > to an unannotated noreturn function.
> > 
> > Timur, can you share your .config and compiler version?
> 
> .config: https://pastebin.com/inDHfmbG
> 
> ttabi@ttabi:~$ llvm-config --version
> 18.1.3
> ttabi@ttabi:~$ gcc --version
> gcc (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0
> 
> Since I build with LLVM=1, I'm assuming the answer is 18.1.3

I'm not able to recreate, can you run with OBJTOOL_VERBOSE=1 and paste
the output?

-- 
Josh
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Timur Tabi 8 months, 3 weeks ago
On Thu, 2025-05-15 at 09:18 -0700, Josh Poimboeuf wrote:
> > Since I build with LLVM=1, I'm assuming the answer is 18.1.3
> 
> I'm not able to recreate, can you run with OBJTOOL_VERBOSE=1 and paste
> the output?

You probably can't repro because it includes code that hasn't been merged upstream yet.  Try this:

https://github.com/ttabi/linux/commits/alex

  CHK     kernel/kheaders_data.tar.xz
drivers/gpu/nova-core/nova_core.o: warning: objtool:
_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFro
mNtB5_13BiosImageBaseE8try_from() falls through to next function
_RNvMsd_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14FwSecBiosImage12fwsec_header()
drivers/gpu/nova-core/nova_core.o: warning: objtool:  
_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFro
mNtB5_13BiosImageBaseE8try_from+0x5c: (branch)
drivers/gpu/nova-core/nova_core.o: warning: objtool:  
_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFro
mNtB5_13BiosImageBaseE8try_from+0x4a: (branch)
drivers/gpu/nova-core/nova_core.o: warning: objtool:  
_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFro
mNtB5_13BiosImageBaseE8try_from+0x0: <=== (sym)
./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --hacks=skylake --mcount --mnop --
retpoline --rethunk --sls --stackval --static-call --uaccess --prefix=16 --module drivers/gpu/nova-
core/nova_core.o.orig -o drivers/gpu/nova-core/nova_core.o
0000 0000000000006230
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from>:
0000     6230:	55                   	push   %rbp
0001     6231:	48 89 e5             	mov    %rsp,%rbp
0004     6234:	53                   	push   %rbx
0005     6235:	48 83 ec 18          	sub    $0x18,%rsp
0009     6239:	48 89 fb             	mov    %rdi,%rbx
000c     623c:	48 8b 3e             	mov    (%rsi),%rdi
000f     623f:	48 8b 4e 10          	mov    0x10(%rsi),%rcx
0013     6243:	c7 45 f2 ff b8 42 49 	movl   $0x4942b8ff,-0xe(%rbp)
001a     624a:	66 c7 45 f6 54 00    	movw   $0x54,-0xa(%rbp)
0020     6250:	48 83 f9 06          	cmp    $0x6,%rcx
0024     6254:	72 42                	jb     6298
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x68>
0026     6256:	48 8d 51 fb          	lea    -0x5(%rcx),%rdx
002a     625a:	31 c0                	xor    %eax,%eax
002c     625c:	0f 1f 40 00          	nopl   0x0(%rax)
0030     6260:	44 8b 04 07          	mov    (%rdi,%rax,1),%r8d
0034     6264:	44 33 45 f2          	xor    -0xe(%rbp),%r8d
0038     6268:	44 0f b7 4c 07 04    	movzwl 0x4(%rdi,%rax,1),%r9d
003e     626e:	66 44 33 4d f6       	xor    -0xa(%rbp),%r9w
0043     6273:	45 0f b7 c9          	movzwl %r9w,%r9d
0047     6277:	45 09 c1             	or     %r8d,%r9d
004a     627a:	74 0a                	je     6286
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x56>
004c     627c:	48 ff c0             	inc    %rax
004f     627f:	48 39 c2             	cmp    %rax,%rdx
0052     6282:	75 dc                	jne    6260
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x30>
0054     6284:	eb 12                	jmp    6298
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x68>
0056     6286:	48 89 ca             	mov    %rcx,%rdx
0059     6289:	48 29 c2             	sub    %rax,%rdx
005c     628c:	0f 82 ac 00 00 00    	jb     633e
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x10e>
0062     6292:	48 83 fa 0c          	cmp    $0xc,%rdx
0066     6296:	73 30                	jae    62c8
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x98>
0068     6298:	c7 43 08 ea ff ff ff 	movl   $0xffffffea,0x8(%rbx)
006f     629f:	48 c7 03 02 00 00 00 	movq   $0x2,(%rbx)
0076     62a6:	48 8b 46 08          	mov    0x8(%rsi),%rax
007a     62aa:	48 85 c0             	test   %rax,%rax
007d     62ad:	48 0f 44 f8          	cmove  %rax,%rdi
0081     62b1:	31 f6                	xor    %esi,%esi
0083     62b3:	31 d2                	xor    %edx,%edx
0085     62b5:	e8 00 00 00 00       	call   62ba
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x8a>	62b6: R_X86_64_PLT32	rust_helper_krealloc-0x4
008a     62ba:	48 89 d8             	mov    %rbx,%rax
008d     62bd:	48 83 c4 18          	add    $0x18,%rsp
0091     62c1:	5b                   	pop    %rbx
0092     62c2:	5d                   	pop    %rbp
0093     62c3:	e9 00 00 00 00       	jmp    62c8
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x98>	62c4: R_X86_64_PLT32	__x86_return_thunk-0x4
0098     62c8:	66 81 3c 07 ff b8    	cmpw   $0xb8ff,(%rdi,%rax,1)
009e     62ce:	75 c8                	jne    6298
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x68>
00a0     62d0:	81 7c 07 02 42 49 54 00 	cmpl   $0x544942,0x2(%rdi,%rax,1)
00a8     62d8:	75 be                	jne    6298
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x68>
00aa     62da:	0f b6 4c 07 0a       	movzbl 0xa(%rdi,%rax,1),%ecx
00af     62df:	8b 54 07 06          	mov    0x6(%rdi,%rax,1),%edx
00b3     62e3:	44 0f b6 44 07 0b    	movzbl 0xb(%rdi,%rax,1),%r8d
00b9     62e9:	c7 45 ec 42 49 54 00 	movl   $0x544942,-0x14(%rbp)
00c0     62f0:	66 c7 45 f0 ff b8    	movw   $0xb8ff,-0x10(%rbp)
00c6     62f6:	48 c1 e1 20          	shl    $0x20,%rcx
00ca     62fa:	49 c1 e0 28          	shl    $0x28,%r8
00ce     62fe:	49 09 c8             	or     %rcx,%r8
00d1     6301:	44 8b 4d ee          	mov    -0x12(%rbp),%r9d
00d5     6305:	48 c7 03 01 00 00 00 	movq   $0x1,(%rbx)
00dc     630c:	48 89 43 08          	mov    %rax,0x8(%rbx)
00e0     6310:	48 8d 7b 10          	lea    0x10(%rbx),%rdi
00e4     6314:	b9 0d 00 00 00       	mov    $0xd,%ecx
00e9     6319:	f3 48 a5             	rep movsq %ds:(%rsi),%es:(%rdi)
00ec     631c:	c7 43 78 01 00 42 49 	movl   $0x49420001,0x78(%rbx)
00f3     6323:	44 89 4b 7c          	mov    %r9d,0x7c(%rbx)
00f7     6327:	49 c1 e8 20          	shr    $0x20,%r8
00fb     632b:	66 44 89 83 84 00 00 00 	mov    %r8w,0x84(%rbx)
0103     6333:	89 93 80 00 00 00    	mov    %edx,0x80(%rbx)
0109     6339:	e9 7c ff ff ff       	jmp    62ba
<_RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFr
omNtB5_13BiosImageBaseE8try_from+0x8a>
010e     633e:	48 89 c7             	mov    %rax,%rdi
0111     6341:	48 89 ce             	mov    %rcx,%rsi
0114     6344:	48 c7 c2 00 00 00 00 	mov    $0x0,%rdx	6347:
R_X86_64_32S	.rodata+0x1058
011b     634b:	e8 00 00 00 00       	call   6350 <.Ltmp38>	634c:
R_X86_64_PLT32	_RNvNtNtCsgK88DPai1lC_4core5slice5index26slice_start_index_len_fail-0x4

Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Josh Poimboeuf 8 months, 3 weeks ago
On Thu, May 15, 2025 at 07:06:10PM +0000, Timur Tabi wrote:
> On Thu, 2025-05-15 at 09:18 -0700, Josh Poimboeuf wrote:
> > > Since I build with LLVM=1, I'm assuming the answer is 18.1.3
> > 
> > I'm not able to recreate, can you run with OBJTOOL_VERBOSE=1 and paste
> > the output?
> 
> You probably can't repro because it includes code that hasn't been merged upstream yet.  Try this:
> 
> https://github.com/ttabi/linux/commits/alex
> 
>   CHK     kernel/kheaders_data.tar.xz
> drivers/gpu/nova-core/nova_core.o: warning: objtool:
> _RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFro

I'm not yet qualified to look at the rust warning, I was actually
wondering about the C one you reported:

  drivers/media/pci/solo6x10/solo6x10-tw28.o: error: objtool: tw28_set_ctrl_val() falls through to next function tw28_get_ctrl_val()

-- 
Josh
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Timur Tabi 8 months, 3 weeks ago
On Thu, 2025-05-15 at 15:16 -0700, Josh Poimboeuf wrote:
> I'm not yet qualified to look at the rust warning, I was actually
> wondering about the C one you reported:
> 
>   drivers/media/pci/solo6x10/solo6x10-tw28.o: error: objtool: tw28_set_ctrl_val() falls through to
> next function tw28_get_ctrl_val()

https://pastebin.com/DYuifnTB
Re: [PATCH 1/5] objtool/rust: add one more `noreturn` Rust function for Rust 1.87.0
Posted by Kane York 8 months, 3 weeks ago
On Thu, 15 May 2025 19:06:10 +0000, Timur Tabi <ttabi@nvidia.com> wrote:
> On Thu, 2025-05-15 at 09:18 -0700, Josh Poimboeuf wrote:
> > > Since I build with LLVM=1, I'm assuming the answer is 18.1.3
> >
> > I'm not able to recreate, can you run with OBJTOOL_VERBOSE=1 and paste
> > the output?
>
> You probably can't repro because it includes code that hasn't been merged upstream yet.  Try this:
>
> https://github.com/ttabi/linux/commits/alex
>
>   CHK     kernel/kheaders_data.tar.xz
> drivers/gpu/nova-core/nova_core.o: warning: objtool:
> _RNvXsa_NtCs8S3917Wilyo_9nova_core5vbiosNtB5_14PciAtBiosImageINtNtCsgK88DPai1lC_4core7convert7TryFro
> mNtB5_13BiosImageBaseE8try_from() falls through to next function

...

> 011b     634b:	e8 00 00 00 00       	call   6350 <.Ltmp38>	634c:
> R_X86_64_PLT32
> _RNvNtNtCsgK88DPai1lC_4core5slice5index26slice_start_index_len_fail-0x4

Yup, that's an unrecognized noreturn function.

src/core/slice/index.rs:
> #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)]
> #[cfg_attr(feature = "panic_immediate_abort", inline)]
> #[track_caller]
> #[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
> const fn slice_start_index_len_fail(index: usize, len: usize) -> ! {
>     // SAFETY: we are just panicking here
>     unsafe {
>         const_eval_select(
>             (index, len),
>             slice_start_index_len_fail_ct,
>             slice_start_index_len_fail_rt,
>         )
>     }
> }
>
> // FIXME const-hack
> #[inline]
> #[track_caller]
> fn slice_start_index_len_fail_rt(index: usize, len: usize) -> ! {
>     panic!("range start index {index} out of range for slice of length {len}");
> }

The return is at offset 0093 (x62c3) with a jump to __x86_return_thunk.