From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936377AbXHLPJz (ORCPT ); Sun, 12 Aug 2007 11:09:55 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S934130AbXHLPHo (ORCPT ); Sun, 12 Aug 2007 11:07:44 -0400 Received: from smtp.polymtl.ca ([132.207.4.11]:47453 "EHLO smtp.polymtl.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936076AbXHLPHk (ORCPT ); Sun, 12 Aug 2007 11:07:40 -0400 Message-Id: <20070812150641.775737851@polymtl.ca> References: <20070812150402.148764478@polymtl.ca> User-Agent: quilt/0.46-1 Date: Sun, 12 Aug 2007 11:04:11 -0400 From: Mathieu Desnoyers To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Cc: Mathieu Desnoyers , Andi Kleen , prasanna@in.ibm.com, ananth@in.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net Subject: [patch 9/9] Text Edit Lock - kprobes x86_64 Content-Disposition: inline; filename=text-edit-lock-kprobes-x86_64.patch X-Poly-FromMTA: (dijkstra.casi.polymtl.ca [132.207.72.10]) at Sun, 12 Aug 2007 15:06:42 +0000 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Kprobes can use the text edit lock to insure mutual exclusion when editing the code. Signed-off-by: Mathieu Desnoyers CC: Andi Kleen CC: prasanna@in.ibm.com CC: ananth@in.ibm.com CC: anil.s.keshavamurthy@intel.com CC: davem@davemloft.net --- arch/x86_64/kernel/kprobes.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) Index: linux-2.6-lttng/arch/x86_64/kernel/kprobes.c =================================================================== --- linux-2.6-lttng.orig/arch/x86_64/kernel/kprobes.c 2007-08-10 16:44:23.000000000 -0400 +++ linux-2.6-lttng/arch/x86_64/kernel/kprobes.c 2007-08-10 17:21:07.000000000 -0400 @@ -42,6 +42,7 @@ #include #include #include +#include void jprobe_return_end(void); static void __kprobes arch_copy_kprobe(struct kprobe *p); @@ -209,12 +210,16 @@ static void __kprobes arch_copy_kprobe(s void __kprobes arch_arm_kprobe(struct kprobe *p) { - text_poke(p->addr, ((unsigned char []){BREAKPOINT_INSTRUCTION}), 1); + kernel_text_mark_rw((unsigned long) p->addr, sizeof(kprobe_opcode_t)); + *p->addr = BREAKPOINT_INSTRUCTION; + kernel_text_unmark((unsigned long) p->addr, sizeof(kprobe_opcode_t)); } void __kprobes arch_disarm_kprobe(struct kprobe *p) { - text_poke(p->addr, &p->opcode, 1); + kernel_text_mark_rw((unsigned long) p->addr, sizeof(kprobe_opcode_t)); + *p->addr = p->opcode; + kernel_text_unmark((unsigned long) p->addr, sizeof(kprobe_opcode_t)); } void __kprobes arch_remove_kprobe(struct kprobe *p) -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68