From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] kprobes with thumb2 conditional code
Date: Wed, 15 Jun 2011 13:41:09 +0100 [thread overview]
Message-ID: <20110615124109.GB3434@arm.com> (raw)
In-Reply-To: <1308140675.3154.61.camel@computer2>
On Wed, Jun 15, 2011 at 01:24:35PM +0100, Tixy wrote:
> On Wed, 2011-06-15 at 12:16 +0100, Dave Martin wrote:
[...]
> > Where branches appear in IT blocks, they're not allowed to be anywhere
> > except at the end of the block, so the next instruction is either outside
> > the block, or is an IT instruction itself (in which case we can still
> > set a probe on it). In valid code there will always be a next instruction,
> > since the CPU will fall through the branch if the condition is false.
>
> But, if we are asked to probe a normal unconditional branch, we don't
> know if its in an IT block or not. E.g. the branch instruction in this:
>
> cmp r1, #0
> itt eq
> moveq r0, #1
> beq somewhere
> ldr r0, [r1]
>
> and in this:
>
> mov r0, #1
> b somewhere
> .word some_literal_pool_value
>
> are the same instruction, the 'beq' syntax is just for readability.
Good point, I understand that those instructions are encoded the same, but
I hadn't considered the possibility that the following bytes will contain data
instead of instructions... though actually that will be common-ish after
unconditional branches.
Attempting to set a probe in data will of course be bad, since it may
lead to undetectable corruption. Ugh.
(Hard to work around, unless you really want to implement full
instruction tracing or watchpoints. OK, let's not do that! ;)
> The real Thumb conditional branch instructions aren't allowed in IT
> blocks. It was when I implemented emulation of these that I began to
> have second thoughts about the approach to conditional instructions.
>
> > That would deal with almost all cases, but it adds a bit of complexity
> > so I'm not convinced it's worth it.
>
> Too complex to go there ;-)
Yup, I agree.
[...]
> > If you think that that #3 is not the simplest reasonable-looking
> > approach after all, then I guess we can think about alternatives.
>
> I'm now convinced that #3 is best after all. It is the only thing we can
> get simple, consistent rules for. I.e.
>
> "Kprobes on conditional instructions don't trigger when the
> condition is false. For conditional branches, this means that
> they don't trigger in the branch not taken case."
Plus it's fairly striaghtforward to implement, so shouldn't waste effort.
As long as people don't get unpleasant surprises from setting a probe
on a function entry point, I think that's OK as an approach.
I think a real function generated by the compiler will never have a
conditional instruction at its entry point, since the ABI permits the
condition flags to be clobbered across procedure calls and returns
anyway... so the result of such an instruction would be indeterminate.
So a probe set on an external function label should always fire even
with the proposed implementation.
So #3 sounds good for me.
Cheers
---Dave
prev parent reply other threads:[~2011-06-15 12:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-11 17:01 [RFC] kprobes with thumb2 conditional code Tixy
2011-03-17 13:48 ` Dave Martin
2011-03-17 22:46 ` Nicolas Pitre
2011-03-18 16:43 ` Dave Martin
2011-06-15 9:45 ` Tixy
2011-06-15 11:16 ` Dave Martin
2011-06-15 12:24 ` Tixy
2011-06-15 12:41 ` Dave Martin [this message]
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=20110615124109.GB3434@arm.com \
--to=dave.martin@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.