Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
Merge tag 'objtool-core-2023-04-27' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/tip/tip

Pull objtool updates from Ingo Molnar:

 - Mark arch_cpu_idle_dead() __noreturn, make all architectures &
   drivers that did this inconsistently follow this new, common
   convention, and fix all the fallout that objtool can now detect
   statically

 - Fix/improve the ORC unwinder becoming unreliable due to
   UNWIND_HINT_EMPTY ambiguity, split it into UNWIND_HINT_END_OF_STACK
   and UNWIND_HINT_UNDEFINED to resolve it

 - Fix noinstr violations in the KCSAN code and the lkdtm/stackleak code

 - Generate ORC data for __pfx code

 - Add more __noreturn annotations to various kernel startup/shutdown
   and panic functions

 - Misc improvements & fixes

* tag 'objtool-core-2023-04-27' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (52 commits)
  x86/hyperv: Mark hv_ghcb_terminate() as noreturn
  scsi: message: fusion: Mark mpt_halt_firmware() __noreturn
  x86/cpu: Mark {hlt,resume}_play_dead() __noreturn
  btrfs: Mark btrfs_assertfail() __noreturn
  objtool: Include weak functions in global_noreturns check
  cpu: Mark nmi_panic_self_stop() __noreturn
  cpu: Mark panic_smp_self_stop() __noreturn
  arm64/cpu: Mark cpu_park_loop() and friends __noreturn
  x86/head: Mark *_start_kernel() __noreturn
  init: Mark start_kernel() __noreturn
  init: Mark [arch_call_]rest_init() __noreturn
  objtool: Generate ORC data for __pfx code
  x86/linkage: Fix padding for typed functions
  objtool: Separate prefix code from stack validation code
  objtool: Remove superfluous dead_end_function() check
  objtool: Add symbol iteration helpers
  objtool: Add WARN_INSN()
  scripts/objdump-func: Support multiple functions
  context_tracking: Fix KCSAN noinstr violation
  objtool: Add stackleak instrumentation to uaccess safe list
  ...
  • Loading branch information
torvalds committed Apr 28, 2023
2 parents 22b8cc3 + 611d4c7 commit 2aff7c7
Show file tree
Hide file tree
Showing 84 changed files with 641 additions and 684 deletions.
2 changes: 1 addition & 1 deletion Documentation/livepatch/reliable-stacktrace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ trampoline or return trampoline. For example, considering the x86_64
.. code-block:: none
SYM_CODE_START(return_to_handler)
UNWIND_HINT_EMPTY
UNWIND_HINT_UNDEFINED
subq $24, %rsp
/* Save the return values */
Expand Down
2 changes: 1 addition & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -15180,8 +15180,8 @@ OBJTOOL
M: Josh Poimboeuf <[email protected]>
M: Peter Zijlstra <[email protected]>
S: Supported
F: include/linux/objtool*.h
F: tools/objtool/
F: include/linux/objtool.h

OCELOT ETHERNET SWITCH DRIVER
M: Vladimir Oltean <[email protected]>
Expand Down
4 changes: 3 additions & 1 deletion arch/alpha/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* This file handles the architecture-dependent parts of process handling.
*/

#include <linux/cpu.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/sched.h>
Expand Down Expand Up @@ -59,9 +60,10 @@ void arch_cpu_idle(void)
wtint(0);
}

void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
wtint(INT_MAX);
BUG();
}
#endif /* ALPHA_WTINT */

Expand Down
6 changes: 4 additions & 2 deletions arch/arm/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void __cpu_die(unsigned int cpu)
* of the other hotplug-cpu capable cores, so presumably coming
* out of idle fixes this.
*/
void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
unsigned int cpu = smp_processor_id();

Expand Down Expand Up @@ -382,6 +382,8 @@ void arch_cpu_idle_dead(void)
: "r" (task_stack_page(current) + THREAD_SIZE - 8),
"r" (current)
: "r0");

unreachable();
}
#endif /* CONFIG_HOTPLUG_CPU */

Expand Down Expand Up @@ -777,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());
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/include/asm/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
9 changes: 4 additions & 5 deletions arch/arm64/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)
extern int __cpu_disable(void);

extern void __cpu_die(unsigned int cpu);
extern void cpu_die(void);
extern void cpu_die_early(void);
extern void __noreturn cpu_die(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();
Expand All @@ -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();
Expand All @@ -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__ */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/entry-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void (*pm_power_off)(void);
EXPORT_SYMBOL_GPL(pm_power_off);

#ifdef CONFIG_HOTPLUG_CPU
void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
cpu_die();
}
Expand Down
12 changes: 7 additions & 5 deletions arch/arm64/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void __cpu_die(unsigned int cpu)
* Called from the idle thread for the CPU which has been shutdown.
*
*/
void cpu_die(void)
void __noreturn cpu_die(void)
{
unsigned int cpu = smp_processor_id();
const struct cpu_operations *ops = get_cpu_ops(cpu);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);

Expand All @@ -830,7 +830,7 @@ static void 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();
}
Expand All @@ -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);
Expand All @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions arch/arm64/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion arch/csky/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void __cpu_die(unsigned int cpu)
pr_notice("CPU%u: shutdown\n", cpu);
}

