This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Fwd: [RFC][PATCH 3/3]Djprobe (Direct Jump Probe) for 2.6.14-rc5-mm1]


Hi,

Masami Hiramatsu wrote:
> +
> +static DEFINE_SPINLOCK(djprobe_handler_lock);
> +
> +/* djprobe handler : switch to a bypass code */
> +int __kprobes djprobe_pre_handler(struct kprobe * kp, struct pt_regs * regs)
> +{
> +	struct djprobe_instance *djpi =
> +		container_of(kp,struct djprobe_instance, kp);
> +	kprobe_opcode_t *stub = djpi->stub.insn;
> +
> +	spin_lock(&djprobe_handler_lock);
> +	if (DJPI_EMPTY(djpi)) {
> +		kp->ainsn.insn[0] = kp->opcode;
> +		return 0;
> +	} else {
> +		regs->eip = (unsigned long)stub;
> +		regs->eflags |= TF_MASK;
> +		regs->eflags &= ~IF_MASK;
> +		kp->ainsn.insn[0] = RETURN_INSTRUCTION;
> +		return 1; /* already prepared */
> +	}
> +}
> +
> +void __kprobes djprobe_post_handler(struct kprobe * kp, struct pt_regs * regs,
> +				    unsigned long flags)
> +{
> +	spin_unlock(&djprobe_handler_lock);
> +}

I learned from kretprobe that I can remove this spinlock and
a trick of instruction buffer. Here is a new pseudo-program.

djprobe_pre_handler()
{
	if (!DJPI_EMPTY(djpi)) {
		regs->eip = (unsigned long)djpi->stub.insn;
		reset_current_kprobe();
		preempt_enable_no_resched();
		return 1;
	}
	return 0;
}

I will send fixed patches again. Please review it.

-- 
Masami HIRAMATSU
2nd Research Dept.
Hitachi, Ltd., Systems Development Laboratory
E-mail: hiramatu@sdl.hitachi.co.jp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]