[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5fd602dd-a909-5209-56b6-39c7a34dfcff@huawei.com>
Date: Mon, 13 Jan 2020 14:18:14 +0800
From: "chengjian (D)" <cj.chengjian@...wei.com>
To: Mark Rutland <mark.rutland@....com>
CC: <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <xiexiuqi@...wei.com>,
<huawei.libin@...wei.com>, <bobo.shaobowang@...wei.com>,
<catalin.marinas@....com>, <duwe@....de>
Subject: Re: [RFC PATCH] arm64/ftrace: support dynamically allocated
trampolines
On 2020/1/10 20:12, Mark Rutland wrote:
> 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.
>
> .
OK, I will do it.
Thank you, Mark.
--Cheng Jian
Powered by blists - more mailing lists