From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 929303A7F78; Fri, 28 Aug 2026 04:51:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892720; cv=none; b=f2BdjvQFtTNCsQUMfzxmeeBHTWSbRe2C8bCg9dh4Ms/6I3o4sEHFiOVbMbFo4iJQuqJBp/jHDs9TQqssB1HWZHmv305JOXq6+Xlfpyx/GOsnxGXF1H9C2o7XalghwymCrz5u7jNvGiixwuhRM5e+WMNSEReabT9aDXZtAAhb3SA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892720; c=relaxed/simple; bh=I490kfot+nYjm1ZsJTCBXUOebN7mdyLtiKCx5v2ySP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GwyaaJ0lHYQlehN1qOe4fVhoqzvrtPi795s4hZNKc5Owqxz0rafgPS3mnsVtde0QZsTZ2gzPmFENvonXLE6SU18FXXbXcT2XPznIY7TPgrrfrzDR+lNL97Yq709vpG8jFcqmt2iyoTBp9tXHzeK+lIf4yo50gUdntpoZtD9ZgN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OFYoS5E7; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OFYoS5E7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 125C21F00ADB; Fri, 28 Aug 2026 04:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892719; bh=ZOSyF4oqdNPgQOrMJKe0tteJI7Nmop2u6Eo0cUbsbpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OFYoS5E7HMFmet3G27+lKQ9vwwdIIuFZAudWLniRRagjMsW8H0H9dDZNcanl6NgYL G2S36c5+hbjcPB11TA/O9pbp1RSAjFJV6J4xmB4rLDxmHALgAc4a0wLdRlWIR4WGRs +AU5QiqzaAepCSlBE1cTASeA/azkFwl82/DD/ggYGIHztrUJX0/Tx6mszHpzvM8764 hnqtlfUjwM245kx//29jyp2o/cljujWpFleLz3vH2J2ZDLm0fYmRRn4TU1ewamxRBH uhxf8F8lh7VhHOnbC4Hdfi8q7C6rwxIHS4RMeUxZkq82hI7gr1K7tKTrhMbA3GgwWo LkZ9/pzqzaspg== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 01/27] objtool: Remove obsolete noreturns.h entries Date: Thu, 27 Aug 2026 21:51:30 -0700 Message-ID: <074584dd38a6d610f64b401a2376dde773a6f6bf.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove some obsolete noreturns.h entries: bcachefs is no longer in-tree, kthread_exit() is a macro, and rust_begin_unwind() is only called by its mangled name. Signed-off-by: Josh Poimboeuf --- tools/objtool/noreturns.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index 14f8ab653449c..08d441b8895cb 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -18,9 +18,6 @@ NORETURN(__x64_sys_exit) NORETURN(__x64_sys_exit_group) NORETURN(acpi_processor_ffh_play_dead) NORETURN(arch_cpu_idle_dead) -NORETURN(bch2_trans_in_restart_error) -NORETURN(bch2_trans_restart_error) -NORETURN(bch2_trans_unlocked_or_in_restart_error) NORETURN(cpu_bringup_and_idle) NORETURN(cpu_startup_entry) NORETURN(do_exit) @@ -30,7 +27,6 @@ NORETURN(ex_handler_msr_mce) NORETURN(hlt_play_dead) NORETURN(hv_ghcb_terminate) NORETURN(kthread_complete_and_exit) -NORETURN(kthread_exit) NORETURN(kunit_try_catch_throw) NORETURN(machine_real_restart) NORETURN(make_task_dead) @@ -43,7 +39,6 @@ NORETURN(vpanic) NORETURN(panic_smp_self_stop) NORETURN(rest_init) NORETURN(rewind_stack_and_make_dead) -NORETURN(rust_begin_unwind) NORETURN(rust_helper_BUG) NORETURN(sev_es_terminate) NORETURN(start_kernel) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AEDA387378; Fri, 28 Aug 2026 04:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892721; cv=none; b=SQttW9+XO3U6hSf42BTHMKGc2OepuXxfwVS4UAVkG8rgyowmWh3EwE/65x37OZkcanvSjWc/VpJZwEt8QLSZwCEQEb5zRsmnqOV5txbz063JvafjMqQ3BPDTw4KAfgOLt7vZVSV5lEdDIivIjXfPw8/CFBC/fnvUpWfAppzjbS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892721; c=relaxed/simple; bh=O17sPWEBzUDpZ3eFIdHZvdyeXtMGdpbhRQ3FrAb7PUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bn/MFByyJq+UPoLGnh0H1Feke7WHYIzAd56UeBGdJf+JLlewiwdNZZxvaKGBWgxrICR8ImGiK1BPcnhRYfJgaTQi6jUBQhTP0rt+P17kyseYcdAtFfx7vp+GC+UyGjuDLr8HLW4Xyaj3BNVDDGRelFrlTJ6qizgM5+2hmse7+vI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FBd+T0co; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FBd+T0co" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E6EF1F00A3A; Fri, 28 Aug 2026 04:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892720; bh=cCzCbUnHZwUow4j2tnWYFPvTYWDRft0EQI0YfGcfzIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FBd+T0coABTJMG5I1mGk0ZyRMFIUcSbIj6FtxF9Y/VbRE5MqsRuVK1Kkes/1lHm4X tDN82upp28YUeyfQdqjR56FHZj5r7eibSKXSdv4AfMrl8FmOkILAniT94ojZEQGvBR VXSLwmIh8WfUxj1a50wJE55try0JHj9sgFQa/sa55Clrhv25Ug9S8PZIYr2l1sP9Td wI34Nj2fXfyvSjhMFL/QGNVyUDfNJM2fxsD9cK3fmy4qMVp1Ujk3ViNh6BC+m2L+In ruznyjRPH7YFeK3fv25A/ENWx9JfiEspvySMbut3bfU1RCu5LmP6ZJHXxQhDFG0SKm qhtGZkEmK5grA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 02/27] kbuild: Add CONFIG_OBJTOOL_DEFERRED Date: Thu, 27 Aug 2026 21:51:31 -0700 Message-ID: <6b9243d1a7ecfa1bf4fc9163724cbc6b3928be30.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For LTO, IBT, and KLP builds, the running of objtool is deferred to vmlinux.o rather than individual translation units. In preparation for deferring it in more cases, add a new config option. No functional change. Signed-off-by: Josh Poimboeuf --- arch/x86/boot/startup/Makefile | 2 +- lib/Kconfig.debug | 7 +++++++ scripts/Makefile.build | 4 ++-- scripts/Makefile.lib | 4 +--- scripts/Makefile.vmlinux_o | 13 +++++++------ scripts/link-vmlinux.sh | 3 +-- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/arch/x86/boot/startup/Makefile b/arch/x86/boot/startup/Makefile index 5e499cfb29b5c..ab6e9970d4f4e 100644 --- a/arch/x86/boot/startup/Makefile +++ b/arch/x86/boot/startup/Makefile @@ -36,7 +36,7 @@ $(patsubst %.o,$(obj)/%.o,$(lib-y)): OBJECT_FILES_NON_STA= NDARD :=3D y # relocations, even if other objtool actions are being deferred. # $(pi-objs): objtool-enabled =3D 1 -$(pi-objs): objtool-args =3D $(if $(delay-objtool),--dry-run,$(objtool-arg= s-y)) --noabs +$(pi-objs): objtool-args =3D $(if $(CONFIG_OBJTOOL_DEFERRED),--dry-run,$(o= bjtool-args-y)) --noabs =20 # # Confine the startup code by prefixing all symbols with __pi_ (for positi= on diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 1244dcac2294a..9ca9b2519d604 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -588,6 +588,13 @@ config NOINSTR_VALIDATION select OBJTOOL default y =20 +# For when objtool defers its work to the linked image (vmlinux.o or modul= e.o) +# rather than running on individual translation units. +config OBJTOOL_DEFERRED + def_bool y + depends on OBJTOOL + depends on LTO_CLANG || X86_KERNEL_IBT || KLP_BUILD + config VMLINUX_MAP bool "Generate vmlinux.map file when linking" depends on EXPERT diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 9117457432463..84ef12f784330 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -277,7 +277,7 @@ endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT is-standard-object =3D $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$= (target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),$(is-kernel-object)) =20 ifdef CONFIG_OBJTOOL -$(obj)/%.o: private objtool-enabled =3D $(if $(is-standard-object),$(if $(= delay-objtool),$(is-single-obj-m),y)) +$(obj)/%.o: private objtool-enabled =3D $(if $(is-standard-object),$(if $(= CONFIG_OBJTOOL_DEFERRED),$(is-single-obj-m),y)) endif =20 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) @@ -502,7 +502,7 @@ define rule_ld_multi_m $(call cmd,gen_objtooldep) endef =20 -$(multi-obj-m): private objtool-enabled :=3D $(delay-objtool) +$(multi-obj-m): private objtool-enabled :=3D $(CONFIG_OBJTOOL_DEFERRED) $(multi-obj-m): private part-of-module :=3D y $(multi-obj-m): %.o: %.mod FORCE $(call if_changed_rule,ld_multi_m) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0a4fdd8bd975d..3622237e41d2e 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -210,11 +210,9 @@ objtool-args-$(or $(CONFIG_GCOV_KERNEL),$(CONFIG_KCOV)= ) +=3D --no-unreachable objtool-args-$(CONFIG_OBJTOOL_WERROR) +=3D --werror =20 objtool-args =3D $(objtool-args-y) \ - $(if $(delay-objtool), --link) \ + $(if $(CONFIG_OBJTOOL_DEFERRED), --link) \ $(if $(part-of-module), --module) =20 -delay-objtool :=3D $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT),$(CON= FIG_KLP_BUILD)) - cmd_objtool =3D $(if $(objtool-enabled), ; $(objtool) $(objtool-args) $@) cmd_gen_objtooldep =3D $(if $(objtool-enabled), { echo ; echo '$@: $$(wild= card $(objtool))' ; } >> $(dot-target).cmd) =20 diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 24a3a4fd271c2..9bac917e8b819 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -30,15 +30,16 @@ endif # objtool for vmlinux.o # ------------------------------------------------------------------------= --- # -# For delay-objtool (IBT or LTO), objtool doesn't run on individual transl= ation -# units. Instead it runs on vmlinux.o. +# For CONFIG_OBJTOOL_DEFERRED (IBT or LTO), objtool doesn't run on individ= ual +# translation units. Instead it runs on vmlinux.o. # -# For !delay-objtool + CONFIG_NOINSTR_VALIDATION, it runs on both translat= ion -# units and vmlinux.o, with the latter only used for noinstr/unret validat= ion. +# For !CONFIG_OBJTOOL_DEFERRED + CONFIG_NOINSTR_VALIDATION, it runs on both +# translation units and vmlinux.o, with the latter only used for noinstr/u= nret +# validation. =20 -objtool-enabled :=3D $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) +objtool-enabled :=3D $(or $(CONFIG_OBJTOOL_DEFERRED),$(CONFIG_NOINSTR_VALI= DATION)) =20 -ifeq ($(delay-objtool),y) +ifeq ($(CONFIG_OBJTOOL_DEFERRED),y) vmlinux-objtool-args-y +=3D $(objtool-args-y) else vmlinux-objtool-args-$(CONFIG_OBJTOOL_WERROR) +=3D --werror diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index f99e196abeea4..aa10867a04de2 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -60,8 +60,7 @@ vmlinux_link() # skip output file argument shift =20 - if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT || - is_enabled CONFIG_KLP_BUILD; then + if is_enabled CONFIG_OBJTOOL_DEFERRED || is_enabled CONFIG_LTO_CLANG; then # Use vmlinux.o instead of performing the slow LTO link again. objs=3Dvmlinux.o libs=3D --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E95D93BE146; Fri, 28 Aug 2026 04:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892722; cv=none; b=tYhxTxBYqs38Whj5t7tdG2CFz4CFDWHq2oPEdLyG0WUXBp2vWcqeCITmYj3U7oKymPeTlU2uYHa9bzdVXNhCFuSUZosHtt7EBu0sPsVtYV5TX6KXzSUmVjxScORnrA8oJ81hwCWke+ZJTtsFi8sPu5ZVD01J1hjgTP1bIwk6Yfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892722; c=relaxed/simple; bh=kMaAzVzqldZi3L+NBU5zmzD1vKq84nBQFgu+Kg0BAok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dQdb1eL7iC8QXY7TgrZfkl9MNq7kOusFC3mYvgkLI12IeNOHL0TaboRPv5UEOt/J87shdE5o+xHD73dL1sc6HozYe4UAyuaVQITSgKpFx39xj+4V/mpJTHsHjPNwkz45qavFt4HE9A4xzTpKZHy2v8GCJx0fCalf7AFi9ob4Arg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OYfI/Ntm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OYfI/Ntm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DFE21F00A3D; Fri, 28 Aug 2026 04:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892720; bh=ZotmoIRC9zGDTZDpYLopDHQLH75rqAHtU3SWvffOJ24=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OYfI/NtmCwpsvB8npeWu/vkAaEhBtGTQbFOph5ZecWWwgkfmthbJ1OB5/0BwCdsK/ bbhg60DUZIIYFpS9W5px3UGL3sPUErFdQvnkrfRZupUEZZ5Z3voCQ2GLQTBFJWgO6v fmDjewtMxgOm3etQSHAm63EtXmHW6DOHv+R11WX8mA3H7XrmnPLTfViMglKRN34coE 2xYaldd0IHh6NY8yr5KqyxMQJYXHM6GB7x8He062WDGx/9gcweeSa1fStRQMe+M27p LLmUq9jdQlTG16zI7Zl3SG2/3SK23lLW0EONOn1kQo4tclZLSA985QHh6LH/r9ZX8L 83C9bcnJnvepw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 03/27] kbuild: Add CONFIG_OBJTOOL_CONTROL_FLOW Date: Thu, 27 Aug 2026 21:51:32 -0700 Message-ID: <3582f93053165d01099c576f756c31df8e8bf50d.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a config option for when objtool reverse engineers the control flow graph of every function. No functional change. Signed-off-by: Josh Poimboeuf --- lib/Kconfig.debug | 10 ++++++++-- lib/Kconfig.ubsan | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 9ca9b2519d604..0ea5ad31969ce 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -588,8 +588,14 @@ config NOINSTR_VALIDATION select OBJTOOL default y =20 -# For when objtool defers its work to the linked image (vmlinux.o or modul= e.o) -# rather than running on individual translation units. +# Objtool reverse-engineers the control flow graph +config OBJTOOL_CONTROL_FLOW + def_bool y + depends on OBJTOOL + depends on UNWINDER_ORC || STACK_VALIDATION || HAVE_UACCESS_VALIDATION + +# Objtool defers its work to the linked image (vmlinux.o or module.o) rath= er +# than running on individual translation units. config OBJTOOL_DEFERRED def_bool y depends on OBJTOOL diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan index 1ecaae7064d2a..61e8c86ef63be 100644 --- a/lib/Kconfig.ubsan +++ b/lib/Kconfig.ubsan @@ -110,7 +110,7 @@ config UBSAN_UNREACHABLE bool "Perform checking for unreachable code" # objtool already handles unreachable checking and gets angry about # seeing UBSan instrumentation located in unreachable places. - depends on !(OBJTOOL && (STACK_VALIDATION || UNWINDER_ORC || HAVE_UACCESS= _VALIDATION)) + depends on !OBJTOOL_CONTROL_FLOW depends on $(cc-option,-fsanitize=3Dunreachable) help This option enables -fsanitize=3Dunreachable which checks for control --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1DEF3C10BD; Fri, 28 Aug 2026 04:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892723; cv=none; b=rpFCsDcXbH3lHbcbK7nm6ayZ9vhntVwleyPDmnEgVZRoaMcZF1a8uNbpND+jntCBp7sc9K1QcL8L/kM1LeFz14t2Qtyr/UIpw0ZW7YFTAtmsAxm3okqIaAPOyJ07WZmHn+IVhCx4J3JD3t9f28emCOyyxfN66wd6GIuKsHMmG58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892723; c=relaxed/simple; bh=Hb0BZMB8mtLFbivp9I1uUtXixTBgS2gRoT00j1tUVh4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t5SU9Hz2mOv8RoEx918eusvMpOO6+1uLO+PDeHJu1ubUbQOlEl4ts5sLWUXCdFVpRUU0BCjWIaWsiHPkL9dh06wobj3WwtqXHIU3bRlng/ok0wk0bOi+KVvl4y9XobSB6Xgxyty3YY3Em0mIniAQESCjaYGd0L7ZD+pn38CQvxc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gXzwa+ma; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gXzwa+ma" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E31E61F000E9; Fri, 28 Aug 2026 04:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892721; bh=p4f8E/RMYR3yUrIve9wZDIuFSVWmc2kSXdiGNK4DR98=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gXzwa+maNCyOufEaIDKWTH+TBbheIFZqCfrjy5cs1B90PMRqB2cfGjeYl+mPyV2wg IYOoar5sBen04Z7xbLLLZbcWf6weFozq+kLNOKYak//DlGW+VGUALUKJoHvqFDzBQ5 KKi/uESBw4Adg17pBquC40Jvqbx0N7cFaYirDdRfdzgQDKW8zGV/S/xIWDbTAIAzlV Ew6LI5ROc4Sc2IeVMeuzvrEzdQF7zz4Y+XRP+DmKmi91qxIOoeHw1BHHiIMh5CeuPs zkyuzT5EvwoujhDlw1xW4pZqo2rrfITeg6VbWth/njcps0DdvmF6hLLtHbcZvoUcAm Pp05rhKLVC6LQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 04/27] objtool: Fix dead end detection for sibling calls Date: Thu, 27 Aug 2026 21:51:33 -0700 Message-ID: <82b063dbeff61b78a4c42643ce5d4ebf8936c291.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The dead end detection for sibling calls has apparently always been broken. There are two issues: it checks jump_dest instead of call_dest, and it only checks the first sibling call instead of all of them. Fix both issues. No warnings were seen, this was only found by code inspection. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index a98d7589d8a48..01c50aa00b6dc 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -272,30 +272,31 @@ static bool __dead_end_function(struct objtool_file *= file, struct symbol *func, return false; =20 /* - * A function can have a sibling call instead of a return. In that - * case, the function's dead-end status depends on whether the target - * of the sibling call returns. + * A function can have sibling calls instead of a return. It's only a + * dead end if *all* the sibling call targets are dead ends. */ func_for_each_insn(file, func, insn) { - if (is_sibling_call(insn)) { - struct instruction *dest =3D insn->jump_dest; + struct symbol *dest; =20 - if (!dest) - /* sibling call to another file */ - return false; + if (!is_sibling_call(insn)) + continue; =20 - /* local sibling call */ - if (recursion =3D=3D 5) { - /* - * Infinite recursion: two functions have - * sibling calls to each other. This is a very - * rare case. It means they aren't dead ends. - */ - return false; - } + dest =3D insn_call_dest(insn); + if (!dest) + /* call to another file */ + return false; =20 - return __dead_end_function(file, insn_func(dest), recursion+1); + if (recursion =3D=3D 5) { + /* + * Infinite recursion: two functions have sibling + * calls to each other. This is a very rare case. + * It means they aren't dead ends. + */ + return false; } + + if (!__dead_end_function(file, dest, recursion+1)) + return false; } =20 return true; --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51CC83C1D5E; Fri, 28 Aug 2026 04:52:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892724; cv=none; b=kSVKVRCNbbQ76OaLmCDnEYcBLcFY1zS55xtfzWJT/VkPVa8+GI4oo+3mLdSnOfSZ5R+dDxt0qXJNzrEVQkQh/oarrrBbmvy5y3dt3WuGkF39Z3PVNoPmlRFYuYpcRxu3Z0EAumzgDrK06C2pLrSNwtD0r6w5mmg6Rvd94WzW44I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892724; c=relaxed/simple; bh=SRYkfuCdSjK/TzXB2UoAtKU62WRN9lryn9O3rRF9OjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lzMrEZ9SBmwrBNU0vOUcYj2ia7t6KEJ+3Gsz+SQRMnWak+agz1dTA1Oto5lQGAZi6xg3uIZ7lxumsSzxbd2x569boPdOqi20S3mXVwgvnEDFw5L3QASbzb937G1AuUfOJtvhI0ktXtQJWSUcq7j2XPE3iLojDdxGXxGz+fu/rfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oxTUvXzL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oxTUvXzL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BB901F00A3F; Fri, 28 Aug 2026 04:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892722; bh=3/+3Of4ViqwVZp+A+D9rtCrRLTKb7mL4NxSc6nOEAlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oxTUvXzLgoo1zFD1mO0wHby8Y4PncPkHsJsdtjRaOfIawWkjKuxHV97NsJgFH0tvy kzUniGOehQ5+IoHZ/xQz/oGMX7TZGxyLj490X0wARElfpjbKosJz26DQZK2QNLPlhk 5oDJJOzcbv9zNIUtzCZZgrJS3v4ZM/uZ3SWYH97dr/59+Kpxr0wNJ+ZwK6grYGIaeX AkUOBvZ/bvgjMX5K+I2d7rOBKE6oAnP9mU098uhXtb4hOswulsmj7wfybFvlkwK74X WKeWe6aIKX3y4/Ym/RgU+4DSzNwkwZUNyDeYJ1B1cmZ2WurHBpOQykIrxNB01ktVPt RWxKbUj7yyMxA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 05/27] objtool: Refactor the noreturn/dead-end detection Date: Thu, 27 Aug 2026 21:51:34 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The dead end detection (basically "is this a call to a noreturn?") is currently derived on demand, at each call site. Also, the answer isn't saved anywhere, so it's redetermined each time. It also has an ugly recursion check. Clean that up by just detecting all the noreturns at the beginning. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 159 ++++++++++++++++------------ tools/objtool/include/objtool/elf.h | 1 + 2 files changed, 93 insertions(+), 67 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 01c50aa00b6dc..4528f017277d2 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -217,94 +217,112 @@ static bool is_rust_noreturn(const struct symbol *fu= nc) str_ends_with(func->name, "_fail")); } =20 -/* - * This checks to see if the given function is a "noreturn" function. - * - * For global functions which are outside the scope of this object file, we - * have to keep a manual list of them. - * - * For local functions, we have to detect them manually by simply looking = for - * the lack of a return instruction. - */ -static bool __dead_end_function(struct objtool_file *file, struct symbol *= func, - int recursion) +static bool is_listed_noreturn(struct symbol *func) { - int i; - struct instruction *insn; - bool empty =3D true; - #define NORETURN(func) __stringify(func), static const char * const global_noreturns[] =3D { #include "noreturns.h" }; #undef NORETURN =20 - if (!func) + if (is_local_sym(func)) return false; =20 - if (!is_local_sym(func)) { - if (is_rust_noreturn(func)) + if (is_rust_noreturn(func)) + return true; + + for (int i =3D 0; i < ARRAY_SIZE(global_noreturns); i++) + if (!strcmp(func->name, global_noreturns[i])) return true; =20 - for (i =3D 0; i < ARRAY_SIZE(global_noreturns); i++) - if (!strcmp(func->name, global_noreturns[i])) - return true; - } + return false; +} + +/* + * Use this rather than reading sym->_noreturn directly: the noreturn stat= us + * lives on the primary alias, and ANNOTATE_IGNORE_NORETURN() overrides it. + */ +static bool is_noreturn(struct symbol *func) +{ + func =3D func->alias->pfunc; + + if (is_listed_noreturn(func)) + return true; + + return func->_noreturn; +} + +static bool might_return(struct objtool_file *file, struct symbol *func) +{ + struct instruction *insn; + struct symbol *dest; =20 if (is_weak_sym(func)) - return false; - - if (!func->len) - return false; - - insn =3D find_insn(file, func->sec, func->offset); - if (!insn || !insn_func(insn)) - return false; + return true; =20 func_for_each_insn(file, func, insn) { - empty =3D false; - if (insn->type =3D=3D INSN_RETURN) - return false; - } - - if (empty) - return false; - - /* - * A function can have sibling calls instead of a return. It's only a - * dead end if *all* the sibling call targets are dead ends. - */ - func_for_each_insn(file, func, insn) { - struct symbol *dest; + return true; =20 if (!is_sibling_call(insn)) continue; =20 dest =3D insn_call_dest(insn); - if (!dest) - /* call to another file */ - return false; - - if (recursion =3D=3D 5) { - /* - * Infinite recursion: two functions have sibling - * calls to each other. This is a very rare case. - * It means they aren't dead ends. - */ - return false; - } - - if (!__dead_end_function(file, dest, recursion+1)) - return false; + if (!dest || !is_noreturn(dest)) + return true; } =20 - return true; + return false; } =20 -static bool dead_end_function(struct objtool_file *file, struct symbol *fu= nc) +static void detect_noreturns(struct objtool_file *file) { - return __dead_end_function(file, func, 0); + struct symbol *func, *dest; + struct instruction *insn; + bool changed; + + /* Mark all functions guilty until proven innocent */ + for_each_sym(file->elf, func) { + + /* Aliases and cold subfunctions inherit the parent's verdict */ + if (!is_func_sym(func) || is_undef_sym(func) || + is_prefix_func(func) || func->embedded_insn || + func !=3D func->alias->pfunc) + continue; + + insn =3D find_insn(file, func->sec, func->offset); + if (!insn || insn_func(insn) !=3D func) + continue; + + func->_noreturn =3D 1; + } + + /* + * A function's noreturn status depends on those of its sibling call + * destinations, which may not be settled yet. Keep clearing the + * noreturn bit for known cases until it stops spreading. + */ + do { + changed =3D false; + + for_each_sym(file->elf, func) { + if (!func->_noreturn || !might_return(file, func)) + continue; + + func->_noreturn =3D 0; + changed =3D true; + } + } while (changed); + + /* Now mark the dead end call sites */ + for_each_insn(file, insn) { + if (insn->type !=3D INSN_CALL) + continue; + + dest =3D insn_call_dest(insn); + if (dest && is_noreturn(dest)) + insn->dead_end =3D true; + } } =20 static void init_cfi_state(struct cfi_state *cfi) @@ -1420,9 +1438,6 @@ static int annotate_call_site(struct objtool_file *fi= le, !insn->_call_dest->embedded_insn) list_add_tail(&insn->call_node, &file->call_list); =20 - if (!sibling && dead_end_function(file, sym)) - insn->dead_end =3D true; - return 0; } =20 @@ -2667,6 +2682,17 @@ int decode_file(struct objtool_file *file) if (add_jump_table_alts(file)) return -1; =20 + /* + * Must be after add_jump_table_alts(), which affects sibling call + * detection (jump table branches vs indirect sibling calls). + * + * The dead end marks are read by validate_branch() -- reached from + * both validate_functions() and validate_noinstr_sections() -- and by + * validate_unret(). + */ + if (validate_branch_enabled() || opts.noinstr || opts.unret) + detect_noreturns(file); + if (read_unwind_hints(file)) return -1; =20 @@ -2674,8 +2700,7 @@ int decode_file(struct objtool_file *file) mark_holes(file); =20 /* - * Must be after add_call_destinations() such that it can override - * dead_end_function() marks. + * Must be after detect_noreturns() so it can override dead_end marks. */ if (read_annotate(file, __annotate_late)) return -1; diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index a82517a76a0f6..46fb2230ca743 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -98,6 +98,7 @@ struct symbol { u8 klp : 1; u8 dont_correlate : 1; u8 fake : 1; + u8 _noreturn : 1; struct list_head pv_target; struct reloc *relocs; struct section *group_sec; --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B21233C2782; Fri, 28 Aug 2026 04:52:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892724; cv=none; b=I4EswDviOy046nnzDIEn5tcs7e/TW7Lz0ErhcSyuQbEUhki2a2cReGz9Dc1YRpi9QSzLB1PYzM54ZRxbWJtcN8lXjDG9dfbeHsCfB6SMK1NHqmoXkOBvYj3UO1AlZyKB90VNnnkNhesJL5hnxhAJeH0/ZPhTvwrFqmVRFj4BZBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892724; c=relaxed/simple; bh=XG8cF63XQa8Xc1aYG1ZtRZX7xY6+LPMKaT6xREKqCh4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sxMtnnpJhFo2xfjEa05LuE7tG7mAYumUpT2+aAQivJaV7j3VQRccYl2MBdRu7EZy/kTxhNnUDrloSwUTVCUizYjDZtpmhTM0vHzGRcqHh0vHNINL/GUtiTYjx1SphdJuKeZuYYof/MT9XfxqTxxht9hz196huCMRABuD1hIs9mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MC5UxQvL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MC5UxQvL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BF561F00A3A; Fri, 28 Aug 2026 04:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892722; bh=oL0/32zIjEk68kWbn5G+FVF7tD9ZwNBrosw3NxneCPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MC5UxQvLUg5803mFZzeEugqrloYBoLSLOeEp+WDphqkSOWLAGXEGE6bJvRBokRd/N 7osqy6qSysnScmt5K45G56JeFYW2Rq5BxROY1LH3UtMA3q4LwXL/fosWD25zJAJ2u1 FYw2o7ObDyjPt2Ogi++DqyA8OjlOexeS6OhhGml2Arz6fHHtSC9yMHIJb4HJj7nCEh czKZWf6DJBLZou4N/j0w25VzS+vV1k4nUmDU1A/xJLMYw0tOz8IzL6Xs7Rsgh93ILV BU6B/PcDmZ+S989QfvCN2s86to8MtzpmGsdcRVUt5sK/q26uEyyen0WmusdnUm503X bdSavd2rrwBbQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 06/27] objtool: Ignore traps after noreturn calls in STT_CODE Date: Thu, 27 Aug 2026 21:51:35 -0700 Message-ID: <44e198b8eb0f377b5e2c61cf6bb753d735201bd7.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Objtool doesn't do unreachable warnings for traps after noreturn calls, but only in functions. Loongarch assembly STT_CODE can have the same pattern: bl start_kernel ASM_BUG() Ignore those as well. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 4528f017277d2..7333b0ed86818 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4269,12 +4269,6 @@ static bool ignore_unreachable_insn(struct objtool_f= ile *file, struct instructio !strcmp(insn->sec->name, ".altinstr_aux")) return true; =20 - if (!func) - return false; - - if (func->static_call_tramp) - return true; - /* * CONFIG_UBSAN_TRAP inserts a UD2 when it sees * __builtin_unreachable(). The BUG() macro has an unreachable() after @@ -4290,6 +4284,12 @@ static bool ignore_unreachable_insn(struct objtool_f= ile *file, struct instructio insn->jump_dest && insn->jump_dest->type =3D=3D INSN_BUG))) return true; =20 + if (!func) + return false; + + if (func->static_call_tramp) + return true; + /* * Check if this (or a subsequent) instruction is related to * CONFIG_UBSAN or CONFIG_KASAN. --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53E2A3C3C17; Fri, 28 Aug 2026 04:52:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892724; cv=none; b=l4QBxbhQikVL1j9SGIY6eali2tRZx5usNyYoKgwGLCDrJ4ra+2aFZ9jDyVveh8nvlOHvc7OSZvnPf3zWDkvQEOQbzLr6iQIBFbk/7BCqSkgWAaSdw3nvrbYhpSnmMrePFCBW2GYLagdWFULIiDCOHsvF1/fzqxwvVVobRSbddxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892724; c=relaxed/simple; bh=a5y1EEkZOPnedpEWtUdzuXTqnsPBymub40I1Wh60MPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VqHXv+JVyJfPaUCa6/7t3d4U6Pns0FQg0vH3UzC3zdFSWDIO+vErQNKHX5XtreK+XO1ewUB+JK7003ZCdrJKHBMxOdQsS/0NBmYxemT+0bz948ovOH4XBKNVdiTpCTi+6ha6jsw8C6fJNlIJGE7HssihdBin/rV5B2y9Qdt3f5U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NDc7II2i; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NDc7II2i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAC691F00A3D; Fri, 28 Aug 2026 04:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892723; bh=SxeKWlCwxhAr4gBBKtFFL+Dx5orsIMBJtg6I3hC4V0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NDc7II2i+sFn8RfROoE+zIzYHQb54rXmGpR52pqgJQzYtdwPnhSOmDu1o/3kg+mhc I3IoelE+qbIcI/smaWiNWA4obCwOI+GdtRFFcl+XeTO0E7J9I2Jbg3FGpi9JHZrgq3 6D4Up0A+ZyhDdSYTkmk3076kbl6KfMAiRYguCS+TDtRA8JcNKPNFjYnvdbcvz3OUMv mAlY8p/czXAtTbaDpgsKjsdJJNKS0jPZlgL3A1mPVEZ+/wrCf6QIvnuEYVS6ejn33s gscu3H311aZaPiKoTkbqCxp+h35Fr89/Dp3z913psnVJ4I3ej0li2r6GB4L12gMoq4 GijWoMV5aAF2w== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 07/27] objtool: Make .discard.stack_frame_non_standard non-allocatable Date: Thu, 27 Aug 2026 21:51:36 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert STACK_FRAME_NON_STANDARD() to an asm macro to prevent it section from being allocatable. This will help it survive being used in libstub, which renames all allocatable sections. Signed-off-by: Josh Poimboeuf --- include/linux/objtool.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/linux/objtool.h b/include/linux/objtool.h index af2e68e496e5d..e9c78e026c7a3 100644 --- a/include/linux/objtool.h +++ b/include/linux/objtool.h @@ -4,6 +4,7 @@ =20 #include #include +#include =20 #ifdef CONFIG_OBJTOOL =20 @@ -30,9 +31,11 @@ * * For more information, see tools/objtool/Documentation/objtool.txt. */ -#define STACK_FRAME_NON_STANDARD(func) \ - static void __used __section(".discard.func_stack_frame_non_standard") \ - *__func_stack_frame_non_standard_##func =3D func +#define STACK_FRAME_NON_STANDARD(func) \ + __ADDRESSABLE(func); \ + asm(".pushsection .discard.func_stack_frame_non_standard\n\t" \ + ".long " #func " - .\n\t" \ + ".popsection") =20 /* * STACK_FRAME_NON_STANDARD_FP() is a frame-pointer-specific function igno= re @@ -91,8 +94,8 @@ .endm =20 .macro STACK_FRAME_NON_STANDARD func:req - .pushsection .discard.func_stack_frame_non_standard, "aw" - .quad \func + .pushsection .discard.func_stack_frame_non_standard, "" + .long \func - . .popsection .endm =20 --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C13E3C585B; Fri, 28 Aug 2026 04:52:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892725; cv=none; b=n6V3TvmMpW1T5lxxlyuP1ILY89iqIYbE24EtjOv1FaRSlFEofyI31AmL2ypAnCT1Y5GfgjhUjHuTK9jnAu3ipF/eRgjRFo1upgqftcQcGjQHnTujVnUGbDF2cPXw0gTzNi6bPm9SkQynLB8onr0CZndF7EbiM8D2tBOkevW4MGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892725; c=relaxed/simple; bh=e6KyJKvQKFiNsK0tdk2JX64adzD69+Bkaek7Wzd0ogw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h1KYRf3My5rRBMlSi8OR+y/hwzQF2e0mlK9UomcJUAHCHOl/9kkaOnY7MyJMEYtlYJUBMeXK28UbFxTbTW6ENYSehzQ95Z+TiJKfuUPZq1bKav74dJsjTl0zoxtnq3Vz3W9E1PAiGENNbzshREPy6/5sso46h8R/FbjvPrWuIXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mu5St60y; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mu5St60y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64CA01F00A3E; Fri, 28 Aug 2026 04:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892723; bh=fdTvcze5X7ZfgZodtkOyMQipZQ892On/LSssO1gYaqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Mu5St60ysGjtb7vgf22dbWtuzrnJTT36wxNRoX5kfS8hSdtHEAr5KO/2tABtNy7A4 +hXRVj0aJIzizpfEJTEGSpUrprh0gPjEOWmo7m8WZ+ZwGAM4gAu0M039JN9n9uhtkJ yFCNlEau2hrqGAij/asGYSL+uPxEcYF9Qv9yDmfHAz/7oilK1aTQYZ5g3Dk3iaSpzv kYVy7Yv0bGu2zuouYYghlCWjkvVPrKOxdI/ptEPdFcJQqa8ZTW4Gd2nbzTWJGVMof4 0nvUVqD7ciRUMKHMoWkNcBOJcY6VUl2g5CY1EiAIsRSSVPKt6SKLdqno9BCefuCrY0 kJlJm9FRdbjng== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 08/27] efi/libstub: Drop .discard.addressable from the stub objects Date: Thu, 27 Aug 2026 21:51:37 -0700 Message-ID: <5f2d4e4327a8bd94c47782076a91cf0ad050acf2.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On arm64, riscv and loongarch, the EFI stub objects are objcopy'd with --prefix-alloc-sections=3D.init, which renames every allocatable section. The .discard.addressable section is allocatable, so if STACK_FRAME_NON_STANDARD() and __ADDRESSABLE() are used, the section gets renamed and never discarded: ld: warning: orphan section `.init.discard.addressable' from `vmlinux.o' = being placed in section `.init.discard.addressable' In preparation for using STACK_FRAME_NON_STANDARD() in libstub code, remove the section during objcopy. Signed-off-by: Josh Poimboeuf --- drivers/firmware/efi/libstub/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/l= ibstub/Makefile index 77a2b2d74f3f6..1344d08b420a2 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -155,6 +155,10 @@ STUBCOPY_FLAGS-$(CONFIG_LOONGARCH) +=3D --prefix-alloc= -sections=3D.init \ --prefix-symbols=3D__efistub_ STUBCOPY_RELOC-$(CONFIG_LOONGARCH) :=3D R_LARCH_MARK_LA =20 +# Drop the section created by __ADDRESSABLE() so it doesn't get prefixed. +# Its job is already done. +STUBCOPY_FLAGS-y +=3D --remove-section=3D.discard.addressable + $(obj)/%.stub.o: $(obj)/%.o FORCE $(call if_changed,stubcopy) =20 --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9783F3C768E; Fri, 28 Aug 2026 04:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892726; cv=none; b=JFHoj8wVJ99IQfDK5qcdPJerbyc9oNO/RnM+eouwS6KQbK4WXnz0GJbzbEq3unKze3W+MOGaWH8JyylyTtheAwhbuFTxmvhP01HJIhPQ+KA6AGFCu4afTWMpiMyzEj6T/gcu0DiSRdNmEAhk3ogj45O8bj5PHevtoZWYwW9CNh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892726; c=relaxed/simple; bh=FBkhZIHsOVOAFGLvGjoaJHbxp5/Ieql+9q6x8eCPjYA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AB48jdYLgA08A9/w8RqCYM7brz40xpRwBKjJNhNf8vHAMe2GVc8t2nMip2SBggYYukh1Gsz7ePqsvFeOjAU97HmUr3XuGBxFyWnEn9wQ9oHUQTnQLa0Q+wF2qCTYS2Fi6qD3xghiJPMkbk1CY5FnnbJlx0D5xeKDdJ9v9gpIzSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cMpKOzy6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cMpKOzy6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2F791F00AC4; Fri, 28 Aug 2026 04:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892724; bh=xeZZ3CRnRZyMKMMDVT6aWXfxyAdK+QQqPR0MFpev8r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cMpKOzy6nCfKKFylzb61PrJ/VfVjuUhfbkp0uFUEZJwTKRIfWGz86nkkvsQ9Nhkaj y09/Wpi3PqGmuvRtaeEQjQDl2CvIOtEP0tWHWr5hO8zPMfRTROEe2SIDyny93UWitO cn0U/iOXtaKtLgTk1F0GwqJOZD9ERtnW9FUuUcheKeLBAk1yDxlmz/PH4VVhMFhwCP dNtl+3qOWieXA2Qp2M8O+LoTgEUPhGsSeG+cwzrL8XArLKEyClg8+MdyNB/fitPQvw n2cA1HLtlyNY2me1ymqB++8BKJL2xxOQcdKV16iX7rRMPSp2CwDVOGVLW7FbTYpPbO yUKRgIYNG37ow== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 09/27] efi/loongarch: Mark loongarch efi_boot_kernel() non-standard for objtool Date: Thu, 27 Aug 2026 21:51:38 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" efi_boot_kernel() ends with a tail call through a __noreturn function pointer, so the compiler emits nothing after it. Objtool can't tell that in indirect call doesn't return, so it sees execution fall off the end of the function: vmlinux.o: warning: objtool: __efistub_efi_boot_kernel() falls through to= next function __efistub_efi_get_memory_map() This is boot code for which objtool/ORC coverage doesn't matter, so tell objtool to ignore it. Signed-off-by: Josh Poimboeuf --- drivers/firmware/efi/libstub/loongarch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/efi/libstub/loongarch.c b/drivers/firmware/ef= i/libstub/loongarch.c index 2b0c87dc99088..737de9afd6a40 100644 --- a/drivers/firmware/efi/libstub/loongarch.c +++ b/drivers/firmware/efi/libstub/loongarch.c @@ -5,6 +5,7 @@ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited */ =20 +#include #include #include #include "efistub.h" @@ -103,3 +104,10 @@ efi_status_t efi_boot_kernel(void *handle, efi_loaded_= image_t *image, real_kernel_entry(true, (unsigned long)cmdline_ptr, (unsigned long)efi_system_table); } + +/* + * Objtool has no way of knowing the real_kernel_entry() indirect call is + * noreturn. Just tell it to ignore this function: it's boot code anyway, = so + * ORC coverage isn't needed. + */ +STACK_FRAME_NON_STANDARD(efi_boot_kernel); --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1728A3C9ECF; Fri, 28 Aug 2026 04:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892726; cv=none; b=NcHQQMnoTBqzNJeMXObVKi+93qGqWsvyUBxArEDBoMS7mzS0aJyKYdpIf2T4CMKOOADbK6ij3B9TQjkZqrEy53dZEeA2nopgRw6kTYXa9T85fxaZYbOwb1e/UXw2SiRjs6rB3CZfDvkdLNW3i/zXsbUKhPYFCJbAjgFUxlwGLpg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892726; c=relaxed/simple; bh=PeDmX7SDU6AhEihArIs5iRLSLqZA5rMMhmXqtc46rtE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IhxDdRZcuhjGUgwcAQNX5uPKDi+K19838H6k4hpUeVQdYxrokRq/sJoAo5IsPjTFQrCxu9fZ6IuGLx9ImR+6WztRQYnjCqtbOgm1pF+KkineZSHCjn0dcXF2rSca9bQQDiUblbY/iz/XoxbKfjgIQnWUiW/7YroWaPgkywIbUAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V32UyxX3; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V32UyxX3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C9CB1F00A3F; Fri, 28 Aug 2026 04:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892725; bh=LTJClFvbim3RR6e7TU+Sb/F6dppOoOMqDF4GEGzM61E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V32UyxX3t3s7rlqOwv0L5v26vYMEI0QAIw1icU5mQANTyCQ0ZL0ucMM+kwG+4xACw bhgJxNNwMVojQ5dHrSJOUcdc1MKaojyatPIot2QGJIC5DZkGjqWgFBV8XaqgSXt/U2 fCegkBcwHxH/lhnNQkfxWfa5OI+WUgNusH3CUO109LGbugDqV4dDUbLT3HPv7hofQz k5UyTbzrltYX5xNX2pCVNO6F4k74zCxZYJSHl5Enwabp3lPm+H+34waVrfRQhAGSyr z9Prwbkbd4gQU1cHBk79tIInuh9UBKelKLBxIRkTJ8ktq0yduqXwJ50zixgRdWmQZ1 srBeXr2tXlaZQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 10/27] objtool: Add ANNOTATE_IGNORE_NORETURN() Date: Thu, 27 Aug 2026 21:51:39 -0700 Message-ID: <49da10e66e03e9acdbb66677afe5b4a89500ba79.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A generic interface may be noreturn in one arch and returnable in another, in which case its common declaration can't say __noreturn. Rust has a similar issue where a few core library calls to returnable functions are replaced after compilation with calls to a noreturn panic function. Add an annotation which tells objtool to ignore the noreturn status of a given function. Signed-off-by: Josh Poimboeuf --- include/linux/annotate.h | 7 +++++++ include/linux/objtool_types.h | 1 + tools/include/linux/objtool_types.h | 1 + tools/objtool/check.c | 19 +++++++++++++++++++ tools/objtool/include/objtool/elf.h | 1 + 5 files changed, 29 insertions(+) diff --git a/include/linux/annotate.h b/include/linux/annotate.h index 2f1599c9e5732..a81ca04b4c501 100644 --- a/include/linux/annotate.h +++ b/include/linux/annotate.h @@ -3,6 +3,7 @@ #define _LINUX_ANNOTATE_H =20 #include +#include =20 #ifdef CONFIG_OBJTOOL =20 @@ -105,6 +106,12 @@ */ #define ANNOTATE_NOCFI_SYM(sym) asm(ASM_ANNOTATE_LABEL(sym, ANNOTYPE_NOCF= I)) =20 +/* + * Treat a function as returnable by its callers despite objtool classifyi= ng it + * as noreturn. + */ +#define ANNOTATE_IGNORE_NORETURN(sym) asm(ASM_ANNOTATE_LABEL(sym, ANNOTYPE= _IGNORE_NORETURN)) + /* * Annotate a special section entry. This emables livepatch module genera= tion * to find and extract individual special section entries as needed. diff --git a/include/linux/objtool_types.h b/include/linux/objtool_types.h index c24e9ea392696..ce08ecc808c67 100644 --- a/include/linux/objtool_types.h +++ b/include/linux/objtool_types.h @@ -66,6 +66,7 @@ struct unwind_hint { #define ANNOTYPE_INTRA_FUNCTION_CALL 7 #define ANNOTYPE_REACHABLE 8 #define ANNOTYPE_NOCFI 9 +#define ANNOTYPE_IGNORE_NORETURN 10 =20 #define ANNOTYPE_DATA_SPECIAL 1 =20 diff --git a/tools/include/linux/objtool_types.h b/tools/include/linux/objt= ool_types.h index c24e9ea392696..ce08ecc808c67 100644 --- a/tools/include/linux/objtool_types.h +++ b/tools/include/linux/objtool_types.h @@ -66,6 +66,7 @@ struct unwind_hint { #define ANNOTYPE_INTRA_FUNCTION_CALL 7 #define ANNOTYPE_REACHABLE 8 #define ANNOTYPE_NOCFI 9 +#define ANNOTYPE_IGNORE_NORETURN 10 =20 #define ANNOTYPE_DATA_SPECIAL 1 =20 diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 7333b0ed86818..ddb8dbe7f71d9 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -246,6 +246,9 @@ static bool is_noreturn(struct symbol *func) { func =3D func->alias->pfunc; =20 + if (func->ignore_noreturn) + return false; + if (is_listed_noreturn(func)) return true; =20 @@ -2389,6 +2392,18 @@ static int __annotate_early(struct objtool_file *fil= e, int type, struct instruct insn->noendbr =3D 1; break; =20 + /* Must be before detect_noreturns() */ + case ANNOTYPE_IGNORE_NORETURN: { + struct symbol *sym =3D insn_sym(insn); + + if (!sym) { + ERROR_INSN(insn, "dodgy IGNORE_NORETURN annotation"); + return -1; + } + sym->ignore_noreturn =3D 1; + break; + } + default: break; } @@ -2435,6 +2450,10 @@ static int __annotate_late(struct objtool_file *file= , int type, struct instructi /* early */ break; =20 + case ANNOTYPE_IGNORE_NORETURN: + /* early */ + break; + case ANNOTYPE_RETPOLINE_SAFE: if (insn->type !=3D INSN_JUMP_DYNAMIC && insn->type !=3D INSN_CALL_DYNAMIC && diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index 46fb2230ca743..0e3593d993ac8 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -99,6 +99,7 @@ struct symbol { u8 dont_correlate : 1; u8 fake : 1; u8 _noreturn : 1; + u8 ignore_noreturn : 1; struct list_head pv_target; struct reloc *relocs; struct section *group_sec; --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3C2E3CB2D2; Fri, 28 Aug 2026 04:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892730; cv=none; b=P0aKwv8YR1PDqX0PodX/niRP8FxtQbFjjoD8A2iF+Qj9kndoNMEahUMd5Cf4nPeCdObqYJIdiTPZvZFb62ltI1Nz2v7O4ZIOcIFtaveEXVnpoA3uHfAGeN20F9GGyiyDK6lr/blACz8ZE5nTluagKXAHyf83Bl3mKMQgd3EIOUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892730; c=relaxed/simple; bh=qWztlRwzMp0eC2vV1a7ZtSRKJ/oNH+JGaEQpizwVGGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u15RQB8exUNNkiwt/DLYkp67VLYbqDs3zX+Ou2MrstpQzmugrfFX3vYtzCaxvXwBZwKEnbBmub9UxPLHtt2haO7YRuXNQyMPIYslKv0U+8TYBLdwncjhCxYfj8wDJNziWiYT817jhlhwHdVhgM56kmUoiRBN12/hi/DCAvQ5ipY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gfRm0PQH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gfRm0PQH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24FE11F00A3A; Fri, 28 Aug 2026 04:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892725; bh=vNjsHB30KZpNjM4w2L4yDqFztf6tF3EEy9YfZGXC5gU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gfRm0PQHvH1SUw4fG+k3MrYGgdzh4mCYV1p/e/Q7jD0zCK7BLA0otkjTYE9c7fW2q nUkcU8cswHUitBinZ3N9w39zqm74l4dk98XJ7I3VFuNArZ8t4O+2Ugpzd+GdJQfCPR BqcNtEYYdRIXN8Sl5RyTp1l43va9dguyDgZG5x9rO3yBCMjtfSD/H2PjvGmwef82Vw 5rxnGMU1VOGhfSD+3VXGmwA/Egd9CWVjfkuMJT2/NqCQBAHL8FVbCcJvDKK7mCkXVW s0zjKb2pPNuGEAaQtVqas4yPcZTT7nwhrZsua9HjcLMI/qHrfZMHIo0zIxltb979fZ 4gyTfTzQON1zA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 11/27] LoongArch: Annotate reboot and kexec paths as returnable Date: Thu, 27 Aug 2026 21:51:40 -0700 Message-ID: <37c0dbd58e99fe79d4cfa0aa9e6c31690c78a279.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Running objtool on LoongArch vmlinux.o shows the following warnings: vmlinux.o: warning: objtool: __do_sys_reboot+0x188: kernel_restart() is m= issing __noreturn in .c/.h vmlinux.o: warning: objtool: hw_failure_emergency_action_func+0x74: kerne= l_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 missin= g __noreturn in .c/.h vmlinux.o: warning: objtool: restart_poweroff_do_poweroff+0x1c: machine_r= estart() 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 --- 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 #include #include +#include =20 #include #include @@ -296,3 +297,4 @@ void machine_kexec(struct kimage *image) =20 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 #include #include +#include =20 #include #include @@ -36,6 +37,7 @@ void machine_halt(void) __asm__ __volatile__("idle 0" : : : "memory"); } } +ANNOTATE_IGNORE_NORETURN(machine_halt); =20 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); =20 void machine_restart(char *command) { @@ -77,3 +80,4 @@ void machine_restart(char *command) __asm__ __volatile__("idle 0" : : : "memory"); } } +ANNOTATE_IGNORE_NORETURN(machine_restart); --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A6513CB8E3; Fri, 28 Aug 2026 04:52:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892727; cv=none; b=mKQVrtLaWC0FpgixFVYcbB6083nLNzmHjh2LJLGUpJIGB9r/yY7zmaWzsL1slAf1yj7tCuDQOtec4HgnIBCRvFw1RvOoCQtLkOteYafgzQW4tZMMXyh5MuDwLB8L1WkoMMe0nmJZbWyZk6yrC8sQataRqSHFYePo36RD4qtcxOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892727; c=relaxed/simple; bh=NxJBbCWzL09dAGhLJHJKulrUlK5ab3gm0E3AEMhUq00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KSJxy4WNcGQk2PSCxKbQ65ETZGx9UratNrSmy/vjU/naLX24Z3BZn3MMgEk0WLMHNpGV4sixN0ggS4H22ZCLREAl1B3yAgstnSlslFU6a8+3ef1d54tVQljcdgxtugyEUR7V6EUaRFMB+tBoyox0OPaSQfid08lh4Yb0LkkFNMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NYN1eeNb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NYN1eeNb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0C111F000E9; Fri, 28 Aug 2026 04:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892726; bh=NkCNN0p4Rluw+hrxzgg+pw01rDWc6qKNH7aHyDCrS2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NYN1eeNbxGlRiJREzyY0vfi/fpzjsNQ4pKdpGc63yQWH4NjL4WLzYyZpRaw688/EI vOCpIlxCDQ887z7rGbkzzyOdzr5KkmJGdpiHSXC0HHC098p9kpLDZ9QRTBEq1sEWEg E7MjTAYwVkr26FkF0xu3dT1DfqxlcJyEI+zvHWL8Ktj9yGVxtRkVbkE0x+cRqhUVj7 XxywYj8wN4MepCZZZIMyMPBfCBvo2FRGNOeMJc7mHVblyGeg+jKH7RovRbJwbp8lzU M/fU2+vLBJ0k209Jhwlzo475rjbSY7JN7tYMsPXcQITzEbxBNt7SfMSm1Cf9Wh/u+c 9fu8D+4JRoxKg== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 12/27] kbuild: Defer running objtool to link time for all CFG features Date: Thu, 27 Aug 2026 21:51:41 -0700 Message-ID: <1447f9f8dc6e7e02e4a8a33ce7ae92ba49d70eb3.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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). Signed-off-by: Josh Poimboeuf --- lib/Kconfig.debug | 3 ++- scripts/Makefile.vmlinux_o | 14 +++----------- tools/objtool/noreturns.h | 23 ----------------------- 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 0ea5ad31969ce..bfb977595631e 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -599,7 +599,8 @@ config OBJTOOL_CONTROL_FLOW 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 =20 config VMLINUX_MAP bool "Generate vmlinux.map file when linking" 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 individ= ual -# 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/u= nret -# validation. +# For CONFIG_OBJTOOL_DEFERRED, objtool doesn't run on individual translati= on +# units. Instead it runs on vmlinux.o. =20 -objtool-enabled :=3D $(or $(CONFIG_OBJTOOL_DEFERRED),$(CONFIG_NOINSTR_VALI= DATION)) +objtool-enabled :=3D $(CONFIG_OBJTOOL_DEFERRED) =20 -ifeq ($(CONFIG_OBJTOOL_DEFERRED),y) vmlinux-objtool-args-y +=3D $(objtool-args-y) -else -vmlinux-objtool-args-$(CONFIG_OBJTOOL_WERROR) +=3D --werror -endif =20 vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) +=3D --noinstr \ $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_S= RSO)), --unret) diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index 08d441b8895cb..cd41f580ccb72 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -7,44 +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(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) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C67653CCFD4; Fri, 28 Aug 2026 04:52:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892728; cv=none; b=ZdVehNNhuXThLoLWI5YwjUMvRUucUesTTh4Vq7cg2JgYfos6LujIQRKYfhenOKHerr+hzzPLNFPyxNNItF3KtcBOZ2B9OF5Uew5Imx9ZJ7InAmxiOgGDGH+NSP3/+GHnJmO4eZN2webxGZvSyl9qjuo7xY8PDMZ94Fb9TVQemeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892728; c=relaxed/simple; bh=vOtShQW5hqWtQLsF6JJqqLEy9K1H2NwWlw6Q7PKK47w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a0MnyNihhpy+buR66H5mn5RW9a3VerXP30PQuoSIekkWn4npUgz/0NR/Do4qiiyGUTA7AvRMZqKLYa5oh1lxkXO88Oah2zoYH6/11o9NhvEonneeCLVRms/CANW5u4FqCeMQPIIttde2MyFeJq8GVwMnMwNAsVIuGK4urQijp/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AjgD8tBy; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AjgD8tBy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AB531F00A3D; Fri, 28 Aug 2026 04:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892726; bh=q4UKoS/KEgRJIb5nCfv+d+0dqJKoVa0rpn2ix/q0LHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AjgD8tBymtQ7msSsHc/RxbIZCDsTlTIMP/HZ06sEyWyfh/RsGspLco1VegYAU8k5n bDH1dq4HoGaaugJalUn3Nqiy16T3WyujJrSxF4mZ3Bv2hMe1JIoOBELNtTkSTCpABM MjGL3tqGsuVd5ZkIgEYt1q1+NAZaRx/jgqgwdeMem38rTNcNgCytaHCHnBCTnS5J58 j0Vkr9O/XG00+XR0rJvse0HOA1Jcjm10HYUZ97ttJgAtauWNUTuTJK7t+w6V7ly+ph ZicE582fmHuePYq01r/EEzogB0CTbODERiBmo+vr1M1V/1BdpwXJ9JC4Ir80V7cFmM iijvS5HksAm7A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 13/27] rust: Annotate the intrinsic stubs as returnable Date: Thu, 27 Aug 2026 21:51:42 -0700 Message-ID: <00f55392e4640b835027a30b0dad79b4b53a56ad.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When building the Rust core library, the compiler emits calls to compiler-rt builtins like __udivti3() for 128-bit arithmetic, which the kernel doesn't want, so objcopy is used to redirect those calls to stubs which just panic. Problem is, their call sites still expect them to return, which confuses objtool. Objtool doesn't report any warnings today because the stubs are weak, which noreturn detection currently ignores. In preparation for removing that restriction, annotate them as returnable. Signed-off-by: Josh Poimboeuf --- rust/.gitignore | 1 + rust/Makefile | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/rust/.gitignore b/rust/.gitignore index d3829ffab80ba..c198d1a52e60e 100644 --- a/rust/.gitignore +++ b/rust/.gitignore @@ -6,5 +6,6 @@ doctests_kernel_generated.rs doctests_kernel_generated_kunit.c uapi_generated.rs exports_*_generated.h +intrinsics_annotate_generated.c doc/ test/ diff --git a/rust/Makefile b/rust/Makefile index 627ed79dc6f50..1cbee6f1ca098 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -33,6 +33,9 @@ endif =20 obj-$(CONFIG_RUST) +=3D exports.o =20 +always-$(CONFIG_RUST) +=3D intrinsics_annotate_generated.c +obj-$(CONFIG_RUST) +=3D intrinsics_annotate_generated.o + always-$(CONFIG_RUST) +=3D libproc_macro2.rlib libquote.rlib libsyn.rlib =20 always-$(CONFIG_RUST_KERNEL_DOCTESTS) +=3D doctests_kernel_generated.rs @@ -684,6 +687,20 @@ ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CO= NFIG_64BIT))),) __ashlti3 __lshrti3 endif =20 +# For objtool, annotate the redirect-intrinsics as returnable. Their call +# sites were compiled against the returnable intrinsics, but the redirected +# versions are noreturn. +quiet_cmd_intrinsics_annotate =3D GEN $@ + cmd_intrinsics_annotate =3D { \ + echo '/* Generated by rust/Makefile - do not edit */'; \ + echo '\#include '; \ + for s in $(redirect-intrinsics); do \ + echo "ANNOTATE_IGNORE_NORETURN(__rust$$s);"; \ + done; } > $@ + +$(obj)/intrinsics_annotate_generated.c: $(srctree)/rust/Makefile FORCE + $(call if_changed,intrinsics_annotate) + ifdef CONFIG_MODVERSIONS cmd_gendwarfksyms =3D $(if $(skip_gendwarfksyms),, \ $(call rust_exports,$@,"%s\n") | \ --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E6FE3CF030; Fri, 28 Aug 2026 04:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892728; cv=none; b=WuNWakkZj4zyWFdbGMeea5N1UlJhk3FcSTNWPAJj/FY+f3Gqa23AJSVGupgm1cQLgFA2+imRAQMOIOmjPW5vFgPGMs74EuOVpDIfpCGgosMxXQ6CsTdDoNN4Qcp33O15/UbPvlNDfjq8MPObmw8VBP4oWB8rb7bMBk3jxsAc2qs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892728; c=relaxed/simple; bh=TpI+ZyO/PPBysvaK3C3nLy5+GCCO4xCb/6Qhoxzxr9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UyCES+dEQ7LndT77Rv2yBcuFl857iMRSIUvPrLb4XY2LBfT0bYXQOnegxtej7KyfH2ZyMlDxPAf5rFdXPEeHJdLue4usxTohnDTeRTgnBTRksM8icit6V6D6cNfqXulXczBuuAuEqpzGyW99yJkn/aeZt2/HctOPYKLSKZYT4G8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=emMgM5C7; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="emMgM5C7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D63BE1F00A3E; Fri, 28 Aug 2026 04:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892727; bh=TtBngXEZ/h+4/NjsyRr1cZakc5vH2AOdgLkSOM9C10Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=emMgM5C7dG7XxifqWh5asWDCERItrgL12f/7ZOUWIxugGUn6fVx3CRH72Dt9cOT0p LLrQG2FpjIETq6NIVFRY+q23eyX2n0OfAQPPiYpHI2c/J01ANpoC9i/ku2y1GUf4lu W/0v/EFIdBAy/mtUSff+Lr0KkaQllxiNTlXBfhRY2AiwW06uyDU1H4HDJzzxnUbqOl qEPF9Pfj3UjnlDTGYzSVB6JYoKFXdXcdegNBEKMlWVyIam68JXCNCGjUYCw6rR3DAB 5dCqajxvJd7LSvBP0e3j7fPKzqHOW3vFxM7xfsHROux4oIQFhq7jbtR6Bsp2Ji5U6y MzSvaUplLXi2Q== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 14/27] panic: Mark abort() __noreturn Date: Thu, 27 Aug 2026 21:51:43 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" abort() is a C compiler builtin interface, so compilers already know it doesn't return, but mark it as such explicitly for documentation purposes. Signed-off-by: Josh Poimboeuf --- arch/arc/kernel/traps.c | 4 +++- arch/arm/kernel/traps.c | 2 +- include/linux/panic.h | 2 +- kernel/exit.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index 8d2ea2cbd98b0..803c131c6aa78 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -153,7 +153,9 @@ void do_insterror_or_kprobe(unsigned long address, stru= ct pt_regs *regs) /* * abort() call generated by older gcc for __builtin_trap() */ -void abort(void) +void __noreturn abort(void) { __asm__ __volatile__("trap_s 5\n"); + + unreachable(); } diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index afbd2ebe5c39d..a3bd26d41612f 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -777,7 +777,7 @@ asmlinkage void __div0(void) } EXPORT_SYMBOL(__div0); =20 -void abort(void) +void __noreturn abort(void) { BUG(); =20 diff --git a/include/linux/panic.h b/include/linux/panic.h index f1dd417e54b29..da8778360dadf 100644 --- a/include/linux/panic.h +++ b/include/linux/panic.h @@ -33,7 +33,7 @@ extern int sysctl_panic_on_stackoverflow; extern bool crash_kexec_post_notifiers; =20 extern void __stack_chk_fail(void); -void abort(void); +void abort(void) __noreturn; =20 /* * panic_cpu is used for synchronizing panic() and crash_kexec() execution= . It diff --git a/kernel/exit.c b/kernel/exit.c index 2c0b1c02920f4..2c55dc0fbbec8 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -2028,7 +2028,7 @@ COMPAT_SYSCALL_DEFINE5(waitid, * * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D88345#c11 */ -__weak __function_aligned void abort(void) +__weak __function_aligned void __noreturn abort(void) { BUG(); =20 --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 019853CF942; Fri, 28 Aug 2026 04:52:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892729; cv=none; b=lNHrNCnk4lYvNOYgZs5Y4c22KjRbkqe4dyQJdbI5QbNr6hDP1mwawRY3ezDABbt6282WW2ti2glGtQSQ5fvZXPil+565zmqjx0o/qvHcY4MIcWTRVn4E5jbFI/+e/qTGwZWIrNgCN5EnJozB8tK77IrLTCM+f53WFmpSy3GpCmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892729; c=relaxed/simple; bh=MoxkdQ1PZtbscQc+lhfZEsLtnTOuV5Kr1isBaLFfg/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YUTbPwrWB6uslDwnM/HjBzTdS8FldjuRBh43efjKRlTxd/t27qr8YNPX69eg3bgUHzat41SIRrVmiN2IlAmR9riHg7JpCRDKN5tR9EN+DEs/O+v8BIYRbrgI0ivKVpmVMhQi/fVbtime3VZJWb1KBLS1k/zZ/SajSdGG4M4SX1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WGYkbray; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WGYkbray" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 714311F00AC4; Fri, 28 Aug 2026 04:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892727; bh=oMAVVsJ+ySiw/1VP59+j9m215Ku23i+uiwwAe+dcMn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WGYkbrayep8wN20L0/XBZuHDOxbEe8AgyfYpOAlQmGtDY4yd9pzgOF0M4qLArdG7i N6aXq3Mtbo/moiXKNw57N832d45cUx8mfO06h+83mJtquDfNKt/4KbweCPGfacu8V3 LU5Dl7KQD5vJo8LZMwoHko4Qa7jnlDuDxok96/1LBriEczUHq5wKvN1cZiekE4o/5i RV73VYixMP4Jg32e4uif971h5QPx/k1plRf4vNPPzK39XnBXVs91yvbMWiKcQx/9Pn RlsE8zRCQYNbPGXW71EGvZo/KZtuBlUvm/7cqPNjZ4E2JuxvdOX5KAEXPN2eGgRv6J CxNoO7n/lbxBQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen , kernel test robot Subject: [PATCH 15/27] x86/xen: Ignore noreturn status of weak mem_map_via_hcall() Date: Thu, 27 Aug 2026 21:51:44 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Unlike the non-weak version, the weak version of mem_map_via_hcall() doesn't return. Tell objtool to ignore that, as the protoype (and the non-weak version) aren't noreturn so its callers can't assume it. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202608280214.c28GlIx6-lkp@int= el.com/ Signed-off-by: Josh Poimboeuf --- arch/x86/platform/pvh/enlighten.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/platform/pvh/enlighten.c b/arch/x86/platform/pvh/enli= ghten.c index f2053cbe9b0ce..9f227f06cbaf5 100644 --- a/arch/x86/platform/pvh/enlighten.c +++ b/arch/x86/platform/pvh/enlighten.c @@ -37,6 +37,7 @@ void __init __weak mem_map_via_hcall(struct boot_params *= ptr __maybe_unused) xen_raw_printk("Error: Could not find memory map\n"); BUG(); } +ANNOTATE_IGNORE_NORETURN(mem_map_via_hcall); =20 static void __init init_pvh_bootparams(bool xen_guest) { --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FC963D16E2; Fri, 28 Aug 2026 04:52:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892729; cv=none; b=anvHTwMlKySpGDeGIcifBiGCoH5VB+0eZUsFN3Pd6IQa8sVqnWFcxNvWprltAmBjz6xouPwjxOi3o54LLCdfR6hpC+HsuvHioiWpTmfs9z85bVlw/Ox8QLoql4uahPoQ8uOl5UoSIFZeahETW+W6F5voTvtjQonFYy259rtRxGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892729; c=relaxed/simple; bh=38+V5eWfdyUtykT7i6weS0PX+rdW2i6FUhGg/knvi8A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a9kKge9R8qmqIUgLSzka/GMJfuKufGU358ec8XNBkf+vmsfZJCdunIt9Az9F8hRSRu/b6Jm1Zs9umlrWTAAj5ccDjYZezdQlZ5GTruQHE1wmekbp2or3z+Tqt99xNytKRMllkhmqLHLc5GA7enwLLNQqLRUXGqzfCi+0mMJ/AT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FsxeR4Jb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FsxeR4Jb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 136041F00A3F; Fri, 28 Aug 2026 04:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892728; bh=QCPC2VydWNhBNTfMl1c4YlqwNYEoCQHQqQsxRdGOi6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FsxeR4JbYkH/M8xs/73HsrxnTvw+pviVBtoq+ROLeZZT8B9Zh8P6JYyk5rsS5/DT1 MWAnBTj9L4N16G3NP8UgXvp9YkCP920cQjHlaDWsz63f2rkkig56LXgStWzvRqu1R1 zBUjoW6ZS3FDyA7w5r5DDHQh2hS5Ayt4rLq8iPYIaIul5EeKbe2b6M7AwT3xJmo4qI CK1jFSSNFAwClB61kGm9KKPKEYkB4xdDIHpsDTes1bnMvt08NbT8UAjipPuhACpdbx DzdNnXhmqHwKHGsHr7AinmFs8SrSmziEkiFpJXGhUTUAyyTmxQJnz+1GAKQnRxGZkE R9A6s+AgDPDHA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 16/27] objtool: Detect noreturns in weak functions Date: Thu, 27 Aug 2026 21:51:45 -0700 Message-ID: <9142b469c79880bd3a33db6e4f7c27d3a40e43c5.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The skipping of weak functions in the noreturn detection logic is a bit weird, as a function's return/noreturn ABI shouldn't change regardless of which version gets linked. Fix that, and update the global noreturns list as needed. Note that abort() now needs to be added to the list: while objtool on vmlinux.o can detect that its noreturn, modules have no way of knowing. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 3 --- tools/objtool/noreturns.h | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index ddb8dbe7f71d9..c55851ec389cd 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -260,9 +260,6 @@ static bool might_return(struct objtool_file *file, str= uct symbol *func) struct instruction *insn; struct symbol *dest; =20 - if (is_weak_sym(func)) - return true; - func_for_each_insn(file, func, insn) { if (insn->type =3D=3D INSN_RETURN) return true; diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index cd41f580ccb72..26f62f98bc8ef 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -11,15 +11,14 @@ NORETURN(__kunit_abort) NORETURN(__module_put_and_kthread_exit) NORETURN(__stack_chk_fail) NORETURN(__ubsan_handle_builtin_unreachable) +NORETURN(abort) NORETURN(acpi_processor_ffh_play_dead) NORETURN(do_exit) NORETURN(kthread_complete_and_exit) NORETURN(kunit_try_catch_throw) NORETURN(mpt_halt_firmware) -NORETURN(nmi_panic_self_stop) NORETURN(panic) NORETURN(vpanic) -NORETURN(panic_smp_self_stop) NORETURN(rewind_stack_and_make_dead) NORETURN(rust_helper_BUG) NORETURN(sev_es_terminate) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 309CF3D25CE; Fri, 28 Aug 2026 04:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892730; cv=none; b=a+eXLZdllZMiM/Q71GEyLrW17QQoSp2BH+/CkvdL5nZ8wbfPXf1YhRLWf1ajIMdM400hooXuBMdlElKdlh2kcDNt/IG09qszrbrYEPTVZctPbW42up1d0u4jceg2Cb5kKXfg5WSbvxFu8E+aMcvIFEuC83wB+MQj7BliEPdQz/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892730; c=relaxed/simple; bh=sCZ3hweuqbfpF1gSR/JkKIXGd/XRyniPEZdBWxif+Kw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZOYML2XeqOOq/jkGWi7CZxDGUJr1J+QNaoILtiIL2A8HioNOJLMnJMR+n4FtD5teBrtAEdFEiHpFSI0UoLONZaKduh5xQgUKG/gDSvPGws5Hl+WdD9082PP8lfdzNJ/kSUfid0Y++po2EV1XCaEdVGFlecWq3Z5I7fyfclilJ7I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ud6Qfdpo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ud6Qfdpo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0C5A1F000E9; Fri, 28 Aug 2026 04:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892729; bh=XLJeW1VlhLkwfJzchxr4ycnasjucLgUzud4kf/dIfwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ud6QfdpoRKGYeQCrIBb/kbBDMmF63SyCaOeCCkRlyJiYEeY2Qm9RQZtcWH/0LY4re frjpau+HEQ6JG6rfOGbftsCW2HLfeq7Rn+Neb9o+ZG3zDHuPi1kHT4GyKKYl7kRca/ l3/DNdVYIosEyhVdoKXIvf7ksnn1wvmgvnYxKqEOeVUigSxLqxLL+atriTYI07iZ5i sbUjKnhxl5D1bP/N+S59SSzEjSfM0kefomjArwXSN1YQFHx2QZdgwpm6xnylLW0/zM zN8/g9bFqOKq0rey6oXmpXrIQt7/ukH4UpdxcHZUSF1AeuV08hL8ptZDujQnON9z9t o86iO2qayKy1g== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 17/27] x86/entry: Make rewind_stack_and_make_dead() a real function Date: Thu, 27 Aug 2026 21:51:46 -0700 Message-ID: <8f13a2da7d267bffb1b2675f26152429da56a273.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" rewind_stack_and_make_dead() is SYM_CODE because it switches stacks, but it's otherwise a callable function from C. Convert it to SYM_FUNC so objtool can detect that it's noreturn and its entry can be removed from the hard-coded global noreturns list. Signed-off-by: Josh Poimboeuf --- arch/x86/entry/entry_64.S | 7 +++---- tools/objtool/noreturns.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index c6d996593f329..1184bf1f9ed7e 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1480,9 +1480,7 @@ SYM_CODE_START(entry_SYSCALL32_ignore) SYM_CODE_END(entry_SYSCALL32_ignore) =20 .pushsection .text, "ax" - __FUNC_ALIGN -SYM_CODE_START_NOALIGN(rewind_stack_and_make_dead) - UNWIND_HINT_FUNC +SYM_FUNC_START(rewind_stack_and_make_dead) /* Prevent any naive code from trying to unwind to our caller. */ xorl %ebp, %ebp =20 @@ -1491,7 +1489,8 @@ SYM_CODE_START_NOALIGN(rewind_stack_and_make_dead) UNWIND_HINT_REGS =20 call make_task_dead -SYM_CODE_END(rewind_stack_and_make_dead) +SYM_FUNC_END(rewind_stack_and_make_dead) +STACK_FRAME_NON_STANDARD_FP(rewind_stack_and_make_dead) .popsection =20 /* diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index 26f62f98bc8ef..ff93e94ee09a0 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -19,7 +19,6 @@ NORETURN(kunit_try_catch_throw) NORETURN(mpt_halt_firmware) NORETURN(panic) NORETURN(vpanic) -NORETURN(rewind_stack_and_make_dead) NORETURN(rust_helper_BUG) NORETURN(sev_es_terminate) NORETURN(xen_cpu_bringup_again) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF15B3D349F; Fri, 28 Aug 2026 04:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892731; cv=none; b=FN1S6ipbicaqsaNuutiE15QFqb08AmcvVh1EST/o++olN+vdketxO5xa+EP685+oxc75/S4wlw/1xBCMR10mKMO7YEJfiFaIvrVGXK56uBS/wgPlKL5f0nPcSZZNMaLzLBaVGQBMRIgrnEmMVFOUgMYsvg5htA7TnzrB+H0YpkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892731; c=relaxed/simple; bh=/Fh6ECh5PUipY2MuOCfqQU9wpCqGcFXXSLNL3uT0NYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DtWDIsOwvLzeoPTfgKu1LMtlP320sWF8iSmfjErZZLMw10ZfY2jAVRJNCJFTpm4JMLq+X6MgwgI4D/mfUcSxQVLVO/D6oD9t8iWTMnUbnkidO8LdBBqYLpKbOjdmX6dTpOm/OP4eh34EYPxxAFN+vP9rZGBUe235ymvGwGzT5pI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mS3HVa76; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mS3HVa76" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 406601F00A3D; Fri, 28 Aug 2026 04:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892729; bh=yxTbQgBZYQugQzsbsUlaD2OTcmFXado/QiZ/FDE5CKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mS3HVa76ljubYwy3Fcb7EHMPutpNboNwj3QF6Un8P1BIqWRNIpDof0kZZxvrJdfeR 3PFDTFY7QOfPhuWmtfzJbFqg1mmUSoqh3JVBUCtVwFNtPXpiEkTPWYurc+lluJBQEg v6o8VgVL462ung0gq4B0MBur4qSyfUzCCGy3qdoUeZtwQkT9vEyif37eElpOdZPxnE 9LzaQ2bBnIPXJJz4i/xnXcAIvH5UpIa9D7dvakCZxs1VVlcxhtKJY6sSHSXSamyCVt VoDkaj5QcTvO2q6vu8CrTX/0K0y5JQngRSGJaYsyqieU0qcR1Q3Ns0vRAcJFiJVGOa T89vtyUqfLHsw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 18/27] x86/xen: Make xen_cpu_bringup_again() a real function Date: Thu, 27 Aug 2026 21:51:47 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" xen_cpu_bringup_again() is SYM_CODE because it switches stacks, but it's otherwise a callable function from C. Convert it to STT_FUNC so objtool can detect that it's noreturn and its entry can be removed from the hard-coded global noreturns list. Signed-off-by: Josh Poimboeuf --- arch/x86/xen/xen-head.S | 5 +++-- tools/objtool/noreturns.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index 5dad6c51cdc34..68d769772f309 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -55,12 +55,13 @@ SYM_CODE_START(asm_cpu_bringup_and_idle) call cpu_bringup_and_idle SYM_CODE_END(asm_cpu_bringup_and_idle) =20 -SYM_CODE_START(xen_cpu_bringup_again) +SYM_FUNC_START(xen_cpu_bringup_again) UNWIND_HINT_FUNC mov %rdi, %rsp UNWIND_HINT_REGS call cpu_bringup_and_idle -SYM_CODE_END(xen_cpu_bringup_again) +SYM_FUNC_END(xen_cpu_bringup_again) +STACK_FRAME_NON_STANDARD_FP(xen_cpu_bringup_again) .popsection #endif #endif diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index ff93e94ee09a0..01c94f20d1818 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -21,5 +21,4 @@ NORETURN(panic) NORETURN(vpanic) NORETURN(rust_helper_BUG) NORETURN(sev_es_terminate) -NORETURN(xen_cpu_bringup_again) NORETURN(xen_start_kernel) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B97A3D4138; Fri, 28 Aug 2026 04:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892731; cv=none; b=uTnEGZbT3Mor8wDVyeJlyv3rTkOKCcuDw/ppcyyvydV2H1B7B8dOwZhXzFgDf+mjiBpLnvh0d24pzJ1lnLxv2Y0gZQZayKHc2vQtOXV8wOA04JETzE/rFVmOUGM7c2t4PofIOAiANQiY1sMeWosuU6bpzuR3XfCA1azosN2WQHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892731; c=relaxed/simple; bh=JJ3QSA7Xyw9zTtk52kmDZvENRNaAW8uwuyQ2Brw8jEc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mTRTdLSZqm794k49kq4+3vM+tEk1It8wxF3m4YsO97wBk4lEBlg8Frh/0SpIgrGJjXq+8qQNgtBJw9+QTTz+/36YYuP0PNo/aJJ9AafhR7TDbWkOwd91UZiLeTXt1bdVLTJjoxVJzdRarWRBbYgsKgXAfyV3ccMuRN5BbFgeofs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mVv31qY8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mVv31qY8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1C951F00AC4; Fri, 28 Aug 2026 04:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892730; bh=E3TFmQytdIgRWxRaZoVO/PuRJdDmyjSLZJjE10JFygM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mVv31qY8DCgFe0ybRcjigI+Ymfi92V1l1GyovUQoE2afg9eJnddx89tlQ5uvvb6yf RBny/rDL7L+0MkCweBIHzwCF9vjNs33utmpCRLYZ/NzdojNVcxWg6MPw5WtEk1PsdC AQAMYs9EzWCvPqSsk0+FPvFBL1mZ1M+yK8AA1aCbLRj94heoNkyrm6v4/Y3PK5LzEe xgH4o/XlPl78f+ABUpDzZaWQ+JoABG2aayxR+ENDNpMt5HR/kZ7Rp5QzyY2u4bFm8u I3+fXwc3k9Sfg5h6ZZhdiacnIW3ZG2Q53cx90q1yfvav83bj2IH3BvWx0MTxFYI2dY dnhr6ynlu3jlA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 19/27] x86/xen: Make xen_start_kernel() noreturn Date: Thu, 27 Aug 2026 21:51:48 -0700 Message-ID: <90d7c1943218be3c95b005e7b0fd004b9c78dbdc.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" startup_xen() calls xen_start_kernel() with the assumption that it never returns, otherwise it would fall off the end of SYM_CODE_END(), triggering undefined behavior. But startup_xen() actually can return if 'si' is NULL. That doesn't seem to be possible, so drop the check and mark xen_start_kernel() __noreturn. A NULL 'si' would now fault on the first xen_start_info dereference, which is at least a more deterministic way to crash. Now that the function can no longer return, objtool can derive its noreturn attribute directly and the noreturns.h entry can be removed. Signed-off-by: Josh Poimboeuf --- arch/x86/xen/enlighten_pv.c | 5 +---- arch/x86/xen/xen-ops.h | 2 +- tools/objtool/noreturns.h | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 2c64b388f6164..8ec78df9d1d5b 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -1325,15 +1325,12 @@ static void __init xen_domu_set_legacy_features(voi= d) extern void early_xen_iret_patch(void); =20 /* First C function to be called on Xen boot */ -asmlinkage __visible void __init xen_start_kernel(struct start_info *si) +asmlinkage __visible void __init __noreturn xen_start_kernel(struct start_= info *si) { struct physdev_set_iopl set_iopl; unsigned long initrd_start =3D 0; int rc; =20 - if (!si) - return; - clear_bss(); =20 xen_start_info =3D si; diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index dc265bdda24d7..20e8fb6244426 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -73,7 +73,7 @@ void xen_force_evtchn_callback(void); =20 void xen_pv_pre_suspend(void); void xen_pv_post_suspend(int suspend_cancelled); -void xen_start_kernel(struct start_info *si); +void __noreturn xen_start_kernel(struct start_info *si); =20 void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags); void xen_init_mmu_ops(void); diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index 01c94f20d1818..c4b93fc6e6299 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -21,4 +21,3 @@ NORETURN(panic) NORETURN(vpanic) NORETURN(rust_helper_BUG) NORETURN(sev_es_terminate) -NORETURN(xen_start_kernel) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 331E13D7A07; Fri, 28 Aug 2026 04:52:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892732; cv=none; b=E0S4zCt/h+mSz7o5WRxzIQUzU0HXrIfXm2kZ59fwzcUYHVziy+GV75q62zHMVoRxgXzOBqSuyZz/DfQB39umb9HLwjKZeU5WqlTIioc4awA/HbQb2UISYv/U+QGbeNJklfVJcz5UwEF1c4w2KYbKDlxRI/HjSmgPNNLCMlZ0JBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892732; c=relaxed/simple; bh=ptdxD3ltbTU9yyHf60G/Gxo4hD4NaDgaTY3yvGbwtJY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LwPRnKOHauLa2peU+V4vTpyeqhi29EbMyIY2GgY+O0U1c2Yj0P6U1Wj8fkiv0qWxy5dh/a6dPZrEVnekcbJGRQymqizVxWH1dM6Q7j3MzO90iKn2s3kXOLK4esLb/Xs1HwRPKAZEwxWCq6vqZOgSl2A5oxLt11vUwarWqbpYDJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TCX8kUUg; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TCX8kUUg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C9591F00A3A; Fri, 28 Aug 2026 04:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892731; bh=/Ejjzh18FtlEZ4Nvf6C2vwJeEz1OHCszBYeKZ5lVR84=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TCX8kUUgotM3eHaQdQjNuLGPd0fuKTsG4lORqoBVPCf/5FVn5K4u8vG0XmrZ3yBKZ hnaFJL1N0NSD8SXYQXqyMEn399TD90vv74kZCxc8uMsJQHB2J1l7jr7KwKMmYR29/D uspOx+TodTiJdDN2burAyHvQlBrWu4yB9J2RowjWbPfExCukdjm0p5NAesSpcyljYI +/a3dlG4kyZ2Fi44u/Ogm/fF8wCpmobu74nDYu5cgbnh5BI7mRFZolaentnSfyjX+C KnINauJ+nAIAMKe+TYmv8o8v2SLgdnc/vGO8tV/bvOL5YTSHVYA64zZDyCfuit+xPf 4C5B/ItciaN1A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 20/27] x86/boot: Rework how pi startup symbols get exposed to vmlinux Date: Thu, 27 Aug 2026 21:51:49 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" objcopy prefixes every symbol in arch/x86/boot/startup/ with __pi_, which confines the startup code so that it can only reach other startup code or symbols deliberately exposed to it with SYM_PIC_ALIAS(). Nine of its functions are called by the core kernel at runtime. They are made accessible to the kernel by exports.h, which is included by vmlinux.lds.S to create aliases for each one. That's problematic for objtool running on vmlinux.o, which is built before the linker script runs, so the call sites to the startup symbols are undefined, so objtool can't see their actual destinations functions. Instead of making aliases at link time, rename the needed symbols using a second objcopy pass so they're visible in vmlinux.o. That also means objtool can now detect that sev_es_terminate() is noreturn, so it can be removed from noreturns.h. Signed-off-by: Josh Poimboeuf --- arch/x86/boot/startup/Makefile | 14 ++++++++++---- arch/x86/boot/startup/exports.h | 14 -------------- arch/x86/boot/startup/unprefix.syms | 13 +++++++++++++ arch/x86/kernel/vmlinux.lds.S | 2 -- tools/objtool/noreturns.h | 1 - 5 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 arch/x86/boot/startup/exports.h create mode 100644 arch/x86/boot/startup/unprefix.syms diff --git a/arch/x86/boot/startup/Makefile b/arch/x86/boot/startup/Makefile index ab6e9970d4f4e..5255abe2bd77f 100644 --- a/arch/x86/boot/startup/Makefile +++ b/arch/x86/boot/startup/Makefile @@ -41,12 +41,18 @@ $(pi-objs): objtool-args =3D $(if $(CONFIG_OBJTOOL_DEFE= RRED),--dry-run,$(objtool-a # # Confine the startup code by prefixing all symbols with __pi_ (for positi= on # independent). This ensures that startup code can only call other startup -# code, or code that has explicitly been made accessible to it via a symbol -# alias. +# code. # +# The few pi symbols which are allowed to be called by the core kernel are= then +# un-prefixed back to their original name using a second objcopy. +# +quiet_cmd_pi_objcopy =3D $(quiet_cmd_objcopy) + cmd_pi_objcopy =3D $(cmd_objcopy) && \ + $(OBJCOPY) --redefine-syms=3D$(src)/unprefix.syms $@ + $(obj)/%.pi.o: OBJCOPYFLAGS :=3D --prefix-symbols=3D__pi_ -$(obj)/%.pi.o: $(obj)/%.o FORCE - $(call if_changed,objcopy) +$(obj)/%.pi.o: $(obj)/%.o $(src)/unprefix.syms FORCE + $(call if_changed,pi_objcopy) =20 targets +=3D $(obj-y) obj-y :=3D $(patsubst %.o,%.pi.o,$(obj-y)) diff --git a/arch/x86/boot/startup/exports.h b/arch/x86/boot/startup/export= s.h deleted file mode 100644 index 01d2363dc445f..0000000000000 --- a/arch/x86/boot/startup/exports.h +++ /dev/null @@ -1,14 +0,0 @@ - -/* - * The symbols below are functions that are implemented by the startup cod= e, - * but called at runtime by the SEV code residing in the core kernel. - */ -PROVIDE(early_set_pages_state =3D __pi_early_set_pages_state); -PROVIDE(early_snp_set_memory_private =3D __pi_early_snp_set_memory_private= ); -PROVIDE(early_snp_set_memory_shared =3D __pi_early_snp_set_memory_shared); -PROVIDE(get_hv_features =3D __pi_get_hv_features); -PROVIDE(sev_es_terminate =3D __pi_sev_es_terminate); -PROVIDE(snp_cpuid =3D __pi_snp_cpuid); -PROVIDE(snp_cpuid_get_table =3D __pi_snp_cpuid_get_table); -PROVIDE(svsm_issue_call =3D __pi_svsm_issue_call); -PROVIDE(svsm_process_result_codes =3D __pi_svsm_process_result_codes); diff --git a/arch/x86/boot/startup/unprefix.syms b/arch/x86/boot/startup/un= prefix.syms new file mode 100644 index 0000000000000..fd80adf558a51 --- /dev/null +++ b/arch/x86/boot/startup/unprefix.syms @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 +# The symbols below are functions that are implemented by the startup code, +# but called at runtime by the SEV code residing in the core kernel. Undo= the +# __pi_ prefixing so the core kernel can call them. +__pi_early_set_pages_state early_set_pages_state +__pi_early_snp_set_memory_private early_snp_set_memory_private +__pi_early_snp_set_memory_shared early_snp_set_memory_shared +__pi_get_hv_features get_hv_features +__pi_sev_es_terminate sev_es_terminate +__pi_snp_cpuid snp_cpuid +__pi_snp_cpuid_get_table snp_cpuid_get_table +__pi_svsm_issue_call svsm_issue_call +__pi_svsm_process_result_codes svsm_process_result_codes diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 74e336d7f9dd2..3d6f4634475cf 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -533,5 +533,3 @@ xen_elfnote_entry_value =3D xen_elfnote_phys32_entry_value =3D ABSOLUTE(xen_elfnote_phys32_entry) + ABSOLUTE(pvh_start_xen - LOAD_OFFSET= ); #endif - -#include "../boot/startup/exports.h" diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index c4b93fc6e6299..2dce56030b980 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -20,4 +20,3 @@ NORETURN(mpt_halt_firmware) NORETURN(panic) NORETURN(vpanic) NORETURN(rust_helper_BUG) -NORETURN(sev_es_terminate) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA6943DAAA0; Fri, 28 Aug 2026 04:52:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892733; cv=none; b=GnpjAH92JNSi0+T3pDe9YdDCjxGZPVnT0RP6nSuA2SWna6uAeeSldG/IW0G/qdzcC5hNBhU0Y2iTmo8671AoTiONQkvpQTRXiEBn8UhQnKfTpRQK7q6Clvpj+C50UEF/Lxz47Ip+KAvhltcsD0FrFLvbRBDOMmKBvi9gWZQX5eA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892733; c=relaxed/simple; bh=ae0liAwEjTv93X8TeRVVErNMqiemfErxQ5+4BAVEeAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=owP5HTtWOpOFQYo9lR4bNfNuk9doehE2aLzKiS8/8ttPKzFJSq6Rt2vJmbhiUqPSz1C46O1XM597EZDwsz7/kjtK/FrQDUgLT/RulxWfSfWsF/ks6WOIq86rTs9uInvs+tp4gd73Zq6aoRnymsK2qMxBNBw/f04D3MAMf2KpJpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WIZ/TgGY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WIZ/TgGY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43E7D1F00A3F; Fri, 28 Aug 2026 04:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892731; bh=NXtBeCwx/teWzDc/2bLnx+HQVge3yMIgNBqFbYj3xYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WIZ/TgGYSQtCmlpMlW7y2J5D3sSA1njAGnDMyfWvDKq9rnhKSqNGWSwRzUMYWtW0j rhjKiEoUTq+0jLnxCkb9cMBVNxWBZZozng6srMgD66FGh+SFj4db4voFWiYfXhQrbZ p2ZX+vw0ZFC26kPiX32cr1xhfU1aoymvjY31wcnE18/O8eBSao0QYfXVs/rax+o1rf bqnCl1VybTbuMh7EnTEgBOW+m+5TdzPRt+NGJOuQPv4T8yGIQ3UFURGxwsnqVgF/OA 89TBQle88GtMoaWQL2T3vJ9KiTPACujcxHzFOpcWKRyzDHuKJ8QwE+0cCVw32r92i3 JWO2EjrUBA6xQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 21/27] objtool: Fix noreturn detection for non-sibling jumps to SYM_CODE Date: Thu, 27 Aug 2026 21:51:50 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Objtool doesn't consider a jump to be a sibling call if the destination isn't a function, so srso_alias_untrain_ret()'s jump to srso_alias_return_thunk() is ignored by objtool and the former is falsely classified as noreturn. Change the noreturn detection to consider such cases as effectively sibling calls, except for one known exception: jumping to .altinstr_aux. Currently the misclassification is harmless: dead ends aren't marked when calling a noreturn from an alternative replacement (CALL_UNTRAIN_RET), they're ignored by rethunk validation, and ORC generation relies on unwind hints in the SRSO code regardless. Fix it in the name of robustness and in preparation for a subsequent patch which generates a list of exported noreturns. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index c55851ec389cd..d27303220c29d 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -264,8 +264,22 @@ static bool might_return(struct objtool_file *file, st= ruct symbol *func) if (insn->type =3D=3D INSN_RETURN) return true; =20 - if (!is_sibling_call(insn)) + if (!is_sibling_call(insn)) { + /* + * Assume a jump into a non-function eventually returns + * to the original caller one way or another, e.g., the + * jump in srso_alias_untrain_ret(). + * + * .altinstr_aux is an exception, cpu_feature_enabled() + * jumps there and then right back. + */ + if (is_static_jump(insn) && insn->jump_dest && + !insn_func(insn->jump_dest) && + strcmp(insn->jump_dest->sec->name, ".altinstr_aux")) + return true; + continue; + } =20 dest =3D insn_call_dest(insn); if (!dest || !is_noreturn(dest)) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72BBB3DCDAC; Fri, 28 Aug 2026 04:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892733; cv=none; b=V92yFWLSJSrWYyFk9GRKDv85xxWBCuvYHNyqFNJur6uE4juLNoWugV/aMUBU4wNZOrEk7YcP+c5wJKTfsvIr8xEELDL2A9pwvZ7uJk8TC1ej88IwlJwJYg5LLFLt6uMejO7KXviW03tC2zPcHRJlXfme7/cthhToYTF65TO1RJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892733; c=relaxed/simple; bh=ujeEIEMwjs/4fR1JkO8/KKz0kIVbJUN7MkzbmDnVGAk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dgczN9izjUD8/lGwt+8oHmFDgkIHRYSinXtWS8SzSWSoJ9nXlZmQVgCbP7pcFtCm6mvSSdx64pIAqBXLo2WmfJAw54xhc0fNVNBBZx/wvfHbM0DDX3PwdVQK/V6TuJDqfvnnPM33fqQ0XJABeTq1UmelqYWmASgwdq9ueyrELEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ljTLdyh4; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ljTLdyh4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E03691F00A3E; Fri, 28 Aug 2026 04:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892732; bh=ZJmzcTeD+I+Tn3JWJgXiPZsKk0Ac7WHrXioao5XTlL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ljTLdyh4FToTTqubVVH7W5BdFXjPxTEWkqpCS2obMkktQwjfLAB9TkbJNhiTugi9V xS2/AsdM9ekGv6732xKBeFueKtoOEcTBeTQtwqQE3Nmgi2rertA1ZjnhhGWvg99sy/ InbZ9eXMsXB/KuUPDKjuzgpDhOW+UIFfZY8UFG0vQxHF+6Cs664bu7ZhlleK1QFHfq Kg82O+zCQbTFyIN9/fBAPPQF26LEeWi3l7Yy45kU3Orom+KUDBJxkVdMzMei2jpay9 gOimIhrKtUt3N7esf3Gmhq/KDKpWDP57iiOjv/45Soa8OECjCFfhFvbF4V00v8inQm Pwj94zKsvfuCQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 22/27] objtool: Add options to write/read exported noreturns to/from a file Date: Thu, 27 Aug 2026 21:51:51 -0700 Message-ID: <109a1033440e9bb33a73dc42599049f18f60df1c.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add --noreturns-write which can be used to write vmlinux's exported noreturns to a file, and --noreturn-read which can be used to read them when running objtool on a module. Signed-off-by: Josh Poimboeuf --- tools/objtool/builtin-check.c | 12 ++ tools/objtool/check.c | 148 +++++++++++++++++++++++- tools/objtool/include/objtool/builtin.h | 2 + tools/objtool/include/objtool/elf.h | 1 + 4 files changed, 162 insertions(+), 1 deletion(-) diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 75b11dc85010e..c4c4210f84662 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -101,6 +101,8 @@ static const struct option check_options[] =3D { OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel modu= le"), OPT_BOOLEAN(0, "mnop", &opts.mnop, "nop out mcount call sites"), OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachab= le instruction' warnings"), + OPT_STRING(0, "noreturns-read", &opts.noreturns_read, "file", "read exp= orted noreturns from a file"), + OPT_STRING(0, "noreturns-write", &opts.noreturns_write, "file", "write = exported noreturns to a file"), OPT_STRING('o', "output", &opts.output, "file", "output file name"), OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section address= es in warnings"), OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"), @@ -180,6 +182,16 @@ static bool opts_valid(void) return false; } =20 + if (opts.noreturns_write && !opts.link) { + ERROR("--noreturns-write requires --link"); + return false; + } + + if (opts.noreturns_write && !opts.stackval && !opts.orc && !opts.uaccess)= { + ERROR("--noreturns-write requires --stackval, --orc, or --uaccess"); + return false; + } + if (opts.disas || opts.hack_jump_label || opts.hack_noinstr || diff --git a/tools/objtool/check.c b/tools/objtool/check.c index d27303220c29d..086e8f9eca867 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -339,6 +339,120 @@ static void detect_noreturns(struct objtool_file *fil= e) } } =20 +static bool noreturns_changed(const char *buf, size_t len) +{ + bool changed =3D true; + char *old =3D NULL; + FILE *fp; + + fp =3D fopen(opts.noreturns_write, "r"); + if (!fp) + return true; + + old =3D malloc(len + 1); + if (!old) + goto out; + + if (fread(old, 1, len + 1, fp) !=3D len) + goto out; + + if (memcmp(old, buf, len)) + goto out; + + changed =3D false; + +out: + free(old); + fclose(fp); + return changed; +} + +/* + * This is called for vmlinux.o. Write the vmlinux.o noreturn list to a f= ile + * so it can be read in module objtool runs by read_noreturns(). + */ +static int write_noreturns(struct objtool_file *file) +{ + struct symbol *func; + char *buf, *pos; + size_t len =3D 0; + FILE *fp; + + for_each_sym(file->elf, func) { + if (is_noreturn(func) && func->exported) + len +=3D strlen(func->name) + 1; + } + + buf =3D malloc(len + 1); + if (!buf) { + ERROR_GLIBC("malloc"); + return -1; + } + + pos =3D buf; + for_each_sym(file->elf, func) { + if (is_noreturn(func) && func->exported) + pos +=3D sprintf(pos, "%s\n", func->name); + } + + /* + * Only write the file when the contents have change to avoid relinking + * all the modules unnecessarily. + */ + if (!noreturns_changed(buf, len)) { + free(buf); + return 0; + } + + fp =3D fopen(opts.noreturns_write, "w"); + if (!fp) { + ERROR_GLIBC("fopen"); + return -1; + } + + if (fwrite(buf, 1, len, fp) !=3D len) { + ERROR_GLIBC("fwrite"); + return -1; + } + + free(buf); + + if (fclose(fp)) { + ERROR_GLIBC("fclose"); + return -1; + } + + return 0; +} + +/* + * This is called for modules. Read the noreturn list generated by the + * vmlinux.o pass and mark the corresponding undefined symbols noreturn. + */ +static int read_noreturns(struct objtool_file *file) +{ + char line[SYM_NAME_LEN]; + struct symbol *func; + FILE *fp; + + fp =3D fopen(opts.noreturns_read, "r"); + if (!fp) { + ERROR("can't open '%s'", opts.noreturns_read); + return -1; + } + + while (fgets(line, sizeof(line), fp)) { + line[strcspn(line, "\n")] =3D '\0'; + + func =3D find_global_symbol_by_name(file->elf, line); + if (func && is_undef_sym(func)) + func->_noreturn =3D 1; + } + + fclose(fp); + return 0; +} + static void init_cfi_state(struct cfi_state *cfi) { int i; @@ -2236,6 +2350,24 @@ static int add_jump_table_alts(struct objtool_file *= file) return 0; } =20 +static void read_exports(struct objtool_file *file) +{ + struct section *sec; + struct symbol *func; + struct reloc *reloc; + + sec =3D find_section_by_name(file->elf, ".export_symbol"); + if (!sec || !sec->rsec) + return; + + for_each_reloc(sec->rsec, reloc) { + func =3D find_func_by_offset(reloc->sym->sec, + reloc->sym->offset + reloc_addend(reloc)); + if (func) + func->exported =3D 1; + } +} + static void set_func_state(struct cfi_state *state) { state->cfa =3D initial_func_cfi.cfa; @@ -2720,8 +2852,10 @@ int decode_file(struct objtool_file *file) * both validate_functions() and validate_noinstr_sections() -- and by * validate_unret(). */ - if (validate_branch_enabled() || opts.noinstr || opts.unret) + if (validate_branch_enabled() || opts.noinstr || opts.unret) { + read_exports(file); detect_noreturns(file); + } =20 if (read_unwind_hints(file)) return -1; @@ -4888,6 +5022,12 @@ int check(struct objtool_file *file) objtool_disas_ctx =3D disas_ctx; } =20 + if (opts.noreturns_read) { + ret =3D read_noreturns(file); + if (ret) + goto out; + } + ret =3D decode_file(file); if (ret) goto out; @@ -4995,6 +5135,12 @@ int check(struct objtool_file *file) goto out; } =20 + if (opts.noreturns_write && !opts.dryrun) { + ret =3D write_noreturns(file); + if (ret) + goto out; + } + if (opts.stats) { printf("nr_insns_visited: %ld\n", nr_insns_visited); printf("nr_cfi: %ld\n", nr_cfi); diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/includ= e/objtool/builtin.h index 349690bb1c50e..fb33d57a54c95 100644 --- a/tools/objtool/include/objtool/builtin.h +++ b/tools/objtool/include/objtool/builtin.h @@ -41,6 +41,8 @@ struct opts { bool mnop; bool module; bool no_unreachable; + const char *noreturns_read; + const char *noreturns_write; const char *output; bool sec_address; bool stats; diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index 0e3593d993ac8..adf6e1322c6df 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -100,6 +100,7 @@ struct symbol { u8 fake : 1; u8 _noreturn : 1; u8 ignore_noreturn : 1; + u8 exported : 1; struct list_head pv_target; struct reloc *relocs; struct section *group_sec; --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13DC23C1998; Fri, 28 Aug 2026 04:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892734; cv=none; b=HFpAlbDtep0fnAnvnUS4mKtIR3qu9+U29gHbMyvXcwkcPD54/YTCrM9n/IqBZPzLSncvo7g8+lQztAEr5vT2zuvgByvYyriscrHJ3bSp7ny0yn0UXDQjM/bB3dMgBcsm7A/gMEdJ0b+dI22eB3MjZrZZJj65P6c7P/eppqjzHYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892734; c=relaxed/simple; bh=5T1ameSdsAHZ5Y+yRdo9Ga1xXBqnuQTxHwMu5VGkXHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BfacypJndC7s7I2vKik/OYW1+gnBgqrId2p/hAyXLaQVs+ilxf/ZkKEfvQHC922uiQmjkLnAS7gj4nAU5+ziSz7KyeGCYUnmMj/XnFsEKu9UgJf+eZOMsrDN4lfm5IWLGjpuD4xrzarjtu/NqjVzngBz+TamXfYdmBrIaisaJ5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cH69+7K/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cH69+7K/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84C251F000E9; Fri, 28 Aug 2026 04:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892733; bh=VQGM2RxgTvTiX2GStLq7PaSzjdRxKf+EhyoZDCqKW8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cH69+7K/8+4hQubATdoSa57CEzb+d60zF7e0EXIh/Mg9L8u2FJHj/LOkxVw+4n2E+ 4ap+9vSXfLJQWN6GZEjloL2LfjS4aN7gssePDd/woXp1I+T94E3V52dGTH7j91A4WU mE0yvqAc9fwvry+BhwcQTPLQ/0GxRyYn0YoX825ooFqfbr/JN82RM64sVJfOyKOOeZ YtjVbi3Z07y4TYNQkP5bvX8UowH/87juHHIS5sg1bjZd6YvGstEmycI0YTX66vGXHS 5TWwN94jnMydt7mpV4uksD1DPQONYkagP+8b8rW/LBntm0PBerb+k1WxXa1BcelCOp SoPaCR9saQl7g== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 23/27] kbuild: Do the per-module objtool pass right before linking Date: Thu, 27 Aug 2026 21:51:52 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With CONFIG_OBJTOOL_CONTROL_FLOW, the objtool pass on vmlinux.o is going to be generating a list of its exported noreturns which will then be read by the modules' objtool pass, so there will need to be a build dependency between them. In preparation for that, run objtool right before the module link so its no longer done on the descend in the deferred case. Signed-off-by: Josh Poimboeuf --- scripts/Makefile.build | 31 +++++++++++++++---------------- scripts/Makefile.modfinal | 20 +++++++++++++++----- scripts/livepatch/klp-build | 4 ++-- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 84ef12f784330..9e672979a976c 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -270,15 +270,21 @@ cmd_record_mcount =3D $(if $(findstring $(strip $(CC_= FLAGS_FTRACE)),$(_c_flags)), $(sub_cmd_record_mcount)) endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT =20 -# 'OBJECT_FILES_NON_STANDARD :=3D y': skip objtool checking for a directory -# 'OBJECT_FILES_NON_STANDARD_foo.o :=3D 'y': skip objtool checking for a f= ile -# 'OBJECT_FILES_NON_STANDARD_foo.o :=3D 'n': override directory skip for a= file - +ifdef CONFIG_OBJTOOL +# +# NOTE: these variables are deprecated, and have no effect when +# CONFIG_OBJTOOL_DEFERRED is enabled. Objtool-allergic code can instead be +# marked with STACK_FRAME_NON_STANDARD() or ANNOTATE_*(). +# +# 'OBJECT_FILES_NON_STANDARD :=3D y': skip objtool checking for a direct= ory +# 'OBJECT_FILES_NON_STANDARD_foo.o :=3D 'y': skip objtool checking for a= file +# 'OBJECT_FILES_NON_STANDARD_foo.o :=3D 'n': override directory skip for= a file +# is-standard-object =3D $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$= (target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),$(is-kernel-object)) =20 -ifdef CONFIG_OBJTOOL -$(obj)/%.o: private objtool-enabled =3D $(if $(is-standard-object),$(if $(= CONFIG_OBJTOOL_DEFERRED),$(is-single-obj-m),y)) -endif +# Enable per-TU objtool for !CONFIG_OBJTOOL_DEFERRED +$(obj)/%.o: private objtool-enabled =3D $(if $(CONFIG_OBJTOOL_DEFERRED),,$= (if $(is-standard-object),y)) +endif # CONFIG_OBJTOOL =20 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) cmd_warn_shared_object =3D $(if $(word 2, $(modname-multi)),$(warning $(kb= uild-file): $*.o is added to multiple modules: $(modname-multi))) @@ -495,17 +501,10 @@ $(obj)/lib.a: $(lib-y) FORCE $(call if_changed,ar) =20 quiet_cmd_ld_multi_m =3D LD [M] $@ - cmd_ld_multi_m =3D $(LD) $(ld_flags) -r -o $@ @$< $(cmd_objtool) + cmd_ld_multi_m =3D $(LD) $(ld_flags) -r -o $@ @$< =20 -define rule_ld_multi_m - $(call cmd_and_savecmd,ld_multi_m) - $(call cmd,gen_objtooldep) -endef - -$(multi-obj-m): private objtool-enabled :=3D $(CONFIG_OBJTOOL_DEFERRED) -$(multi-obj-m): private part-of-module :=3D y $(multi-obj-m): %.o: %.mod FORCE - $(call if_changed_rule,ld_multi_m) + $(call if_changed,ld_multi_m) $(call multi_depend, $(multi-obj-m), .o, -objs -y -m) =20 # Add intermediate targets: diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 01a37ec872b90..56b4227cc6863 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -32,11 +32,18 @@ ifneq ($(WARN_ON_UNUSED_TRACEPOINTS),) cmd_check_tracepoint =3D $(objtree)/scripts/tracepoint-update --module $<; endif =20 +$(modules:%.o=3D%.ko): private objtool-enabled =3D $(CONFIG_OBJTOOL_DEFERR= ED) + +mod-objtool =3D $(if $(objtool-enabled),$(objtool) $(objtool-args) -o $@.o= $< ;) +mod-obj =3D $(if $(objtool-enabled),$@.o,$<) + quiet_cmd_ld_ko_o =3D LD [M] $@ cmd_ld_ko_o =3D \ + $(mod-objtool) \ $(LD) -r $(KBUILD_LDFLAGS) \ $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ - -T $(objtree)/scripts/module.lds -o $@ $(filter %.o, $^) + -T $(objtree)/scripts/module.lds -o $@ \ + $(mod-obj) $(filter-out $<, $(filter %.o, $^)) =20 quiet_cmd_btf_ko =3D BTF [M] $@ cmd_btf_ko =3D \ @@ -46,12 +53,15 @@ quiet_cmd_btf_ko =3D BTF [M] $@ $(CONFIG_SHELL) $(srctree)/scripts/gen-btf.sh --btf_base $(objtree)/vmli= nux $@; \ fi; =20 +define rule_ld_ko_o + +$(call cmd_and_savecmd,ld_ko_o) + +$(call cmd,gen_objtooldep) + +$(if $(CONFIG_DEBUG_INFO_BTF_MODULES),$(if $(newer-prereqs),$(call cmd,b= tf_ko))) +endef + # Re-generate module BTFs if either module's .ko or vmlinux changed %.ko: %.o %.mod.o .module-common.o $(objtree)/scripts/module.lds $(and $(C= ONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(objtree)/vmlinux) FORCE - +$(call if_changed,ld_ko_o) -ifdef CONFIG_DEBUG_INFO_BTF_MODULES - +$(if $(newer-prereqs),$(call cmd,btf_ko)) -endif + $(call if_changed_rule,ld_ko_o) +$(call cmd,check_tracepoint) =20 targets +=3D $(modules:%.o=3D%.ko) $(modules:%.o=3D%.mod.o) .module-common= .o diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build index b52a8489d9f67..5237bad90f2cb 100755 --- a/scripts/livepatch/klp-build +++ b/scripts/livepatch/klp-build @@ -600,7 +600,7 @@ copy_orig_objects() { xtrace_save "copying original objects" for _file in "${files[@]}"; do local rel_file=3D"${_file/.ko/.o}" - local file=3D"$PWD/$rel_file" + local file=3D"$PWD/${_file/%.ko/.ko.o}" local orig_file=3D"$ORIG_DIR/$rel_file" local orig_dir=3D"$(dirname "$orig_file")" =20 @@ -636,7 +636,7 @@ copy_patched_objects() { xtrace_save "copying changed objects" for _file in "${files[@]}"; do local rel_file=3D"${_file/.ko/.o}" - local file=3D"$PWD/$rel_file" + local file=3D"$PWD/${_file/%.ko/.ko.o}" local orig_file=3D"$ORIG_DIR/$rel_file" local patched_file=3D"$PATCHED_DIR/$rel_file" local patched_dir=3D"$(dirname "$patched_file")" --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DCF13E022B; Fri, 28 Aug 2026 04:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892735; cv=none; b=W26NriFn5hz6o14+ccb2INFsSFMnEzU/pppqWKLU442Xhom+6Gu0oYN7i+pnM/7vms/MDlq0Peo59Xw3Yawmn1aGNixKMlTJ8T/CL+LLfAFKdFnVg6Kld3fPwfEVTLT1Sqq4a3YozyTN71zuJV2MTrGGhI5h+rdyktKyZZWkuDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892735; c=relaxed/simple; bh=xk9c1i7C96y8hCSX0H4ZfjMIbQHKNlSLtrsihaxED+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZwZBVpR1LWNMTPkDwtFA/hN8Rb7NTJLIvz/e9SGUYAV/fsP2Zr7KbsUH5CHhnavTQlLS8njJ/vS+coId6FpeA5biJs9HlB3C2Bw1WZ1HWN/zcwhTtv3G8OtZXOiUiwlG6xl0+NRXDAzQJu+Xq37IBkalehh+2DfKkuv+CEFaI3o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=drVRrQRu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="drVRrQRu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22C2F1F00A3A; Fri, 28 Aug 2026 04:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892733; bh=ZzXUQOr20qco54eXF7Qwm0XoeNWx0ihDAkCp/KM0QWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=drVRrQRu0hVW4p2M3tdEabkTzNemDqjgbtd95mKyosO8avSGnFnLVRCK9P8Tlz+SM HQkFcLAcXR7rcoFmNiXpYYq+NqDcNygkpftHdD6bxbxLSUL64v0UfbZFxk+ZQr+Z1/ QM0V6Qx4r1urTIIrptUKuaoVniKAQT+rFQxLHsprzkRUB4LSd385nThRREeRTFYmY4 xGWoCX+DI+wj9JMMPOkKhbC+raZpkBwQ1K0oBiu/KVeEybQ86VZZ7bJWwCYYAMlNEW Imzq6eMYiJcbApuiu8wfmBxNomWxjt7CUhLklPwx1nzPwjNwrIE0e+8tyWcXmPNeTT L1NwnLwpXAV+g== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 24/27] kbuild: Generate the noreturn list and validate modules against it Date: Thu, 27 Aug 2026 21:51:53 -0700 Message-ID: <48390d44cc3796932e1eef180b08259a33121f74.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Most of the remaining hard-coded noreturn functions are exported symbols which live in vmlinux.o. The objtool vmlinux.o pass can detect them automatically, but modules can't. Instead of hard-coding them in noreturns.h, dynamically generate the list in a new scripts/noreturns.builtin file, which objtool on modules can then read. That allows most of the remaining hard-coded noreturn entries to go away, including the Rust ones. Note this means that modules need to be linked after vmlinux.o has been built and analyzed by objtool. Objtool running on OOT modules will also need to read the generated file. Its location in scripts/ should ensure it gets installed with kernel build files automatically. Signed-off-by: Josh Poimboeuf --- Makefile | 8 +++++ scripts/.gitignore | 1 + scripts/Makefile.modfinal | 15 +++++++-- scripts/Makefile.vmlinux_o | 2 ++ tools/objtool/Documentation/objtool.txt | 8 ++--- tools/objtool/check.c | 44 ------------------------- tools/objtool/noreturns.h | 17 ++-------- 7 files changed, 29 insertions(+), 66 deletions(-) diff --git a/Makefile b/Makefile index 902f3f3d54b71..1c443309dbc4d 100644 --- a/Makefile +++ b/Makefile @@ -1708,6 +1708,13 @@ KBUILD_BUILTIN :=3D y modules: vmlinux endif =20 +# Objtool for modules (run before module link) needs to come after objtool= for +# vmlinux.o so it can read the generated exported noreturns file. +ifdef CONFIG_OBJTOOL_CONTROL_FLOW +KBUILD_BUILTIN :=3D y +modules: vmlinux.o +endif + modules: modules_prepare =20 # Target to prepare building external modules @@ -1738,6 +1745,7 @@ MRPROPER_FILES +=3D include/config include/generated = \ debian snap tar-install PKGBUILD pacman \ .config .config.old .version \ Module.symvers \ + scripts/noreturns.builtin \ certs/signing_key.pem \ certs/x509.genkey \ vmlinux-gdb.py \ diff --git a/scripts/.gitignore b/scripts/.gitignore index 4215c2208f7e4..15d99dfd7c936 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -5,6 +5,7 @@ /insert-sys-cert /kallsyms /module.lds +/noreturns.builtin /recordmcount /rustdoc_test_builder /rustdoc_test_gen diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 56b4227cc6863..23b07ad7eb9bd 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -32,6 +32,15 @@ ifneq ($(WARN_ON_UNUSED_TRACEPOINTS),) cmd_check_tracepoint =3D $(objtree)/scripts/tracepoint-update --module $<; endif =20 +ifdef CONFIG_OBJTOOL_CONTROL_FLOW +noreturns-builtin :=3D $(wildcard $(objtree)/scripts/noreturns.builtin) +ifeq ($(noreturns-builtin),) +$(warning scripts/noreturns.builtin is missing) +else +objtool-args +=3D --noreturns-read=3D$(noreturns-builtin) +endif +endif + $(modules:%.o=3D%.ko): private objtool-enabled =3D $(CONFIG_OBJTOOL_DEFERR= ED) =20 mod-objtool =3D $(if $(objtool-enabled),$(objtool) $(objtool-args) -o $@.o= $< ;) @@ -59,8 +68,10 @@ define rule_ld_ko_o +$(if $(CONFIG_DEBUG_INFO_BTF_MODULES),$(if $(newer-prereqs),$(call cmd,b= tf_ko))) endef =20 -# Re-generate module BTFs if either module's .ko or vmlinux changed -%.ko: %.o %.mod.o .module-common.o $(objtree)/scripts/module.lds $(and $(C= ONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(objtree)/vmlinux) FORCE +# Re-generate module BTFs if either module's .ko or vmlinux changed. +# Re-run module objtool if the generated noreturn list changed. +%.ko: %.o %.mod.o .module-common.o $(objtree)/scripts/module.lds $(noretur= ns-builtin) \ + $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),$(objtree)/= vmlinux) FORCE $(call if_changed_rule,ld_ko_o) +$(call cmd,check_tracepoint) =20 diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index df1e3584883e6..9c60a4918a756 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -37,6 +37,8 @@ objtool-enabled :=3D $(CONFIG_OBJTOOL_DEFERRED) =20 vmlinux-objtool-args-y +=3D $(objtool-args-y) =20 +vmlinux-objtool-args-$(CONFIG_OBJTOOL_CONTROL_FLOW) +=3D --noreturns-write= =3Dscripts/noreturns.builtin + vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) +=3D --noinstr \ $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_S= RSO)), --unret) =20 diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docume= ntation/objtool.txt index 9e97fc25b2d8a..c7ebfb9a8ca6b 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -334,8 +334,7 @@ the objtool maintainers. =20 The call from foo() to bar() doesn't return, but bar() is incorrectly annotated. A noreturn function must be marked __noreturn in both its - declaration and its definition, and must have a NORETURN() annotation - in tools/objtool/noreturns.h. + declaration and its definition. =20 =20 4. file.o: warning: objtool: func(): can't find starting instruction @@ -393,9 +392,8 @@ the objtool maintainers. reasons for this: =20 a) funcA()'s last instruction is a call to a "noreturn" function like - panic(). In this case the noreturn function needs to be added to - objtool's hard-coded global_noreturns array. Feel free to bug the - objtool maintainer, or you can submit a patch. + panic(), and objtool doesn't know that function never returns. See + warning 3 above. =20 b) funcA() uses the unreachable() annotation in a section of code that is actually reachable. diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 086e8f9eca867..583d86220e040 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -176,47 +176,6 @@ static bool is_sibling_call(struct instruction *insn) return (is_static_jump(insn) && insn_call_dest(insn)); } =20 -/* - * Checks if a function is a Rust "noreturn" one. - */ -static bool is_rust_noreturn(const struct symbol *func) -{ - /* - * If it does not start with "_R", then it is not a Rust symbol. - */ - if (strncmp(func->name, "_R", 2)) - return false; - - /* - * These are just heuristics -- we do not control the precise symbol - * name, due to the crate disambiguators (which depend on the compiler) - * as well as changes to the source code itself between versions (since - * these come from the Rust standard library). - */ - return str_ends_with(func->name, "_4core3num20from_str_radix_panic") || - str_ends_with(func->name, "_4core3num22from_ascii_radix_panic") = || - str_ends_with(func->name, "_4core5sliceSp15copy_from_slice17len_mi= smatch_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") || - str_ends_with(func->name, "_4core9panicking9panic_fmt") || - str_ends_with(func->name, "_4core9panicking14panic_explicit") || - str_ends_with(func->name, "_4core9panicking14panic_nounwind") || - str_ends_with(func->name, "_4core9panicking18panic_bounds_check") = || - str_ends_with(func->name, "_4core9panicking18panic_nounwind_fmt") = || - str_ends_with(func->name, "_4core9panicking19assert_failed_inner")= || - str_ends_with(func->name, "_4core9panicking30panic_null_pointer_de= reference") || - str_ends_with(func->name, "_4core9panicking32panic_null_reference_= constructed") || - str_ends_with(func->name, "_4core9panicking36panic_misaligned_poin= ter_dereference") || - str_ends_with(func->name, "_7___rustc17rust_begin_unwind") || - strstr(func->name, "_4core9panicking13assert_failed") || - strstr(func->name, "_4core9panicking11panic_const24panic_const_") = || - (strstr(func->name, "_4core5slice5index") && - strstr(func->name, "slice_") && - str_ends_with(func->name, "_fail")); -} - static bool is_listed_noreturn(struct symbol *func) { #define NORETURN(func) __stringify(func), @@ -228,9 +187,6 @@ static bool is_listed_noreturn(struct symbol *func) if (is_local_sym(func)) return false; =20 - if (is_rust_noreturn(func)) - return true; - for (int i =3D 0; i < ARRAY_SIZE(global_noreturns); i++) if (!strcmp(func->name, global_noreturns[i])) return true; diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index 2dce56030b980..4e8007a8c2584 100644 --- a/tools/objtool/noreturns.h +++ b/tools/objtool/noreturns.h @@ -1,22 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ =20 /* - * This is a (sorted!) list of all known __noreturn functions in the kerne= l. - * It's needed for objtool to properly reverse-engineer the control flow g= raph. - * - * Yes, this is unfortunate. A better solution is in the works. + * This is a list of noreturn functions which are exported *by modules*. + * No other noreturns need to be listed here. */ -NORETURN(__fortify_panic) NORETURN(__kunit_abort) -NORETURN(__module_put_and_kthread_exit) -NORETURN(__stack_chk_fail) -NORETURN(__ubsan_handle_builtin_unreachable) -NORETURN(abort) -NORETURN(acpi_processor_ffh_play_dead) -NORETURN(do_exit) -NORETURN(kthread_complete_and_exit) NORETURN(kunit_try_catch_throw) NORETURN(mpt_halt_firmware) -NORETURN(panic) -NORETURN(vpanic) -NORETURN(rust_helper_BUG) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35EB83E1228; Fri, 28 Aug 2026 04:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892735; cv=none; b=jN+KcQ8dGBje2yUmsnSPody8XM8DorMdHgElQ3EvHwKM6aEw4rrjvJmJwR+8TgMqg6DLSlpuXXp1YH8Sg+/VbW19Hai8IU9nm4YU1TZRjLYZ08s83jFHrgMIPIbnOrhHwbMPelPHLHj/64Yzudxu3isR3VAVc7NhNinlKQqY4IE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892735; c=relaxed/simple; bh=Dw8ImwHNGI02o5j54nBfeDGmPkNrpZp/8y2VAHk5ErE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nrCB0p7krSjuZgobMP/bpbuepCdgcMZu+a6L+sb0x0ulA3kDZDLLef6qjSkX/x4HoS8O1bEzyhS8HMmE8sZjIJNoyEpyffquSGev452f2DsY/a0qBDcdy+DTNKG1ZauMh3v0J8/69vkwhWf7/UpTry4obCFlYUcuD+Ai479+ABQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LzLqzhAy; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LzLqzhAy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE55D1F00A3D; Fri, 28 Aug 2026 04:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892734; bh=MdNWGB7r1kZ2AVLhJlwhGUFr2V6cniFkjQc9iSIwdDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LzLqzhAyGoPT6aU7jtQSacKeArRTY4UoNz1Ek70iHUbRVI+87PgqUKzmP0P3ABb/D on86dt2LxAUdO13ICKEegTwzBNQJzatRe89eTNGBfhu/nzcei5WBve/ufyNXAfRN8n Z7xk8MM/eYmw2hRdwfzcI0AAPYn6qFl8Nb6TOTzy2xkNRaacDVuMXH+IoEC5MlMq/z mj1kKjf5amFTj60WYpSTgtMhy0q07SntIPISOU17DNClAVEeRcPiuYhXrgCkdYD/b6 DBjcJRyCBO1jJJxRZveeKsXwJOOjEDK6SfJy4K+dNnosZS2NJvB/CRNlOr0tZWj2aX behGhSr4faM+A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 25/27] objtool: Add ANNOTATE_EXPORTED_NORETURN() Date: Thu, 27 Aug 2026 21:51:54 -0700 Message-ID: <5cb3ce81ac9bc1087313397d5e4b9fc066748dea.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add ANNOTATE_EXPORTED_NORETURN() for the rare case where a module exports a noreturn function. Signed-off-by: Josh Poimboeuf --- include/linux/annotate.h | 17 +++++++++++++++++ tools/objtool/check.c | 27 +++++++++++++++++++++++++++ tools/objtool/klp-diff.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/include/linux/annotate.h b/include/linux/annotate.h index a81ca04b4c501..70450eeec3186 100644 --- a/include/linux/annotate.h +++ b/include/linux/annotate.h @@ -25,6 +25,15 @@ "912: " \ __stringify(__ASM_ANNOTATE(.discard.annotate_data, 912b, type)) =20 +/* + * Annotate a symbol by name rather than by relocation, so it can optional= ly be + * used in a header file. + */ +#define ASM_ANNOTATE_NAME(section, sym) \ + ".pushsection " section ", \"MS\", @progbits, 1\n\t" \ + ".asciz \"" __stringify(sym) "\"\n\t" \ + ".popsection" + #else /* __ASSEMBLY__ */ =20 .macro ANNOTATE type @@ -44,6 +53,7 @@ #define ASM_ANNOTATE_LABEL(label, type) "" #define ASM_ANNOTATE(type) #define ASM_ANNOTATE_DATA(type) +#define ASM_ANNOTATE_NAME(section, sym) "" #else /* __ASSEMBLY__ */ .macro ANNOTATE type .endm @@ -112,6 +122,13 @@ */ #define ANNOTATE_IGNORE_NORETURN(sym) asm(ASM_ANNOTATE_LABEL(sym, ANNOTYPE= _IGNORE_NORETURN)) =20 +/* + * Tell objtool running on a module that a function exported by another mo= dule + * is __noreturn. Objtool has no way of communicating that between module= s due + * to the parallel nature of module linking in kbuild. + */ +#define ANNOTATE_EXPORTED_NORETURN(sym) asm(ASM_ANNOTATE_NAME(".discard.an= notate_noreturn", sym)) + /* * Annotate a special section entry. This emables livepatch module genera= tion * to find and extract individual special section entries as needed. diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 583d86220e040..6eaac32374722 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -409,6 +409,31 @@ static int read_noreturns(struct objtool_file *file) return 0; } =20 +static void read_annotate_noreturn(struct objtool_file *file) +{ + struct section *sec; + struct symbol *func; + unsigned long off; + const char *name; + + sec =3D find_section_by_name(file->elf, ".discard.annotate_noreturn"); + if (!sec || !sec->data) + return; + + for (off =3D 0; off < sec_size(sec); off +=3D strlen(name) + 1) { + name =3D sec->data->d_buf + off; + if (!*name) + continue; + + func =3D find_global_symbol_by_name(file->elf, name); + if (!func) + continue; + + if (is_undef_sym(func)) + func->_noreturn =3D 1; + } +} + static void init_cfi_state(struct cfi_state *cfi) { int i; @@ -4984,6 +5009,8 @@ int check(struct objtool_file *file) goto out; } =20 + read_annotate_noreturn(file); + ret =3D decode_file(file); if (ret) goto out; diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c index 16681a76f13d0..5719a8e016cb3 100644 --- a/tools/objtool/klp-diff.c +++ b/tools/objtool/klp-diff.c @@ -361,6 +361,7 @@ static bool is_special_section(struct section *sec) =20 static const char * const non_special_discards[] =3D { ".discard.addressable", + ".discard.annotate_noreturn", ".discard.sym_checksum", }; =20 @@ -2217,6 +2218,34 @@ static int copy_import_ns(struct elfs *e) return 0; } =20 +/* + * ANNOTATE_EXPORTED_NORETURN() annotations reference their functions by n= ame + * rather than by relocation, so individual entries can't be extracted. C= opy + * the (tiny) section as-is. + */ +static int copy_annotate_noreturn(struct elfs *e) +{ + struct section *patched_sec, *out_sec; + + patched_sec =3D find_section_by_name(e->patched, ".discard.annotate_noret= urn"); + if (!patched_sec || !patched_sec->data || !sec_size(patched_sec)) + return 0; + + out_sec =3D elf_create_section(e->out, patched_sec->name, 0, + patched_sec->sh.sh_entsize, + patched_sec->sh.sh_type, + patched_sec->sh.sh_addralign, + patched_sec->sh.sh_flags); + if (!out_sec) + return -1; + + if (!elf_add_data(e->out, out_sec, patched_sec->data->d_buf, + sec_size(patched_sec))) + return -1; + + return 0; +} + int cmd_klp_diff(int argc, const char **argv) { struct elfs e =3D {0}; @@ -2288,6 +2317,9 @@ int cmd_klp_diff(int argc, const char **argv) if (copy_import_ns(&e)) return -1; =20 + if (copy_annotate_noreturn(&e)) + return -1; + if (elf_write(e.out)) return -1; =20 --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEC273DD85E; Fri, 28 Aug 2026 04:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892736; cv=none; b=ThkUTKYERYyN5YuNduRT8l6/j6wtgdXxVMWbosViqMy3NEorDcN0Tl+ZHArWKjwvDAxlTJUcw7kFYp/Uzid+gqqmf3l+ROBw3NZS8XPNw5iIia45xIciJJOij22N9eX79ynAtpaCatXHlvflzhxraAxUSNpUWYfWpJCQtg9ugeY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892736; c=relaxed/simple; bh=DvjjFExsZOOD1K2mxhdATgKxVDsld2SQQlzGr43kyY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fdhy/bC9ZjY+xvoboiAGJ64Ryz/fe/hQI0A25HGsNG/bPkNp/y1lhXH+o22nYzoDq0shzEgoMtNi2xjlE3SwPAX+chkLmD61nFoi6DfXu8frm9jz4KKSo7/7V1Hlip4FhdSgSeSpQYKU4xakolISw8QCREX+LZDZuXhMy1WTdrE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P38yzKNR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P38yzKNR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44B141F00A3E; Fri, 28 Aug 2026 04:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892734; bh=P/doVFv1fDuCSQmC7TljaItr/6ugtsTyZjknTu6oerU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P38yzKNR2zYB5nRMIcyCWvK7Fo/rDMegUt16zrM3NzJOeCAPTcB+2yvSM94ZO+W8O yrmERR6y/8RWTcgPV8L6/WDpUuHOO3151ASEMw7PUvKipOyXA6MnHDbrBLNAtlXo04 VFp2oOwKfhj49jS/9dS1S85CU7FAp+Aqnqczoftw7mxeADrf+Tox6BUf8RXzh1/Nae hi/NzT4OSWhWAY3XThGepmcDV+rIy/QJl11t/VZjkXbtXbhOF+8TkWBGhyDvTPFtMn ZshLdz9eAyWrglI7n6GlCVGRk2AFNhR269umS1cYLZpJHx0ALpqJOBrnL82Lna5Zb8 xmRtoc/zFUAkw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 26/27] objtool: Annotate all module-exported noreturns and remove noreturns.h Date: Thu, 27 Aug 2026 21:51:55 -0700 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The vmlinux.o objtool pass detects its exported noreturns and writes them to scripts/noreturns.builtins to avoid needing to keep them hard-coded in noreturns.h. However, due to the parallel nature of module linking, module-exported noreturns are detected too late to be included in the generated file, so they still need noreturns.h entries. Instead of hard-coding them in noreturns.h, annotate the functions next to their declaration sites with ANNOTATE_EXPORTED_NORETURN(), which is a more robust annotation, and allows us to finally be rid of noreturns.h. Signed-off-by: Josh Poimboeuf --- drivers/message/fusion/mptbase.h | 2 ++ include/kunit/test.h | 1 + include/kunit/try-catch.h | 2 ++ include/linux/rtc/ds1685.h | 2 ++ tools/objtool/Documentation/objtool.txt | 2 +- tools/objtool/check.c | 23 +---------------------- tools/objtool/noreturns.h | 9 --------- 7 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 tools/objtool/noreturns.h diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptb= ase.h index b406fd676da09..387b707a66742 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h @@ -49,6 +49,7 @@ #define MPTBASE_H_INCLUDED /*{-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-= =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D= -=3D*/ =20 +#include #include #include #include @@ -942,6 +943,7 @@ extern int mpt_raid_phys_disk_get_num_paths(MPT_ADAPTER= *ioc, extern int mpt_set_taskmgmt_in_progress_flag(MPT_ADAPTER *ioc); extern void mpt_clear_taskmgmt_in_progress_flag(MPT_ADAPTER *ioc); extern void __noreturn mpt_halt_firmware(MPT_ADAPTER *ioc); +ANNOTATE_EXPORTED_NORETURN(mpt_halt_firmware); =20 =20 /* diff --git a/include/kunit/test.h b/include/kunit/test.h index e52452e58305a..01a1531f8fe54 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -722,6 +722,7 @@ void __printf(2, 3) kunit_log_append(struct string_stre= am *log, const char *fmt, #define KUNIT_SUCCEED(test) _KUNIT_SAVE_LOC(test) =20 void __noreturn __kunit_abort(struct kunit *test); +ANNOTATE_EXPORTED_NORETURN(__kunit_abort); =20 void __printf(6, 7) __kunit_do_failed_assertion(struct kunit *test, const struct kunit_loc *loc, diff --git a/include/kunit/try-catch.h b/include/kunit/try-catch.h index d4e1a5b98ed67..f3c0af4650080 100644 --- a/include/kunit/try-catch.h +++ b/include/kunit/try-catch.h @@ -10,6 +10,7 @@ #ifndef _KUNIT_TRY_CATCH_H #define _KUNIT_TRY_CATCH_H =20 +#include #include =20 typedef void (*kunit_try_catch_func_t)(void *); @@ -54,6 +55,7 @@ struct kunit_try_catch { void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context); =20 void __noreturn kunit_try_catch_throw(struct kunit_try_catch *try_catch); +ANNOTATE_EXPORTED_NORETURN(kunit_try_catch_throw); =20 static inline int kunit_try_catch_get_result(struct kunit_try_catch *try_c= atch) { diff --git a/include/linux/rtc/ds1685.h b/include/linux/rtc/ds1685.h index 8ec0ebfaef04f..a0e1bf99407b7 100644 --- a/include/linux/rtc/ds1685.h +++ b/include/linux/rtc/ds1685.h @@ -21,6 +21,7 @@ #ifndef _LINUX_RTC_DS1685_H_ #define _LINUX_RTC_DS1685_H_ =20 +#include #include #include #include @@ -362,5 +363,6 @@ struct ds1685_rtc_platform_data { */ extern void __noreturn ds1685_rtc_poweroff(struct platform_device *pdev); +ANNOTATE_EXPORTED_NORETURN(ds1685_rtc_poweroff); =20 #endif /* _LINUX_RTC_DS1685_H_ */ diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docume= ntation/objtool.txt index c7ebfb9a8ca6b..d5ac48bc203ec 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -330,7 +330,7 @@ the objtool maintainers. traces and want objtool to ignore it, see "Adding exceptions" below. =20 =20 -3. file.o: warning: objtool: foo+0x48c: bar() missing __noreturn in .c/.h = or NORETURN() in noreturns.h +3. file.o: warning: objtool: foo+0x48c: bar() is missing __noreturn in .c/= .h =20 The call from foo() to bar() doesn't return, but bar() is incorrectly annotated. A noreturn function must be marked __noreturn in both its diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 6eaac32374722..aced52ad6fc81 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -176,24 +176,6 @@ static bool is_sibling_call(struct instruction *insn) return (is_static_jump(insn) && insn_call_dest(insn)); } =20 -static bool is_listed_noreturn(struct symbol *func) -{ -#define NORETURN(func) __stringify(func), - static const char * const global_noreturns[] =3D { -#include "noreturns.h" - }; -#undef NORETURN - - if (is_local_sym(func)) - return false; - - for (int i =3D 0; i < ARRAY_SIZE(global_noreturns); i++) - if (!strcmp(func->name, global_noreturns[i])) - return true; - - return false; -} - /* * Use this rather than reading sym->_noreturn directly: the noreturn stat= us * lives on the primary alias, and ANNOTATE_IGNORE_NORETURN() overrides it. @@ -205,9 +187,6 @@ static bool is_noreturn(struct symbol *func) if (func->ignore_noreturn) return false; =20 - if (is_listed_noreturn(func)) - return true; - return func->_noreturn; } =20 @@ -4891,7 +4870,7 @@ static int validate_reachable_instructions(struct obj= tool_file *file) if (prev_insn && prev_insn->dead_end) { call_dest =3D insn_call_dest(prev_insn); if (call_dest) { - WARN_INSN(insn, "%s() missing __noreturn in .c/.h or NORETURN() in nor= eturns.h", + WARN_INSN(insn, "%s() is missing __noreturn in .c/.h", call_dest->name); warnings++; continue; diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h deleted file mode 100644 index 4e8007a8c2584..0000000000000 --- a/tools/objtool/noreturns.h +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -/* - * This is a list of noreturn functions which are exported *by modules*. - * No other noreturns need to be listed here. - */ -NORETURN(__kunit_abort) -NORETURN(kunit_try_catch_throw) -NORETURN(mpt_halt_firmware) --=20 2.55.0 From nobody Sat Sep 26 23:50:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 584683E2769; Fri, 28 Aug 2026 04:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892736; cv=none; b=K3LaCNDwmhJP4fc4ED8k7KW2pzlpWOac0FMwaFJbzxALz6alyVeuIcG6qGuiCF3Ig4NQUNLx4O0OPZ/0hVsstPThUt1rJ28T6WO5UCMMNMSiDE9AJoQWjVNLySCY8KsQkGNxst+31IFYrQRyWqA0OMXFRSRZqG8mY+gIdgyE9rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787892736; c=relaxed/simple; bh=RzfTI7uQBvp9k+BuIqEdlBvxw7qN7SgpzwRaqcp27vw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R8V+/yrt2BcMASpW3hcEzx7aibRFP7WSGqJDBNSMiCImSOsl1cLesZoV69pyrrUtFC6lh8GFyEgNLA1cvEG0R2YKIf2u8yQ8TLtWKa38qQEEB5FIX4fv4EiGRL2j+T4OAd/BKY48gOWGUxlSCyxR6YEqwopy8Z9UdfOjPAcJv1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fyo6yvQI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fyo6yvQI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF24B1F00A3F; Fri, 28 Aug 2026 04:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787892735; bh=DzRLb9fVOui+CIzGA5sRoi6KZ73tjqkQTajZiUXBPHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Fyo6yvQIpYn/xjlsR3HT78bAIlhJc956175EsMmalq4D+krEgOKkZcqZj2B4rto0x iHG958pXTC9LfwVCPvYFmOaVLLxX1nTfC6ouXWHRoAHqvxNGuPE+o3kfKWk+bKfE9d 1O+qlNyugSzjOdHB0oolgbyN2eNrDtIoD76X9WbZvuz4EpXb9Lo1uzvO5Nb8CqLDu1 0OxhLpxcXNfrA3lCIHX9vDJfkYKSd79aIcfYJwLNmvZ40DQjo7JHxhGSV9aWJ1OMDO p46Rlq4B9D0ZIV43oxgZe5jrJkQPaPoaYX48Lj4me24URhZPL9a+ccYcmDpyjSl4ha mXy6DyDbWCWVw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Gary Guo , rust-for-linux@vger.kernel.org, Ard Biesheuvel , Miguel Ojeda , Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, Huacai Chen Subject: [PATCH 27/27] objtool: Warn about missing/stale ANNOTATE_EXPORTED_NORETURN() usage Date: Thu, 27 Aug 2026 21:51:56 -0700 Message-ID: <4db947677ac3e655a094335c8a23fc0dfe5b2e56.1787890035.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add some warnings to keep ANNOTATE_EXPORTED_NORETURN() annotations correct. Signed-off-by: Josh Poimboeuf --- tools/objtool/Documentation/objtool.txt | 22 ++++++++- tools/objtool/check.c | 59 ++++++++++++++++++++----- tools/objtool/include/objtool/elf.h | 1 + 3 files changed, 71 insertions(+), 11 deletions(-) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docume= ntation/objtool.txt index d5ac48bc203ec..950e88c713d1d 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -393,7 +393,7 @@ the objtool maintainers. =20 a) funcA()'s last instruction is a call to a "noreturn" function like panic(), and objtool doesn't know that function never returns. See - warning 3 above. + warnings 3 and 13. =20 b) funcA() uses the unreachable() annotation in a section of code that is actually reachable. @@ -455,6 +455,26 @@ the objtool maintainers. macros to create them. =20 =20 +13. file.o: warning: objtool: func() is exported and noreturn, its declara= tion needs __noreturn and ANNOTATE_EXPORTED_NORETURN() + + func() is exported and never returns, but is defined in a module, so + its noreturn status needs to be manually annotated. Put an + ANNOTATE_EXPORTED_NORETURN() next to its declaration. + + Mark the declaration __noreturn while you're there, if it isn't + already. The two go together: __noreturn stops the compiler from + emitting code after the call, and the annotation tells objtool the + call doesn't return. + + +14. file.o: warning: objtool: func() has ANNOTATE_EXPORTED_NORETURN() but = returns + + func() is annotated as never returning, but it does. Usually this + means the annotation outlived the fact: the function grew a return path + and the ANNOTATE_EXPORTED_NORETURN() next to its declaration was left + behind. Remove it, along with the __noreturn. + + If the error doesn't seem to make sense, it could be a bug in objtool. Feel free to ask objtool maintainers for help. =20 diff --git a/tools/objtool/check.c b/tools/objtool/check.c index aced52ad6fc81..ac6ae823a2d45 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -224,6 +224,22 @@ static bool might_return(struct objtool_file *file, st= ruct symbol *func) return false; } =20 +static bool is_noreturn_candidate(struct objtool_file *file, struct symbol= *func) +{ + struct instruction *insn; + + if (!is_func_sym(func) || is_undef_sym(func) || + is_prefix_func(func) || func->embedded_insn || + func !=3D func->alias->pfunc) + return false; + + insn =3D find_insn(file, func->sec, func->offset); + if (!insn || insn_func(insn) !=3D func) + return false; + + return true; +} + static void detect_noreturns(struct objtool_file *file) { struct symbol *func, *dest; @@ -232,15 +248,7 @@ static void detect_noreturns(struct objtool_file *file) =20 /* Mark all functions guilty until proven innocent */ for_each_sym(file->elf, func) { - - /* Aliases and cold subfunctions inherit the parent's verdict */ - if (!is_func_sym(func) || is_undef_sym(func) || - is_prefix_func(func) || func->embedded_insn || - func !=3D func->alias->pfunc) - continue; - - insn =3D find_insn(file, func->sec, func->offset); - if (!insn || insn_func(insn) !=3D func) + if (!is_noreturn_candidate(file, func)) continue; =20 func->_noreturn =3D 1; @@ -410,9 +418,38 @@ static void read_annotate_noreturn(struct objtool_file= *file) =20 if (is_undef_sym(func)) func->_noreturn =3D 1; + + func->annotate_noreturn =3D 1; } } =20 +static int validate_noreturns(struct objtool_file *file) +{ + struct symbol *func; + int warnings =3D 0; + + for_each_sym(file->elf, func) { + if (!is_noreturn_candidate(file, func)) + continue; + + if (opts.module && is_noreturn(func) && func->exported && + !func->annotate_noreturn) { + WARN("%s() is exported and noreturn, its declaration needs __noreturn a= nd ANNOTATE_EXPORTED_NORETURN()", + func->name); + warnings++; + } + + if (func->annotate_noreturn && !func->ignore_noreturn && + !is_noreturn(func)) { + WARN("%s() has ANNOTATE_EXPORTED_NORETURN() but returns", + func->name); + warnings++; + } + } + + return warnings; +} + static void init_cfi_state(struct cfi_state *cfi) { int i; @@ -5005,8 +5042,10 @@ int check(struct objtool_file *file) =20 w +=3D validate_functions(file); w +=3D validate_unwind_hints(file, NULL); - if (!w) + if (!w) { w +=3D validate_reachable_instructions(file); + w +=3D validate_noreturns(file); + } =20 warnings +=3D w; =20 diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index adf6e1322c6df..e79cdabf09c26 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -100,6 +100,7 @@ struct symbol { u8 fake : 1; u8 _noreturn : 1; u8 ignore_noreturn : 1; + u8 annotate_noreturn : 1; u8 exported : 1; struct list_head pv_target; struct reloc *relocs; --=20 2.55.0