soc: qcom: dump current task stack and task_struct for minidump

Register the current stack and task_struct of all cpus to
the minidump table on panic.

Change-Id: I6906721f8c734dbf8142dc49e80dc730530f028c
Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org>
This commit is contained in:
Lingutla Chandrasekhar 2017-08-05 14:26:56 +05:30 committed by Gerrit - the friendly Code Review server
parent 285229fa97
commit af5a88a343
4 changed files with 36 additions and 0 deletions

View file

@ -54,6 +54,7 @@
#include <asm/ptrace.h>
#include <asm/virt.h>
#include <asm/edac.h>
#include <soc/qcom/minidump.h>
#define CREATE_TRACE_POINTS
#include <trace/events/ipi.h>
@ -740,6 +741,7 @@ static void ipi_cpu_stop(unsigned int cpu, struct pt_regs *regs)
pr_crit("CPU%u: stopping\n", cpu);
show_regs(regs);
dump_stack();
dump_stack_minidump(regs->sp);
arm64_check_cache_ecc(NULL);
raw_spin_unlock(&stop_lock);
}

View file

@ -18,6 +18,7 @@
#include <linux/slab.h>
#include <linux/kmemleak.h>
#include <linux/async.h>
#include <linux/thread_info.h>
#include <soc/qcom/memory_dump.h>
#include <soc/qcom/minidump.h>
#include <asm/sections.h>
@ -256,6 +257,32 @@ static void __init register_kernel_sections(void)
}
}
#ifdef CONFIG_QCOM_MINIDUMP
void dump_stack_minidump(u64 sp)
{
struct md_region ksp_entry, ktsk_entry;
u32 cpu = smp_processor_id();
if (sp < KIMAGE_VADDR || sp > -256UL)
sp = current_stack_pointer;
sp &= ~(THREAD_SIZE - 1);
scnprintf(ksp_entry.name, sizeof(ksp_entry.name), "KSTACK%d", cpu);
ksp_entry.virt_addr = sp;
ksp_entry.phys_addr = virt_to_phys((uintptr_t *)sp);
ksp_entry.size = THREAD_SIZE;
if (msm_minidump_add_region(&ksp_entry))
pr_err("Failed to add stack of cpu %d in Minidump\n", cpu);
scnprintf(ktsk_entry.name, sizeof(ktsk_entry.name), "KTASK%d", cpu);
ktsk_entry.virt_addr = (u64)current;
ktsk_entry.phys_addr = virt_to_phys((uintptr_t *)current);
ktsk_entry.size = sizeof(struct task_struct);
if (msm_minidump_add_region(&ktsk_entry))
pr_err("Failed to add current task %d in Minidump\n", cpu);
}
#endif
static void __init async_common_log_init(void *data, async_cookie_t cookie)
{
register_kernel_sections();

View file

@ -39,11 +39,16 @@ struct md_region {
extern int msm_minidump_add_region(const struct md_region *entry);
/* Sets to true, if minidump table is initialized */
extern bool minidump_enabled;
extern void dump_stack_minidump(u64 sp);
#else
static inline int msm_minidump_add_region(const struct md_region *entry)
{
/* Return quietly, if minidump is not supported */
return 0;
}
static inline void dump_stack_minidump(u64 sp) {}
#endif
#endif

View file

@ -24,6 +24,7 @@
#include <linux/init.h>
#include <linux/nmi.h>
#include <linux/console.h>
#include <soc/qcom/minidump.h>
#define CREATE_TRACE_POINTS
#include <trace/events/exception.h>
@ -108,6 +109,7 @@ void panic(const char *fmt, ...)
va_start(args, fmt);
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
dump_stack_minidump(0);
pr_emerg("Kernel panic - not syncing: %s\n", buf);
#ifdef CONFIG_DEBUG_BUGVERBOSE
/*