Thumb kprobe API. was Re: Determining an ARM CPU's architecture
tixy at yxit.co.uk
Wed Jul 6 12:38:44 UTC 2011
On Tue, 2011-07-05 at 14:46 +0100, Dave Martin wrote:
> On Tue, Jul 5, 2011 at 12:35 PM, Tixy <tixy at yxit.co.uk> wrote:
> > On Tue, 2011-07-05 at 12:01 +0100, Dave Martin wrote:
> >> One question though -- how do we know when setting a probe whether the target
> >> instruction is ARM or Thumb?
> > I'm using the bottom bit of the probe address. The kprobes API lets you
> > specify the probe location as a symbol
> > the_probe.symbol_name = "function_name";
> > or as an address
> > the_probe.addr = &function_name;
> > and both of these cases will work. If the address is obtained by another
> > means which doesn't set bit zero to indicate thumb code, then it's going
> > to go bang.
> The only code locations which exist from the point of view of ELF are
> function entry points, so the convention is clear for those.
> The main other means I can think of is if people are setting ad-hoc
> probes in the middle of functions.
> Now, we could make correct setting of the Thumb bit part of the
> semantics of the kprobes interface, but I think we have to document it
> explicitly in that case, and there's a risk it could interfere with
> some existing uses of kprobes.
Now we decided that we wouldn't support probing ARM code on Thumb
kernels I've been changing the code to ignore bit 0 of the probe
address. However, one problem with this is that the address is used by
the non-arch specific framework code to identify probes.
This causes two problems.
1. In the ARM kprobe_handler I have to decide whether to call get_kprobe
with an address which has bit 0 set or not, which I can't do without
knowing how the probe was originally registered. And doing a second
lookups if the first fails seems too horrible.
2. The generic kprobes code supports the case where two or more probes
are placed at the same location, this will fail if bit 0 of the address
I think therefore, that we should keep my original implementation where:
Probe addresses in thumb code must have bit 0 set. This will naturally
be the case when using symbol lookup or "&function" to set a probe at
the start of a function. It will also be the case for setting a probe in
the middle of a function if the offset parameter is used for this. Other
uses which calculate addresses by other means may need to be modified to
set bit zero accordingly.
Does this sound reasonable?
More information about the linaro-kernel