void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
idle_task_exit();

Expand All @@ -317,5 +317,7 @@ void arch_cpu_idle_dead(void)
"jmpi csky_start_secondary"
:
: "r" (secondary_stack));

BUG();
}
#endif
6 changes: 3 additions & 3 deletions arch/ia64/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ __setup("nohalt", nohalt_setup);

#ifdef CONFIG_HOTPLUG_CPU
/* We don't actually take CPU down, just spin without interrupts. */
static inline void play_dead(void)
static inline void __noreturn play_dead(void)
{
unsigned int this_cpu = smp_processor_id();

Expand All @@ -219,13 +219,13 @@ static inline void play_dead(void)
BUG();
}
#else
static inline void play_dead(void)
static inline void __noreturn play_dead(void)
{
BUG();
}
#endif /* CONFIG_HOTPLUG_CPU */

void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
play_dead();
}
Expand Down
2 changes: 1 addition & 1 deletion arch/loongarch/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static inline void __cpu_die(unsigned int cpu)
loongson_cpu_die(cpu);
}

extern void play_dead(void);
extern void __noreturn play_dead(void);
#endif

#endif /* __ASM_SMP_H */
2 changes: 1 addition & 1 deletion arch/loongarch/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
EXPORT_SYMBOL(boot_option_idle_override);

#ifdef CONFIG_HOTPLUG_CPU
void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
play_dead();
}
Expand Down
2 changes: 1 addition & 1 deletion arch/loongarch/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void play_dead(void)
iocsr_write32(0xffffffff, LOONGARCH_IOCSR_IPI_CLEAR);

init_fn();
unreachable();
BUG();
}

#endif
Expand Down
1 change: 1 addition & 0 deletions arch/mips/cavium-octeon/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <asm/mmu_context.h>
#include <asm/time.h>
#include <asm/setup.h>
#include <asm/smp.h>

#include <asm/octeon/octeon.h>

Expand Down
2 changes: 1 addition & 1 deletion arch/mips/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static inline void __cpu_die(unsigned int cpu)
mp_ops->cpu_die(cpu);
}

extern void play_dead(void);
extern void __noreturn play_dead(void);
#endif

#ifdef CONFIG_KEXEC
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <asm/stacktrace.h>

#ifdef CONFIG_HOTPLUG_CPU
void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
play_dead();
}
Expand Down
4 changes: 4 additions & 0 deletions arch/mips/kernel/smp-bmips.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ static void bmips_set_reset_vec(int cpu, u32 val);

#ifdef CONFIG_SMP

#include <asm/smp.h>

/* initial $sp, $gp - used by arch/mips/kernel/bmips_vec.S */
unsigned long bmips_smp_boot_sp;
unsigned long bmips_smp_boot_gp;
Expand Down Expand Up @@ -413,6 +415,8 @@ void __ref play_dead(void)
" wait\n"
" j bmips_secondary_reentry\n"
: : : "memory");

BUG();
}

#endif /* CONFIG_HOTPLUG_CPU */
Expand Down
1 change: 1 addition & 0 deletions arch/mips/kernel/smp-cps.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <asm/mipsregs.h>
#include <asm/pm-cps.h>
#include <asm/r4kcache.h>
#include <asm/smp.h>
#include <asm/smp-cps.h>
#include <asm/time.h>
#include <asm/uasm.h>
Expand Down
2 changes: 2 additions & 0 deletions arch/mips/loongson64/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/cpufreq.h>
#include <linux/kexec.h>
#include <asm/processor.h>
#include <asm/smp.h>
#include <asm/time.h>
#include <asm/tlbflush.h>
#include <asm/cacheflush.h>
Expand Down Expand Up @@ -808,6 +809,7 @@ void play_dead(void)
state_addr = &per_cpu(cpu_state, cpu);
mb();
play_dead_at_ckseg1(state_addr);
BUG();
}

static int loongson3_disable_clock(unsigned int cpu)
Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ EXPORT_SYMBOL(running_on_qemu);
/*
* Called from the idle thread for the CPU which has been shutdown.
*/
void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
#ifdef CONFIG_HOTPLUG_CPU
idle_task_exit();
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void start_secondary(void *unused);
extern int smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us);
extern int smp_send_safe_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us);
extern void smp_send_debugger_break(void);
extern void start_secondary_resume(void);
extern void __noreturn start_secondary_resume(void);
extern void smp_generic_give_timebase(void);
extern void smp_generic_take_timebase(void);

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/setup_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ void __cpu_die(unsigned int cpu)
smp_ops->cpu_die(cpu);
}

void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
/*
* Disable on the down path. This will be re-enabled by
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/kernel/cpu-hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void __cpu_die(unsigned int cpu)
/*
* Called from the idle thread for the CPU which has been shutdown.
*/
void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
idle_task_exit();

Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void arch_cpu_idle_exit(void)
{
}

void arch_cpu_idle_dead(void)
void __noreturn arch_cpu_idle_dead(void)
{
cpu_die();
}
Loading

0 comments on commit 2aff7c7

Please sign in to comment.