stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] objtool/rust: add one more `noreturn` Rust function
@ 2025-01-12 14:39 Miguel Ojeda
  2025-01-12 14:47 ` Miguel Ojeda
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Miguel Ojeda @ 2025-01-12 14:39 UTC (permalink / raw)
  To: Josh Poimboeuf, Peter Zijlstra, Miguel Ojeda, Alex Gaynor
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, rust-for-linux,
	linux-kernel, patches, stable

Starting with Rust 1.85.0 (currently in beta, to be released 2025-02-20),
under some kernel configurations with `CONFIG_RUST_DEBUG_ASSERTIONS=y`,
one may trigger a new `objtool` warning:

    rust/kernel.o: warning: objtool: _R...securityNtB2_11SecurityCtx8as_bytes()
    falls through to next function _R...core3ops4drop4Drop4drop()

due to a call to the `noreturn` symbol:

    core::panicking::assert_failed::<usize, usize>

Thus add it to the list so that `objtool` knows it is actually `noreturn`.
Do so matching with `strstr` since it is a generic.

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

Cc: <stable@vger.kernel.org> # Needed in 6.12.y only (Rust is pinned in older LTSs).
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 76060da755b5..e7ec29dfdff2 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -218,6 +218,7 @@ static bool is_rust_noreturn(const struct symbol *func)
 	       str_ends_with(func->name, "_4core9panicking18panic_bounds_check")			||
 	       str_ends_with(func->name, "_4core9panicking19assert_failed_inner")			||
 	       str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference")	||
+	       strstr(func->name, "_4core9panicking13assert_failed")					||
 	       strstr(func->name, "_4core9panicking11panic_const24panic_const_")			||
 	       (strstr(func->name, "_4core5slice5index24slice_") &&
 		str_ends_with(func->name, "_fail"));

base-commit: 9d89551994a430b50c4fffcb1e617a057fa76e20
-- 
2.48.0


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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-01-12 14:39 Miguel Ojeda
@ 2025-01-12 14:47 ` Miguel Ojeda
  2025-01-12 14:54   ` Greg KH
  2025-01-15 19:25 ` Gary Guo
  2025-02-12 22:28 ` Miguel Ojeda
  2 siblings, 1 reply; 16+ messages in thread
From: Miguel Ojeda @ 2025-01-12 14:47 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Josh Poimboeuf, Peter Zijlstra, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, rust-for-linux, linux-kernel, patches, stable

On Sun, Jan 12, 2025 at 3:40 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> for more details.
>
> Cc: <stable@vger.kernel.org> # Needed in 6.12.y only (Rust is pinned in older LTSs).

Greg/Sasha: I didn't add a Fixes since it is not really a "fix" for
that commit, but if you want it for automation please feel free to add
it:

    Fixes: 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")

> +              strstr(func->name, "_4core9panicking13assert_failed")                                    ||
>                strstr(func->name, "_4core9panicking11panic_const24panic_const_")                        ||

Nit: I should have probably put it after this one to keep it sorted.

objtool: happy to take this through the Rust tree or not, as you
prefer -- it is not urgent.

Thanks!

Cheers,
Miguel

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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-01-12 14:47 ` Miguel Ojeda
@ 2025-01-12 14:54   ` Greg KH
  0 siblings, 0 replies; 16+ messages in thread
From: Greg KH @ 2025-01-12 14:54 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, Josh Poimboeuf, Peter Zijlstra, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, rust-for-linux,
	linux-kernel, patches, stable

On Sun, Jan 12, 2025 at 03:47:03PM +0100, Miguel Ojeda wrote:
> On Sun, Jan 12, 2025 at 3:40 PM Miguel Ojeda <ojeda@kernel.org> wrote:
> >
> > See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> > for more details.
> >
> > Cc: <stable@vger.kernel.org> # Needed in 6.12.y only (Rust is pinned in older LTSs).
> 
> Greg/Sasha: I didn't add a Fixes since it is not really a "fix" for
> that commit, but if you want it for automation please feel free to add
> it:
> 
>     Fixes: 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")

Yeah, putting the Fixes: tag triggers our tools easier, but we can
manage either way :)

thanks,

greg k-h

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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-01-12 14:39 Miguel Ojeda
  2025-01-12 14:47 ` Miguel Ojeda
