Sprinkle more __noreturn
Subsystems (12)
Josh Poimboeuf
maintainerPATCH v2 1/11 init: Mark [arch_call_]rest_init() __noreturn
In reply to Josh PoimboeufIn preparation for improving objtool's handling of weak noreturn functions, mark start_kernel(), arch_call_rest_init(), and rest_init() __noreturn.
--- arch/s390/kernel/setup.c | 2 +- include/linux/start_kernel.h | 4 ++-- init/main.c | 4 ++-- tools/objtool/check.c | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-)
arch/s390/kernel/setup.c +1 -1
@@ -396,7 +396,7 @@ int __init arch_early_irq_init(void)return 0 ; } -void __init arch_call_rest_init (void ) +void __init __noreturn arch_call_rest_init (void ) {unsigned long stack;
include/linux/start_kernel.h +2 -2
@@ -9,7 +9,7 @@up something else. */ extern asmlinkage void __init start_kernel(void); -extern void __init arch_call_rest_init (void ); -extern void __ref rest_init (void ); +extern void __init __noreturn arch_call_rest_init (void ); +extern void __ref __noreturn rest_init (void );#endif /* _LINUX_START_KERNEL_H */
init/main.c +2 -2
@@ -683,7 +683,7 @@ static void __init setup_command_line(char *command_line)static __initdata DECLARE_COMPLETION (kthreadd_done); -noinline void __ref rest_init(void) +noinline void __ref __noreturn rest_init(void) {struct task_struct *tsk;int pid;
@@ -889,7 +889,7 @@ static int __init early_randomize_kstack_offset(char *buf)early_param ("randomize_kstack_offset" , early_randomize_kstack_offset);#endif -void __init __weak arch_call_rest_init (void ) +void __init __weak __noreturn arch_call_rest_init (void ) {rest_init (); }
tools/objtool/check.c +2 -0
@@ -202,6 +202,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"__reiserfs_panic" ,"__stack_chk_fail" ,"__ubsan_handle_builtin_unreachable" , +"arch_call_rest_init" ,"arch_cpu_idle_dead" ,"cpu_bringup_and_idle" , "cpu_startup_entry",
@@ -217,6 +218,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"machine_real_restart" ,"make_task_dead" ,"panic" , +"rest_init" ,"rewind_stack_and_make_dead" ,"sev_es_terminate" , "snp_abort",
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 2/11 init: Mark start_kernel() __noreturn
In reply to Josh PoimboeufNow that arch_call_rest_init() is __noreturn, mark its caller start_kernel() __noreturn.
--- include/linux/start_kernel.h | 2 +- init/main.c | 2 +- tools/objtool/check.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
include/linux/start_kernel.h +1 -1
@@ -8,7 +8,7 @@/* Define the prototype for start_kernel here, rather than cluttering up something else. */ -extern asmlinkage void __init start_kernel(void); +extern asmlinkage void __init __noreturn start_kernel(void);extern void __init __noreturn arch_call_rest_init (void );extern void __ref __noreturn rest_init (void );
init/main.c +1 -1
@@ -937,7 +937,7 @@ static void __init print_unknown_bootoptions(void)memblock_free (unknown_options, len); } -asmlinkage __visible void __init __no_sanitize_address start_kernel(void) +asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(void) {char *command_line;char *after_dashes;
tools/objtool/check.c +1 -0
@@ -222,6 +222,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"rewind_stack_and_make_dead" ,"sev_es_terminate" ,"snp_abort" , +"start_kernel" ,"stop_this_cpu" ,"usercopy_abort" , "xen_cpu_bringup_again",
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerv2 cover Sprinkle more __noreturn
v2:
- improve commit logs
- reorder patches: patches 1-6 are prereqs for patch 7
Add some more __noreturn annotations.
Many of these have been flushed out by kernel IBT support which made objtool vmlinux validation much more common.
These annotations are generally a good thing as they improve readability and code generation.
Guilherme G. Piccoli (1):
x86/hyperv: Mark hv_ghcb_terminate() as noreturn
Josh Poimboeuf (10):
init: Mark [arch_call_]rest_init() __noreturn
init: Mark start_kernel() __noreturn
x86/head: Mark *_start_kernel() __noreturn arm64/cpu: Mark cpu_park_loop() and friends __noreturn
cpu: Mark panic_smp_self_stop() __noreturn
cpu: Mark nmi_panic_self_stop() __noreturn
objtool: Include weak functions in global_noreturns check
btrfs: Mark btrfs_assertfail() __noreturn x86/cpu: Mark {hlt,resume}_play_dead() __noreturn
scsi: message: fusion: Mark mpt_halt_firmware() __noreturn
arch/arm/kernel/smp.c | 2 +- arch/arm64/include/asm/exception.h | 4 ++-- arch/arm64/include/asm/smp.h | 7 +++---- arch/arm64/kernel/entry-common.c | 2 +- arch/arm64/kernel/smp.c | 10 ++++++---- arch/arm64/kernel/traps.c | 3 +-- arch/powerpc/kernel/setup_64.c | 2 +- arch/s390/kernel/setup.c | 2 +- arch/x86/hyperv/ivm.c | 2 +- arch/x86/include/asm/mshyperv.h | 2 +- arch/x86/include/asm/reboot.h | 1 - arch/x86/include/asm/setup.h | 6 +++--- arch/x86/include/asm/smp.h | 2 +- arch/x86/kernel/head32.c | 2 +- arch/x86/kernel/head64.c | 4 ++-- arch/x86/kernel/reboot.c | 2 +- arch/x86/kernel/smpboot.c | 2 +- arch/x86/power/cpu.c | 2 +- drivers/message/fusion/mptbase.c | 2 +- drivers/message/fusion/mptbase.h | 2 +- fs/btrfs/messages.c | 2 +- fs/btrfs/messages.h | 2 +- include/linux/smp.h | 4 ++-- include/linux/start_kernel.h | 6 +++--- init/main.c | 6 +++--- kernel/panic.c | 4 ++-- tools/objtool/check.c | 20 ++++++++++++++++---- 27 files changed, 58 insertions(+), 47 deletions(-)
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 3/11 x86/head: Mark *_start_kernel() __noreturn
Now that start_kernel() is __noreturn, mark its chain of callers __noreturn.
--- arch/x86/include/asm/setup.h | 6 +++--- arch/x86/kernel/head32.c | 2 +- arch/x86/kernel/head64.c | 4 ++-- tools/objtool/check.c | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/include/asm/setup.h +3 -3
@@ -125,11 +125,11 @@ void clear_bss(void);#ifdef __i386__ -asmlinkage void __init i386_start_kernel(void); +asmlinkage void __init __noreturn i386_start_kernel(void);#else -asmlinkage void __init x86_64_start_kernel(char *real_mode); -asmlinkage void __init x86_64_start_reservations(char *real_mode_data); +asmlinkage void __init __noreturn x86_64_start_kernel(char *real_mode); +asmlinkage void __init __noreturn x86_64_start_reservations(char *real_mode_data);#endif /* __i386__ */ #endif /* _SETUP */
arch/x86/kernel/head32.c +1 -1
@@ -29,7 +29,7 @@ static void __init i386_default_early_setup(void) x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc; } -asmlinkage __visible void __init i386_start_kernel(void) +asmlinkage __visible void __init __noreturn i386_start_kernel(void) {/* Make sure IDT is set up before any exception happens */ idt_setup_early_handler ();
arch/x86/kernel/head64.c +2 -2
@@ -471,7 +471,7 @@ static void __init copy_bootdata(char *real_mode_data)sme_unmap_bootdata (real_mode_data); } -asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) +asmlinkage __visible void __init __noreturn x86_64_start_kernel(char * real_mode_data) {/* * Build-time sanity checks on the kernel image and module
@@ -537,7 +537,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)x86_64_start_reservations (real_mode_data); } -void __init x86_64_start_reservations (char *real_mode_data) +void __init __noreturn x86_64_start_reservations (char *real_mode_data) {/* version is always not zero if it is copied */ if (!boot_params.hdr.version)
tools/objtool/check.c +2 -0
@@ -225,6 +225,8 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"start_kernel" ,"stop_this_cpu" ,"usercopy_abort" , +"x86_64_start_kernel" , +"x86_64_start_reservations" ,"xen_cpu_bringup_again" , "xen_start_kernel", };
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 4/11 arm64/cpu: Mark cpu_park_loop() and friends __noreturn
In reply to Josh PoimboeufIn preparation for marking panic_smp_self_stop() __noreturn across the kernel, first mark the arm64 implementation of cpu_park_loop() and related functions __noreturn.
--- arch/arm64/include/asm/exception.h | 4 ++-- arch/arm64/include/asm/smp.h | 6 +++--- arch/arm64/kernel/entry-common.c | 2 +- arch/arm64/kernel/smp.c | 8 +++++--- arch/arm64/kernel/traps.c | 3 +-- 5 files changed, 12 insertions(+), 11 deletions(-)
arch/arm64/include/asm/exception.h +2 -2
@@ -31,7 +31,7 @@ static inline unsigned long disr_to_esr(u64 disr)return esr; } -asmlinkage void handle_bad_stack(struct pt_regs *regs); +asmlinkage void __noreturn handle_bad_stack(struct pt_regs *regs); asmlinkage void el1t_64_sync_handler(struct pt_regs *regs); asmlinkage void el1t_64_irq_handler(struct pt_regs *regs);
@@ -80,5 +80,5 @@ void do_el1_fpac(struct pt_regs *regs, unsigned long esr);void do_serror (struct pt_regs *regs,unsigned long esr);void do_notify_resume (struct pt_regs *regs,unsigned long thread_flags); -void panic_bad_stack (struct pt_regs *regs,unsigned long esr,unsigned long far); +void __noreturn panic_bad_stack (struct pt_regs *regs,unsigned long esr,unsigned long far);#endif /* __ASM_EXCEPTION_H */
arch/arm64/include/asm/smp.h +3 -3
@@ -101,9 +101,9 @@ extern int __cpu_disable(void);extern void __cpu_die (unsigned int cpu);extern void __noreturn cpu_die (void ); -extern void cpu_die_early (void ); +extern void __noreturn cpu_die_early (void ); -static inline void cpu_park_loop (void ) +static inline void __noreturn cpu_park_loop (void ) {for (;;) {wfe ();
@@ -123,7 +123,7 @@ static inline void update_cpu_boot_status(int val)* which calls for a kernel panic. Update the boot status and park the calling * CPU. */ -static inline void cpu_panic_kernel (void ) +static inline void __noreturn cpu_panic_kernel (void ) {update_cpu_boot_status (CPU_PANIC_KERNEL );cpu_park_loop ();
arch/arm64/kernel/entry-common.c +1 -1
@@ -840,7 +840,7 @@ UNHANDLED(el0t, 32, error)#endif /* CONFIG_COMPAT */ #ifdef CONFIG_VMAP_STACK -asmlinkage void noinstr handle_bad_stack(struct pt_regs *regs) +asmlinkage void noinstr __noreturn handle_bad_stack(struct pt_regs *regs) {unsigned long esr =read_sysreg (esr_el1);unsigned long far =read_sysreg (far_el1);
arch/arm64/kernel/smp.c +5 -3
@@ -398,7 +398,7 @@ static void __cpu_try_die(int cpu)* Kill the calling secondary CPU, early in bringup before it is turned * online. */ -void cpu_die_early (void ) +void __noreturn cpu_die_early (void ) {int cpu =smp_processor_id ();
@@ -816,7 +816,7 @@ void arch_irq_work_raise(void) }#endif -static void local_cpu_stop (void ) +static void __noreturn local_cpu_stop (void ) {set_cpu_online (smp_processor_id (), false);
@@ -839,7 +839,7 @@ void panic_smp_self_stop(void)static atomic_t waiting_for_crash_ipi =ATOMIC_INIT (0 );#endif -static void ipi_cpu_crash_stop (unsigned int cpu,struct pt_regs *regs) +static void __noreturn ipi_cpu_crash_stop (unsigned int cpu,struct pt_regs *regs) {#ifdef CONFIG_KEXEC_CORE crash_save_cpu (regs, cpu);
@@ -854,6 +854,8 @@ static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)/* just in case */ cpu_park_loop (); +#else +BUG ();#endif }
arch/arm64/kernel/traps.c +1 -2
@@ -863,7 +863,7 @@ void bad_el0_sync(struct pt_regs *regs, int reason, unsigned long esr) DEFINE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack)__aligned(16) ; -void panic_bad_stack (struct pt_regs *regs,unsigned long esr,unsigned long far) +void __noreturn panic_bad_stack (struct pt_regs *regs,unsigned long esr,unsigned long far) {unsigned long tsk_stk = (unsigned long )current->stack;unsigned long irq_stk = (unsigned long )this_cpu_read (irq_stack_ptr);
@@ -905,7 +905,6 @@ void __noreturn arm64_serror_panic(struct pt_regs *regs, unsigned long esr)nmi_panic (regs,"Asynchronous SError Interrupt" );cpu_park_loop (); -unreachable (); }bool arm64_is_fatal_ras_serror (struct pt_regs *regs,unsigned long esr)
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 8/11 btrfs: Mark btrfs_assertfail() __noreturn
In reply to Josh PoimboeufFixes a bunch of warnings including:
vmlinux.o: warning: objtool: select_reloc_root+0x314: unreachable instruction vmlinux.o: warning: objtool: finish_inode_if_needed+0x15b1: unreachable instruction vmlinux.o: warning: objtool: get_bio_sector_nr+0x259: unreachable instruction vmlinux.o: warning: objtool: raid_wait_read_end_io+0xc26: unreachable instruction vmlinux.o: warning: objtool: raid56_parity_alloc_scrub_rbio+0x37b: unreachable instruction
...
--- fs/btrfs/messages.c | 2 +- fs/btrfs/messages.h | 2 +- tools/objtool/check.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/messages.c +1 -1
@@ -253,7 +253,7 @@ void __cold _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt,#endif #ifdef CONFIG_BTRFS_ASSERT -void __cold btrfs_assertfail (const char *expr,const char *file,int line) +void __cold __noreturn btrfs_assertfail (const char *expr,const char *file,int line) {pr_err ("assertion failed: %s, in %s:%d\n" , expr, file, line);BUG ();
fs/btrfs/messages.h +1 -1
@@ -160,7 +160,7 @@ do { \ } while (0)#ifdef CONFIG_BTRFS_ASSERT -void __cold btrfs_assertfail (const char *expr,const char *file,int line); +void __cold __noreturn btrfs_assertfail (const char *expr,const char *file,int line);#define ASSERT (expr) \ (likely(expr) ? (void)0 : btrfs_assertfail(#expr, __FILE__, __LINE__))
tools/objtool/check.c +1 -0
@@ -204,6 +204,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"__ubsan_handle_builtin_unreachable" ,"arch_call_rest_init" ,"arch_cpu_idle_dead" , +"btrfs_assertfail" ,"cpu_bringup_and_idle" ,"cpu_startup_entry" , "do_exit",
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 5/11 cpu: Mark panic_smp_self_stop() __noreturn
In reply to Josh PoimboeufIn preparation for improving objtool's handling of weak noreturn functions, mark panic_smp_self_stop() __noreturn.
--- arch/arm/kernel/smp.c | 2 +- arch/arm64/include/asm/smp.h | 1 - arch/arm64/kernel/smp.c | 2 +- arch/powerpc/kernel/setup_64.c | 2 +- include/linux/smp.h | 2 +- kernel/panic.c | 2 +- tools/objtool/check.c | 1 + 7 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/kernel/smp.c +1 -1
@@ -779,7 +779,7 @@ void smp_send_stop(void)* kdump fails. So split out the panic_smp_self_stop() and add * set_cpu_online(smp_processor_id(), false). */ -void panic_smp_self_stop (void ) +void __noreturn panic_smp_self_stop (void ) {pr_debug ("CPU %u will stop doing anything useful since another CPU has paniced\n" ,smp_processor_id ());
arch/arm64/include/asm/smp.h +0 -1
@@ -143,7 +143,6 @@ bool cpus_are_stuck_in_kernel(void);extern void crash_smp_send_stop (void );extern bool smp_crash_stop_failed (void ); -extern void panic_smp_self_stop (void );#endif /* ifndef __ASSEMBLY__ */
arch/arm64/kernel/smp.c +1 -1
@@ -830,7 +830,7 @@ static void __noreturn local_cpu_stop(void)* that cpu_online_mask gets correctly updated and smp_send_stop() can skip * CPUs that have already stopped themselves. */ -void panic_smp_self_stop (void ) +void __noreturn panic_smp_self_stop (void ) {local_cpu_stop (); }
arch/powerpc/kernel/setup_64.c +1 -1
@@ -480,7 +480,7 @@ void early_setup_secondary(void)#endif /* CONFIG_SMP */ -void panic_smp_self_stop (void ) +void __noreturn panic_smp_self_stop (void ) {hard_irq_disable ();spin_begin ();
include/linux/smp.h +1 -1
@@ -59,7 +59,7 @@ int smp_call_function_single_async(int cpu, struct __call_single_data *csd);* Cpus stopping functions in panic. All have default weak definitions. * Architecture-dependent code may override them. */ -void panic_smp_self_stop (void ); +void __noreturn panic_smp_self_stop (void );void nmi_panic_self_stop (struct pt_regs *regs);void crash_smp_send_stop (void );
kernel/panic.c +1 -1
@@ -141,7 +141,7 @@ EXPORT_SYMBOL(panic_blink);/* * Stop ourself in panic -- architecture code may override this */ -void __weak panic_smp_self_stop (void ) +void __weak __noreturn panic_smp_self_stop (void ) {while (1 )cpu_relax ();
tools/objtool/check.c +1 -0
@@ -218,6 +218,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"machine_real_restart" ,"make_task_dead" ,"panic" , +"panic_smp_self_stop" ,"rest_init" ,"rewind_stack_and_make_dead" , "sev_es_terminate",
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 7/11 objtool: Include weak functions in global_noreturns check
In reply to Josh PoimboeufIf a global function doesn't return, and its prototype has the __noreturn attribute, its weak counterpart must also not return so that it matches the prototype and meets call site expectations.
To properly follow the compiled control flow at the call sites, change the global_noreturns check to include both global and weak functions.
On the other hand, if a weak function isn't in global_noreturns, assume the prototype doesn't have __noreturn. Even if the weak function doesn't return, call sites treat it like a returnable function.
Fixes the following warning:
kernel/sched/build_policy.o: warning: objtool: do_idle() falls through to next function play_idle_precise()
--- tools/objtool/check.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/objtool/check.c +4 -4
@@ -236,14 +236,14 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,if (!func)return false; -if (func->bind ==STB_WEAK ) -return false; - -if (func->bind ==STB_GLOBAL ) +if (func->bind ==STB_GLOBAL || func->bind ==STB_WEAK )for (i =0 ; i <ARRAY_SIZE (global_noreturns); i++)if (!strcmp (func->name, global_noreturns[i]))return true; +if (func->bind ==STB_WEAK ) +return false; +if (!func->len)return false;
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 6/11 cpu: Mark nmi_panic_self_stop() __noreturn
In reply to Josh PoimboeufIn preparation for improving objtool's handling of weak noreturn functions, mark nmi_panic_self_stop() __noreturn.
--- arch/x86/include/asm/reboot.h | 1 - arch/x86/kernel/reboot.c | 2 +- include/linux/smp.h | 2 +- kernel/panic.c | 2 +- tools/objtool/check.c | 1 + 5 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/reboot.h +0 -1
@@ -28,7 +28,6 @@ void __noreturn machine_real_restart(unsigned int type);void cpu_emergency_disable_virtualization (void );typedef void (*nmi_shootdown_cb )(int ,struct pt_regs *); -void nmi_panic_self_stop (struct pt_regs *regs);void nmi_shootdown_cpus (nmi_shootdown_cb callback);void run_crash_ipi_callback (struct pt_regs *regs);
arch/x86/kernel/reboot.c +1 -1
@@ -920,7 +920,7 @@ void run_crash_ipi_callback(struct pt_regs *regs) }/* Override the weak function in kernel/panic.c */ -void nmi_panic_self_stop (struct pt_regs *regs) +void __noreturn nmi_panic_self_stop (struct pt_regs *regs) {while (1 ) {/* If no CPU is preparing crash dump, we simply loop here. */
include/linux/smp.h +1 -1
@@ -60,7 +60,7 @@ int smp_call_function_single_async(int cpu, struct __call_single_data *csd);* Architecture-dependent code may override them. */ void __noreturn panic_smp_self_stop (void ); -void nmi_panic_self_stop (struct pt_regs *regs); +void __noreturn nmi_panic_self_stop (struct pt_regs *regs);void crash_smp_send_stop (void );/*
kernel/panic.c +1 -1
@@ -151,7 +151,7 @@ void __weak __noreturn panic_smp_self_stop(void)* Stop ourselves in NMI context if another CPU has already panicked. Arch code * may override this to prepare for crash dumping, e.g. save regs info. */ -void __weak nmi_panic_self_stop (struct pt_regs *regs) +void __weak __noreturn nmi_panic_self_stop (struct pt_regs *regs) {panic_smp_self_stop (); }
tools/objtool/check.c +1 -0
@@ -217,6 +217,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"lbug_with_loc" ,"machine_real_restart" ,"make_task_dead" , +"nmi_panic_self_stop" ,"panic" ,"panic_smp_self_stop" , "rest_init",
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 11/11 x86/hyperv: Mark hv_ghcb_terminate() as noreturn
In reply to Josh PoimboeufFrom: "Guilherme G. Piccoli" <[email protected]>
Annotate the function prototype and definition as noreturn to prevent objtool warnings like:
vmlinux.o: warning: objtool: hyperv_init+0x55c: unreachable instruction
Also, as per Josh's suggestion, add it to the global_noreturns list. As a comparison, an objdump output without the annotation:
[...]
1b63: mov $0x1,%esi 1b68: xor %edi,%edi 1b6a: callq ffffffff8102f680 <hv_ghcb_terminate> 1b6f: jmpq ffffffff82f217ec <hyperv_init+0x9c> # unreachable 1b74: cmpq $0xffffffffffffffff,-0x702a24(%rip)
[...]
Now, after adding the __noreturn to the function prototype:
[...]
17df: callq ffffffff8102f6d0 <hv_ghcb_negotiate_protocol> 17e4: test %al,%al 17e6: je ffffffff82f21bb9 <hyperv_init+0x469> [...] <many insns> 1bb9: mov $0x1,%esi 1bbe: xor %edi,%edi 1bc0: callq ffffffff8102f680 <hv_ghcb_terminate> 1bc5: nopw %cs:0x0(%rax,%rax,1) # end of function
--- arch/x86/hyperv/ivm.c | 2 +- arch/x86/include/asm/mshyperv.h | 2 +- tools/objtool/check.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/hyperv/ivm.c +1 -1
@@ -127,7 +127,7 @@ static enum es_result hv_ghcb_hv_call(struct ghcb *ghcb, u64 exit_code,return ES_OK ; } -void hv_ghcb_terminate (unsigned int set,unsigned int reason) +void __noreturn hv_ghcb_terminate (unsigned int set,unsigned int reason) {u64 val =GHCB_MSR_TERM_REQ ;
arch/x86/include/asm/mshyperv.h +1 -1
@@ -212,7 +212,7 @@ int hv_set_mem_host_visibility(unsigned long addr, int numpages, bool visible);void hv_ghcb_msr_write (u64 msr,u64 value);void hv_ghcb_msr_read (u64 msr,u64 *value);bool hv_ghcb_negotiate_protocol (void ); -void hv_ghcb_terminate (unsigned int set,unsigned int reason); +void __noreturn hv_ghcb_terminate (unsigned int set,unsigned int reason);#else static inline void hv_ghcb_msr_write (u64 msr,u64 value) {}static inline void hv_ghcb_msr_read (u64 msr,u64 *value) {}
tools/objtool/check.c +1 -0
@@ -213,6 +213,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"ex_handler_msr_mce" ,"fortify_panic" ,"hlt_play_dead" , +"hv_ghcb_terminate" ,"kthread_complete_and_exit" ,"kthread_exit" , "kunit_try_catch_throw",
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 9/11 x86/cpu: Mark {hlt,resume}_play_dead() __noreturn
In reply to Josh PoimboeufFixes the following warning:
vmlinux.o: warning: objtool: resume_play_dead+0x21: unreachable instruction
--- arch/x86/include/asm/smp.h | 2 +- arch/x86/kernel/smpboot.c | 2 +- arch/x86/power/cpu.c | 2 +- tools/objtool/check.c | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/asm/smp.h +1 -1
@@ -125,7 +125,7 @@ int native_cpu_up(unsigned int cpunum, struct task_struct *tidle);int native_cpu_disable (void );int common_cpu_die (unsigned int cpu);void native_cpu_die (unsigned int cpu); -void hlt_play_dead (void ); +void __noreturn hlt_play_dead (void );void native_play_dead (void );void play_dead_common (void );void wbinvd_on_cpu (int cpu);
arch/x86/kernel/smpboot.c +1 -1
@@ -1816,7 +1816,7 @@ static inline void mwait_play_dead(void) } } -void hlt_play_dead (void ) +void __noreturn hlt_play_dead (void ) {if (__this_cpu_read (cpu_info.x86) >=4 )wbinvd ();
arch/x86/power/cpu.c +1 -1
@@ -288,7 +288,7 @@ EXPORT_SYMBOL(restore_processor_state);#endif #if defined(CONFIG_HIBERNATION ) && defined(CONFIG_HOTPLUG_CPU ) -static void resume_play_dead (void ) +static void __noreturn resume_play_dead (void ) {play_dead_common ();tboot_shutdown (TB_SHUTDOWN_WFS );
tools/objtool/check.c +2 -0
@@ -212,6 +212,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"do_task_dead" ,"ex_handler_msr_mce" ,"fortify_panic" , +"hlt_play_dead" ,"kthread_complete_and_exit" ,"kthread_exit" , "kunit_try_catch_throw",
@@ -222,6 +223,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"panic" ,"panic_smp_self_stop" ,"rest_init" , +"resume_play_dead" ,"rewind_stack_and_make_dead" ,"sev_es_terminate" , "snp_abort",
Signature · 1 line
2.39.2
Josh Poimboeuf
maintainerPATCH v2 10/11 scsi: message: fusion: Mark mpt_halt_firmware() __noreturn
In reply to Josh Poimboeufmpt_halt_firmware() doesn't return. Mark it as such.
Fixes the following warnings:
vmlinux.o: warning: objtool: mptscsih_abort+0x7f4: unreachable instruction vmlinux.o: warning: objtool: mptctl_timeout_expired+0x310: unreachable instruction
--- drivers/message/fusion/mptbase.c | 2 +- drivers/message/fusion/mptbase.h | 2 +- tools/objtool/check.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
drivers/message/fusion/mptbase.c +1 -1
@@ -6935,7 +6935,7 @@ EXPORT_SYMBOL(mpt_clear_taskmgmt_in_progress_flag);* @ioc: Pointer to MPT_ADAPTER structure * **/ -void +void __noreturn mpt_halt_firmware (MPT_ADAPTER *ioc) {u32 ioc_raw_state;
drivers/message/fusion/mptbase.h +1 -1
@@ -945,7 +945,7 @@ extern int mpt_raid_phys_disk_get_num_paths(MPT_ADAPTER *ioc, u8 phys_disk_num);extern int mpt_set_taskmgmt_in_progress_flag (MPT_ADAPTER *ioc);extern void mpt_clear_taskmgmt_in_progress_flag (MPT_ADAPTER *ioc); -extern void mpt_halt_firmware (MPT_ADAPTER *ioc); +extern void __noreturn mpt_halt_firmware (MPT_ADAPTER *ioc);/*
tools/objtool/check.c +1 -0
@@ -219,6 +219,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"lbug_with_loc" ,"machine_real_restart" ,"make_task_dead" , +"mpt_halt_firmware" ,"nmi_panic_self_stop" ,"panic" , "panic_smp_self_stop",
Signature · 1 line
2.39.2
Re: [PATCH v2 08/11] btrfs: Mark btrfs_assertfail() __noreturn
In reply to Josh PoimboeufQuoted 9 lines · Josh Poimboeuf
Fixes a bunch of warnings including:
vmlinux.o: warning: objtool:
select_reloc_root+0x314: unreachable instruction vmlinux.o: warning: objtool:finish_inode_if_needed+0x15b1: unreachable instruction vmlinux.o: warning: objtool:get_bio_sector_nr+0x259: unreachable instruction vmlinux.o: warning: objtool:raid_wait_read_end_io+0xc26: unreachable instruction vmlinux.o: warning: objtool:raid56_parity_alloc_scrub_rbio+0x37b: unreachable instruction
...
Quoted 3 lines
I'll add this one to btrfs queue, thanks.
Re: [PATCH v2 07/11] objtool: Include weak functions in global_noreturns check
In reply to Josh PoimboeufQuoted 11 lines · Josh Poimboeuf
If a global function doesn't return, and its prototype has the
__noreturnattribute, its weak counterpart must also not return so that it matches the prototype and meets call site expectations.To properly follow the compiled control flow at the call sites, change the
global_noreturnscheck to include both global and weak functions.On the other hand, if a weak function isn't in
global_noreturns, assume the prototype doesn't have__noreturn. Even if the weak function doesn't return, call sites treat it like a returnable function.
Quoted 7 lines
Fixes the following warning:
kernel/sched/build_policy.o: warning: objtool:do_idle()falls through to next functionplay_idle_precise()
The rest of the patch set looks good to me too.
M
Re: [PATCH v2 08/11] btrfs: Mark btrfs_assertfail() __noreturn
In reply to Josh PoimboeufQuoted 9 lines · Josh Poimboeuf
Fixes a bunch of warnings including:
vmlinux.o: warning: objtool: select_reloc_root+0x314: unreachable instruction vmlinux.o: warning: objtool: finish_inode_if_needed+0x15b1: unreachable instruction vmlinux.o: warning: objtool: get_bio_sector_nr+0x259: unreachable instruction vmlinux.o: warning: objtool: raid_wait_read_end_io+0xc26: unreachable instruction vmlinux.o: warning: objtool: raid56_parity_alloc_scrub_rbio+0x37b: unreachable instruction ...
Quoted 3 lines
LGTM.
[tip: objtool/core] scsi: message: fusion: Mark mpt_halt_firmware() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 6e36a56a5f617262c0e8ae7e961487361c720b9e Gitweb: https://git.kernel.org/tip/6e36a56a5f617262c0e8ae7e961487361c720b9e Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:40 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:27 +02:00
scsi: message: fusion: Mark mpt_halt_firmware() __noreturn
mpt_halt_firmware() doesn't return. Mark it as such.
Fixes the following warnings:
vmlinux.o: warning: objtool: mptscsih_abort+0x7f4: unreachable instruction vmlinux.o: warning: objtool: mptctl_timeout_expired+0x310: unreachable instruction
--- drivers/message/fusion/mptbase.c | 2 +- drivers/message/fusion/mptbase.h | 2 +- tools/objtool/check.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
drivers/message/fusion/mptbase.c +1 -1
@@ -6935,7 +6935,7 @@ EXPORT_SYMBOL(mpt_clear_taskmgmt_in_progress_flag);* @ioc: Pointer to MPT_ADAPTER structure * **/ -void +void __noreturn mpt_halt_firmware (MPT_ADAPTER *ioc) {u32 ioc_raw_state;
drivers/message/fusion/mptbase.h +1 -1
@@ -945,7 +945,7 @@ extern int mpt_raid_phys_disk_get_num_paths(MPT_ADAPTER *ioc, u8 phys_disk_num);extern int mpt_set_taskmgmt_in_progress_flag (MPT_ADAPTER *ioc);extern void mpt_clear_taskmgmt_in_progress_flag (MPT_ADAPTER *ioc); -extern void mpt_halt_firmware (MPT_ADAPTER *ioc); +extern void __noreturn mpt_halt_firmware (MPT_ADAPTER *ioc);/*
tools/objtool/check.c +1 -0
@@ -219,6 +219,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"lbug_with_loc" ,"machine_real_restart" ,"make_task_dead" , +"mpt_halt_firmware" ,"nmi_panic_self_stop" ,"panic" , "panic_smp_self_stop",
[tip: objtool/core] x86/hyperv: Mark hv_ghcb_terminate() as noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 611d4c716db0141cfc436994dc5aff1d69c924ad Gitweb: https://git.kernel.org/tip/611d4c716db0141cfc436994dc5aff1d69c924ad Author: Guilherme G. Piccoli <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:41 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:28 +02:00
x86/hyperv: Mark hv_ghcb_terminate() as noreturn
Annotate the function prototype and definition as noreturn to prevent objtool warnings like:
vmlinux.o: warning: objtool: hyperv_init+0x55c: unreachable instruction
Also, as per Josh's suggestion, add it to the global_noreturns list. As a comparison, an objdump output without the annotation:
[...]
1b63: mov $0x1,%esi 1b68: xor %edi,%edi 1b6a: callq ffffffff8102f680 <hv_ghcb_terminate> 1b6f: jmpq ffffffff82f217ec <hyperv_init+0x9c> # unreachable 1b74: cmpq $0xffffffffffffffff,-0x702a24(%rip)
[...]
Now, after adding the __noreturn to the function prototype:
[...]
17df: callq ffffffff8102f6d0 <hv_ghcb_negotiate_protocol> 17e4: test %al,%al 17e6: je ffffffff82f21bb9 <hyperv_init+0x469> [...] <many insns> 1bb9: mov $0x1,%esi 1bbe: xor %edi,%edi 1bc0: callq ffffffff8102f680 <hv_ghcb_terminate> 1bc5: nopw %cs:0x0(%rax,%rax,1) # end of function
--- arch/x86/hyperv/ivm.c | 2 +- arch/x86/include/asm/mshyperv.h | 2 +- tools/objtool/check.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/hyperv/ivm.c +1 -1
@@ -127,7 +127,7 @@ static enum es_result hv_ghcb_hv_call(struct ghcb *ghcb, u64 exit_code,return ES_OK ; } -void hv_ghcb_terminate (unsigned int set,unsigned int reason) +void __noreturn hv_ghcb_terminate (unsigned int set,unsigned int reason) {u64 val =GHCB_MSR_TERM_REQ ;
arch/x86/include/asm/mshyperv.h +1 -1
@@ -212,7 +212,7 @@ int hv_set_mem_host_visibility(unsigned long addr, int numpages, bool visible);void hv_ghcb_msr_write (u64 msr,u64 value);void hv_ghcb_msr_read (u64 msr,u64 *value);bool hv_ghcb_negotiate_protocol (void ); -void hv_ghcb_terminate (unsigned int set,unsigned int reason); +void __noreturn hv_ghcb_terminate (unsigned int set,unsigned int reason);#else static inline void hv_ghcb_msr_write (u64 msr,u64 value) {}static inline void hv_ghcb_msr_read (u64 msr,u64 *value) {}
tools/objtool/check.c +1 -0
@@ -213,6 +213,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"ex_handler_msr_mce" ,"fortify_panic" ,"hlt_play_dead" , +"hv_ghcb_terminate" ,"kthread_complete_and_exit" ,"kthread_exit" , "kunit_try_catch_throw",
[tip: objtool/core] x86/cpu: Mark {hlt,resume}_play_dead() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 52668badd34b4b346f32c33a9bcba069a06c3caa Gitweb: https://git.kernel.org/tip/52668badd34b4b346f32c33a9bcba069a06c3caa Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:39 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:27 +02:00
x86/cpu: Mark {hlt,resume}_play_dead() __noreturn
Fixes the following warning:
vmlinux.o: warning: objtool: resume_play_dead+0x21: unreachable instruction
--- arch/x86/include/asm/smp.h | 2 +- arch/x86/kernel/smpboot.c | 2 +- arch/x86/power/cpu.c | 2 +- tools/objtool/check.c | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/asm/smp.h +1 -1
@@ -125,7 +125,7 @@ int native_cpu_up(unsigned int cpunum, struct task_struct *tidle);int native_cpu_disable (void );int common_cpu_die (unsigned int cpu);void native_cpu_die (unsigned int cpu); -void hlt_play_dead (void ); +void __noreturn hlt_play_dead (void );void native_play_dead (void );void play_dead_common (void );void wbinvd_on_cpu (int cpu);
arch/x86/kernel/smpboot.c +1 -1
@@ -1816,7 +1816,7 @@ static inline void mwait_play_dead(void) } } -void hlt_play_dead (void ) +void __noreturn hlt_play_dead (void ) {if (__this_cpu_read (cpu_info.x86) >=4 )wbinvd ();
arch/x86/power/cpu.c +1 -1
@@ -288,7 +288,7 @@ EXPORT_SYMBOL(restore_processor_state);#endif #if defined(CONFIG_HIBERNATION ) && defined(CONFIG_HOTPLUG_CPU ) -static void resume_play_dead (void ) +static void __noreturn resume_play_dead (void ) {play_dead_common ();tboot_shutdown (TB_SHUTDOWN_WFS );
tools/objtool/check.c +2 -0
@@ -212,6 +212,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"do_task_dead" ,"ex_handler_msr_mce" ,"fortify_panic" , +"hlt_play_dead" ,"kthread_complete_and_exit" ,"kthread_exit" , "kunit_try_catch_throw",
@@ -222,6 +223,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"panic" ,"panic_smp_self_stop" ,"rest_init" , +"resume_play_dead" ,"rewind_stack_and_make_dead" ,"sev_es_terminate" , "snp_abort",
[tip: objtool/core] x86/head: Mark *_start_kernel() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 4208d2d79837ef70f260d6170e3ac7fd6fde7788 Gitweb: https://git.kernel.org/tip/4208d2d79837ef70f260d6170e3ac7fd6fde7788 Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:33 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:24 +02:00
x86/head: Mark *_start_kernel() __noreturn
Now that start_kernel() is __noreturn, mark its chain of callers __noreturn.
--- arch/x86/include/asm/setup.h | 6 +++--- arch/x86/kernel/head32.c | 2 +- arch/x86/kernel/head64.c | 4 ++-- tools/objtool/check.c | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/include/asm/setup.h +3 -3
@@ -125,11 +125,11 @@ void clear_bss(void);#ifdef __i386__ -asmlinkage void __init i386_start_kernel(void); +asmlinkage void __init __noreturn i386_start_kernel(void);#else -asmlinkage void __init x86_64_start_kernel(char *real_mode); -asmlinkage void __init x86_64_start_reservations(char *real_mode_data); +asmlinkage void __init __noreturn x86_64_start_kernel(char *real_mode); +asmlinkage void __init __noreturn x86_64_start_reservations(char *real_mode_data);#endif /* __i386__ */ #endif /* _SETUP */
arch/x86/kernel/head32.c +1 -1
@@ -29,7 +29,7 @@ static void __init i386_default_early_setup(void) x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc; } -asmlinkage __visible void __init i386_start_kernel(void) +asmlinkage __visible void __init __noreturn i386_start_kernel(void) {/* Make sure IDT is set up before any exception happens */ idt_setup_early_handler ();
arch/x86/kernel/head64.c +2 -2
@@ -471,7 +471,7 @@ static void __init copy_bootdata(char *real_mode_data)sme_unmap_bootdata (real_mode_data); } -asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) +asmlinkage __visible void __init __noreturn x86_64_start_kernel(char * real_mode_data) {/* * Build-time sanity checks on the kernel image and module
@@ -537,7 +537,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)x86_64_start_reservations (real_mode_data); } -void __init x86_64_start_reservations (char *real_mode_data) +void __init __noreturn x86_64_start_reservations (char *real_mode_data) {/* version is always not zero if it is copied */ if (!boot_params.hdr.version)
tools/objtool/check.c +2 -0
@@ -225,6 +225,8 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"start_kernel" ,"stop_this_cpu" ,"usercopy_abort" , +"x86_64_start_kernel" , +"x86_64_start_reservations" ,"xen_cpu_bringup_again" , "xen_start_kernel", };
[tip: objtool/core] arm64/cpu: Mark cpu_park_loop() and friends __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 5ab6876c7843db5fe8bef691c5fdb92518b12070 Gitweb: https://git.kernel.org/tip/5ab6876c7843db5fe8bef691c5fdb92518b12070 Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:34 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:24 +02:00
arm64/cpu: Mark cpu_park_loop() and friends __noreturn
In preparation for marking panic_smp_self_stop() __noreturn across the kernel, first mark the arm64 implementation of cpu_park_loop() and related functions __noreturn.
--- arch/arm64/include/asm/exception.h | 4 ++-- arch/arm64/include/asm/smp.h | 6 +++--- arch/arm64/kernel/entry-common.c | 2 +- arch/arm64/kernel/smp.c | 8 +++++--- arch/arm64/kernel/traps.c | 3 +-- 5 files changed, 12 insertions(+), 11 deletions(-)
arch/arm64/include/asm/exception.h +2 -2
@@ -31,7 +31,7 @@ static inline unsigned long disr_to_esr(u64 disr)return esr; } -asmlinkage void handle_bad_stack(struct pt_regs *regs); +asmlinkage void __noreturn handle_bad_stack(struct pt_regs *regs); asmlinkage void el1t_64_sync_handler(struct pt_regs *regs); asmlinkage void el1t_64_irq_handler(struct pt_regs *regs);
@@ -80,5 +80,5 @@ void do_el1_fpac(struct pt_regs *regs, unsigned long esr);void do_serror (struct pt_regs *regs,unsigned long esr);void do_notify_resume (struct pt_regs *regs,unsigned long thread_flags); -void panic_bad_stack (struct pt_regs *regs,unsigned long esr,unsigned long far); +void __noreturn panic_bad_stack (struct pt_regs *regs,unsigned long esr,unsigned long far);#endif /* __ASM_EXCEPTION_H */
arch/arm64/include/asm/smp.h +3 -3
@@ -101,9 +101,9 @@ extern int __cpu_disable(void);extern void __cpu_die (unsigned int cpu);extern void __noreturn cpu_die (void ); -extern void cpu_die_early (void ); +extern void __noreturn cpu_die_early (void ); -static inline void cpu_park_loop (void ) +static inline void __noreturn cpu_park_loop (void ) {for (;;) {wfe ();
@@ -123,7 +123,7 @@ static inline void update_cpu_boot_status(int val)* which calls for a kernel panic. Update the boot status and park the calling * CPU. */ -static inline void cpu_panic_kernel (void ) +static inline void __noreturn cpu_panic_kernel (void ) {update_cpu_boot_status (CPU_PANIC_KERNEL );cpu_park_loop ();
arch/arm64/kernel/entry-common.c +1 -1
@@ -840,7 +840,7 @@ UNHANDLED(el0t, 32, error)#endif /* CONFIG_COMPAT */ #ifdef CONFIG_VMAP_STACK -asmlinkage void noinstr handle_bad_stack(struct pt_regs *regs) +asmlinkage void noinstr __noreturn handle_bad_stack(struct pt_regs *regs) {unsigned long esr =read_sysreg (esr_el1);unsigned long far =read_sysreg (far_el1);
arch/arm64/kernel/smp.c +5 -3
@@ -398,7 +398,7 @@ static void __cpu_try_die(int cpu)* Kill the calling secondary CPU, early in bringup before it is turned * online. */ -void cpu_die_early (void ) +void __noreturn cpu_die_early (void ) {int cpu =smp_processor_id ();
@@ -816,7 +816,7 @@ void arch_irq_work_raise(void) }#endif -static void local_cpu_stop (void ) +static void __noreturn local_cpu_stop (void ) {set_cpu_online (smp_processor_id (), false);
@@ -839,7 +839,7 @@ void panic_smp_self_stop(void)static atomic_t waiting_for_crash_ipi =ATOMIC_INIT (0 );#endif -static void ipi_cpu_crash_stop (unsigned int cpu,struct pt_regs *regs) +static void __noreturn ipi_cpu_crash_stop (unsigned int cpu,struct pt_regs *regs) {#ifdef CONFIG_KEXEC_CORE crash_save_cpu (regs, cpu);
@@ -854,6 +854,8 @@ static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)/* just in case */ cpu_park_loop (); +#else +BUG ();#endif }
arch/arm64/kernel/traps.c +1 -2
@@ -863,7 +863,7 @@ void bad_el0_sync(struct pt_regs *regs, int reason, unsigned long esr) DEFINE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack)__aligned(16) ; -void panic_bad_stack (struct pt_regs *regs,unsigned long esr,unsigned long far) +void __noreturn panic_bad_stack (struct pt_regs *regs,unsigned long esr,unsigned long far) {unsigned long tsk_stk = (unsigned long )current->stack;unsigned long irq_stk = (unsigned long )this_cpu_read (irq_stack_ptr);
@@ -905,7 +905,6 @@ void __noreturn arm64_serror_panic(struct pt_regs *regs, unsigned long esr)nmi_panic (regs,"Asynchronous SError Interrupt" );cpu_park_loop (); -unreachable (); }bool arm64_is_fatal_ras_serror (struct pt_regs *regs,unsigned long esr)
[tip: objtool/core] cpu: Mark panic_smp_self_stop() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 7412a60decec2a6744cf773280ff17a0f89e8395 Gitweb: https://git.kernel.org/tip/7412a60decec2a6744cf773280ff17a0f89e8395 Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:35 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:25 +02:00
cpu: Mark panic_smp_self_stop() __noreturn
In preparation for improving objtool's handling of weak noreturn functions, mark panic_smp_self_stop() __noreturn.
--- arch/arm/kernel/smp.c | 2 +- arch/arm64/include/asm/smp.h | 1 - arch/arm64/kernel/smp.c | 2 +- arch/powerpc/kernel/setup_64.c | 2 +- include/linux/smp.h | 2 +- kernel/panic.c | 2 +- tools/objtool/check.c | 1 + 7 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/kernel/smp.c +1 -1
@@ -779,7 +779,7 @@ void smp_send_stop(void)* kdump fails. So split out the panic_smp_self_stop() and add * set_cpu_online(smp_processor_id(), false). */ -void panic_smp_self_stop (void ) +void __noreturn panic_smp_self_stop (void ) {pr_debug ("CPU %u will stop doing anything useful since another CPU has paniced\n" ,smp_processor_id ());
arch/arm64/include/asm/smp.h +0 -1
@@ -143,7 +143,6 @@ bool cpus_are_stuck_in_kernel(void);extern void crash_smp_send_stop (void );extern bool smp_crash_stop_failed (void ); -extern void panic_smp_self_stop (void );#endif /* ifndef __ASSEMBLY__ */
arch/arm64/kernel/smp.c +1 -1
@@ -830,7 +830,7 @@ static void __noreturn local_cpu_stop(void)* that cpu_online_mask gets correctly updated and smp_send_stop() can skip * CPUs that have already stopped themselves. */ -void panic_smp_self_stop (void ) +void __noreturn panic_smp_self_stop (void ) {local_cpu_stop (); }
arch/powerpc/kernel/setup_64.c +1 -1
@@ -480,7 +480,7 @@ void early_setup_secondary(void)#endif /* CONFIG_SMP */ -void panic_smp_self_stop (void ) +void __noreturn panic_smp_self_stop (void ) {hard_irq_disable ();spin_begin ();
include/linux/smp.h +1 -1
@@ -59,7 +59,7 @@ int smp_call_function_single_async(int cpu, struct __call_single_data *csd);* Cpus stopping functions in panic. All have default weak definitions. * Architecture-dependent code may override them. */ -void panic_smp_self_stop (void ); +void __noreturn panic_smp_self_stop (void );void nmi_panic_self_stop (struct pt_regs *regs);void crash_smp_send_stop (void );
kernel/panic.c +1 -1
@@ -141,7 +141,7 @@ EXPORT_SYMBOL(panic_blink);/* * Stop ourself in panic -- architecture code may override this */ -void __weak panic_smp_self_stop (void ) +void __weak __noreturn panic_smp_self_stop (void ) {while (1 )cpu_relax ();
tools/objtool/check.c +1 -0
@@ -218,6 +218,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"machine_real_restart" ,"make_task_dead" ,"panic" , +"panic_smp_self_stop" ,"rest_init" ,"rewind_stack_and_make_dead" , "sev_es_terminate",
[tip: objtool/core] cpu: Mark nmi_panic_self_stop() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 27dea14c7f05106f39850a9239874cd38703b405 Gitweb: https://git.kernel.org/tip/27dea14c7f05106f39850a9239874cd38703b405 Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:36 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:26 +02:00
cpu: Mark nmi_panic_self_stop() __noreturn
In preparation for improving objtool's handling of weak noreturn functions, mark nmi_panic_self_stop() __noreturn.
--- arch/x86/include/asm/reboot.h | 1 - arch/x86/kernel/reboot.c | 2 +- include/linux/smp.h | 2 +- kernel/panic.c | 2 +- tools/objtool/check.c | 1 + 5 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/reboot.h +0 -1
@@ -28,7 +28,6 @@ void __noreturn machine_real_restart(unsigned int type);void cpu_emergency_disable_virtualization (void );typedef void (*nmi_shootdown_cb )(int ,struct pt_regs *); -void nmi_panic_self_stop (struct pt_regs *regs);void nmi_shootdown_cpus (nmi_shootdown_cb callback);void run_crash_ipi_callback (struct pt_regs *regs);
arch/x86/kernel/reboot.c +1 -1
@@ -920,7 +920,7 @@ void run_crash_ipi_callback(struct pt_regs *regs) }/* Override the weak function in kernel/panic.c */ -void nmi_panic_self_stop (struct pt_regs *regs) +void __noreturn nmi_panic_self_stop (struct pt_regs *regs) {while (1 ) {/* If no CPU is preparing crash dump, we simply loop here. */
include/linux/smp.h +1 -1
@@ -60,7 +60,7 @@ int smp_call_function_single_async(int cpu, struct __call_single_data *csd);* Architecture-dependent code may override them. */ void __noreturn panic_smp_self_stop (void ); -void nmi_panic_self_stop (struct pt_regs *regs); +void __noreturn nmi_panic_self_stop (struct pt_regs *regs);void crash_smp_send_stop (void );/*
kernel/panic.c +1 -1
@@ -151,7 +151,7 @@ void __weak __noreturn panic_smp_self_stop(void)* Stop ourselves in NMI context if another CPU has already panicked. Arch code * may override this to prepare for crash dumping, e.g. save regs info. */ -void __weak nmi_panic_self_stop (struct pt_regs *regs) +void __weak __noreturn nmi_panic_self_stop (struct pt_regs *regs) {panic_smp_self_stop (); }
tools/objtool/check.c +1 -0
@@ -217,6 +217,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"lbug_with_loc" ,"machine_real_restart" ,"make_task_dead" , +"nmi_panic_self_stop" ,"panic" ,"panic_smp_self_stop" , "rest_init",
[tip: objtool/core] init: Mark [arch_call_]rest_init() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 9ea7e6b62c2bd2f7bbfc3f10099df803002dd33b Gitweb: https://git.kernel.org/tip/9ea7e6b62c2bd2f7bbfc3f10099df803002dd33b Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:31 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:23 +02:00
init: Mark [arch_call_]rest_init() __noreturn
In preparation for improving objtool's handling of weak noreturn functions, mark start_kernel(), arch_call_rest_init(), and rest_init() __noreturn.
--- arch/s390/kernel/setup.c | 2 +- include/linux/start_kernel.h | 4 ++-- init/main.c | 4 ++-- tools/objtool/check.c | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-)
arch/s390/kernel/setup.c +1 -1
@@ -396,7 +396,7 @@ int __init arch_early_irq_init(void)return 0 ; } -void __init arch_call_rest_init (void ) +void __init __noreturn arch_call_rest_init (void ) {unsigned long stack;
include/linux/start_kernel.h +2 -2
@@ -9,7 +9,7 @@up something else. */ extern asmlinkage void __init start_kernel(void); -extern void __init arch_call_rest_init (void ); -extern void __ref rest_init (void ); +extern void __init __noreturn arch_call_rest_init (void ); +extern void __ref __noreturn rest_init (void );#endif /* _LINUX_START_KERNEL_H */
init/main.c +2 -2
@@ -683,7 +683,7 @@ static void __init setup_command_line(char *command_line)static __initdata DECLARE_COMPLETION (kthreadd_done); -noinline void __ref rest_init(void) +noinline void __ref __noreturn rest_init(void) {struct task_struct *tsk;int pid;
@@ -889,7 +889,7 @@ static int __init early_randomize_kstack_offset(char *buf)early_param ("randomize_kstack_offset" , early_randomize_kstack_offset);#endif -void __init __weak arch_call_rest_init (void ) +void __init __weak __noreturn arch_call_rest_init (void ) {rest_init (); }
tools/objtool/check.c +2 -0
@@ -202,6 +202,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"__reiserfs_panic" ,"__stack_chk_fail" ,"__ubsan_handle_builtin_unreachable" , +"arch_call_rest_init" ,"arch_cpu_idle_dead" ,"cpu_bringup_and_idle" , "cpu_startup_entry",
@@ -217,6 +218,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"machine_real_restart" ,"make_task_dead" ,"panic" , +"rest_init" ,"rewind_stack_and_make_dead" ,"sev_es_terminate" , "snp_abort",
[tip: objtool/core] init: Mark start_kernel() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 25a6917ca63ad4470bf88535c56f0dec72b570fe Gitweb: https://git.kernel.org/tip/25a6917ca63ad4470bf88535c56f0dec72b570fe Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:32 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:23 +02:00
init: Mark start_kernel() __noreturn
Now that arch_call_rest_init() is __noreturn, mark its caller start_kernel() __noreturn.
--- include/linux/start_kernel.h | 2 +- init/main.c | 2 +- tools/objtool/check.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
include/linux/start_kernel.h +1 -1
@@ -8,7 +8,7 @@/* Define the prototype for start_kernel here, rather than cluttering up something else. */ -extern asmlinkage void __init start_kernel(void); +extern asmlinkage void __init __noreturn start_kernel(void);extern void __init __noreturn arch_call_rest_init (void );extern void __ref __noreturn rest_init (void );
init/main.c +1 -1
@@ -937,7 +937,7 @@ static void __init print_unknown_bootoptions(void)memblock_free (unknown_options, len); } -asmlinkage __visible void __init __no_sanitize_address start_kernel(void) +asmlinkage __visible void __init __no_sanitize_address __noreturn start_kernel(void) {char *command_line;char *after_dashes;
tools/objtool/check.c +1 -0
@@ -222,6 +222,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"rewind_stack_and_make_dead" ,"sev_es_terminate" ,"snp_abort" , +"start_kernel" ,"stop_this_cpu" ,"usercopy_abort" , "xen_cpu_bringup_again",
[tip: objtool/core] objtool: Include weak functions in global_noreturns check
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 1c47c8758a11345ac643fa68cb70b708a6668883 Gitweb: https://git.kernel.org/tip/1c47c8758a11345ac643fa68cb70b708a6668883 Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:37 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:26 +02:00
objtool: Include weak functions in global_noreturns check
If a global function doesn't return, and its prototype has the __noreturn attribute, its weak counterpart must also not return so that it matches the prototype and meets call site expectations.
To properly follow the compiled control flow at the call sites, change the global_noreturns check to include both global and weak functions.
On the other hand, if a weak function isn't in global_noreturns, assume the prototype doesn't have __noreturn. Even if the weak function doesn't return, call sites treat it like a returnable function.
Fixes the following warning:
kernel/sched/build_policy.o: warning: objtool: do_idle() falls through to next function play_idle_precise()
--- tools/objtool/check.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/objtool/check.c +4 -4
@@ -236,14 +236,14 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,if (!func)return false; -if (func->bind ==STB_WEAK ) -return false; - -if (func->bind ==STB_GLOBAL ) +if (func->bind ==STB_GLOBAL || func->bind ==STB_WEAK )for (i =0 ; i <ARRAY_SIZE (global_noreturns); i++)if (!strcmp (func->name, global_noreturns[i]))return true; +if (func->bind ==STB_WEAK ) +return false; +if (!func->len)return false;
[tip: objtool/core] btrfs: Mark btrfs_assertfail() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 09c5ae30d007514a1be870fa5873ad55c3319f3a Gitweb: https://git.kernel.org/tip/09c5ae30d007514a1be870fa5873ad55c3319f3a Author: Josh Poimboeuf <[email protected]> AuthorDate: Wed, 12 Apr 2023 16:49:38 -07:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 14 Apr 2023 17:31:26 +02:00
btrfs: Mark btrfs_assertfail() __noreturn
Fixes a bunch of warnings including:
vmlinux.o: warning: objtool: select_reloc_root+0x314: unreachable instruction vmlinux.o: warning: objtool: finish_inode_if_needed+0x15b1: unreachable instruction vmlinux.o: warning: objtool: get_bio_sector_nr+0x259: unreachable instruction vmlinux.o: warning: objtool: raid_wait_read_end_io+0xc26: unreachable instruction vmlinux.o: warning: objtool: raid56_parity_alloc_scrub_rbio+0x37b: unreachable instruction
...
--- fs/btrfs/messages.c | 2 +- fs/btrfs/messages.h | 2 +- tools/objtool/check.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/messages.c +1 -1
@@ -253,7 +253,7 @@ void __cold _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt,#endif #ifdef CONFIG_BTRFS_ASSERT -void __cold btrfs_assertfail (const char *expr,const char *file,int line) +void __cold __noreturn btrfs_assertfail (const char *expr,const char *file,int line) {pr_err ("assertion failed: %s, in %s:%d\n" , expr, file, line);BUG ();
fs/btrfs/messages.h +1 -1
@@ -160,7 +160,7 @@ do { \ } while (0)#ifdef CONFIG_BTRFS_ASSERT -void __cold btrfs_assertfail (const char *expr,const char *file,int line); +void __cold __noreturn btrfs_assertfail (const char *expr,const char *file,int line);#define ASSERT (expr) \ (likely(expr) ? (void)0 : btrfs_assertfail(#expr, __FILE__, __LINE__))
tools/objtool/check.c +1 -0
@@ -204,6 +204,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"__ubsan_handle_builtin_unreachable" ,"arch_call_rest_init" ,"arch_cpu_idle_dead" , +"btrfs_assertfail" ,"cpu_bringup_and_idle" ,"cpu_startup_entry" , "do_exit",