public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: u-boot@lists.denx.de
Cc: Pavel Skripkin <paskripkin@gmail.com>
Subject: [PATCH] arm64: interrupts: print FAR_ELx on sync exceptions
Date: Sun,  2 Apr 2023 19:27:34 +0300	[thread overview]
Message-ID: <20230402162734.121322-1-paskripkin@gmail.com> (raw)

Default synchronous exceptions handler prints only esr and register
dump. Sometimes it requiers to see an address which caused exceptions
to understand what's going on

ARM ARM in section D13.2.41 states that FAR_EL2 will contain meanfull
value in case of ESR.EC holds 0x20, 0x21, 0x24, 0x25, 0x22, 0x34 or
0x35. Same applies for EL1.

This patch adds function whivh determine current EL, gets correct FAR
register and prints it on panic.

Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 arch/arm/lib/interrupts_64.c | 38 +++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/interrupts_64.c b/arch/arm/lib/interrupts_64.c
index 2e091415a4..125dc0bb39 100644
--- a/arch/arm/lib/interrupts_64.c
+++ b/arch/arm/lib/interrupts_64.c
@@ -37,6 +37,40 @@ static void show_efi_loaded_images(struct pt_regs *regs)
 	efi_print_image_infos((void *)regs->elr);
 }
 
+static void dump_far(unsigned long esr)
+{
+	unsigned long el, far;
+
+	switch ((esr >> 26) & 0b111111) {
+	case 0x20:
+	case 0x21:
+	case 0x24:
+	case 0x25:
+	case 0x22:
+	case 0x34:
+	case 0x35:
+		break;
+	default:
+		return;
+	}
+
+	asm("mrs	%0, CurrentEl": "=r" (el));
+
+	switch (el >> 2) {
+	case 1:
+		asm("mrs	%0, FAR_EL1": "=r" (far));
+		break;
+	case 2:
+		asm("mrs	%0, FAR_EL2": "=r" (far));
+		break;
+	default:
+		/* don't print anything to make output pretty */
+		return;
+	}
+
+	printf(", far 0x%lx", far);
+}
+
 static void dump_instr(struct pt_regs *regs)
 {
 	u32 *addr = (u32 *)(regs->elr & ~3UL);
@@ -165,7 +199,9 @@ void do_sync(struct pt_regs *pt_regs)
 	    smh_emulate_trap(pt_regs))
 		return;
 	efi_restore_gd();
-	printf("\"Synchronous Abort\" handler, esr 0x%08lx\n", pt_regs->esr);
+	printf("\"Synchronous Abort\" handler, esr 0x%08lx", pt_regs->esr);
+	dump_far(pt_regs->esr);
+	printf("\n");
 	show_regs(pt_regs);
 	show_efi_loaded_images(pt_regs);
 	panic("Resetting CPU ...\n");
-- 
2.39.2


             reply	other threads:[~2023-04-03 12:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-02 16:27 Pavel Skripkin [this message]
2023-04-26 12:30 ` [PATCH] arm64: interrupts: print FAR_ELx on sync exceptions Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230402162734.121322-1-paskripkin@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox