ARM: kprobes: introduces checker
This patch introdces 'checker' to decoding phase, and calls checkers when instruction decoding. This allows further decoding for specific instructions. This patch introduces a stub call of checkers in kprobe arch_prepare_kprobe() as an example and for further expansion. Signed-off-by: Wang Nan <wangnan0@huawei.com> Reviewed-by: Jon Medhurst <tixy@linaro.org> Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Jon Medhurst <tixy@linaro.org>
This commit is contained in:
@@ -339,3 +339,5 @@ const union decode_action kprobes_arm_actions[NUM_PROBES_ARM_ACTIONS] = {
|
||||
[PROBES_BRANCH] = {.handler = simulate_bbl},
|
||||
[PROBES_LDMSTM] = {.decoder = kprobe_decode_ldmstm}
|
||||
};
|
||||
|
||||
const struct decode_checker *kprobes_arm_checkers[] = {NULL};
|
||||
|
@@ -664,3 +664,6 @@ const union decode_action kprobes_t32_actions[NUM_PROBES_T32_ACTIONS] = {
|
||||
[PROBES_T32_MUL_ADD_LONG] = {
|
||||
.handler = t32_emulate_rdlo12rdhi8rn16rm0_noflags},
|
||||
};
|
||||
|
||||
const struct decode_checker *kprobes_t32_checkers[] = {NULL};
|
||||
const struct decode_checker *kprobes_t16_checkers[] = {NULL};
|
||||
|
@@ -61,6 +61,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
|
||||
kprobe_decode_insn_t *decode_insn;
|
||||
const union decode_action *actions;
|
||||
int is;
|
||||
const struct decode_checker **checkers;
|
||||
|
||||
if (in_exception_text(addr))
|
||||
return -EINVAL;
|
||||
@@ -74,9 +75,11 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
|
||||
insn = __opcode_thumb32_compose(insn, inst2);
|
||||
decode_insn = thumb32_probes_decode_insn;
|
||||
actions = kprobes_t32_actions;
|
||||
checkers = kprobes_t32_checkers;
|
||||
} else {
|
||||
decode_insn = thumb16_probes_decode_insn;
|
||||
actions = kprobes_t16_actions;
|
||||
checkers = kprobes_t16_checkers;
|
||||
}
|
||||
#else /* !CONFIG_THUMB2_KERNEL */
|
||||
thumb = false;
|
||||
@@ -85,12 +88,13 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
|
||||
insn = __mem_to_opcode_arm(*p->addr);
|
||||
decode_insn = arm_probes_decode_insn;
|
||||
actions = kprobes_arm_actions;
|
||||
checkers = kprobes_arm_checkers;
|
||||
#endif
|
||||
|
||||
p->opcode = insn;
|
||||
p->ainsn.insn = tmp_insn;
|
||||
|
||||
switch ((*decode_insn)(insn, &p->ainsn, true, actions)) {
|
||||
switch ((*decode_insn)(insn, &p->ainsn, true, actions, checkers)) {
|
||||
case INSN_REJECTED: /* not supported */
|
||||
return -EINVAL;
|
||||
|
||||
|
@@ -37,16 +37,19 @@ kprobe_decode_ldmstm(kprobe_opcode_t insn, struct arch_probes_insn *asi,
|
||||
typedef enum probes_insn (kprobe_decode_insn_t)(probes_opcode_t,
|
||||
struct arch_probes_insn *,
|
||||
bool,
|
||||
const union decode_action *);
|
||||
const union decode_action *,
|
||||
const struct decode_checker *[*]);
|
||||
|
||||
#ifdef CONFIG_THUMB2_KERNEL
|
||||
|
||||
extern const union decode_action kprobes_t32_actions[];
|
||||
extern const union decode_action kprobes_t16_actions[];
|
||||
|
||||
extern const struct decode_checker *kprobes_t32_checkers[];
|
||||
extern const struct decode_checker *kprobes_t16_checkers[];
|
||||
#else /* !CONFIG_THUMB2_KERNEL */
|
||||
|
||||
extern const union decode_action kprobes_arm_actions[];
|
||||
extern const struct decode_checker *kprobes_arm_checkers[];
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user