Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752330AbbBMFtL (ORCPT ); Fri, 13 Feb 2015 00:49:11 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:23176 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752106AbbBMFtH (ORCPT ); Fri, 13 Feb 2015 00:49:07 -0500 From: Wang Nan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , Subject: [RFC PATCH v3 13/26] early kprobes: ARM: directly modify code. Date: Fri, 13 Feb 2015 13:40:48 +0800 Message-ID: <1423806048-62028-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1423805941-61407-1-git-send-email-wangnan0@huawei.com> References: <1423805941-61407-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.54DD8FFB.0173,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9d4690ed8653a17569a4f85afe280757 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1440 Lines: 40 For early kprobe, we can simply patch text because we are in a relative simple environment. Signed-off-by: Wang Nan --- arch/arm/probes/kprobes/opt-arm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/probes/kprobes/opt-arm.c b/arch/arm/probes/kprobes/opt-arm.c index bcdecc2..43446df 100644 --- a/arch/arm/probes/kprobes/opt-arm.c +++ b/arch/arm/probes/kprobes/opt-arm.c @@ -330,8 +330,18 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist) * Similar to __arch_disarm_kprobe, operations which * removing breakpoints must be wrapped by stop_machine * to avoid racing. + * + * If this function is called before kprobes initialized, + * the kprobe should be an early kprobe, the instruction + * is not armed with breakpoint. There should be only + * one core now, so directly __patch_text is enough. */ - kprobes_remove_breakpoint(op->kp.addr, insn); + if (unlikely(kprobes_is_early())) { + BUG_ON(!(op->kp.flags & KPROBE_FLAG_EARLY)); + __patch_text(op->kp.addr, insn); + } else { + kprobes_remove_breakpoint(op->kp.addr, insn); + } list_del_init(&op->list); } -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/