@ 2025-01-15 19:25 ` Gary Guo
  2025-02-12 22:28 ` Miguel Ojeda
  2 siblings, 0 replies; 16+ messages in thread
From: Gary Guo @ 2025-01-15 19:25 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Josh Poimboeuf, Peter Zijlstra, Alex Gaynor, Boqun Feng,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, rust-for-linux, linux-kernel, patches, stable

On Sun, 12 Jan 2025 15:39:51 +0100
Miguel Ojeda <ojeda@kernel.org> wrote:

> Starting with Rust 1.85.0 (currently in beta, to be released 2025-02-20),
> under some kernel configurations with `CONFIG_RUST_DEBUG_ASSERTIONS=y`,
> one may trigger a new `objtool` warning:
> 
>     rust/kernel.o: warning: objtool: _R...securityNtB2_11SecurityCtx8as_bytes()
>     falls through to next function _R...core3ops4drop4Drop4drop()
> 
> due to a call to the `noreturn` symbol:
> 
>     core::panicking::assert_failed::<usize, usize>
> 
> Thus add it to the list so that `objtool` knows it is actually `noreturn`.
> Do so matching with `strstr` since it is a generic.
> 
> See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> for more details.
> 
> Cc: <stable@vger.kernel.org> # Needed in 6.12.y only (Rust is pinned in older LTSs).
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Gary Guo <gary@garyguo.net>

> ---
>  tools/objtool/check.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 76060da755b5..e7ec29dfdff2 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -218,6 +218,7 @@ static bool is_rust_noreturn(const struct symbol *func)
>  	       str_ends_with(func->name, "_4core9panicking18panic_bounds_check")			||
>  	       str_ends_with(func->name, "_4core9panicking19assert_failed_inner")			||
>  	       str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference")	||
> +	       strstr(func->name, "_4core9panicking13assert_failed")					||
>  	       strstr(func->name, "_4core9panicking11panic_const24panic_const_")			||
>  	       (strstr(func->name, "_4core5slice5index24slice_") &&
>  		str_ends_with(func->name, "_fail"));
> 
> base-commit: 9d89551994a430b50c4fffcb1e617a057fa76e20


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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-01-12 14:39 Miguel Ojeda
  2025-01-12 14:47 ` Miguel Ojeda
  2025-01-15 19:25 ` Gary Guo
@ 2025-02-12 22:28 ` Miguel Ojeda
  2 siblings, 0 replies; 16+ messages in thread
From: Miguel Ojeda @ 2025-02-12 22:28 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Josh Poimboeuf, Peter Zijlstra, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, rust-for-linux, linux-kernel, patches, stable

On Sun, Jan 12, 2025 at 3:40 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Starting with Rust 1.85.0 (currently in beta, to be released 2025-02-20),
> under some kernel configurations with `CONFIG_RUST_DEBUG_ASSERTIONS=y`,
> one may trigger a new `objtool` warning:
>
>     rust/kernel.o: warning: objtool: _R...securityNtB2_11SecurityCtx8as_bytes()
>     falls through to next function _R...core3ops4drop4Drop4drop()
>
> due to a call to the `noreturn` symbol:
>
>     core::panicking::assert_failed::<usize, usize>
>
> Thus add it to the list so that `objtool` knows it is actually `noreturn`.
> Do so matching with `strstr` since it is a generic.
>
> See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> for more details.
>
> Cc: <stable@vger.kernel.org> # Needed in 6.12.y only (Rust is pinned in older LTSs).
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Applied to `rust-fixes` -- thanks everyone!

    [ Updated Cc: stable@ to include 6.13.y. - Miguel ]

Cheers,
Miguel

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

* [PATCH] objtool/rust: add one more `noreturn` Rust function
@ 2025-04-13  0:23 Miguel Ojeda
  2025-04-13 17:18 ` Sasha Levin
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Miguel Ojeda @ 2025-04-13  0:23 UTC (permalink / raw)
  To: Josh Poimboeuf, Peter Zijlstra, Miguel Ojeda, Alex Gaynor
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	rust-for-linux, linux-kernel, patches, stable

