mirror of https://lore.kernel.org/lkml/
 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 v3 12/28] kbuild: Defer running objtool to link time for all CFG features
Date: Mon, 21 Sep 2026 15:31:13 -0700	[thread overview]
Message-ID: <989e3baa55cfb395d5dbcc4223816dbbd4dc45b1.1790028654.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1790028654.git.jpoimboe@kernel.org>

noreturns.h file is hand-maintained file which hard codes all the known
__noreturn functions in the kernel.  It's fragile, often missing
entries, and keeping it up to date is a maintenance burden.

For LTO, IBT, and klp-build configs, the majority of those entries
aren't needed, because objtool runs on vmlinux.o, so it already has
visibility into whether a given function returns (with its dead end
detection).

Remove the need for many of the noreturns.h entries by just always
deferring objtool for all features which rely on having the noreturn
information: namely the ones which rely on the reverse-engineered
control flow graph (CFG).

Note that NOINSTR_VALIDATION is a special case, where objtool runs on
individual TUs (with all the objtool-args-y), and then again on
vmlinux.o (without objtool-args-y except for --werror).

This change makes NOINSTR_VALIDATION just another OBJTOOL_DEFERRED
feature which runs deferred, and *not* on TUs, so now it gets all the
args like the others, and the special case for adding --werror on
!OBJTOOL_DEFERRED is no longer needed.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 lib/Kconfig.debug          |  3 ++-
 scripts/Makefile.vmlinux_o | 14 +++-----------
 tools/objtool/noreturns.h  | 24 ------------------------
 3 files changed, 5 insertions(+), 36 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 798a10ded19fd..e5aea1c0e54a2 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -575,7 +575,8 @@ config OBJTOOL_WERROR
 config OBJTOOL_DEFERRED
 	def_bool y
 	depends on OBJTOOL
-	depends on LTO_CLANG || X86_KERNEL_IBT || KLP_BUILD
+	depends on OBJTOOL_CONTROL_FLOW || NOINSTR_VALIDATION || LTO_CLANG || \
+		   X86_KERNEL_IBT || KLP_BUILD
 
 # Objtool reverse-engineers the control flow graph
 config OBJTOOL_CONTROL_FLOW
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index 9bac917e8b819..df1e3584883e6 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -30,20 +30,12 @@ endif
 # objtool for vmlinux.o
 # ---------------------------------------------------------------------------
 #
-# For CONFIG_OBJTOOL_DEFERRED (IBT or LTO), objtool doesn't run on individual
-# translation units.  Instead it runs on vmlinux.o.
-#
-# For !CONFIG_OBJTOOL_DEFERRED + CONFIG_NOINSTR_VALIDATION, it runs on both
-# translation units and vmlinux.o, with the latter only used for noinstr/unret
-# validation.
+# For CONFIG_OBJTOOL_DEFERRED, objtool doesn't run on individual translation
+# units.  Instead it runs on vmlinux.o.
 
-objtool-enabled := $(or $(CONFIG_OBJTOOL_DEFERRED),$(CONFIG_NOINSTR_VALIDATION))
+objtool-enabled := $(CONFIG_OBJTOOL_DEFERRED)
 
-ifeq ($(CONFIG_OBJTOOL_DEFERRED),y)
 vmlinux-objtool-args-y					+= $(objtool-args-y)
-else
-vmlinux-objtool-args-$(CONFIG_OBJTOOL_WERROR)		+= --werror
-endif
 
 vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION)	+= --noinstr \
 							   $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_SRSO)), --unret)
diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h
index 72ffa71aa19b8..cd41f580ccb72 100644
--- a/tools/objtool/noreturns.h
+++ b/tools/objtool/noreturns.h
@@ -7,45 +7,21 @@
  * Yes, this is unfortunate.  A better solution is in the works.
  */
 NORETURN(__fortify_panic)
-NORETURN(__ia32_sys_exit)
-NORETURN(__ia32_sys_exit_group)
 NORETURN(__kunit_abort)
 NORETURN(__module_put_and_kthread_exit)
 NORETURN(__stack_chk_fail)
-NORETURN(__tdx_hypercall_failed)
 NORETURN(__ubsan_handle_builtin_unreachable)
-NORETURN(__x64_sys_exit)
-NORETURN(__x64_sys_exit_group)
 NORETURN(acpi_processor_ffh_play_dead)
-NORETURN(arch_cpu_idle_dead)
-NORETURN(cpu_bringup_and_idle)
-NORETURN(cpu_startup_entry)
 NORETURN(do_exit)
-NORETURN(do_group_exit)
-NORETURN(do_task_dead)
-NORETURN(efi_rts_park_worker)
-NORETURN(ex_handler_msr_mce)
-NORETURN(hlt_play_dead)
-NORETURN(hv_ghcb_terminate)
 NORETURN(kthread_complete_and_exit)
 NORETURN(kunit_try_catch_throw)
-NORETURN(machine_real_restart)
-NORETURN(make_task_dead)
 NORETURN(mpt_halt_firmware)
-NORETURN(mwait_play_dead)
-NORETURN(native_play_dead)
 NORETURN(nmi_panic_self_stop)
 NORETURN(panic)
 NORETURN(vpanic)
 NORETURN(panic_smp_self_stop)
-NORETURN(rest_init)
 NORETURN(rewind_stack_and_make_dead)
 NORETURN(rust_helper_BUG)
 NORETURN(sev_es_terminate)
-NORETURN(start_kernel)
-NORETURN(stop_this_cpu)
-NORETURN(usercopy_abort)
-NORETURN(x86_64_start_kernel)
-NORETURN(x86_64_start_reservations)
 NORETURN(xen_cpu_bringup_again)
 NORETURN(xen_start_kernel)
-- 
2.55.0


  parent reply	other threads:[~2026-09-21 22:31 UTC|newest]

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

all inboxes | Powered by JetHome®