public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Kprobes: pre-handler with interrupts enabled - is it possible?
@ 2015-02-23 15:04 Eugene Shatokhin
  2015-02-24  3:47 ` Masami Hiramatsu
  0 siblings, 1 reply; 7+ messages in thread
From: Eugene Shatokhin @ 2015-02-23 15:04 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: linux-kernel

Hi,


First of all, many thanks to the developers of Kprobes! I use both 
Kprobes and parts of their code a lot in my projects these days.

As far as I can see, the pre-handlers of Kprobes run with interrupts and 
preemption disabled on the given CPU, at least on x86 without Kprobe 
optimization.

Is it possible, however, to use Kprobes to somehow execute my code 
before a given instruction but with the same restrictions as the 
original instruction, at least, w.r.t. the interrupts?

I mean, if the instruction is executed with interrupts enabled, my code 
would also execute with interrupts enabled, etc.

If it is possible, how would you recommend to do that? Without patching 
the implementation of Kprobes, I mean.

Same for preemption, but, it seems, Kprobes really need it disabled, at 
least to be able to use kprobe_running() and other per-cpu data.

In RaceHound project I am now working on 
(https://github.com/winnukem/racehound/tree/rh_rework), the breakpoints 
are used to detect data races in the kernel code in runtime. Software 
breakpoints for the code, hardware breakpoints for the data that is 
about to be accessed.

However, to make it all work, the detector introduces delays before the 
instructions of interest. I could do this in Kprobes' pre-handlers but 
the interrupts would always be disabled on the current CPU during the 
delays, which is no good.

So far, I implemented it using software breakpoints directly, without 
Kprobes. The pre-handlers are executed then in the same context as the 
original instructions.

Still the implementation becomes more and more like Kprobes in some 
places over time. If there is a way to avoid reinventing the wheel and 
just use Kprobes, I would do that.

So, any ideas?

Regards,
Eugene

-- 
Eugene Shatokhin, ROSA
www.rosalab.com

^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <54ED88BC.8080705@rosalab.ru>]

end of thread, other threads:[~2015-03-22 17:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-23 15:04 Kprobes: pre-handler with interrupts enabled - is it possible? Eugene Shatokhin
2015-02-24  3:47 ` Masami Hiramatsu
2015-02-24  6:04   ` Eugene Shatokhin
2015-02-24 10:24     ` Masami Hiramatsu
2015-03-09 11:04       ` Eugene Shatokhin
2015-03-22 17:26       ` Eugene Shatokhin
     [not found] <54ED88BC.8080705@rosalab.ru>
2015-02-25 11:20 ` Eugene Shatokhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox