From: wangnan0@huawei.com (Wang Nan)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] kprobes: arm: enable OPTPROBES for arm 32
Date: Fri, 8 Aug 2014 09:25:24 +0800 [thread overview]
Message-ID: <53E42704.3090909@huawei.com> (raw)
In-Reply-To: <53E323D1.8020209@hitachi.com>
On 2014/8/7 14:59, Masami Hiramatsu wrote:
> (2014/08/06 15:24), Wang Nan wrote:
>>>> +
>>>> +static void
>>>> +optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
>>>> +{
>>>> + unsigned long flags;
>>>> +
>>>> + regs->ARM_pc = (unsigned long)op->kp.addr;
>>>> + regs->ARM_ORIG_r0 = ~0UL;
>>>> +
>>>> +
>>>> + local_irq_save(flags);
>>>> + /*
>>>> + * This is possible if op is under delayed unoptimizing.
>>>> + * We need simulate the replaced instruction.
>>>> + */
>>>> + if (kprobe_disabled(&op->kp)) {
>>>> + struct kprobe *p = &op->kp;
>>>> + op->kp.ainsn.insn_singlestep(p->opcode, &p->ainsn, regs);
>>>> + } else {
>>>> + kprobe_handler(regs);
>>>> + }
>>>
>>> You don't need brace "{}" for one statement.
>>> By the way, why don't you call opt_pre_handler()?
>>>
>>
>> I use kprobe_handler because it handles instruction emulation.
>>
>> In addition, I'm not very sure whether skipping the complex checks
>> in kprobe_handler() is safe or not.
>
> That seems to do same thing on x86. Then you should do something like
> the optimized_callback() on x86 as below.
>
> static void
> optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
> {
> struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
> unsigned long flags;
>
> local_irq_save(flags);
> if (kprobe_running()) {
> kprobes_inc_nmissed_count(&op->kp);
In this case we still need a singlestep, right?
> } else {
> /* Save skipped registers */
> regs->ARM_pc = (unsigned long)op->kp.addr;
> regs->ARM_ORIG_r0 = ~0UL;
>
> __this_cpu_write(current_kprobe, &op->kp);
> kcb->kprobe_status = KPROBE_HIT_ACTIVE;
> opt_pre_handler(&op->kp, regs);
> __this_cpu_write(current_kprobe, NULL);
> op->kp.ainsn.insn_singlestep(op->kp.opcode, &op->kp.ainsn, regs);
> }
> local_irq_restore(flags);
> }
>
> Thank you,
>
WARNING: multiple messages have this Message-ID (diff)
From: Wang Nan <wangnan0@huawei.com>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
<davem@davemloft.net>, Russell King <linux@arm.linux.org.uk>,
Will Deacon <will.deacon@arm.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <peifeiyue@huawei.com>,
Li Zefan <lizefan@huawei.com>
Subject: Re: [RFC PATCH] kprobes: arm: enable OPTPROBES for arm 32
Date: Fri, 8 Aug 2014 09:25:24 +0800 [thread overview]
Message-ID: <53E42704.3090909@huawei.com> (raw)
In-Reply-To: <53E323D1.8020209@hitachi.com>
On 2014/8/7 14:59, Masami Hiramatsu wrote:
> (2014/08/06 15:24), Wang Nan wrote:
>>>> +
>>>> +static void
>>>> +optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
>>>> +{
>>>> + unsigned long flags;
>>>> +
>>>> + regs->ARM_pc = (unsigned long)op->kp.addr;
>>>> + regs->ARM_ORIG_r0 = ~0UL;
>>>> +
>>>> +
>>>> + local_irq_save(flags);
>>>> + /*
>>>> + * This is possible if op is under delayed unoptimizing.
>>>> + * We need simulate the replaced instruction.
>>>> + */
>>>> + if (kprobe_disabled(&op->kp)) {
>>>> + struct kprobe *p = &op->kp;
>>>> + op->kp.ainsn.insn_singlestep(p->opcode, &p->ainsn, regs);
>>>> + } else {
>>>> + kprobe_handler(regs);
>>>> + }
>>>
>>> You don't need brace "{}" for one statement.
>>> By the way, why don't you call opt_pre_handler()?
>>>
>>
>> I use kprobe_handler because it handles instruction emulation.
>>
>> In addition, I'm not very sure whether skipping the complex checks
>> in kprobe_handler() is safe or not.
>
> That seems to do same thing on x86. Then you should do something like
> the optimized_callback() on x86 as below.
>
> static void
> optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
> {
> struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
> unsigned long flags;
>
> local_irq_save(flags);
> if (kprobe_running()) {
> kprobes_inc_nmissed_count(&op->kp);
In this case we still need a singlestep, right?
> } else {
> /* Save skipped registers */
> regs->ARM_pc = (unsigned long)op->kp.addr;
> regs->ARM_ORIG_r0 = ~0UL;
>
> __this_cpu_write(current_kprobe, &op->kp);
> kcb->kprobe_status = KPROBE_HIT_ACTIVE;
> opt_pre_handler(&op->kp, regs);
> __this_cpu_write(current_kprobe, NULL);
> op->kp.ainsn.insn_singlestep(op->kp.opcode, &op->kp.ainsn, regs);
> }
> local_irq_restore(flags);
> }
>
> Thank you,
>
next prev parent reply other threads:[~2014-08-08 1:25 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-05 7:28 [RFC PATCH] kprobes: arm: enable OPTPROBES for arm 32 Wang Nan
2014-08-05 7:28 ` Wang Nan
2014-08-06 4:44 ` Masami Hiramatsu
2014-08-06 4:44 ` Masami Hiramatsu
2014-08-06 6:24 ` Wang Nan
2014-08-06 6:24 ` Wang Nan
2014-08-07 6:59 ` Masami Hiramatsu
2014-08-07 6:59 ` Masami Hiramatsu
2014-08-08 1:25 ` Wang Nan [this message]
2014-08-08 1:25 ` Wang Nan
2014-08-08 2:07 ` Masami Hiramatsu
2014-08-08 2:07 ` Masami Hiramatsu
2014-08-06 13:36 ` Jon Medhurst (Tixy)
2014-08-06 13:36 ` Jon Medhurst (Tixy)
2014-08-06 13:40 ` Wang Nan
2014-08-06 13:40 ` Wang Nan
2014-08-06 14:23 ` Jon Medhurst (Tixy)
2014-08-06 14:23 ` Jon Medhurst (Tixy)
2014-08-06 22:57 ` Russell King - ARM Linux
2014-08-06 22:57 ` Russell King - ARM Linux
2014-08-06 22:55 ` Russell King - ARM Linux
2014-08-06 22:55 ` Russell King - ARM Linux
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=53E42704.3090909@huawei.com \
--to=wangnan0@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.