From patchwork Fri Nov 21 06:35:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 41280 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9FE4425AF8 for ; Fri, 21 Nov 2014 06:39:15 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf1505477lbj.3 for ; Thu, 20 Nov 2014 22:39:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=vWe0tHaxpwOkKBtC1HBDLb+v/LUGKOZbFEXXDhhbnbY=; b=Dx3bfMlXaFbb1XoJ4gbIUpeJSJVbnua4XeVgrtJ8ZJBUOwX8qwwcpj2BQZINPWIMCl cmimf4UPppgpYNWOxwoERQ7H8s8fAM17+/utACVcBb+hxZiY/QBDy4MW6knPRdEZpkHB GjUSl0QYqRL4FMg2fEImy1oGt/hj21qKUyUcW28fMdOxpvxc8BzTrM2ViY0XaWCk73r1 HcyvdAQPpiYNgX4sLQVjjz7Awdba3PwyErfP/BiSdDIvd8m7aQApOWOjj/15REBbcrKI wYORP64mhaGW7QI9BLzDzJCYRy5PtOsgUG2nkBDvkc2B96rizKZ3xtD7EKT/0KQqerRe HwCw== X-Gm-Message-State: ALoCoQkJZvL0tqJzMIAmurJQiFHd5LPKqumF9SHsHGGK7eNM4jzjrJVRuT62l31kFZaYg9jHnRJw X-Received: by 10.112.142.36 with SMTP id rt4mr930506lbb.3.1416551954616; Thu, 20 Nov 2014 22:39:14 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.167 with SMTP id l7ls153253lal.43.gmail; Thu, 20 Nov 2014 22:39:14 -0800 (PST) X-Received: by 10.112.132.2 with SMTP id oq2mr2234074lbb.11.1416551954278; Thu, 20 Nov 2014 22:39:14 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id u1si4015858lbb.79.2014.11.20.22.39.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 22:39:14 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gd6so3756651lab.33 for ; Thu, 20 Nov 2014 22:39:14 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr2168676laa.71.1416551954188; Thu, 20 Nov 2014 22:39:14 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp30013lbc; Thu, 20 Nov 2014 22:39:13 -0800 (PST) X-Received: by 10.66.231.37 with SMTP id td5mr3966966pac.80.1416551952345; Thu, 20 Nov 2014 22:39:12 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ri11si2959124pbb.33.2014.11.20.22.39.10 for ; Thu, 20 Nov 2014 22:39:12 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758083AbaKUGjF (ORCPT + 26 others); Fri, 21 Nov 2014 01:39:05 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:53843 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757982AbaKUGjB (ORCPT ); Fri, 21 Nov 2014 01:39:01 -0500 Received: from 172.24.2.119 (EHLO lggeml422-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CCR78826; Fri, 21 Nov 2014 14:38:52 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml422-hub.china.huawei.com (10.72.61.32) with Microsoft SMTP Server id 14.3.158.1; Fri, 21 Nov 2014 14:38:45 +0800 From: Wang Nan To: , , , , , , , , CC: , , Subject: [PATCH v10 1/2] kprobes: Pass the original kprobe for preparing optimized kprobe Date: Fri, 21 Nov 2014 14:35:50 +0800 Message-ID: <1416551751-50846-2-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1416551751-50846-1-git-send-email-wangnan0@huawei.com> References: <1416551751-50846-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Masami Hiramatsu Pass the original kprobe for preparing an optimized kprobe arch-dep part, since for some architecture (e.g. ARM32) requires the information in original kprobe. Signed-off-by: Masami Hiramatsu Cc: Wang Nan --- arch/x86/kernel/kprobes/opt.c | 3 ++- include/linux/kprobes.h | 3 ++- kernel/kprobes.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index f1314d0..7028296 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c @@ -320,7 +320,8 @@ void arch_remove_optimized_kprobe(struct optimized_kprobe *op) * Target instructions MUST be relocatable (checked inside) * This is called when new aggr(opt)probe is allocated or reused. */ -int arch_prepare_optimized_kprobe(struct optimized_kprobe *op) +int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, + struct kprobe *__unused) { u8 *buf; int ret; diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index f7296e5..7ab2c93 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h @@ -308,7 +308,8 @@ struct optimized_kprobe { /* Architecture dependent functions for direct jump optimization */ extern int arch_prepared_optinsn(struct arch_optimized_insn *optinsn); extern int arch_check_optimized_kprobe(struct optimized_kprobe *op); -extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op); +extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, + struct kprobe *orig); extern void arch_remove_optimized_kprobe(struct optimized_kprobe *op); extern void arch_optimize_kprobes(struct list_head *oplist); extern void arch_unoptimize_kprobes(struct list_head *oplist, diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 3995f54..9f28aa7 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -717,7 +717,7 @@ static void prepare_optimized_kprobe(struct kprobe *p) struct optimized_kprobe *op; op = container_of(p, struct optimized_kprobe, kp); - arch_prepare_optimized_kprobe(op); + arch_prepare_optimized_kprobe(op, p); } /* Allocate new optimized_kprobe and try to prepare optimized instructions */ @@ -731,7 +731,7 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p) INIT_LIST_HEAD(&op->list); op->kp.addr = p->addr; - arch_prepare_optimized_kprobe(op); + arch_prepare_optimized_kprobe(op, p); return &op->kp; }