Starting with Rust 1.86.0 (see upstream commit b151b513ba2b ("Insert null
checks for pointer dereferences when debug assertions are enabled") [1]),
under some kernel configurations with `CONFIG_RUST_DEBUG_ASSERTIONS=y`,
one may trigger a new `objtool` warning:

    rust/kernel.o: warning: objtool: _R..._6kernel9workqueue6system()
    falls through to next function _R...9workqueue14system_highpri()

due to a call to the `noreturn` symbol:

    core::panicking::panic_null_pointer_dereference

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

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

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Fixes: 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
Link: https://github.com/rust-lang/rust/commit/b151b513ba2b65c7506ec1a80f2712bbd09154d1 [1]
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 4a1f6c3169b3..67006eeb30c8 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -225,6 +225,7 @@ static bool is_rust_noreturn(const struct symbol *func)
 	       str_ends_with(func->name, "_4core9panicking14panic_nounwind")				||
 	       str_ends_with(func->name, "_4core9panicking18panic_bounds_check")			||
 	       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")	||
 	       strstr(func->name, "_4core9panicking13assert_failed")					||
 	       strstr(func->name, "_4core9panicking11panic_const24panic_const_")			||

base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
-- 
2.49.0


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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-04-13  0:23 [PATCH] " Miguel Ojeda
@ 2025-04-13 17:18 ` Sasha Levin
  2025-04-13 17:22   ` Miguel Ojeda
  2025-04-14 14:07 ` Alice Ryhl
  2025-04-14 15:08 ` Miguel Ojeda
  2 siblings, 1 reply; 16+ messages in thread
From: Sasha Levin @ 2025-04-13 17:18 UTC (permalink / raw)
  To: stable, ojeda; +Cc: Sasha Levin

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it

Found matching upstream commit: cee6f9a9c87b6ecfb51845950c28216b231c3610

Note: The patch differs from the upstream commit:
---
1:  cee6f9a9c87b6 < -:  ------------- objtool/rust: add one more `noreturn` Rust function
-:  ------------- > 1:  a6ee72c789bbc objtool/rust: add one more `noreturn` Rust function
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.14.y       |  Success    |  Success   |
| stable/linux-6.13.y       |  Success    |  Success   |
| stable/linux-6.12.y       |  Success    |  Success   |
| stable/linux-6.6.y        |  Success    |  Success   |
| stable/linux-6.1.y        |  Success    |  Success   |
| stable/linux-5.15.y       |  Success    |  Success   |
| stable/linux-5.10.y       |  Success    |  Success   |
| stable/linux-5.4.y        |  Success    |  Success   |

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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-04-13 17:18 ` Sasha Levin
@ 2025-04-13 17:22   ` Miguel Ojeda
  0 siblings, 0 replies; 16+ messages in thread
From: Miguel Ojeda @ 2025-04-13 17:22 UTC (permalink / raw)
  To: Sasha Levin; +Cc: stable, ojeda

On Sun, Apr 13, 2025 at 7:18 PM Sasha Levin <sashal@kernel.org> wrote:
>
> 1:  cee6f9a9c87b6 < -:  ------------- objtool/rust: add one more `noreturn` Rust function
> -:  ------------- > 1:  a6ee72c789bbc objtool/rust: add one more `noreturn` Rust function

I guess this is due to the same title -- the patch is a new one.
Sorry, I guess I should have changed the title a bit. When I apply it
I can do so.

Cheers,
Miguel

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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-04-13  0:23 [PATCH] " Miguel Ojeda
  2025-04-13 17:18 ` Sasha Levin
@ 2025-04-14 14:07 ` Alice Ryhl
  2025-04-14 15:08 ` Miguel Ojeda
  2 siblings, 0 replies; 16+ messages in thread
From: Alice Ryhl @ 2025-04-14 14:07 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Josh Poimboeuf, Peter Zijlstra, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches, stable

On Sun, Apr 13, 2025 at 02:23:38AM +0200, Miguel Ojeda wrote:
> Starting with Rust 1.86.0 (see upstream commit b151b513ba2b ("Insert null
> checks for pointer dereferences when debug assertions are enabled") [1]),
> under some kernel configurations with `CONFIG_RUST_DEBUG_ASSERTIONS=y`,
> one may trigger a new `objtool` warning:
> 
>     rust/kernel.o: warning: objtool: _R..._6kernel9workqueue6system()
>     falls through to next function _R...9workqueue14system_highpri()
> 
> due to a call to the `noreturn` symbol:
> 
>     core::panicking::panic_null_pointer_dereference
> 
> Thus add it to the list so that `objtool` knows it is actually `noreturn`.
> 
> See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> for more details.
> 
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Fixes: 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> Link: https://github.com/rust-lang/rust/commit/b151b513ba2b65c7506ec1a80f2712bbd09154d1 [1]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-04-13  0:23 [PATCH] " Miguel Ojeda
  2025-04-13 17:18 ` Sasha Levin
  2025-04-14 14:07 ` Alice Ryhl
@ 2025-04-14 15:08 ` Miguel Ojeda
  2 siblings, 0 replies; 16+ messages in thread
From: Miguel Ojeda @ 2025-04-14 15:08 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Josh Poimboeuf, Peter Zijlstra, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches, stable

On Sun, Apr 13, 2025 at 2:26 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Thus add it to the list so that `objtool` knows it is actually `noreturn`.

Applied to `rust-fixes` -- thanks everyone! I applied it early to
start to get testing -- tags still welcomed for a day or so.

I changed the title a bit (adding "for Rust 1.86.0") to avoid
confusion with a previous patch (and future ones), since a bot already
got confused.

If `objtool` prefers to apply this instead, please let me know and I
will drop it!

Cheers,
Miguel

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

* [PATCH] objtool/rust: add one more `noreturn` Rust function
@ 2025-10-20  2:07 Miguel Ojeda
  2025-10-20  8:17 ` Alice Ryhl
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Miguel Ojeda @ 2025-10-20  2:07 UTC (permalink / raw)
  To: Josh Poimboeuf, Peter Zijlstra, Miguel Ojeda, Alex Gaynor
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	rust-for-linux, linux-kernel, patches, stable

Between Rust 1.79 and 1.86, under `CONFIG_RUST_KERNEL_DOCTESTS=y`,
`objtool` may report:

    rust/doctests_kernel_generated.o: warning: objtool:
    rust_doctest_kernel_alloc_kbox_rs_13() falls through to next
    function rust_doctest_kernel_alloc_kvec_rs_0()

(as well as in rust_doctest_kernel_alloc_kvec_rs_0) due to calls to the
`noreturn` symbol:

    core::option::expect_failed

from code added in commits 779db37373a3 ("rust: alloc: kvec: implement
AsPageIter for VVec") and 671618432f46 ("rust: alloc: kbox: implement
AsPageIter for VBox").

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

This can be reproduced as well in other versions by tweaking the code,
such as the latest stable Rust (1.90.0).

Stable does not have code that triggers this, but it could have it in
the future. Downstream forks could too. Thus tag it for backport.

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

Cc: stable@vger.kernel.org # Needed in 6.12.y and later.
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 a5770570b106..3c7ab910b189 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -217,6 +217,7 @@ static bool is_rust_noreturn(const struct symbol *func)
 	 * these come from the Rust standard library).
 	 */
 	return str_ends_with(func->name, "_4core5sliceSp15copy_from_slice17len_mismatch_fail")		||
+	       str_ends_with(func->name, "_4core6option13expect_failed")				||
 	       str_ends_with(func->name, "_4core6option13unwrap_failed")				||
 	       str_ends_with(func->name, "_4core6result13unwrap_failed")				||
 	       str_ends_with(func->name, "_4core9panicking5panic")					||

base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
-- 
2.51.0


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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-10-20  2:07 [PATCH] objtool/rust: add one more `noreturn` Rust function Miguel Ojeda
@ 2025-10-20  8:17 ` Alice Ryhl
  2025-10-20 10:51 ` Peter Zijlstra
  2025-10-22 13:28 ` [tip: objtool/urgent] " tip-bot2 for Miguel Ojeda
  2 siblings, 0 replies; 16+ messages in thread
From: Alice Ryhl @ 2025-10-20  8:17 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Josh Poimboeuf, Peter Zijlstra, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches, stable

On Mon, Oct 20, 2025 at 04:07:14AM +0200, Miguel Ojeda wrote:
> Between Rust 1.79 and 1.86, under `CONFIG_RUST_KERNEL_DOCTESTS=y`,
> `objtool` may report:
> 
>     rust/doctests_kernel_generated.o: warning: objtool:
>     rust_doctest_kernel_alloc_kbox_rs_13() falls through to next
>     function rust_doctest_kernel_alloc_kvec_rs_0()
> 
> (as well as in rust_doctest_kernel_alloc_kvec_rs_0) due to calls to the
> `noreturn` symbol:
> 
>     core::option::expect_failed
> 
> from code added in commits 779db37373a3 ("rust: alloc: kvec: implement
> AsPageIter for VVec") and 671618432f46 ("rust: alloc: kbox: implement
> AsPageIter for VBox").
> 
> Thus add the mangled one to the list so that `objtool` knows it is
> actually `noreturn`.
> 
> This can be reproduced as well in other versions by tweaking the code,
> such as the latest stable Rust (1.90.0).
> 
> Stable does not have code that triggers this, but it could have it in
> the future. Downstream forks could too. Thus tag it for backport.
> 
> See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> for more details.
> 
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later.
> Cc: Josh Poimboeuf <jpoimboe@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-10-20  2:07 [PATCH] objtool/rust: add one more `noreturn` Rust function Miguel Ojeda
  2025-10-20  8:17 ` Alice Ryhl
@ 2025-10-20 10:51 ` Peter Zijlstra
  2025-10-21 17:25   ` Miguel Ojeda
  2025-10-22 13:28 ` [tip: objtool/urgent] " tip-bot2 for Miguel Ojeda
  2 siblings, 1 reply; 16+ messages in thread
From: Peter Zijlstra @ 2025-10-20 10:51 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Josh Poimboeuf, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches, stable

On Mon, Oct 20, 2025 at 04:07:14AM +0200, Miguel Ojeda wrote:
> Between Rust 1.79 and 1.86, under `CONFIG_RUST_KERNEL_DOCTESTS=y`,
> `objtool` may report:
> 
>     rust/doctests_kernel_generated.o: warning: objtool:
>     rust_doctest_kernel_alloc_kbox_rs_13() falls through to next
>     function rust_doctest_kernel_alloc_kvec_rs_0()
> 
> (as well as in rust_doctest_kernel_alloc_kvec_rs_0) due to calls to the
> `noreturn` symbol:
> 
>     core::option::expect_failed
> 
> from code added in commits 779db37373a3 ("rust: alloc: kvec: implement
> AsPageIter for VVec") and 671618432f46 ("rust: alloc: kbox: implement
> AsPageIter for VBox").
> 
> Thus add the mangled one to the list so that `objtool` knows it is
> actually `noreturn`.
> 
> This can be reproduced as well in other versions by tweaking the code,
> such as the latest stable Rust (1.90.0).
> 
> Stable does not have code that triggers this, but it could have it in
> the future. Downstream forks could too. Thus tag it for backport.
> 
> See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
> for more details.
> 
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later.
> 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 a5770570b106..3c7ab910b189 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -217,6 +217,7 @@ static bool is_rust_noreturn(const struct symbol *func)
>  	 * these come from the Rust standard library).
>  	 */
>  	return str_ends_with(func->name, "_4core5sliceSp15copy_from_slice17len_mismatch_fail")		||
> +	       str_ends_with(func->name, "_4core6option13expect_failed")				||
>  	       str_ends_with(func->name, "_4core6option13unwrap_failed")				||
>  	       str_ends_with(func->name, "_4core6result13unwrap_failed")				||
>  	       str_ends_with(func->name, "_4core9panicking5panic")					||
> 

I'll go stick it in tip/objtool/core; but I gotta ask, where are we with
the toolchain support for noreturn?

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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-10-20 10:51 ` Peter Zijlstra
@ 2025-10-21 17:25   ` Miguel Ojeda
  2025-10-22  8:13     ` Peter Zijlstra
  0 siblings, 1 reply; 16+ messages in thread
From: Miguel Ojeda @ 2025-10-21 17:25 UTC (permalink / raw)
  To: Peter Zijlstra, Gary Guo
  Cc: Miguel Ojeda, Josh Poimboeuf, Alex Gaynor, Boqun Feng,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches, stable

On Tue, Oct 21, 2025 at 7:19 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> I'll go stick it in tip/objtool/core; but I gotta ask, where are we with
> the toolchain support for noreturn?

Thanks Peter!

We discussed it with upstream Rust, and they understood the need, so
we may get something like `--emit=noreturn` or similar, but it is
still open (and not too high in the priority list since we can survive
with this for now and we have other things that we really need them to
get stabilized etc. But if you feel it should be prioritized more,
please let me know).

I have the status under "Export (somehow) a list of all noreturn symbols." at:

    https://github.com/Rust-for-Linux/linux/issues/355

In particular, Gary proposed an alternative during those discussions:

    "Gary proposed reading DWARF instead and wrote a quick Rust script
for it via object and gimli, though DWARF would need to be available
or generated on the fly just for that (and we cannot commit a fixed
list since the kernel config may change and we support several Rust
versions and so on):
https://gist.github.com/nbdd0121/449692570622c2f46a29ad9f47c3379a."

Cheers,
Miguel

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

* Re: [PATCH] objtool/rust: add one more `noreturn` Rust function
  2025-10-21 17:25   ` Miguel Ojeda
@ 2025-10-22  8:13     ` Peter Zijlstra
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Zijlstra @ 2025-10-22  8:13 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Gary Guo, Miguel Ojeda, Josh Poimboeuf, Alex Gaynor, Boqun Feng,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches, stable

On Tue, Oct 21, 2025 at 07:25:11PM +0200, Miguel Ojeda wrote:
> On Tue, Oct 21, 2025 at 7:19 PM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > I'll go stick it in tip/objtool/core; but I gotta ask, where are we with
> > the toolchain support for noreturn?
> 
> Thanks Peter!
> 
> We discussed it with upstream Rust, and they understood the need, so
> we may get something like `--emit=noreturn` or similar, but it is
> still open (and not too high in the priority list since we can survive
> with this for now and we have other things that we really need them to
> get stabilized etc. But if you feel it should be prioritized more,
> please let me know).

Nah, as long as its not forgotten I suppose it'll show up at some point.

I would place including C headers in Rust at a *MUCH* higher priority
than this. This bindgen nonsense is a giant pain in the arse.

> I have the status under "Export (somehow) a list of all noreturn symbols." at:
> 
>     https://github.com/Rust-for-Linux/linux/issues/355
> 
> In particular, Gary proposed an alternative during those discussions:
> 
>     "Gary proposed reading DWARF instead and wrote a quick Rust script
> for it via object and gimli, though DWARF would need to be available
> or generated on the fly just for that (and we cannot commit a fixed
> list since the kernel config may change and we support several Rust
> versions and so on):
> https://gist.github.com/nbdd0121/449692570622c2f46a29ad9f47c3379a."

Right, the problem with DWARF is that you need to have DWARF and debug
builds are *SLOW* :/ But perhaps rust compile times are such that that
isn't noticable?

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

* [tip: objtool/urgent] objtool/rust: add one more `noreturn` Rust function
  2025-10-20  2:07 [PATCH] objtool/rust: add one more `noreturn` Rust function Miguel Ojeda
  2025-10-20  8:17 ` Alice Ryhl
  2025-10-20 10:51 ` Peter Zijlstra
@ 2025-10-22 13:28 ` tip-bot2 for Miguel Ojeda
  2 siblings, 0 replies; 16+ messages in thread
From: tip-bot2 for Miguel Ojeda @ 2025-10-22 13:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Miguel Ojeda, Peter Zijlstra (Intel), Alice Ryhl, stable, #,
	Needed, in, 6.12.y, and, "later.", x86, linux-kernel

The following commit has been merged into the objtool/urgent branch of tip:

Commit-ID:     dbdf2a7feb422f9bacfd12774e624cf26f503eb0
Gitweb:        https://git.kernel.org/tip/dbdf2a7feb422f9bacfd12774e624cf26f503eb0
Author:        Miguel Ojeda <ojeda@kernel.org>
AuthorDate:    Mon, 20 Oct 2025 04:07:14 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 22 Oct 2025 15:21:54 +02:00

objtool/rust: add one more `noreturn` Rust function

Between Rust 1.79 and 1.86, under `CONFIG_RUST_KERNEL_DOCTESTS=y`,
`objtool` may report:

    rust/doctests_kernel_generated.o: warning: objtool:
    rust_doctest_kernel_alloc_kbox_rs_13() falls through to next
    function rust_doctest_kernel_alloc_kvec_rs_0()

(as well as in rust_doctest_kernel_alloc_kvec_rs_0) due to calls to the
`noreturn` symbol:

    core::option::expect_failed

from code added in commits 779db37373a3 ("rust: alloc: kvec: implement
AsPageIter for VVec") and 671618432f46 ("rust: alloc: kbox: implement
AsPageIter for VBox").

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

This can be reproduced as well in other versions by tweaking the code,
such as the latest stable Rust (1.90.0).

Stable does not have code that triggers this, but it could have it in
the future. Downstream forks could too. Thus tag it for backport.

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

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Cc: stable@vger.kernel.org # Needed in 6.12.y and later.
Link: https://patch.msgid.link/20251020020714.2511718-1-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 a577057..3c7ab91 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -217,6 +217,7 @@ static bool is_rust_noreturn(const struct symbol *func)
 	 * these come from the Rust standard library).
 	 */
 	return str_ends_with(func->name, "_4core5sliceSp15copy_from_slice17len_mismatch_fail")		||
+	       str_ends_with(func->name, "_4core6option13expect_failed")				||
 	       str_ends_with(func->name, "_4core6option13unwrap_failed")				||
 	       str_ends_with(func->name, "_4core6result13unwrap_failed")				||
 	       str_ends_with(func->name, "_4core9panicking5panic")					||

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

end of thread, other threads:[~2025-10-22 13:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20  2:07 [PATCH] objtool/rust: add one more `noreturn` Rust function Miguel Ojeda
2025-10-20  8:17 ` Alice Ryhl
2025-10-20 10:51 ` Peter Zijlstra
2025-10-21 17:25   ` Miguel Ojeda
2025-10-22  8:13     ` Peter Zijlstra
2025-10-22 13:28 ` [tip: objtool/urgent] " tip-bot2 for Miguel Ojeda
  -- strict thread matches above, loose matches on Subject: below --
2025-04-13  0:23 [PATCH] " Miguel Ojeda
2025-04-13 17:18 ` Sasha Levin
2025-04-13 17:22   ` Miguel Ojeda
2025-04-14 14:07 ` Alice Ryhl
2025-04-14 15:08 ` Miguel Ojeda
2025-01-12 14:39 Miguel Ojeda
2025-01-12 14:47 ` Miguel Ojeda
2025-01-12 14:54   ` Greg KH
2025-01-15 19:25 ` Gary Guo
2025-02-12 22:28 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).