linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: dave.long@linaro.org (David Long)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 4/6] arm64: Kprobes instruction simulation support
Date: Fri, 16 Jan 2015 16:34:04 -0500	[thread overview]
Message-ID: <54B983CC.6090507@linaro.org> (raw)
In-Reply-To: <CAHM4w1n6wCUSX1QjP8EyA9zkJBZTM=6Vc32Vjm3wPuDv=FXZzw@mail.gmail.com>

On 01/14/15 04:32, Pratyush Anand wrote:
> On Sun, Jan 11, 2015 at 9:33 AM, David Long <dave.long@linaro.org> wrote:
>> From: Sandeepa Prabhu <sandeepa.prabhu@linaro.org>
>>
>> Add support for AArch64 instruction simulation in kprobes.
>>
>> Kprobes needs simulation of instructions that cannot be stepped
>> from different memory location, e.g.: those instructions
>> that uses PC-relative addressing. In simulation, the behaviour
>> of the instruction is implemented using a copy of pt_regs.
>>
>> Following instruction catagories are simulated:
>>   - All branching instructions(conditional, register, and immediate)
>>   - Literal access instructions(load-literal, adr/adrp)
>>
>> Conditional execution is limited to branching instructions in
>> ARM v8. If conditions at PSTATE do not match the condition fields
>> of opcode, the instruction is effectively NOP. Kprobes considers
>> this case as 'miss'.
>> changes since v3:
>> from David A. Long:
>> 1) Fix incorrect simulate_ldrsw_literal() semantics.
>> 2) Use instruction test functions instead of private parse table.
>> from Will Cohen:
>> 3) Remove PC adjustments when simulating an instruction.
>> 4) Fix displacement calculations.
>>
>> Signed-off-by: Sandeepa Prabhu <sandeepa.prabhu@linaro.org>
>> Signed-off-by: William Cohen <wcohen@redhat.com>
>> Signed-off-by: David A. Long <dave.long@linaro.org>
>> ---
>
> [...]
>
>>   static bool aarch64_insn_is_steppable(u32 insn)
>>   {
>> @@ -60,6 +130,32 @@ arm_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi)
>>           */
>>          if (aarch64_insn_is_steppable(insn))
>>                  return INSN_GOOD;
>> +
>> +       asi->prepare = prepare_none;
>> +
>> +       if (aarch64_insn_is_bcond(insn)) {
>> +               asi->prepare = prepare_bcond;
>> +               asi->handler = simulate_b_cond;
>> +       } else if (aarch64_insn_is_cb(insn)) {
>> +               asi->prepare = prepare_cbz_cbnz;
>> +               asi->handler = simulate_cbz_cbnz;
>> +       } else if (aarch64_insn_is_tb(insn)) {
>> +               asi->prepare = prepare_tbz_tbnz;
>> +               asi->handler = simulate_tbz_tbnz;
>> +       } else if (aarch64_insn_is_adr(insn))
>
> aarch64_insn_is_adr should be modified to aarch64_insn_is_adr_adrp

Yes.

>> +               asi->handler = simulate_adr_adrp;
>> +       else if (aarch64_insn_is_b_bl(insn))
>> +               asi->handler = simulate_b_bl;
>> +       else if (aarch64_insn_is_ldr_lit(insn))
>> +               asi->handler = simulate_ldr_literal;
>> +       else if (aarch64_insn_is_ldrsw_lit(insn))
>> +               asi->handler = simulate_ldrsw_literal;
>
> also
>
> else if (aarch64_insn_is_br_blr(insn) || aarch64_insn_is_ret(insn))
>                 asi->handler = simulate_br_blr_ret;

Yes.

>
> ~Pratyush
>

-dl

  reply	other threads:[~2015-01-16 21:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-11  4:03 [PATCH v4 0/6] arm64: Add kernel probes (kprobes) support David Long
2015-01-11  4:03 ` [PATCH v4 1/6] arm64: Add HAVE_REGS_AND_STACK_ACCESS_API feature David Long
2015-01-12 12:51   ` Steve Capper
2015-01-15  7:07     ` Masami Hiramatsu
2015-01-11  4:03 ` [PATCH v4 2/6] arm64: Add more test functions to insn.c David Long
2015-01-14  9:32   ` Pratyush Anand
2015-01-16 21:27     ` David Long
2015-01-11  4:03 ` [PATCH v4 3/6] arm64: Kprobes with single stepping support David Long
2015-01-12 13:31   ` Steve Capper
2015-01-14  9:30   ` Pratyush Anand
2015-01-16 19:28     ` David Long
2015-01-19  9:03       ` Pratyush Anand
2015-01-21 18:02         ` David Long
2015-01-11  4:03 ` [PATCH v4 4/6] arm64: Kprobes instruction simulation support David Long
2015-01-14  9:32   ` Pratyush Anand
2015-01-16 21:34     ` David Long [this message]
2015-01-11  4:03 ` [PATCH v4 5/6] arm64: Add kernel return probes support(kretprobes) David Long
2015-01-12 14:01   ` Steve Capper
2015-01-11  4:03 ` [PATCH v4 6/6] kprobes: Add arm64 case in kprobe example module David Long
2015-01-12 14:09 ` [PATCH v4 0/6] arm64: Add kernel probes (kprobes) support Steve Capper
2015-01-14 11:55   ` Pratyush Anand

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=54B983CC.6090507@linaro.org \
    --to=dave.long@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).