Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1439593

Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS
Date 2016-07-08 17:50 +0200
Message-ID <rSGcp-6ES-1@gated-at.bofh.it> (permalink)
References <rOGul-20Y-5@gated-at.bofh.it> <rOGul-20Y-3@gated-at.bofh.it> <rSFq2-68d-23@gated-at.bofh.it> <rSFzI-6qY-17@gated-at.bofh.it> <rSFT4-6xS-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jul 08, 2016 at 05:24:21PM +0200, Petr Mladek wrote:
> On Fri 2016-07-08 17:07:09, Torsten Duwe wrote:
> > On Fri, Jul 08, 2016 at 04:58:00PM +0200, Petr Mladek wrote:
> > > On Mon 2016-06-27 17:17:17, Torsten Duwe wrote:
> > > > Once gcc is enhanced to optionally generate NOPs at the beginning
> > > > of each function, like the concept proven in
> > > > https://gcc.gnu.org/ml/gcc-patches/2016-04/msg01671.html
> > > > (sans the "fprintf (... pad_size);", which spoils the data structure
> > > > for kernel use), the generated pads can nicely be used to reroute
> > > > function calls for tracing/profiling, or live patching.
> > > > diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
> > > > index ebecf9a..917065c 100644
> > > > --- a/arch/arm64/kernel/ftrace.c
> > > > +++ b/arch/arm64/kernel/ftrace.c
> > > > @@ -39,6 +39,12 @@ static int ftrace_modify_code(unsigned long pc, u32 old, u32 new,
> > > >  		if (aarch64_insn_read((void *)pc, &replaced))
> > > >  			return -EFAULT;
> > > >  
> > > > +		/* If we already have what we'll finally want,
> > > > +		 * report success. This is needed on startup.
> > > > +		 */
> > > > +		if (replaced == new)
> > > > +			return 0;
> > > 
> > > This looks strange. I wonder if it actually hides a real bug that we
> > > modify the code twice or so.
> > 
> > Not at all. All "profilers" we abused so far generate code that needs to
> > be disabled on boot first. prolog-pad generates nops, initially.
> 
> Yeah, but I cannot find this kind of check in other architectures.
> I checked arch/x86/kernel/ftrace.c, arch/s390/kernel/ftrace.c, and
> arch/powerpc/kernel/ftrace.c. These all support ftrace with
> regs and livepatching.

My understanding is that other arches don't need this check because they
use -mfentry, so they have to modify the "call fentry" instruction to a
nop on startup.

Here, with -fprolog-pad, it's already a nop, so no change is needed.

-- 
Josh

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Torsten Duwe <duwe@lst.de> - 2016-06-27 17:20 +0200
  Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Josh Poimboeuf <jpoimboe@redhat.com> - 2016-07-01 15:00 +0200
    Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Torsten Duwe <duwe@lst.de> - 2016-07-04 11:20 +0200
  Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Petr Mladek <pmladek@suse.com> - 2016-07-08 17:00 +0200
    Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Torsten Duwe <duwe@lst.de> - 2016-07-08 17:10 +0200
      Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Petr Mladek <pmladek@suse.com> - 2016-07-08 17:30 +0200
        Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Josh Poimboeuf <jpoimboe@redhat.com> - 2016-07-08 17:50 +0200
          Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Steven Rostedt <rostedt@goodmis.org> - 2016-07-08 18:00 +0200
            Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Torsten Duwe <duwe@lst.de> - 2016-07-08 22:30 +0200
              Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Steven Rostedt <rostedt@goodmis.org> - 2016-07-08 23:10 +0200
                Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Torsten Duwe <duwe@lst.de> - 2016-07-09 11:10 +0200
                Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Steven Rostedt <rostedt@goodmis.org> - 2016-07-15 20:40 +0200
        Re: [PATCH v2 1/2] arm64: implement FTRACE_WITH_REGS Steven Rostedt <rostedt@goodmis.org> - 2016-07-08 17:50 +0200

csiph-web