Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932422AbbBLM3O (ORCPT ); Thu, 12 Feb 2015 07:29:14 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:37789 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932111AbbBLM3L (ORCPT ); Thu, 12 Feb 2015 07:29:11 -0500 From: Wang Nan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , Subject: [RFC PATCH v2 15/26] early kprobes: x86: directly modify code. Date: Thu, 12 Feb 2015 20:20:40 +0800 Message-ID: <1423743640-12674-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1423743476-11927-1-git-send-email-wangnan0@huawei.com> References: <1423743476-11927-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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1433 Lines: 47 When registering early kprobes, SMP should has not been enabled, so doesn't require synchronization in text_poke_bp(). Simply memcpy is enough. 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); } -- 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/