From mboxrd@z Thu Jan 1 00:00:00 1970 From: Frederic Weisbecker Subject: Re: [PATCH -tip v14 03/12] kprobes: checks probe address is instruction boudary on x86 Date: Wed, 19 Aug 2009 01:43:42 +0200 Message-ID: <20090818234341.GG5231@nowhere> References: <20090813203403.31965.20973.stgit@localhost.localdomain> <20090813203428.31965.21939.stgit@localhost.localdomain> <20090818230340.GF5231@nowhere> <4A8B3693.9000301@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Ingo Molnar , Steven Rostedt , lkml , systemtap , kvm , DLE , Ananth N Mavinakayanahalli , Avi Kivity , Andi Kleen , Christoph Hellwig , "Frank Ch. Eigler" , "H. Peter Anvin" , Jason Baron , Jim Keniston , "K.Prasad" , Lai Jiangshan , Li Zefan , =?utf-8?B?UHJ6ZW15c8WCYXdQYXdlxYJjenlr?= , Roland McGrath , Sam Ravnborg , Srikar Dronamraju , Tom Zanussi , Vegard Nossum To: Masami Hiramatsu Return-path: Received: from ey-out-2122.google.com ([74.125.78.24]:53777 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbZHRXno (ORCPT ); Tue, 18 Aug 2009 19:43:44 -0400 Content-Disposition: inline In-Reply-To: <4A8B3693.9000301@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Aug 18, 2009 at 07:17:39PM -0400, Masami Hiramatsu wrote: > Frederic Weisbecker wrote: > >> + while (addr < paddr) { > >> + kernel_insn_init(&insn, (void *)addr); > >> + insn_get_opcode(&insn); > >> + > >> + /* Check if the instruction has been modified. */ > >> + if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) { > >> + ret = recover_probed_instruction(buf, addr); > > > > > > > > I'm confused about the reason of this recovering. Is it to remove > > kprobes behind the current setting one in the current function? > > No, it recovers just an instruction which is probed by a kprobe, > because we need to know the first byte of this instruction for > decoding it. > > Perhaps we'd better to have more generic interface (text_peek?) > for it because another subsystem (e.g. kgdb) may want to insert int3... > > Thank you, Aah, I see now, it's to keep a sane check of the instructions boundaries without int 3 artifacts in the middle. But in that case, you should re-arm the breakpoint after your check, right? Or may be you could do the check without repatching? May be by doing a copy of insn.opcode.bytes and replacing bytes[0] with what a random kprobe has stolen?