mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, yrl.pp-manager.tt@hitachi.com,
	systemtap@sourceware.org, anderson@redhat.com,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Subject: Re: Re: [PATCH v3 -tip] [BUGFIX] x86/kprobes: Fix to recover instructions on optimized path
Date: Tue, 28 Feb 2012 11:52:50 +0900	[thread overview]
Message-ID: <4F4C4182.1040706@hitachi.com> (raw)
In-Reply-To: <20120227093421.GA10078@elte.hu>

(2012/02/27 18:34), Ingo Molnar wrote:
> 
> * Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote:
> 
>> +
>> +#ifdef CONFIG_OPTPROBES
>> +static unsigned long __recover_optprobed_insn(struct kprobe *kp,
>> +					      kprobe_opcode_t *buf,
>> +					      unsigned long addr)
>> +{
>> +	long offs = addr - (unsigned long)kp->addr - 1;
>> +	struct optimized_kprobe *op = container_of(kp, struct optimized_kprobe, kp);
>> +
>> +	/*
>> +	 * If the kprobe can be optimized, original bytes which can be
>> +	 * overwritten by jump destination address. In this case, original
>> +	 * bytes must be recovered from op->optinsn.copied_insn buffer.
>> +	 */
>> +	memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
>> +	if (addr == (unsigned long)kp->addr) {
>> +		buf[0] = kp->opcode;
>> +		memcpy(buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
>> +	} else
>> +		memcpy(buf, op->optinsn.copied_insn + offs, RELATIVE_ADDR_SIZE - offs);
>> +
>> +	return (unsigned long)buf;
>> +}
>> +#endif
> 
> Why not stick this into a new kprobes-opt.c file?

Would you mean that I should split all optprobe stuffs
into new file?

> 
>> +
>> +/*
>> + * Recover the probed instruction at addr for further analysis.
>> + * Caller must lock kprobes by kprobe_mutex, or disable preemption
>> + * for preventing to release referencing kprobes.
>> + */
>> +static unsigned long recover_probed_instruction(kprobe_opcode_t *buf,
>> +						unsigned long addr)
>> +{
>> +	struct kprobe *kp;
>> +#ifdef CONFIG_OPTPROBES
>> +	int i;
>> +
>> +	for (i = 0; i < RELATIVEJUMP_SIZE; i++) {
>> +		kp = get_kprobe((void *)addr - i);
>> +		if (kp && kprobe_optready(kp))
>> +			return __recover_optprobed_insn(kp, buf, addr);
>> +	}
>> +#endif
> 
> This should be a separate, kprobes_recover_opt() method and be 
> inside kprobes-opt.c as well.

OK, I'll do that. But I think it should be separated work.
Just for the bugfix, I think this should go into this style,
because this should be pushed into stable tree too.

Thank you,

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

  reply	other threads:[~2012-02-28  2:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21  8:36 [PATCH v2 " Masami Hiramatsu
2012-02-22 16:07 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2012-02-22 16:22   ` Ingo Molnar
2012-02-23  1:41     ` Masami Hiramatsu
2012-02-23  7:07       ` Ingo Molnar
2012-02-23  8:37         ` Ingo Molnar
2012-02-23 14:29           ` Masami Hiramatsu
2012-02-24  9:54           ` [PATCH v3 -tip] [BUGFIX] " Masami Hiramatsu
2012-02-27  9:34             ` Ingo Molnar
2012-02-28  2:52               ` Masami Hiramatsu [this message]
2012-02-28  8:48                 ` Ingo Molnar
2012-02-28  9:51                   ` Masami Hiramatsu
2012-02-28  9:59                     ` Ingo Molnar
2012-02-29 13:20                       ` Masami Hiramatsu

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=4F4C4182.1040706@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=ananth@in.ibm.com \
    --cc=anderson@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=systemtap@sourceware.org \
    --cc=tglx@linutronix.de \
    --cc=yrl.pp-manager.tt@hitachi.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

Powered by JetHome