From: "liuqi (BA)" <email@example.com>
To: Masami Hiramatsu <firstname.lastname@example.org>, Linuxarm <email@example.com>
Cc: Mark Rutland <firstname.lastname@example.org>, <email@example.com>,
Subject: Re: [PATCH v4 2/2] arm64: kprobe: Enable OPTPROBE for arm64
Date: Tue, 30 Nov 2021 14:48:06 +0800 [thread overview]
Message-ID: <firstname.lastname@example.org> (raw)
On 2021/11/29 22:35, Masami Hiramatsu wrote:
>>>>>> Hi all,
>>>>>> I meet a problem when I use SYM_CODE_START(optprobe_template) to replace
>>>>>> If SYM_CODE_START is used, all optprobe will share one trampoline space.
>>>>>> Under this circumstances, if user register two optprobes, trampoline
>>>>>> will be overwritten by the newer one, and this will cause kernel panic
>>>>>> when the old optprobe is trigger.
>>>>> Hm, this is curious, because the template should be copied to the
>>>>> trampoline buffer for each optprobe and be modified.
>>>>>> Using optprobe_template_entry will not have this problem, as each
>>>>>> optprobe has its own trampoline space (alloced in get_opinsn_slot()).
>>>>> Yes, it is designed to do so.
>>>>> Thank you,
>>>> Hi Masami,
>>>> Thanks for your reply. But I also met a problem when using
>>>> get_opinsn_slot() to alloc trampoline buffer.
>>>> As module_alloc(like x86) is used to alloc buffer, trampoline is in
>>>> module space, so if origin insn is in kernel space, the range between
>>>> origin insn and trampoline is out of 128M.
>>>> As module PLT cannot used here, I have no idea to achieve long jump in
>>>> this situation. Do you have any good idea?
>> Hi Masami,
>> Thanks so much for your reply.
>>> One possible solution is to use pre-allocated trampoline space in
>>> the text area, as same as ppc64 does.
>>> (See arch/powerpc/kernel/optprobes_head.S, it embeds a space at "optinsn_slot")
>> I find something interesting in arch/powerpc/kernel/optprobes.c, it use
>> "optinsn_slot" as a public buffer, and use a static "insn_page_in_use"
>> to make sure there is only one optprobe in kernel.
>> If we use this solution , users could only register one optprobe each
>> time. This will also be a limitation for users, what's your opinion
>> about this?
> No, that is just a memory area for pooling trampoline buffer. So optprobe
> can allocate the buffer from that area. Please see kernel/kprobes.c:344.
> optprobe allocates "insn_slot" from kprobe_optinsn_slots, which uses
> alloc_optinsn_page() to allocate the pool of slots.
> Thank you,
Thanks for your reply, I test alloc_optinsn_page() and it does work well
to alloc the pool of slots.
But when I tried to use module PLT, something seems wrong here.
Arm64 Module PLT in mod->arch.ftrace_trampolines is set in
module_finalize, after that, mod->arch.ftrace_trampolines seems to be a
read-only memory. But in arch_optimize_kprobes() we need to modify the
destination of PLT (as each optprobe has its own trampoline buffer), if
so, we cannot get rid of the 128M branch limit :(
next prev parent reply other threads:[~2021-11-30 6:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 7:33 [PATCH v4 0/2] arm64: Enable OPTPROBE for arm64 Qi Liu
2021-08-18 7:33 ` [PATCH v4 1/2] Make save_all_base_regs and restore_all_base_regs as common macro Qi Liu
2021-08-18 7:33 ` [PATCH v4 2/2] arm64: kprobe: Enable OPTPROBE for arm64 Qi Liu
2021-08-18 16:27 ` Masami Hiramatsu
2021-08-24 10:50 ` Mark Rutland
2021-08-24 11:50 ` Barry Song
2021-08-24 12:11 ` Mark Rutland
2021-08-24 12:42 ` Barry Song
2021-08-25 2:13 ` Masami Hiramatsu
2021-08-25 3:12 ` Barry Song
2021-09-07 3:14 ` liuqi (BA)
2021-11-26 10:31 ` liuqi (BA)
2021-11-27 12:23 ` Masami Hiramatsu
2021-11-29 1:40 ` liuqi (BA)
2021-11-29 5:00 ` Masami Hiramatsu
2021-11-29 6:50 ` liuqi (BA)
2021-11-29 14:35 ` Masami Hiramatsu
2021-11-30 6:48 ` liuqi (BA) [this message]
2021-12-01 1:50 ` Masami Hiramatsu
2021-12-01 2:55 ` liuqi (BA)
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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;
as well as URLs for NNTP newsgroup(s).