mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix bug of markup_oops.pl when first line of range is the  faulting instruction
@ 2010-01-17 13:36 Hui Zhu
  2010-01-28  6:49 ` Hui Zhu
  0 siblings, 1 reply; 2+ messages in thread
From: Hui Zhu @ 2010-01-17 13:36 UTC (permalink / raw)
  To: Andrew Morton, Arjan van de Ven, Sam Ravnborg,
	Ozan Çaglayan, Matthew Wilcox, linux-kernel

I got a "No matching code found" when I use markup_oops.pl parse a
error in a x8664 module.

BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
IP: [<ffffffffa0000000>] init_module+0x0/0x10 [e]
PGD 610a067 PUD 610b067 PMD 0
Oops: 0002 [1] PREEMPT SMP
CPU 0
Modules linked in: e(+)
Pid: 2064, comm: insmod Not tainted
2.6.27.39-WR3.0.2zz_standard-00073-g6471dad-dirty #3
RIP: 0010:[<ffffffffa0000000>]  [<ffffffffa0000000>] init_module+0x0/0x10 [e]
RSP: 0018:ffff8800060f5ef0  EFLAGS: 00000246
RAX: ffff8800060f5fd8 RBX: ffffffffa0000340 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffa0000000
RBP: ffffffffa0000000 R08: 0000000000000000 R09: ffff880001101000
R10: 0000000000000002 R11: 0000000000000472 R12: 0000000000000000
R13: 00000000006905b0 R14: 00007fff7c934f15 R15: 0000000000000003
FS:  000000000068f850(0063) GS:ffffffff80749040(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000000 CR3: 0000000006108000 CR4: 00000000000006a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 0000000000004000 DR7: 0000000000000000
Process insmod (pid: 2064, threadinfo ffff8800060f4000, task ffff8800079078e0)
Stack:  ffffffff8020903b 0000000000000000 ffffffff803a2fa1 0000000000000000
 ffffffff8058ab82 0000000000000000 ffffffff80253e15 0000000000000001
 ffffffffa0000340 000000000000c4ce ffffffffa0000340 000000000000c4ce
Call Trace:
 [<ffffffff8020903b>] ? _stext+0x3b/0x160
 [<ffffffff803a2fa1>] ? __up_read+0x21/0xb0
 [<ffffffff8058ab82>] ? _spin_unlock_irqrestore+0x12/0x40
 [<ffffffff80253e15>] ? __blocking_notifier_call_chain+0x65/0x90
 [<ffffffff80261e55>] ? sys_init_module+0xb5/0x210
 [<ffffffff8020bb0b>] ? system_call_done+0x0/0x5


Code: <c6> 04 25 00 00 00 00 03 31 c0 c3 0f 1f 44 00 00 f3 c3 90 90 04 00
RIP  [<ffffffffa0000000>] init_module+0x0/0x10 [e]
 RSP <ffff8800060f5ef0>
CR2: 0000000000000000
---[ end trace 1f34257349e749de ]---


0000000000000000 <init_module>:
init_module():
/home/teawater/study/kernel/stack2core/example/e.c:10
   0:	c6 04 25 00 00 00 00 	movb   $0x3,0x0
   7:	03
/home/teawater/study/kernel/stack2core/example/e.c:13
   8:	31 c0                	xor    %eax,%eax
   a:	c3                   	retq
   b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)

0000000000000010 <cleanup_module>:
cleanup_module():
/home/teawater/study/kernel/stack2core/example/e.c:20
  10:	f3 c3                	repz retq
  12:	90                   	nop
  13:	90                   	nop
Disassembly of section .modinfo:

This is because the faulting instruction "movb   $0x3,0x0" is the
first line of the range.

In the markup_oops.pl:
open(FILE, "objdump -dS --adjust-vma=$vmaoffset
--start-address=$decodestart --stop-address=$decodestop $filename |")
|| die "Cannot start objdump";

while (<FILE>) {
	my $line = $_;
	chomp($line);
	if ($state == 0) {
		if ($line =~ /^([a-f0-9]+)\:/) {
			if (InRange($1, $target)) {
				$state = 1;
			}
		}
	} else {
		if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) {
			my $val = $1;
			if (!InRange($val, $target)) {
				last;
			}
			if ($val eq $target) {
				$center = $counter;
			}
		}
The first line cannot be eq, so $center cannot be set. I make a patch to fix it.

Thanks,
Hui

Signed-off-by: Hui Zhu <teawater@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Ozan Çaglayan <ozan@pardus.org.tr>
Cc: Matthew Wilcox <willy@linux.intel.com>

---
 scripts/markup_oops.pl |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/scripts/markup_oops.pl
+++ b/scripts/markup_oops.pl
@@ -204,7 +204,7 @@ if ($module ne "") {

 my $counter = 0;
 my $state   = 0;
-my $center  = 0;
+my $center  = -1;
 my @lines;
 my @reglines;

@@ -236,7 +236,8 @@ while (<FILE>) {
 				$state = 1;
 			}
 		}
-	} else {
+	}
+	if ($state == 1) {
 		if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) {
 			my $val = $1;
 			if (!InRange($val, $target)) {
@@ -259,7 +260,7 @@ if ($counter == 0) {
 	exit;
 }

-if ($center == 0) {
+if ($center == -1) {
 	print "No matching code found \n";
 	exit;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix bug of markup_oops.pl when first line of range is the  faulting instruction
  2010-01-17 13:36 [PATCH] Fix bug of markup_oops.pl when first line of range is the faulting instruction Hui Zhu
@ 2010-01-28  6:49 ` Hui Zhu
  0 siblings, 0 replies; 2+ messages in thread
