public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Kao <nonerkao@gmail.com>
To: patches@groups.riscv.org
Cc: Palmer Dabbelt <palmer@sifive.com>, Albert Ou <albert@sifive.com>,
	Christoph Hellwig <hch@lst.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Kamil Rytarowski <n54@gmx.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Alan Kao <alankao@andestech.com>,
	Greentime Hu <greentime@andestech.com>
Subject: Re: [patches] [PATCH v2 2/6] riscv/ftrace: Add dynamic function tracer support
Date: Mon, 15 Jan 2018 15:38:23 +0800	[thread overview]
Message-ID: <20180115073821.GA9496@93d8b218059b> (raw)
In-Reply-To: <CADJ6UvOZz=WZ18wYVhZcH0u58u_snDxmgbwsfTOS2ski-4O7tg@mail.gmail.com>

On Sun, Jan 14, 2018 at 11:24:53PM -0800, Stefan O'Rear wrote:
> On Sun, Jan 14, 2018 at 10:47 PM, Alan Kao <nonerkao@gmail.com> wrote:
> > +       /*
> > +        * For the dynamic ftrace to work, here we should reserve at least
> > +        * 8 bytes for a functional auipc-jalr pair. Pseudo inst nop may be
> > +        * interpreted as different length in different models, so we manually
> > +        * *expand* two 4-byte nops here.
> > +        *
> > +        * Calling ftrace_update_ftrace_func would overwrite the nops below.
> > +        * Check ftrace_modify_all_code for details.
> > +        */
> > +       addi    x0, x0, 0
> > +       addi    x0, x0, 0
> 
> This relies on behavior of the assembler which is undocumented and, if
> my reading of the specification is correct, a bug.
> 
> The documented way to assemble an sequence of 2 4-byte NOPs regardless
> of subtarget is as follows:
> 
> .option push
> .option norvc
>     nop
>     nop
> .option pop
> 
> I have filed https://github.com/riscv/riscv-binutils-gdb/issues/135 to
> get clarity on the assembler behavior; the explicit approach may be
> preferable even if the assembler behavior turns out to be correct.
> 
> -s
> 

Thanks for pointing this out.

After checking the way other architectures have done this, I think we can 
just put a 

	call ftrace_stub

here.  Currently we don't support linker relaxing with ftrace, so this
macro will be expand to 8-byte inst-pair.

Alan

> -- 
> You received this message because you are subscribed to the Google Groups "RISC-V Patches" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to patches+unsubscribe@groups.riscv.org.
> To post to this group, send email to patches@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/patches/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/patches/CADJ6UvOZz%3DWZ18wYVhZcH0u58u_snDxmgbwsfTOS2ski-4O7tg%40mail.gmail.com.
> For more options, visit https://groups.google.com/a/groups.riscv.org/d/optout.

  reply	other threads:[~2018-01-15  7:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  6:47 [PATCH v2 0/6] Add dynamic ftrace support for RISC-V platforms Alan Kao
2018-01-15  6:47 ` [PATCH v2 1/6] riscv/ftrace: Add RECORD_MCOUNT support Alan Kao
2018-01-15  6:47 ` [PATCH v2 2/6] riscv/ftrace: Add dynamic function tracer support Alan Kao
2018-01-15  7:24   ` [patches] " Stefan O'Rear
2018-01-15  7:38     ` Alan Kao [this message]
2018-01-15  6:47 ` [PATCH v2 3/6] riscv/ftrace: Add dynamic function graph " Alan Kao
2018-01-15  6:47 ` [PATCH v2 4/6] riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support Alan Kao
2018-01-15  6:47 ` [PATCH v2 5/6] riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support Alan Kao
2018-01-15  6:47 ` [PATCH v2 6/6] riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support Alan Kao

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=20180115073821.GA9496@93d8b218059b \
    --to=nonerkao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alankao@andestech.com \
    --cc=albert@sifive.com \
    --cc=greentime@andestech.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=n54@gmx.com \
    --cc=palmer@sifive.com \
    --cc=patches@groups.riscv.org \
    --cc=rostedt@goodmis.org \
    --cc=yamada.masahiro@socionext.com \
    /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