aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPratyush Anand <panand@redhat.com>2015-01-13 16:35:14 +0530
committerSteve Capper <steve.capper@linaro.org>2015-01-27 16:46:19 +0000
commit1c021aa17bfc4e5c2681ed27808a4eb8304798ca (patch)
treee3dcae0be078b8ba1ac78f4e83b79fdf4100aa76
parentaac252383560cbdefcc5cf778e0fea5285d294af (diff)
downloadlinux-1c021aa17bfc4e5c2681ed27808a4eb8304798ca.tar.gz
ARM64: kprobe: Make prepare and handler function struct kprobe independent
prepare and handler function will also be used by uprobe. So, make them struct kprobe independent. Signed-off-by: Pratyush Anand <panand@redhat.com>
-rw-r--r--arch/arm64/include/asm/probes.h5
-rw-r--r--arch/arm64/kernel/kprobes-arm64.c33
-rw-r--r--arch/arm64/kernel/kprobes.c9
3 files changed, 22 insertions, 25 deletions
diff --git a/arch/arm64/include/asm/probes.h b/arch/arm64/include/asm/probes.h
index 9dba74d8ee8..38bc32e2b22 100644
--- a/arch/arm64/include/asm/probes.h
+++ b/arch/arm64/include/asm/probes.h
@@ -21,9 +21,10 @@ struct arch_specific_insn;
typedef u32 kprobe_opcode_t;
typedef unsigned long (kprobes_pstate_check_t)(unsigned long);
typedef unsigned long
-(kprobes_condition_check_t)(struct kprobe *p, struct pt_regs *);
+(kprobes_condition_check_t)(u32 opcode, struct arch_specific_insn *asi,
+ struct pt_regs *);
typedef void
-(kprobes_prepare_t)(struct kprobe *, struct arch_specific_insn *);
+(kprobes_prepare_t)(u32 insn, struct arch_specific_insn *);
typedef void (kprobes_handler_t) (u32 opcode, long addr, struct pt_regs *);
enum pc_restore_type {
diff --git a/arch/arm64/kernel/kprobes-arm64.c b/arch/arm64/kernel/kprobes-arm64.c
index 7d2a5c48b80..b5201db80fb 100644
--- a/arch/arm64/kernel/kprobes-arm64.c
+++ b/arch/arm64/kernel/kprobes-arm64.c
@@ -26,68 +26,61 @@
* condition check functions for kprobes simulation
*/
static unsigned long __kprobes
-__check_pstate(struct kprobe *p, struct pt_regs *regs)
+__check_pstate(u32 opcode, struct arch_specific_insn *asi, struct pt_regs *regs)
{
- struct arch_specific_insn *asi = &p->ainsn;
unsigned long pstate = regs->pstate & 0xffffffff;
return asi->pstate_cc(pstate);
}
static unsigned long __kprobes
-__check_cbz(struct kprobe *p, struct pt_regs *regs)
+__check_cbz(u32 opcode, struct arch_specific_insn *asi, struct pt_regs *regs)
{
- return check_cbz((u32)p->opcode, regs);
+ return check_cbz(opcode, regs);
}
static unsigned long __kprobes
-__check_cbnz(struct kprobe *p, struct pt_regs *regs)
+__check_cbnz(u32 opcode, struct arch_specific_insn *asi, struct pt_regs *regs)
{
- return check_cbnz((u32)p->opcode, regs);
+ return check_cbnz(opcode, regs);
}
static unsigned long __kprobes
-__check_tbz(struct kprobe *p, struct pt_regs *regs)
+__check_tbz(u32 opcode, struct arch_specific_insn *asi, struct pt_regs *regs)
{
- return check_tbz((u32)p->opcode, regs);
+ return check_tbz(opcode, regs);
}
static unsigned long __kprobes
-__check_tbnz(struct kprobe *p, struct pt_regs *regs)
+__check_tbnz(u32 opcode, struct arch_specific_insn *asi, struct pt_regs *regs)
{
- return check_tbnz((u32)p->opcode, regs);
+ return check_tbnz(opcode, regs);
}
/*
* prepare functions for instruction simulation
*/
static void __kprobes
-prepare_none(struct kprobe *p, struct arch_specific_insn *asi)
+prepare_none(u32 insn, struct arch_specific_insn *asi)
{
}
static void __kprobes
-prepare_bcond(struct kprobe *p, struct arch_specific_insn *asi)
+prepare_bcond(u32 insn, struct arch_specific_insn *asi)
{
- kprobe_opcode_t insn = p->opcode;
-
asi->check_condn = __check_pstate;
asi->pstate_cc = kprobe_condition_checks[insn & 0xf];
}
static void __kprobes
-prepare_cbz_cbnz(struct kprobe *p, struct arch_specific_insn *asi)
+prepare_cbz_cbnz(u32 insn, struct arch_specific_insn *asi)
{
- kprobe_opcode_t insn = p->opcode;
-
asi->check_condn = (insn & (1 << 24)) ? __check_cbnz : __check_cbz;
}
static void __kprobes
-prepare_tbz_tbnz(struct kprobe *p, struct arch_specific_insn *asi)
+prepare_tbz_tbnz(u32 insn, struct arch_specific_insn *asi)
{
- kprobe_opcode_t insn = p->opcode;
-
asi->check_condn = (insn & (1 << 24)) ? __check_tbnz : __check_tbz;
}
diff --git a/arch/arm64/kernel/kprobes.c b/arch/arm64/kernel/kprobes.c
index cd1069cdaa9..7d83161ee3e 100644
--- a/arch/arm64/kernel/kprobes.c
+++ b/arch/arm64/kernel/kprobes.c
@@ -60,7 +60,7 @@ static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
static void __kprobes arch_prepare_simulate(struct kprobe *p)
{
if (p->ainsn.prepare)
- p->ainsn.prepare(p, &p->ainsn);
+ p->ainsn.prepare(p->opcode, &p->ainsn);
/* This instructions is not executed xol. No need to adjust the PC */
p->ainsn.restore.addr = 0;
@@ -271,7 +271,9 @@ static int __kprobes reenter_kprobe(struct kprobe *p,
switch (kcb->kprobe_status) {
case KPROBE_HIT_SSDONE:
case KPROBE_HIT_ACTIVE:
- if (!p->ainsn.check_condn || p->ainsn.check_condn(p, regs)) {
+ if (!p->ainsn.check_condn ||
+ p->ainsn.check_condn((u32)p->opcode, &p->ainsn,
+ regs)) {
kprobes_inc_nmissed_count(p);
setup_singlestep(p, regs, kcb, 1);
} else {
@@ -401,7 +403,8 @@ void __kprobes kprobe_handler(struct pt_regs *regs)
if (reenter_kprobe(p, regs, kcb))
return;
} else if (!p->ainsn.check_condn ||
- p->ainsn.check_condn(p, regs)) {
+ p->ainsn.check_condn((u32)p->opcode, &p->ainsn,
+ regs)) {
/* Probe hit and conditional execution check ok. */
set_current_kprobe(p);
kcb->kprobe_status = KPROBE_HIT_ACTIVE;