Skip to content

Commit

Permalink
ARM: Make arch_specific_insn a define for new arch_probes_insn structure
Browse files Browse the repository at this point in the history
Because the common underlying code for ARM kprobes and uprobes needs
to share a common architecrure-specific context structure, and because
the generic kprobes include file insists on defining this to a dummy
structure when kprobes is not configured, a new common structure is
required which can exist when uprobes is configured without kprobes.
In this case kprobes will define a dummy structure, but without the
define aliasing the two structure tags it will not affect uprobes and
the shared probes code.

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Jon Medhurst <tixy@linaro.org>
  • Loading branch information
David A. Long committed Mar 18, 2014
1 parent 602cd26 commit b4cd605
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 82 deletions.
2 changes: 2 additions & 0 deletions arch/arm/include/asm/kprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ typedef u32 kprobe_opcode_t;
struct kprobe;
#include <asm/probes.h>

#define arch_specific_insn arch_probes_insn

struct prev_kprobe {
struct kprobe *kp;
unsigned int status;
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/include/asm/probes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@

typedef u32 probes_opcode_t;

struct arch_specific_insn;
struct arch_probes_insn;
typedef void (probes_insn_handler_t)(probes_opcode_t,
struct arch_specific_insn *,
struct arch_probes_insn *,
struct pt_regs *);
typedef unsigned long (probes_check_cc)(unsigned long);
typedef void (probes_insn_singlestep_t)(probes_opcode_t,
struct arch_specific_insn *,
struct arch_probes_insn *,
struct pt_regs *);
typedef void (probes_insn_fn_t)(void);

/* Architecture specific copy of original instruction. */
struct arch_specific_insn {
struct arch_probes_insn {
probes_opcode_t *insn;
probes_insn_handler_t *insn_handler;
probes_check_cc *insn_check_cc;
Expand Down
16 changes: 8 additions & 8 deletions arch/arm/kernel/kprobes-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

static void __kprobes
emulate_ldrdstrd(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
unsigned long pc = regs->ARM_pc + 4;
int rt = (insn >> 12) & 0xf;
Expand Down Expand Up @@ -103,7 +103,7 @@ emulate_ldrdstrd(probes_opcode_t insn,

static void __kprobes
emulate_ldr(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
unsigned long pc = regs->ARM_pc + 4;
int rt = (insn >> 12) & 0xf;
Expand Down Expand Up @@ -133,7 +133,7 @@ emulate_ldr(probes_opcode_t insn,

static void __kprobes
emulate_str(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
unsigned long rtpc = regs->ARM_pc - 4 + str_pc_offset;
unsigned long rnpc = regs->ARM_pc + 4;
Expand All @@ -160,7 +160,7 @@ emulate_str(probes_opcode_t insn,

static void __kprobes
emulate_rd12rn16rm0rs8_rwflags(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
unsigned long pc = regs->ARM_pc + 4;
int rd = (insn >> 12) & 0xf;
Expand Down Expand Up @@ -195,7 +195,7 @@ emulate_rd12rn16rm0rs8_rwflags(probes_opcode_t insn,

static void __kprobes
emulate_rd12rn16rm0_rwflags_nopc(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
int rd = (insn >> 12) & 0xf;
int rn = (insn >> 16) & 0xf;
Expand All @@ -222,7 +222,7 @@ emulate_rd12rn16rm0_rwflags_nopc(probes_opcode_t insn,

static void __kprobes
emulate_rd16rn12rm0rs8_rwflags_nopc(probes_opcode_t insn,
struct arch_specific_insn *asi,
struct arch_probes_insn *asi,
struct pt_regs *regs)
{
int rd = (insn >> 16) & 0xf;
Expand Down Expand Up @@ -252,7 +252,7 @@ emulate_rd16rn12rm0rs8_rwflags_nopc(probes_opcode_t insn,

static void __kprobes
emulate_rd12rm0_noflags_nopc(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
int rd = (insn >> 12) & 0xf;
int rm = insn & 0xf;
Expand All @@ -272,7 +272,7 @@ emulate_rd12rm0_noflags_nopc(probes_opcode_t insn,

static void __kprobes
emulate_rdlo12rdhi16rn0rm8_rwflags_nopc(probes_opcode_t insn,
struct arch_specific_insn *asi,
struct arch_probes_insn *asi,
struct pt_regs *regs)
{
int rdlo = (insn >> 12) & 0xf;
Expand Down
14 changes: 7 additions & 7 deletions arch/arm/kernel/kprobes-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


static void __kprobes simulate_ldm1stm1(probes_opcode_t insn,
struct arch_specific_insn *asi,
struct arch_probes_insn *asi,
struct pt_regs *regs)
{
int rn = (insn >> 16) & 0xf;
Expand Down Expand Up @@ -60,7 +60,7 @@ static void __kprobes simulate_ldm1stm1(probes_opcode_t insn,
}

static void __kprobes simulate_stm1_pc(probes_opcode_t insn,
struct arch_specific_insn *asi,
struct arch_probes_insn *asi,
struct pt_regs *regs)
{
unsigned long addr = regs->ARM_pc - 4;
Expand All @@ -71,7 +71,7 @@ static void __kprobes simulate_stm1_pc(probes_opcode_t insn,
}

static void __kprobes simulate_ldm1_pc(probes_opcode_t insn,
struct arch_specific_insn *asi,
struct arch_probes_insn *asi,
struct pt_regs *regs)
{
simulate_ldm1stm1(insn, asi, regs);
Expand All @@ -80,7 +80,7 @@ static void __kprobes simulate_ldm1_pc(probes_opcode_t insn,

static void __kprobes
emulate_generic_r0_12_noflags(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
register void *rregs asm("r1") = regs;
register void *rfn asm("lr") = asi->insn_fn;
Expand Down Expand Up @@ -108,23 +108,23 @@ emulate_generic_r0_12_noflags(probes_opcode_t insn,

static void __kprobes
emulate_generic_r2_14_noflags(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
emulate_generic_r0_12_noflags(insn, asi,
(struct pt_regs *)(regs->uregs+2));
}

static void __kprobes
emulate_ldm_r3_15(probes_opcode_t insn,
struct arch_specific_insn *asi, struct pt_regs *regs)
struct arch_probes_insn *asi, struct pt_regs *regs)
{
emulate_generic_r0_12_noflags(insn, asi,
(struct pt_regs *)(regs->uregs+3));
load_write_pc(regs->ARM_pc, regs);
}

enum probes_insn __kprobes
kprobe_decode_ldmstm(probes_opcode_t insn, struct arch_specific_insn *asi,
kprobe_decode_ldmstm(probes_opcode_t insn, struct arch_probes_insn *asi,
const struct decode_header *h)
{
probes_insn_handler_t *handler = 0;
Expand Down
Loading

0 comments on commit b4cd605

Please sign in to comment.