linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: translate register values to physical addresses in kernel panics
@ 2022-08-12 18:35 Peter Collingbourne
  2022-09-09 10:37 ` Catalin Marinas
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Collingbourne @ 2022-08-12 18:35 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Brown, Mark Rutland
  Cc: Peter Collingbourne, linux-arm-kernel, linux-kernel

When debugging a kernel panic it is sometimes useful to know the physical
address of any virtual addresses stored in registers. Therefore, pass
all register values through AT S1E1R and print the resulting PAR_EL1
value next to the register.

Signed-off-by: Peter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/I7c6be65f27052da57088ff58b463fdbe2394f43c
---
Not sure if this should land in this form (I imagine there could be
all kinds of parsers that are expecting the existing format) but
maybe behind an option. Let me know what you think.

 arch/arm64/kernel/process.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 92bcc1768f0b..8b5f8c2c8abf 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -197,6 +197,18 @@ static void print_pstate(struct pt_regs *regs)
 	}
 }
 
+static unsigned long at(unsigned long addr)
+{
+	unsigned long pa;
+
+	__asm__ __volatile__("at s1e1r, %1\n"
+			     "mrs %0, par_el1\n"
+			     : "=r"(pa)
+			     : "r"(addr)
+			     : "memory");
+	return pa;
+}
+
 void __show_regs(struct pt_regs *regs)
 {
 	int i, top_reg;
@@ -231,10 +243,10 @@ void __show_regs(struct pt_regs *regs)
 	i = top_reg;
 
 	while (i >= 0) {
-		printk("x%-2d: %016llx", i, regs->regs[i]);
+		printk("x%-2d: %016llx (%016llx)", i, regs->regs[i], at(regs->regs[i]));
 
 		while (i-- % 3)
-			pr_cont(" x%-2d: %016llx", i, regs->regs[i]);
+			pr_cont(" x%-2d: %016llx (%016llx)", i, regs->regs[i], at(regs->regs[i]));
 
 		pr_cont("\n");
 	}
-- 
2.37.1.595.g718a3a8f04-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-09 10:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12 18:35 [PATCH] arm64: translate register values to physical addresses in kernel panics Peter Collingbourne
2022-09-09 10:37 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).