Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754845AbbLKK1Y (ORCPT ); Fri, 11 Dec 2015 05:27:24 -0500 Received: from smarthost01c.mail.zen.net.uk ([212.23.1.5]:39289 "EHLO smarthost01c.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751645AbbLKK1W (ORCPT ); Fri, 11 Dec 2015 05:27:22 -0500 Message-ID: <1449829633.2815.27.camel@linaro.org> Subject: Re: [RFC] kprobe'ing conditionally executed instructions From: "Jon Medhurst (Tixy)" To: David Long Cc: masami.hiramatsu.pt@hitachi.com, Ananth N Mavinakayanahalli , anil.s.keshavamurthy@intel.com, davem@davemloft.net, Steve Capper , will.deacon@arm.com, "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Sandeepa Prabhu , wcohen@redhat.com, Pratyush Anand Date: Fri, 11 Dec 2015 10:27:13 +0000 In-Reply-To: <566A5997.9020908@linaro.org> References: <566A5997.9020908@linaro.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-smarthost01c-IP: [82.69.122.217] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1971 Lines: 45 On Fri, 2015-12-11 at 00:05 -0500, David Long wrote: > There is a moderate amount of code already in kprobes on ARM and the > current ARMv8 patch to deal with conditional execution of instructions. > One aspect of how this is handled is that instructions that fail their > predicate and are not (technically) executed are also not treated as a > hit kprobe. Steve Capper has suggested that the probe handling should > still take place because we stepped through the instruction even if it > was effectively a nop. This would be a significant change in how it > currently works on 32-bit ARM 32-bit ARM uses undefined instructions for kprobe 'breakpoints' and the ARM ARM says it's implementation defined behaviour whether these generate exceptions or not, i.e. whether the kprobe handler will be called. You could say that we could always use unconditional breakpoints, but this doesn't work with thumb where the instruction could be in an IT block. So, the only way to have consistent behaviour on all platforms is to not call kprobe handlers if condition check fails. Which is the reason for the current implementation's design. Also, if we change the current implementation as suggested, then looking at things from a source code point of view... if (test) foo() else bar(); If you put a probe on the call to foo() and the compiler uses a branch instruction for the test you're never going to hit the probe fortest==false. But if it decides to use conditional instructions it will (on some CPU implementations). And the choice between branch/conditional instructions probably varies between GCC version and kernel configs. So again, IMO, the current kprobes implementation leads to consistency. -- Tixy -- 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/