mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 22:51:35 +00:00
22ecd975b6
To enable RELIABLE_STACKTRACE and LIVEPATCH on arm64, we need to substantially rework arm64's unwinding code. As part of this, we want to minimize the set of unwind interfaces we expose, and avoid open-coding of unwind logic outside of stacktrace.c. Currently profile_pc() walks the stack of an interrupted context by calling start_backtrace() with the context's PC and FP, and iterating unwind steps using walk_stackframe(). This is functionally equivalent to calling arch_stack_walk() with the interrupted context's pt_regs, which will start with the PC and FP from the regs. Make profile_pc() use arch_stack_walk(). This simplifies profile_pc(), and in future will alow us to make walk_stackframe() private to stacktrace.c. At the same time, we remove the early return for when regs->pc is not in lock functions, as this will be handled by the first call to the profile_pc_cb() callback. There should be no functional change as a result of this patch. Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> [Mark: remove early return, elaborate commit message, fix includes] Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20211129142849.3056714-8-mark.rutland@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
73 lines
1.5 KiB
C
73 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Based on arch/arm/kernel/time.c
|
|
*
|
|
* Copyright (C) 1991, 1992, 1995 Linus Torvalds
|
|
* Modifications for ARM (C) 1994-2001 Russell King
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
*/
|
|
|
|
#include <linux/clockchips.h>
|
|
#include <linux/export.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/time.h>
|
|
#include <linux/init.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/timex.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/profile.h>
|
|
#include <linux/stacktrace.h>
|
|
#include <linux/syscore_ops.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/clocksource.h>
|
|
#include <linux/of_clk.h>
|
|
#include <linux/acpi.h>
|
|
|
|
#include <clocksource/arm_arch_timer.h>
|
|
|
|
#include <asm/thread_info.h>
|
|
#include <asm/paravirt.h>
|
|
|
|
static bool profile_pc_cb(void *arg, unsigned long pc)
|
|
{
|
|
unsigned long *prof_pc = arg;
|
|
|
|
if (in_lock_functions(pc))
|
|
return true;
|
|
*prof_pc = pc;
|
|
return false;
|
|
}
|
|
|
|
unsigned long profile_pc(struct pt_regs *regs)
|
|
{
|
|
unsigned long prof_pc = 0;
|
|
|
|
arch_stack_walk(profile_pc_cb, &prof_pc, current, regs);
|
|
|
|
return prof_pc;
|
|
}
|
|
EXPORT_SYMBOL(profile_pc);
|
|
|
|
void __init time_init(void)
|
|
{
|
|
u32 arch_timer_rate;
|
|
|
|
of_clk_init(NULL);
|
|
timer_probe();
|
|
|
|
tick_setup_hrtimer_broadcast();
|
|
|
|
arch_timer_rate = arch_timer_get_rate();
|
|
if (!arch_timer_rate)
|
|
panic("Unable to initialise architected timer.\n");
|
|
|
|
/* Calibrate the delay loop directly */
|
|
lpj_fine = arch_timer_rate / HZ;
|
|
|
|
pv_time_init();
|
|
}
|