Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753612AbbBTEBB (ORCPT ); Thu, 19 Feb 2015 23:01:01 -0500 Received: from mail7.hitachi.co.jp ([133.145.228.42]:56595 "EHLO mail7.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753445AbbBTEA7 (ORCPT ); Thu, 19 Feb 2015 23:00:59 -0500 Message-ID: <54E6B172.7080604@hitachi.com> Date: Fri, 20 Feb 2015 13:00:50 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Wang Nan Cc: linux@arm.linux.org.uk, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, rostedt@goodmis.org, ananth@in.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, luto@amacapital.net, keescook@chromium.org, oleg@redhat.com, dave.long@linaro.org, tixy@linaro.org, nico@linaro.org, yalin.wang2010@gmail.com, catalin.marinas@arm.com, Yalin.Wang@sonymobile.com, mark.rutland@arm.com, dave.hansen@linux.intel.com, jkenisto@us.ibm.com, anton@samba.org, stefani@seibold.net, JBeulich@suse.com, akpm@linux-foundation.org, rusty@rustcorp.com.au, peterz@infradead.org, prarit@redhat.com, fabf@skynet.be, hannes@cmpxchg.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, lizefan@huawei.com, "yrl.pp-manager.tt@hitachi.com" Subject: Re: [RFC PATCH v3 15/26] early kprobes: x86: directly modify code. References: <1423805941-61407-1-git-send-email-wangnan0@huawei.com> <1423806053-62111-1-git-send-email-wangnan0@huawei.com> In-Reply-To: <1423806053-62111-1-git-send-email-wangnan0@huawei.com> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1786 Lines: 60 (2015/02/13 14:40), Wang Nan wrote: > When registering early kprobes, SMP should has not been enabled, so > doesn't require synchronization in text_poke_bp(). Simply memcpy is > enough. BTW, we've already have text_poke_early for this purpose. Thank you, > > Signed-off-by: Wang Nan > --- > arch/x86/kernel/kprobes/opt.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c > index 0dd8d08..21847ab 100644 > --- a/arch/x86/kernel/kprobes/opt.c > +++ b/arch/x86/kernel/kprobes/opt.c > @@ -36,6 +36,7 @@ > #include > #include > #include > +#include > > #include "common.h" > > @@ -397,8 +398,15 @@ void arch_optimize_kprobes(struct list_head *oplist) > insn_buf[0] = RELATIVEJUMP_OPCODE; > *(s32 *)(&insn_buf[1]) = rel; > > - text_poke_bp(op->kp.addr, insn_buf, RELATIVEJUMP_SIZE, > - op->optinsn.insn); > + if (unlikely(kprobes_is_early())) { > + BUG_ON(!(op->kp.flags & KPROBE_FLAG_EARLY)); > + memcpy(op->kp.addr, insn_buf, RELATIVEJUMP_SIZE); > + local_flush_tlb(); > + sync_core(); > + } else { > + text_poke_bp(op->kp.addr, insn_buf, RELATIVEJUMP_SIZE, > + op->optinsn.insn); > + } > > list_del_init(&op->list); > } > -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com -- 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/