[PATCH] BUG preserve registers

Hugh Dickins
2002-02-09T08:12:00Z

It's frustrating that when Verbose BUG() reporting is configured,
info gets lost: fix for i386 below. This is your area, Andrew:
please confirm to Marcelo if you'd like him to apply this.

Example: in hpa's recent prune_dcache crash, %eax showed the length of
the kernel BUG printk, when we'd have liked to see the invalid d_count:
off-by-one or obviously corrupted?

Hugh

--- 2.4.18-pre9/arch/i386/kernel/entry.S Thu Feb 7 14:38:06 2002
+++ linux/arch/i386/kernel/entry.S Fri Feb 8 21:47:39 2002
@@ -132,6 +132,30 @@
movl $-8192, reg; \
andl %esp, reg

+#ifdef CONFIG_DEBUG_BUGVERBOSE
+BUG_format:
+ .asciz "kernel BUG at %s:%d!\n"
+ENTRY(do_BUG)
+ pushfl # Save flags and registers changed in C
+ pushl %eax
+ pushl %ecx
+ pushl %edx
+ pushl $1
+ call SYMBOL_NAME(bust_spinlocks)
+ movl 28(%esp),%eax
+ movl 24(%esp),%ecx
+ pushl %eax
+ pushl %ecx
+ pushl $BUG_format
+ call SYMBOL_NAME(printk)
+ addl $16,%esp
+ popl %edx # Restore registers and flags for display
+ popl %ecx
+ popl %eax
+ popfl
+ ret
+#endif /* CONFIG_DEBUG_BUGVERBOSE */
+
ENTRY(lcall7)
pushfl # We get a different stack layout with call gates,
pushl %eax # which has to be cleaned up later..
--- 2.4.18-pre9/arch/i386/mm/fault.c Thu Feb 7 14:38:07 2002
+++ linux/arch/i386/mm/fault.c Fri Feb 8 19:06:45 2002
@@ -125,12 +125,6 @@
}
}

-void do_BUG(const char *file, int line)
-{
- bust_spinlocks(1);
- printk("kernel BUG at %s:%d!\n", file, line);
-}
-
asmlinkage void do_invalid_op(struct pt_regs *, unsigned long);
extern unsigned long idt;