All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pratyush Anand <pratyush.anand@gmail.com>
To: David Long <dave.long@linaro.org>
Cc: "linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Russell King <linux@arm.linux.org.uk>,
	Sandeepa Prabhu <sandeepa.prabhu@linaro.org>,
	William Cohen <wcohen@redhat.com>,
	Steve Capper <steve.capper@linaro.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	"Jon Medhurst (Tixy)" <tixy@linaro.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	davem@davemloft.net, linux-kernel@vger.kernel.org,
	Pratyush Anand <panand@redhat.com>
Subject: Re: [PATCH v4 4/6] arm64: Kprobes instruction simulation support
Date: Wed, 14 Jan 2015 15:02:32 +0530	[thread overview]
Message-ID: <CAHM4w1n6wCUSX1QjP8EyA9zkJBZTM=6Vc32Vjm3wPuDv=FXZzw@mail.gmail.com> (raw)
In-Reply-To: <1420949002-3726-5-git-send-email-dave.long@linaro.org>

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

> +               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;


~Pratyush

WARNING: multiple messages have this Message-ID (diff)
From: pratyush.anand@gmail.com (Pratyush Anand)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 4/6] arm64: Kprobes instruction simulation support
Date: Wed, 14 Jan 2015 15:02:32 +0530	[thread overview]
Message-ID: <CAHM4w1n6wCUSX1QjP8EyA9zkJBZTM=6Vc32Vjm3wPuDv=FXZzw@mail.gmail.com> (raw)
In-Reply-To: <1420949002-3726-5-git-send-email-dave.long@linaro.org>

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

> +               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;


~Pratyush

  reply	other threads:[~2015-01-14  9:32 UTC|newest]

Thread overview: 42+ 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 ` David Long
2015-01-11  4:03 ` [PATCH v4 1/6] arm64: Add HAVE_REGS_AND_STACK_ACCESS_API feature David Long
2015-01-11  4:03   ` David Long
2015-01-12 12:51   ` Steve Capper
2015-01-12 12:51     ` Steve Capper
2015-01-15  7:07     ` Masami Hiramatsu
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-11  4:03   ` David Long
2015-01-14  9:32   ` Pratyush Anand
2015-01-14  9:32     ` Pratyush Anand
2015-01-16 21:27     ` David Long
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-11  4:03   ` David Long
2015-01-12 13:31   ` Steve Capper
2015-01-12 13:31     ` Steve Capper
2015-01-14  9:30   ` Pratyush Anand
2015-01-14  9:30     ` Pratyush Anand
2015-01-16 19:28     ` David Long
2015-01-16 19:28       ` David Long
2015-01-19  9:03       ` Pratyush Anand
2015-01-19  9:03         ` Pratyush Anand
2015-01-21 18:02         ` David Long
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-11  4:03   ` David Long
2015-01-14  9:32   ` Pratyush Anand [this message]
2015-01-14  9:32     ` Pratyush Anand
2015-01-16 21:34     ` David Long
2015-01-16 21:34       ` David Long
2015-01-11  4:03 ` [PATCH v4 5/6] arm64: Add kernel return probes support(kretprobes) David Long
2015-01-11  4:03   ` David Long
2015-01-12 14:01   ` Steve Capper
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-11  4:03   ` David Long
2015-01-12 14:09 ` [PATCH v4 0/6] arm64: Add kernel probes (kprobes) support Steve Capper
2015-01-12 14:09   ` Steve Capper
2015-01-14 11:55   ` Pratyush Anand
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='CAHM4w1n6wCUSX1QjP8EyA9zkJBZTM=6Vc32Vjm3wPuDv=FXZzw@mail.gmail.com' \
    --to=pratyush.anand@gmail.com \
    --cc=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=catalin.marinas@arm.com \
    --cc=dave.long@linaro.org \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=panand@redhat.com \
    --cc=sandeepa.prabhu@linaro.org \
    --cc=steve.capper@linaro.org \
    --cc=tixy@linaro.org \
    --cc=wcohen@redhat.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 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.