Rust for Linux List
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Gary Guo <gary@garyguo.net>,
	rust-for-linux@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
	Miguel Ojeda <ojeda@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nsc@kernel.org>,
	linux-kbuild@vger.kernel.org, Huacai Chen <chenhuacai@kernel.org>
Subject: [PATCH v2 11/27] LoongArch: Annotate reboot and kexec paths as returnable
Date: Tue,  8 Sep 2026 13:33:23 -0700	[thread overview]
Message-ID: <0d3a29d394bf1d2448294b9a68e4ace80a403c06.1788899473.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1788899473.git.jpoimboe@kernel.org>

Running objtool on LoongArch vmlinux.o shows the following warnings:

  vmlinux.o: warning: objtool: __do_sys_reboot+0x188: kernel_restart() is missing __noreturn in .c/.h
  vmlinux.o: warning: objtool: hw_failure_emergency_action_func+0x74: kernel_restart() is missing __noreturn in .c/.h
  vmlinux.o: warning: objtool: hibernate+0x3cc: kernel_halt() is missing __noreturn in .c/.h
  vmlinux.o: warning: objtool: kernel_kexec+0xbc: machine_kexec() is missing __noreturn in .c/.h
  vmlinux.o: warning: objtool: restart_poweroff_do_poweroff+0x1c: machine_restart() is missing __noreturn in .c/.h

The problem is that the generic declarations of the above functions are
not declared noreturn.

But marking them __noreturn wouldn't be straightforward given the
inconsistent behaviors they have across the arches:

  - In many cases they don't return, but the compiler doesn't have
    visibility to that for various reasons including inline asm and
    indirect calls to noreturn functions (which objtool is currently not
    equipped to deal with).

  - In some cases they even *do* return, e.g. x86 machine_exec(), arm64
    machine_power_off(), and hexagon machine_restart().

In lieu of undertaking such a large cleanup, fix the above warnings with
a few annotations so objtool doesn't consider them noreturn, consistent
with their call sites.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 arch/loongarch/kernel/machine_kexec.c | 2 ++
 arch/loongarch/kernel/reset.c         | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/arch/loongarch/kernel/machine_kexec.c b/arch/loongarch/kernel/machine_kexec.c
index 1883cae93bc31..e40b6767df24e 100644
--- a/arch/loongarch/kernel/machine_kexec.c
+++ b/arch/loongarch/kernel/machine_kexec.c
@@ -16,6 +16,7 @@
 #include <linux/reboot.h>
 #include <linux/sched.h>
 #include <linux/sched/task_stack.h>
+#include <linux/annotate.h>
 
 #include <asm/bootinfo.h>
 #include <asm/cacheflush.h>
@@ -296,3 +297,4 @@ void machine_kexec(struct kimage *image)
 
 	kexec_reboot();
 }
+ANNOTATE_IGNORE_NORETURN(machine_kexec);
diff --git a/arch/loongarch/kernel/reset.c b/arch/loongarch/kernel/reset.c
index de8fa5a8a825c..89ee0edcf58d2 100644
--- a/arch/loongarch/kernel/reset.c
+++ b/arch/loongarch/kernel/reset.c
@@ -11,6 +11,7 @@
 #include <linux/reboot.h>
 #include <linux/delay.h>
 #include <linux/console.h>
+#include <linux/annotate.h>
 
 #include <acpi/reboot.h>
 #include <asm/idle.h>
@@ -36,6 +37,7 @@ void machine_halt(void)
 		__asm__ __volatile__("idle 0" : : : "memory");
 	}
 }
+ANNOTATE_IGNORE_NORETURN(machine_halt);
 
 void machine_power_off(void)
 {
@@ -56,6 +58,7 @@ void machine_power_off(void)
 		__asm__ __volatile__("idle 0" : : : "memory");
 	}
 }
+ANNOTATE_IGNORE_NORETURN(machine_power_off);
 
 void machine_restart(char *command)
 {
@@ -77,3 +80,4 @@ void machine_restart(char *command)
 		__asm__ __volatile__("idle 0" : : : "memory");
 	}
 }
+ANNOTATE_IGNORE_NORETURN(machine_restart);
-- 
2.55.0


  parent reply	other threads:[~2026-09-08 20:34 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 20:33 [PATCH v2 00/27] objtool: dynamically detect noreturns Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 01/27] objtool: Remove obsolete noreturns.h entries Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 02/27] kbuild: Add CONFIG_OBJTOOL_DEFERRED Josh Poimboeuf
2026-09-10 19:22   ` Julian Braha
2026-09-08 20:33 ` [PATCH v2 03/27] kbuild: Add CONFIG_OBJTOOL_CONTROL_FLOW Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 04/27] objtool: Fix dead end detection for sibling calls Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 05/27] objtool: Refactor the noreturn/dead-end detection Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 06/27] objtool: Ignore traps after noreturn calls in STT_CODE Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 07/27] objtool: Make .discard.stack_frame_non_standard non-allocatable Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 08/27] efi/libstub: Drop .discard.addressable from the stub objects Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 09/27] efi/loongarch: Mark loongarch efi_boot_kernel() non-standard for objtool Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 10/27] objtool: Add ANNOTATE_IGNORE_NORETURN() Josh Poimboeuf
2026-09-08 20:33 ` Josh Poimboeuf [this message]
2026-09-08 20:33 ` [PATCH v2 12/27] kbuild: Defer running objtool to link time for all CFG features Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 13/27] rust: Annotate the intrinsic stubs as returnable Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 14/27] panic: Mark abort() __noreturn Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 15/27] x86/xen: Ignore noreturn status of weak mem_map_via_hcall() Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 16/27] objtool: Detect noreturns in weak functions Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 17/27] x86/entry: Make rewind_stack_and_make_dead() a real function Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 18/27] x86/xen: Make xen_cpu_bringup_again() " Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 19/27] x86/xen: Make xen_start_kernel() noreturn Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 20/27] x86/boot: Rework how pi startup symbols get exposed to vmlinux Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 21/27] objtool: Fix noreturn detection for non-sibling jumps to SYM_CODE Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 22/27] objtool: Add options to write/read exported noreturns to/from a file Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 23/27] kbuild: Do the per-module objtool pass right before linking Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 24/27] kbuild: Generate the noreturn list and validate modules against it Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 25/27] objtool: Add ANNOTATE_EXPORTED_NORETURN() Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 26/27] objtool: Annotate all module-exported noreturns and remove noreturns.h Josh Poimboeuf
2026-09-08 20:33 ` [PATCH v2 27/27] objtool: Warn about missing/stale ANNOTATE_EXPORTED_NORETURN() usage Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d3a29d394bf1d2448294b9a68e4ace80a403c06.1788899473.git.jpoimboe@kernel.org \
    --to=jpoimboe@kernel.org \
    --cc=ardb@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox