Skip to content

Commit

Permalink
[PATCH] i386: show_registers(): try harder to print failing code
Browse files Browse the repository at this point in the history
show_registers() tries to dump failing code starting 43 bytes before the
offending instruction, but this address can be bad, for example in a device
driver where the failing instruction is less than 43 bytes from the start
of the driver's code.  When that happens, try to dump code starting at the
failing instruction instead of printing no code at all.

Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Andi Kleen <ak@muc.de>
Cc: Keith Owens <kaos@ocs.com.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Chuck Ebbert authored and Linus Torvalds committed Sep 26, 2006
1 parent 1447c27 commit 9932532
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions arch/i386/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,21 @@ void show_registers(struct pt_regs *regs)
*/
if (in_kernel) {
u8 __user *eip;
int code_bytes = 64;
unsigned char c;

printk("\n" KERN_EMERG "Stack: ");
show_stack_log_lvl(NULL, regs, (unsigned long *)esp, KERN_EMERG);

printk(KERN_EMERG "Code: ");

eip = (u8 __user *)regs->eip - 43;
for (i = 0; i < 64; i++, eip++) {
unsigned char c;

if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) {
/* try starting at EIP */
eip = (u8 __user *)regs->eip;
code_bytes = 32;
}
for (i = 0; i < code_bytes; i++, eip++) {
if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) {
printk(" Bad EIP value.");
break;
Expand Down

0 comments on commit 9932532

Please sign in to comment.