From 4580a3d11db199683aaa7e2d7f03cd8d943f5af8 Mon Sep 17 00:00:00 2001 From: Tao Zeng Date: Thu, 7 Mar 2019 10:17:29 +0800 Subject: [PATCH] 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 --- arch/arm/kernel/process.c | 21 +++++++++++++++++++++ arch/arm64/kernel/process.c | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 324b32b..c0c1730 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -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; diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 6084d01..7f377c1 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -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); -- 2.7.4