From: Mark Rutland <mark.rutland@arm.com>
To: "chengjian (D)" <cj.chengjian@huawei.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, xiexiuqi@huawei.com,
huawei.libin@huawei.com, bobo.shaobowang@huawei.com,
catalin.marinas@arm.com, duwe@lst.de
Subject: Re: [RFC PATCH] arm64/ftrace: support dynamically allocated trampolines
Date: Fri, 10 Jan 2020 12:12:35 +0000 [thread overview]
Message-ID: <20200110121234.GA31707@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <b0457ef0-f1b2-e258-b59d-aa9af8e48c5d@huawei.com>
On Fri, Jan 10, 2020 at 07:28:17PM +0800, chengjian (D) wrote:
> On 2020/1/10 0:48, Mark Rutland wrote:
> > On Thu, Jan 09, 2020 at 02:27:36PM +0000, Cheng Jian wrote:
> > > + /*
> > > + * Update the trampoline ops REF
> > > + *
> > > + * OLD INSNS : ldr_l x2, function_trace_op
> > > + * adrp x2, sym
> > > + * ldr x2, [x2, :lo12:\sym]
> > > + *
> > > + * NEW INSNS:
> > > + * nop
> > > + * ldr x2, <ftrace_ops>
> > > + */
> > > + op_offset -= start_offset_common;
> > > + ip = (unsigned long)trampoline + caller_size + op_offset;
> > > + nop = aarch64_insn_gen_nop();
> > > + memcpy((void *)ip, &nop, AARCH64_INSN_SIZE);
> > > +
> > > + op_offset += AARCH64_INSN_SIZE;
> > > + ip = (unsigned long)trampoline + caller_size + op_offset;
> > > + offset = (unsigned long)ptr - ip;
> > > + if (WARN_ON(offset % AARCH64_INSN_SIZE != 0))
> > > + goto free;
> > > + offset = offset / AARCH64_INSN_SIZE;
> > > + pc_ldr |= (offset & mask) << shift;
> > > + memcpy((void *)ip, &pc_ldr, AARCH64_INSN_SIZE);
> > I think it would be much better to have a separate template for the
> > trampoline which we don't have to patch in this way. It can even be
> > placed into a non-executable RO section, since the template shouldn't be
> > executed directly.
>
> A separate template !
>
> This may be a good way, and I think the patching here is very HACK too(Not
> very friendly).
>
> I had thought of other ways before, similar to the method on X86_64,
> remove the ftrace_common(), directly modifying
> ftrace_caller/ftrace_reg_caller, We will only need to copy the code
> once in this way, and these is no need to modify call ftrace_common to
> NOP.
>
> Using a trampoline template sounds great. but this also means that we
> need to aintain a template(or maybe two templates: one for caller,
> another for regs_caller).
>
> Hi, Mark, what do you think about it ?
I think that having two templates is fine. We can factor
ftrace_common_return into a macro mirroring ftrace_regs_entry, and I
suspect we can probably figure out some way to factor the common
portion.
Thanks,
Mark.
next prev parent reply other threads:[~2020-01-10 12:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-09 14:27 Cheng Jian
2020-01-09 16:48 ` Mark Rutland
2020-01-10 11:28 ` chengjian (D)
2020-01-10 12:12 ` Mark Rutland [this message]
2020-01-13 6:18 ` chengjian (D)
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=20200110121234.GA31707@lakrids.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=bobo.shaobowang@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=cj.chengjian@huawei.com \
--cc=duwe@lst.de \
--cc=huawei.libin@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiexiuqi@huawei.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
all inboxes | Powered by JetHome®