Skip to contentSkip to conversation

arm64: traps: Dump registers prior to panic() in bad_mode()

PATCH In review Will Deacon 2 participants 2 messages Jun 15, 2020 arm64

lore
Share & tools
lore

Will Deacon

author maintainer
#0 lore raw

PATCH 1/1 arm64: traps: Dump registers prior to panic() in bad_mode()

When panicing due to an unknown/unhandled exception at EL1, dump the registers of the faulting context so that it's easier to figure out what went wrong. In particular, this makes it a lot easier to debug in-kernel BTI failures since it pretty-prints PSTATE.BTYPE in the crash log.

Cc Mark Brown <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 arch/arm64/kernel/traps.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/kernel/traps.c +2 -0
index 50cc30acf106..f1869e5bd743 100644
@@ -812,6 +812,8 @@ asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
 	pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n",
 		handler[reason], smp_processor_id(), esr,
 		esr_get_class_string(esr));
+	if (regs)
+		__show_regs(regs);
 
 	local_daif_mask();
 	panic("bad mode");
Signature · 7 lines
2.27.0.290.gba653c62da-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Will Deacon

When panicing due to an unknown/unhandled exception at EL1, dump the registers of the faulting context so that it's easier to figure out what went wrong. In particular, this makes it a lot easier to debug in-kernel BTI failures since it pretty-prints PSTATE.BTYPE in the crash log.

Cc Mark Brown <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 arch/arm64/kernel/traps.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/kernel/traps.c +0 -0
index 50cc30acf106..f1869e5bd743 100644

arch/arm64/kernel/traps.c asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr) · line 816

Quoted 5 lines
arch/arm64/kernel/traps.c +2 -0
@@ -812,6 +812,8 @@ asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
 	pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n",
 		handler[reason], smp_processor_id(), esr,
 		esr_get_class_string(esr));
+	if (regs)
+		__show_regs(regs);

For bad_mode() regs is never NULL, so you don't need to check that here.

Otherwise, this looks sane to me, so with the redundant check removed:

Mark.

Quoted 6 lines
arch/arm64/kernel/traps.c +0 -0
 	local_daif_mask();
 	panic("bad mode");
Signature · 1 line
2.27.0.290.gba653c62da-goog

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel