[PATCH 12/27] kbuild: Defer running objtool to link time for all CFG features
Josh Poimboeuf <[email protected]>
| Newsgroups | gmane.linux.kernel,gmane.linux.kernel.rust,gmane.linux.kbuild.devel |
|---|---|
| Message-ID | <1447f9f8dc6e7e02e4a8a33ce7ae92ba49d70eb3.1787890035.git.jpoimboe@kernel.org> |
noreturns.h file is hand-maintained file which hard codes all the known __noreturn functions in the kernel. It's fragile, often missing entries, and keeping it up to date is a maintenance burden. For LTO, IBT, and klp-build configs, the majority of those entries aren't needed, because objtool runs on vmlinux.o, so it already has visibility into whether a given function returns (with its dead end detection). Remove the need for many of the noreturns.h entries by just always deferring objtool for all features which rely on having the noreturn information: namely the ones which rely on the reverse-engineered control flow graph (CFG). Signed-off-by: Josh Poimboeuf <[email protected]> --- 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 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 individual -# translation units. Instead it runs on vmlinux.o. -# -# For !CONFIG_OBJTOOL_DEFERRED + CONFIG_NOINSTR_VALIDATION, it runs on both -# translation units and vmlinux.o, with the latter only used for noinstr/unret -# validation. +# For CONFIG_OBJTOOL_DEFERRED, objtool doesn't run on individual translation +# units. Instead it runs on vmlinux.o. -objtool-enabled := $(or $(CONFIG_OBJTOOL_DEFERRED),$(CONFIG_NOINSTR_VALIDATION)) +objtool-enabled := $(CONFIG_OBJTOOL_DEFERRED) -ifeq ($(CONFIG_OBJTOOL_DEFERRED),y) vmlinux-objtool-args-y += $(objtool-args-y) -else -vmlinux-objtool-args-$(CONFIG_OBJTOOL_WERROR) += --werror -endif vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \ $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_SRSO)), --unret) diff --git a/tools/objtool/noreturns.h b/tools/objtool/noreturns.h index 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) -- 2.55.0