vmap: print pfn for register in vmalloc range [1/1]
authorTao Zeng <tao.zeng@amlogic.com>
Thu, 7 Mar 2019 02:17:29 +0000 (10:17 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Wed, 20 Mar 2019 06:00:32 +0000 (22:00 -0800)
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>
arch/arm/kernel/process.c
arch/arm64/kernel/process.c

index 324b32b..c0c1730 100644 (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;
index 6084d01..7f377c1 100644 (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);