* [PATCH] arm64: interrupts: print FAR_ELx on sync exceptions
@ 2023-04-02 16:27 Pavel Skripkin
2023-04-26 12:30 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Skripkin @ 2023-04-02 16:27 UTC (permalink / raw)
To: u-boot; +Cc: Pavel Skripkin
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] arm64: interrupts: print FAR_ELx on sync exceptions
2023-04-02 16:27 [PATCH] arm64: interrupts: print FAR_ELx on sync exceptions Pavel Skripkin
@ 2023-04-26 12:30 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2023-04-26 12:30 UTC (permalink / raw)
To: Pavel Skripkin; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 645 bytes --]
On Sun, Apr 02, 2023 at 07:27:34PM +0300, Pavel Skripkin wrote:
> 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>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-26 12:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-02 16:27 [PATCH] arm64: interrupts: print FAR_ELx on sync exceptions Pavel Skripkin
2023-04-26 12:30 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox