From: Eugene Shatokhin <eugene.shatokhin@rosalab.ru>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Kprobes: pre-handler with interrupts enabled - is it possible?
Date: Sun, 22 Mar 2015 20:26:38 +0300 [thread overview]
Message-ID: <550EFB4E.5000809@rosalab.ru> (raw)
In-Reply-To: <54EC5160.7090400@hitachi.com>
Hello,
It took a while to properly implement the technique I wrote about
earlier but I have prepared a working example. Initially, I did not
reset the Kprobe properly and that caused difficult-to-debug problems.
Anyway, it works now.
In this example, Kprobes are used to execute my functions before and
after the insn of interest, in the same context as the insn w.r.t. the
interrupts and the preemption. There are some drawbacks and tricky
points, but still.
I tested this code on my simple modules as well as on the network
drivers (atl1c, e1000e, e1000) in Ubuntu 14.04 and ROSA R5 (x86, both 32
and 64-bit).
If you are interested, the source code is here:
https://abf.io/spectre/kernel-examples#?path=kprobe_lite. Most of the
logic is in module.c, the details are in Readme.txt.
I will try now to reimplement the relevant parts of our RaceHound system
using the Kprobes and the technique from the example.
By the way, while working on that code, I found that Kprobes consider
the following insns as not boostable (can_boost() in
arch/x86/kernel/kprobes/core.c):
* opcodes c0, c1, d0 - d3 with ModRM.reg != 110(b): ROL, ROR, RCL, RCR,
SHL/SAL, SHR, SAR (Grp 2-1A)
* opcodes f6 and f7 with ModRM.reg != 001(b): TEST, NOT, NEG, MUL, IMUL,
DIV, IDIV (Grp 3-1A)
* opcodes fe and ff with ModRM.reg being 000(b) or 001(b): INC, DEC (Grp
4-1A and 5-1A)
* opcode 0f c7 with ModRM.reg == 001(b): CMPXCHG8B, CMPXCHG16B.
Not sure why Kprobes do so.
Regards,
Eugene
next prev parent reply other threads:[~2015-03-22 17:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
[not found] <54ED88BC.8080705@rosalab.ru>
2015-02-25 11:20 ` Eugene Shatokhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=550EFB4E.5000809@rosalab.ru \
--to=eugene.shatokhin@rosalab.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox