From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12543 invoked by alias); 28 Feb 2012 10:00:30 -0000 Received: (qmail 12535 invoked by uid 22791); 28 Feb 2012 10:00:30 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx2.mail.elte.hu (HELO mx2.mail.elte.hu) (157.181.151.9) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Feb 2012 10:00:14 +0000 Received: from elvis.elte.hu ([157.181.1.14]) by mx2.mail.elte.hu with esmtp (Exim) id 1S2Jqi-00080j-Hl from ; Tue, 28 Feb 2012 11:00:05 +0100 Received: by elvis.elte.hu (Postfix, from userid 1004) id 00ADE3E2596; Tue, 28 Feb 2012 10:59:47 +0100 (CET) Date: Tue, 28 Feb 2012 10:00:00 -0000 From: Ingo Molnar To: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, yrl.pp-manager.tt@hitachi.com, systemtap@sourceware.org, anderson@redhat.com, Thomas Gleixner , "H. Peter Anvin" , Ananth N Mavinakayanahalli Subject: Re: Re: Re: [PATCH v3 -tip] [BUGFIX] x86/kprobes: Fix to recover instructions on optimized path Message-ID: <20120228095953.GA17149@elte.hu> References: <20120223083703.GA26781@elte.hu> <20120224095412.8462.55698.stgit@localhost.localdomain> <20120227093421.GA10078@elte.hu> <4F4C4182.1040706@hitachi.com> <20120228084828.GK21106@elte.hu> <4F4CA3BC.7050909@hitachi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F4CA3BC.7050909@hitachi.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-ELTE-SpamScore: -2.0 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-2.0 required=5.9 tests=BAYES_00 autolearn=no SpamAssassin version=3.3.1 -2.0 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2012-q1/txt/msg00210.txt.bz2 * Masami Hiramatsu wrote: > (2012/02/28 17:48), Ingo Molnar wrote: > > > > * Masami Hiramatsu wrote: > > > >> (2012/02/27 18:34), Ingo Molnar wrote: > >>> > >>> * Masami Hiramatsu wrote: > >>> > >>>> + > >>>> +#ifdef CONFIG_OPTPROBES > >>>> +static unsigned long __recover_optprobed_insn(struct kprobe *kp, > >>>> + kprobe_opcode_t *buf, > >>>> + unsigned long addr) > >>>> +{ > >>>> + long offs = addr - (unsigned long)kp->addr - 1; > >>>> + struct optimized_kprobe *op = container_of(kp, struct optimized_kprobe, kp); > >>>> + > >>>> + /* > >>>> + * If the kprobe can be optimized, original bytes which can be > >>>> + * overwritten by jump destination address. In this case, original > >>>> + * bytes must be recovered from op->optinsn.copied_insn buffer. > >>>> + */ > >>>> + memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); > >>>> + if (addr == (unsigned long)kp->addr) { > >>>> + buf[0] = kp->opcode; > >>>> + memcpy(buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE); > >>>> + } else > >>>> + memcpy(buf, op->optinsn.copied_insn + offs, RELATIVE_ADDR_SIZE - offs); > >>>> + > >>>> + return (unsigned long)buf; > >>>> +} > >>>> +#endif > >>> > >>> Why not stick this into a new kprobes-opt.c file? > >> > >> Would you mean that I should split all optprobe stuffs into > >> new file? > > > > Yeah, that would be sensible I think - and it might help avoid > > similar complications in the future. > > > > Could (and probably should) be done in a separate patch - to > > keep the bits that you already fixed and tested intact. > > OK, I'll make a separate patch. Could be done on top of your existing patch, to keep things simpler for you - a split-up patch done before your fix would create a lot of conflicts in the fix patch. Thanks, Ingo