Subject: [PATCH v5 2/3] kprobes: copy ainsn after alloc aggr kprobe

From: [email-masked] (Masami Hiramatsu)
Date: Thu, 28 Aug 2014 18:39:40 +0900

(2014/08/27 22:02), Wang Nan wrote:
> Copy old kprobe to newly alloced optimized_kprobe before
> arch_prepare_optimized_kprobe(). Original kprove can brings more
> information to optimizer.
> 
> Signed-off-by: Wang Nan <[email-masked]>
> Cc: Russell King <[email-masked]>
> Cc: "David A. Long" <[email-masked]> 
> Cc: Jon Medhurst <[email-masked]>
> Cc: Taras Kondratiuk <[email-masked]>
> Cc: Ben Dooks <[email-masked]>
> Cc: Ananth N Mavinakayanahalli <[email-masked]>
> Cc: Anil S Keshavamurthy <[email-masked]>
> Cc: "David S. Miller" <[email-masked]>
> Cc: Masami Hiramatsu <[email-masked]>
> Cc: Will Deacon <[email-masked]>
> ---
>  kernel/kprobes.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 3995f54..33cf568 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -730,7 +730,12 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p)
>  		return NULL;
>  
>  	INIT_LIST_HEAD(&op->list);
> -	op->kp.addr = p->addr;

Do not remove this, since copy_kprobe() doesn't copy kp.addr.

static inline void copy_kprobe(struct kprobe *ap, struct kprobe *p)
{
        memcpy(&p->opcode, &ap->opcode, sizeof(kprobe_opcode_t));
        memcpy(&p->ainsn, &ap->ainsn, sizeof(struct arch_specific_insn));
}

Thank you,

> +
> +	/*
> +	 * copy gives arch_prepare_optimized_kprobe
> +	 * more information
> +	 */
> +	copy_kprobe(p, &op->kp);
>  	arch_prepare_optimized_kprobe(op);
>  
>  	return &op->kp;
> 

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