From: Hui Zhu @ 2010-01-28  6:49 UTC (permalink / raw)
  To: Andrew Morton, Arjan van de Ven, Sam Ravnborg,
	Ozan Çaglayan, Matthew Wilcox, linux-kernel

Please ignore this mail.

I just sent a mail "[PATCH] markup_oops.pl: fix get "No matching code
found" when first line of range is the faulting instruction" for it.

Thanks,
Hui

On Sun, Jan 17, 2010 at 21:36, Hui Zhu <teawater@gmail.com> wrote:
> I got a "No matching code found" when I use markup_oops.pl parse a
> error in a x8664 module.
>
> BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
> IP: [<ffffffffa0000000>] init_module+0x0/0x10 [e]
> PGD 610a067 PUD 610b067 PMD 0
> Oops: 0002 [1] PREEMPT SMP
> CPU 0
> Modules linked in: e(+)
> Pid: 2064, comm: insmod Not tainted
> 2.6.27.39-WR3.0.2zz_standard-00073-g6471dad-dirty #3
> RIP: 0010:[<ffffffffa0000000>]  [<ffffffffa0000000>] init_module+0x0/0x10 [e]
> RSP: 0018:ffff8800060f5ef0  EFLAGS: 00000246
> RAX: ffff8800060f5fd8 RBX: ffffffffa0000340 RCX: 0000000000000000
> RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffa0000000
> RBP: ffffffffa0000000 R08: 0000000000000000 R09: ffff880001101000
> R10: 0000000000000002 R11: 0000000000000472 R12: 0000000000000000
> R13: 00000000006905b0 R14: 00007fff7c934f15 R15: 0000000000000003
> FS:  000000000068f850(0063) GS:ffffffff80749040(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> CR2: 0000000000000000 CR3: 0000000006108000 CR4: 00000000000006a0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 0000000000004000 DR7: 0000000000000000
> Process insmod (pid: 2064, threadinfo ffff8800060f4000, task ffff8800079078e0)
> Stack:  ffffffff8020903b 0000000000000000 ffffffff803a2fa1 0000000000000000
>  ffffffff8058ab82 0000000000000000 ffffffff80253e15 0000000000000001
>  ffffffffa0000340 000000000000c4ce ffffffffa0000340 000000000000c4ce
> Call Trace:
>  [<ffffffff8020903b>] ? _stext+0x3b/0x160
>  [<ffffffff803a2fa1>] ? __up_read+0x21/0xb0
>  [<ffffffff8058ab82>] ? _spin_unlock_irqrestore+0x12/0x40
>  [<ffffffff80253e15>] ? __blocking_notifier_call_chain+0x65/0x90
>  [<ffffffff80261e55>] ? sys_init_module+0xb5/0x210
>  [<ffffffff8020bb0b>] ? system_call_done+0x0/0x5
>
>
> Code: <c6> 04 25 00 00 00 00 03 31 c0 c3 0f 1f 44 00 00 f3 c3 90 90 04 00
> RIP  [<ffffffffa0000000>] init_module+0x0/0x10 [e]
>  RSP <ffff8800060f5ef0>
> CR2: 0000000000000000
> ---[ end trace 1f34257349e749de ]---
>
>
> 0000000000000000 <init_module>:
> init_module():
> /home/teawater/study/kernel/stack2core/example/e.c:10
>   0:   c6 04 25 00 00 00 00    movb   $0x3,0x0
>   7:   03
> /home/teawater/study/kernel/stack2core/example/e.c:13
>   8:   31 c0                   xor    %eax,%eax
>   a:   c3                      retq
>   b:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
>
> 0000000000000010 <cleanup_module>:
> cleanup_module():
> /home/teawater/study/kernel/stack2core/example/e.c:20
>  10:   f3 c3                   repz retq
>  12:   90                      nop
>  13:   90                      nop
> Disassembly of section .modinfo:
>
> This is because the faulting instruction "movb   $0x3,0x0" is the
> first line of the range.
>
> In the markup_oops.pl:
> open(FILE, "objdump -dS --adjust-vma=$vmaoffset
> --start-address=$decodestart --stop-address=$decodestop $filename |")
> || die "Cannot start objdump";
>
> while (<FILE>) {
>        my $line = $_;
>        chomp($line);
>        if ($state == 0) {
>                if ($line =~ /^([a-f0-9]+)\:/) {
>                        if (InRange($1, $target)) {
>                                $state = 1;
>                        }
>                }
>        } else {
>                if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) {
>                        my $val = $1;
>                        if (!InRange($val, $target)) {
>                                last;
>                        }
>                        if ($val eq $target) {
>                                $center = $counter;
>                        }
>                }
> The first line cannot be eq, so $center cannot be set. I make a patch to fix it.
>
> Thanks,
> Hui
>
> Signed-off-by: Hui Zhu <teawater@gmail.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Arjan van de Ven <arjan@linux.intel.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Ozan Çaglayan <ozan@pardus.org.tr>
> Cc: Matthew Wilcox <willy@linux.intel.com>
>
> ---
>  scripts/markup_oops.pl |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> --- a/scripts/markup_oops.pl
> +++ b/scripts/markup_oops.pl
> @@ -204,7 +204,7 @@ if ($module ne "") {
>
>  my $counter = 0;
>  my $state   = 0;
> -my $center  = 0;
> +my $center  = -1;
>  my @lines;
>  my @reglines;
>
> @@ -236,7 +236,8 @@ while (<FILE>) {
>                                $state = 1;
>                        }
>                }
> -       } else {
> +       }
> +       if ($state == 1) {
>                if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) {
>                        my $val = $1;
>                        if (!InRange($val, $target)) {
> @@ -259,7 +260,7 @@ if ($counter == 0) {
>        exit;
>  }
>
> -if ($center == 0) {
> +if ($center == -1) {
>        print "No matching code found \n";
>        exit;
>  }
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-28  6:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-17 13:36 [PATCH] Fix bug of markup_oops.pl when first line of range is the faulting instruction Hui Zhu
2010-01-28  6:49 ` Hui Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome