[RESEND][PATCH] Fix BUG_ON() reporting in real mode on PPC

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

2 messages, 2 authors, 2016-02-29 · open the first message on its own page

[RESEND][PATCH] Fix BUG_ON() reporting in real mode on PPC

From: Balbir Singh <bsingharora@gmail.com>
Date: 2016-02-18 02:48:10

Changelog:
    Don't use REGION_ID, breaks on some platforms
    Don't blindly add PAGE_OFFSET to bugaddr

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: Paul Mackerras <redacted>
Signed-off-by: Balbir Singh <bsingharora@gmail.com>
---
 arch/powerpc/kernel/traps.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index b6becc7..4e5c11d 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1148,6 +1148,7 @@ void __kprobes program_check_exception(struct pt_regs *regs)
 		goto bail;
 	}
 	if (reason & REASON_TRAP) {
+		unsigned long bugaddr;
 		/* Debugger is first in line to stop recursive faults in
 		 * rcu_lock, notify_die, or atomic_notifier_call_chain */
 		if (debugger_bpt(regs))
@@ -1158,8 +1159,15 @@ void __kprobes program_check_exception(struct pt_regs *regs)
 				== NOTIFY_STOP)
 			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 */
-		    report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) {
+		    report_bug(bugaddr, regs) == BUG_TRAP_TYPE_WARN) {
 			regs->nip += 4;
 			goto bail;
 		}
-- 
2.5.0

Re: [RESEND] Fix BUG_ON() reporting in real mode on PPC

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2016-02-29 11:05:25

On Thu, 2016-18-02 at 02:48:01 UTC, Balbir Singh wrote:
Changelog:
    Don't use REGION_ID, breaks on some platforms
    Don't blindly add PAGE_OFFSET to bugaddr

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: Paul Mackerras <redacted>
Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/a4c3f909b4d9bb9430bf42ad58

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help