public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: "Jon Medhurst (Tixy)" <tixy@linaro.org>
Cc: Wang Nan <wangnan0@huawei.com>,
	linux@arm.linux.org.uk, lizefan@huawei.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: Re: [RESEND][PATCH v15 7/7] ARM: kprobes: enable OPTPROBES for ARM 32
Date: Tue, 09 Dec 2014 19:25:06 +0900	[thread overview]
Message-ID: <5486CE02.5070808@hitachi.com> (raw)
In-Reply-To: <1418116450.3641.7.camel@linaro.org>

(2014/12/09 18:14), Jon Medhurst (Tixy) wrote:
[...]
>>> diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c
>>> index 3a58db4..a4ec240 100644
>>> --- a/arch/arm/probes/kprobes/core.c
>>> +++ b/arch/arm/probes/kprobes/core.c
>>> @@ -163,19 +163,31 @@ void __kprobes arch_arm_kprobe(struct kprobe *p)
>>>   * memory. It is also needed to atomically set the two half-words of a 32-bit
>>>   * Thumb breakpoint.
>>>   */
>>> -int __kprobes __arch_disarm_kprobe(void *p)
>>> -{
>>> -	struct kprobe *kp = p;
>>> -	void *addr = (void *)((uintptr_t)kp->addr & ~1);
>>> -
>>> -	__patch_text(addr, kp->opcode);
>>> +struct patch {
>>> +	void *addr;
>>> +	unsigned int insn;
>>> +};
>>>  
>>> +static int __kprobes_remove_breakpoint(void *data)
>>> +{
>>> +	struct patch *p = data;
>>> +	__patch_text(p->addr, p->insn);
>>>  	return 0;
>>>  }
>>>  
>>> +void __kprobes kprobes_remove_breakpoint(void *addr, unsigned int insn)
>>> +{
>>> +	struct patch p = {
>>> +		.addr = addr,
>>> +		.insn = insn,
>>> +	};
>>> +	stop_machine(__kprobes_remove_breakpoint, &p, cpu_online_mask);
>>> +}
>>
>> Hmm, I think finally we should fix patch_text() in patch.c to forcibly use stop_machine
>> by adding "bool stop" parameter, instead of introducing new another patch_text()
>> implementation, because we'd better avoid two private "patch" data structures.
> 
> That was my first thought too, then I realised that breaks encapsulation
> of the patch_text implementation, because its use of stop_machine is an
> implementation detail and it could be rewritten to not use stop machine.
> (That is sort of on my long term todo list
> https://lkml.org/lkml/2014/9/4/188)

Indeed. OK, now let it goes. :)

> Whereas stop machine is used by kprobes to avoid race conditions with
> the undefined instruction exception handler and something like that
> would be needed even if patch_text didn't use stop_machine.

At this point, it's OK.

However, I'm not convinced completely. Perhaps, it depends on cache-coherent bus
implementation, but there may be some implementations which can allow us to
change one instruction atomically without stop_machine.

I'm actually interested in PREEMPT_RT on arm32, and this stop_machine() is a barrier
to apply kprobes on real-time systems.

Thank you,


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



  reply	other threads:[~2014-12-09 10:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-08 14:09 [RESEND][PATCH v15 0/7] ARM: kprobes: OPTPROBES and other improvements Wang Nan
2014-12-08 14:09 ` [RESEND][PATCH v15 1/7] ARM: probes: move all probe code to dedicate directory Wang Nan
2014-12-08 14:09 ` [RESEND][PATCH v15 2/7] ARM: kprobes: introduces checker Wang Nan
2014-12-08 14:09 ` [RESEND][PATCH v15 3/7] ARM: kprobes: collects stack consumption for store instructions Wang Nan
2014-12-08 14:09 ` [RESEND][PATCH v15 4/7] ARM: kprobes: disallow probing stack consuming instructions Wang Nan
2014-12-08 14:09 ` [RESEND][PATCH v15 5/7] ARM: kprobes: Add test cases for " Wang Nan
2014-12-09 16:43   ` [PATCH v2] " Jon Medhurst (Tixy)
2014-12-09 17:11     ` [PATCH v3] " Jon Medhurst (Tixy)
2014-12-10  8:23       ` Wang Nan
2014-12-10 12:34         ` Jon Medhurst (Tixy)
2014-12-10 13:18           ` Wang Nan
2014-12-10 13:49             ` Jon Medhurst (Tixy)
2014-12-11  9:56             ` Wang Nan
2014-12-08 14:09 ` [RESEND][PATCH v15 6/7] kprobes: Pass the original kprobe for preparing optimized kprobe Wang Nan
2014-12-10 13:23   ` Jon Medhurst (Tixy)
2014-12-08 14:09 ` [RESEND][PATCH v15 7/7] ARM: kprobes: enable OPTPROBES for ARM 32 Wang Nan
2014-12-09  6:47   ` Masami Hiramatsu
2014-12-09  9:14     ` Jon Medhurst (Tixy)
2014-12-09 10:25       ` Masami Hiramatsu [this message]
2014-12-09 10:12     ` Wang Nan

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=5486CE02.5070808@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=lizefan@huawei.com \
    --cc=tixy@linaro.org \
    --cc=wangnan0@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