public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: git pull request for tip/tracing/urgent
Date: Wed, 11 Feb 2009 02:28:56 +0100	[thread overview]
Message-ID: <20090211012856.GA4921@nowhere> (raw)
In-Reply-To: <alpine.DEB.1.10.0902101724190.23505@gandalf.stny.rr.com>

On Tue, Feb 10, 2009 at 06:00:14PM -0500, Steven Rostedt wrote:
> 
> 
> On Tue, 10 Feb 2009, Frederic Weisbecker wrote:
> > > 
> > > diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> > > index 1b43086..9d549e4 100644
> > > --- a/arch/x86/kernel/ftrace.c
> > > +++ b/arch/x86/kernel/ftrace.c
> > > @@ -491,13 +491,15 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
> > >  		"1: " _ASM_MOV " (%[parent_old]), %[old]\n"
> > >  		"2: " _ASM_MOV " %[return_hooker], (%[parent_replaced])\n"
> > >  		"   movl $0, %[faulted]\n"
> > > +		"3:\n"
> > >  
> > >  		".section .fixup, \"ax\"\n"
> > > -		"3: movl $1, %[faulted]\n"
> > > +		"4: movl $1, %[faulted]\n"
> > > +		"   jmp 3b\n"
> > >  		".previous\n"
> > 
> > 
> > It thought after the fixup section, the code would continue to rest of the C code.
> > Where would it go without the jmp?
> 
> To the next item the linker placed into the .fixup section.  And that 
> would jump back to the location for that fixup. Basically, what you have 
> is this:
> 
> (just picking random and factitious registers)
> 
> .section .text
> [...]
> L1:	mov	%a, %b
> L2:	cmp	%x, $1
> <continue code>
> 
> 
> <Someplace else>
> 
> .section .text
> [...]
> L3:	mov	%c, %d
> L4:	cmp	%x, $22
> [...]
> 
> .section .fixup
> [...]
> L5:	mov	$1, %x
> 	jmp L2
> L6:	mov	$22, %x
> 	jmp L4
> [...]
> 
> 
> .section __ex_table
> [...]
> .long	L1, L5
> .long	L3, L6
> [...]
> 
> 
> So when we take an exception at label L1, the page fault code will look 
> to see if it is OK, by doing a binary search of the exception table.
> When it finds the L1, L5 pair, it will then set up a return to the L5 
> label.
> 
> When the fault returns to L5, it loads that reg %x with $1 and jumps back 
> to L2, where it can see that it took a fault.
> 
> Now lets look at what happens when we do not have that jump back to L2. 
> Instead of going back to the original code, it will load $22 into %x and 
> jmp back to the wrong area. God knows what will happen then, since the 
> stack pointer thinks it is from where the original fault occurred.


Heh, that's fairly logic. Don't ask me why, but I did not imagine each
part of .fixup unified in a separate contiguous section (but what else can it be?...).

Thanks for your explanations :-)

 
> -- Steve
> 


  reply	other threads:[~2009-02-11  1:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10 18:19 git pull request for tip/tracing/urgent Steven Rostedt
2009-02-10 18:30 ` Frederic Weisbecker
2009-02-10 23:00   ` Steven Rostedt
2009-02-11  1:28     ` Frederic Weisbecker [this message]
2009-02-11  9:02       ` Ingo Molnar
2009-02-11  9:16         ` Tejun Heo
2009-02-11  9:53           ` Ingo Molnar
2009-02-12  1:24             ` H. Peter Anvin
2009-02-11 13:40         ` Frederic Weisbecker
2009-02-11  8:49 ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090211012856.GA4921@nowhere \
    --to=fweisbec@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox