arm64: traps: Dump registers prior to panic() in bad_mode()
Will Deacon
maintainerPATCH 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.
--- arch/arm64/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+)
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);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
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]>Signed-off-by Will Deacon <[email protected]>--- arch/arm64/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/kernel/traps.c +0
-0
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
-0local_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