From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Wang Nan <wangnan0@huawei.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
davem@davemloft.net,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Will Deacon <will.deacon@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Li Zefan <lizefan@huawei.com>,
peifeiyue@huawei.com
Subject: Re: [RFC PATCH] kprobes: arm: enable OPTPROBES for arm 32
Date: Wed, 6 Aug 2014 23:55:03 +0100 [thread overview]
Message-ID: <20140806225503.GV30282@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1407223697-74911-1-git-send-email-wangnan0@huawei.com>
On Tue, Aug 05, 2014 at 03:28:17PM +0800, Wang Nan wrote:
> This patch introduce kprobeopt for ARM 32.
>
> Limitations:
> - Currently only kernel compiled with ARM ISA is supported.
>
> - offset between probe point and kprobe pre_handler must not larger
> than 64MiB. Masami Hiramatsu suggests replacing 2 words, it will
> make things complex. Futher patch can make such optimization.
Why 64MiB? I think you mean +/- 32MiB.
> +static inline int
> +arm_branch_to_addr(unsigned int *pinst, void *src, void *dest)
> +{
> + unsigned int inst = 0xea000000;
> + long offset = (unsigned long)(dest) -
> + ((unsigned long)(src) + 8);
> + if ((offset > 0x3fffffc) || (offset < -0x3fffffc)) {
> + printk(KERN_WARNING "Failed to instrument %pS to %pS\n", src, dest);
> + return -EINVAL;
> + }
> +
> + inst |= (((unsigned long)offset) >> 2) & (0x00ffffffUL);
So if offset is 0x3fffffc, then inst becomes 0xea000000 |
((0x3fffffc >> 2) & 0x00ffffff), or 0xeaffffff.
If offset is -4, then offset is 0xfffffffc. So inst becomes 0xea00000 |
((0xfffffffc >> 2) & 0x00ffffff), or 0xeaffffff.
To prove it, let's disassemble this instruction:
00000000 <.text>:
0: eafffffc b 0xfffffff8
Yep, it branches backwards.
The second point is you don't mean -0x3fffffc - that's not how two's
complement arithmetic works - the branch instruction offset is a
signed integer of 24 bits. Bit 23 is the sign bit, it's maximum
positive value is 0x7fffff and it's maximum negative value is 0x800000.
Hence, you actually mean here 0x1fffffc (which gives the maximum
forward branch) and -0x2000000 (which gives the maximum backward
branch).
--
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.
prev parent reply other threads:[~2014-08-06 22:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-05 7:28 Wang Nan
2014-08-06 4:44 ` Masami Hiramatsu
2014-08-06 6:24 ` Wang Nan
2014-08-07 6:59 ` Masami Hiramatsu
2014-08-08 1:25 ` Wang Nan
2014-08-08 2:07 ` Masami Hiramatsu
2014-08-06 13:36 ` Jon Medhurst (Tixy)
2014-08-06 13:40 ` Wang Nan
2014-08-06 14:23 ` Jon Medhurst (Tixy)
2014-08-06 22:57 ` Russell King - ARM Linux
2014-08-06 22:55 ` Russell King - ARM Linux [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=20140806225503.GV30282@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=ananth@in.ibm.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=davem@davemloft.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=peifeiyue@huawei.com \
--cc=wangnan0@huawei.com \
--cc=will.deacon@arm.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
Powered by JetHome