vmap: print pfn for register in vmalloc range [1/1]

PD#SWPL-5564

Problem:
When open VMAP for kernel stack, if we meet kernel panic log, we
can't know physical address of stack and hard to debug.

Solution:
Print pfn for register in vmalloc range

Verify:
p212

Change-Id: Iee120df1feab88e412ef63e87c2e2bb4ad0645fb
Signed-off-by: Tao Zeng <tao.zeng@amlogic.com>
This commit is contained in:
Tao Zeng
2019-03-07 10:17:29 +08:00
parent 90264baf39
commit 4580a3d11d
2 changed files with 39 additions and 0 deletions

View File

@@ -350,6 +350,23 @@ done:
pr_cont("%s", name);
pr_cont("\n");
}
static void show_vmalloc_pfn(struct pt_regs *regs)
{
int i;
struct page *page;
for (i = 0; i < 16; i++) {
if (is_vmalloc_or_module_addr((void *)regs->uregs[i])) {
page = vmalloc_to_page((void *)regs->uregs[i]);
if (!page)
continue;
pr_info("R%-2d : %08lx, PFN:%5lx\n",
i, regs->uregs[i], page_to_pfn(page));
}
}
}
#endif /* CONFIG_AMLOGIC_USER_FAULT */
void __show_regs(struct pt_regs *regs)
@@ -408,6 +425,10 @@ void __show_regs(struct pt_regs *regs)
buf[3] = flags & PSR_V_BIT ? 'V' : 'v';
buf[4] = '\0';
#ifdef CONFIG_AMLOGIC_USER_FAULT
show_vmalloc_pfn(regs);
#endif
#ifndef CONFIG_CPU_V7M
{
const char *segment;

View File

@@ -268,6 +268,23 @@ static void show_user_data(unsigned long addr, int nbytes, const char *name)
pr_cont("\n");
}
}
static void show_vmalloc_pfn(struct pt_regs *regs)
{
int i;
struct page *page;
for (i = 0; i < 16; i++) {
if (is_vmalloc_or_module_addr((void *)regs->regs[i])) {
page = vmalloc_to_page((void *)regs->regs[i]);
if (!page)
continue;
pr_info("R%-2d : %016llx, PFN:%5lx\n",
i, regs->regs[i], page_to_pfn(page));
}
}
}
#endif /* CONFIG_AMLOGIC_USER_FAULT */
static void show_extra_register_data(struct pt_regs *regs, int nbytes)
@@ -443,6 +460,7 @@ void __show_regs(struct pt_regs *regs)
show_vma(current->mm, instruction_pointer(regs));
show_vma(current->mm, lr);
}
show_vmalloc_pfn(regs);
#endif /* CONFIG_AMLOGIC_USER_FAULT */
printk("pc : [<%016llx>] lr : [<%016llx>] pstate: %08llx\n",
regs->pc, lr, regs->pstate);