Commit a4c3f909 authored by Balbir Singh's avatar Balbir Singh Committed by Michael Ellerman

powerpc: Fix BUG_ON() reporting in real mode

I ran into this issue while debugging an early boot problem. The system
hit a BUG_ON() but report bug failed to print the line number and file
name. The reason being that the system was running in real mode and
report_bug() searches for addresses in the PAGE_OFFSET+ region.
Suggested-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarBalbir Singh <bsingharora@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 10d8b148
...@@ -1148,6 +1148,7 @@ void __kprobes program_check_exception(struct pt_regs *regs) ...@@ -1148,6 +1148,7 @@ void __kprobes program_check_exception(struct pt_regs *regs)
goto bail; goto bail;
} }
if (reason & REASON_TRAP) { if (reason & REASON_TRAP) {
unsigned long bugaddr;
/* Debugger is first in line to stop recursive faults in /* Debugger is first in line to stop recursive faults in
* rcu_lock, notify_die, or atomic_notifier_call_chain */ * rcu_lock, notify_die, or atomic_notifier_call_chain */
if (debugger_bpt(regs)) if (debugger_bpt(regs))
...@@ -1158,8 +1159,15 @@ void __kprobes program_check_exception(struct pt_regs *regs) ...@@ -1158,8 +1159,15 @@ void __kprobes program_check_exception(struct pt_regs *regs)
== NOTIFY_STOP) == NOTIFY_STOP)
goto bail; goto bail;
bugaddr = regs->nip;
/*
* Fixup bugaddr for BUG_ON() in real mode
*/
if (!is_kernel_addr(bugaddr) && !(regs->msr & MSR_IR))
bugaddr += PAGE_OFFSET;
if (!(regs->msr & MSR_PR) && /* not user-mode */ if (!(regs->msr & MSR_PR) && /* not user-mode */
report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) { report_bug(bugaddr, regs) == BUG_TRAP_TYPE_WARN) {
regs->nip += 4; regs->nip += 4;
goto bail; goto bail;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment