mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-09-22 12:24:38 +00:00
ARM: kprobes: Add Thumb instruction decoding stubs
Extend arch_prepare_kprobe to support probing of Thumb code. For the actual decoding of Thumb instructions, stub functions are added which currently just reject the probe. Signed-off-by: Jon Medhurst <tixy@yxit.co.uk> Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
This commit is contained in:
parent
de41984003
commit
2437170710
4 changed files with 61 additions and 2 deletions
|
@ -38,7 +38,11 @@ obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
|
||||||
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
|
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
|
||||||
obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
|
obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
|
||||||
obj-$(CONFIG_KPROBES) += kprobes.o kprobes-common.o
|
obj-$(CONFIG_KPROBES) += kprobes.o kprobes-common.o
|
||||||
|
ifdef CONFIG_THUMB2_KERNEL
|
||||||
|
obj-$(CONFIG_KPROBES) += kprobes-thumb.o
|
||||||
|
else
|
||||||
obj-$(CONFIG_KPROBES) += kprobes-arm.o
|
obj-$(CONFIG_KPROBES) += kprobes-arm.o
|
||||||
|
endif
|
||||||
obj-$(CONFIG_ATAGS_PROC) += atags.o
|
obj-$(CONFIG_ATAGS_PROC) += atags.o
|
||||||
obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
|
obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o
|
||||||
obj-$(CONFIG_ARM_THUMBEE) += thumbee.o
|
obj-$(CONFIG_ARM_THUMBEE) += thumbee.o
|
||||||
|
|
26
arch/arm/kernel/kprobes-thumb.c
Normal file
26
arch/arm/kernel/kprobes-thumb.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* arch/arm/kernel/kprobes-thumb.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/kprobes.h>
|
||||||
|
|
||||||
|
#include "kprobes.h"
|
||||||
|
|
||||||
|
enum kprobe_insn __kprobes
|
||||||
|
thumb16_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi)
|
||||||
|
{
|
||||||
|
return INSN_REJECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum kprobe_insn __kprobes
|
||||||
|
thumb32_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi)
|
||||||
|
{
|
||||||
|
return INSN_REJECTED;
|
||||||
|
}
|
|
@ -51,16 +51,32 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
|
||||||
kprobe_opcode_t insn;
|
kprobe_opcode_t insn;
|
||||||
kprobe_opcode_t tmp_insn[MAX_INSN_SIZE];
|
kprobe_opcode_t tmp_insn[MAX_INSN_SIZE];
|
||||||
unsigned long addr = (unsigned long)p->addr;
|
unsigned long addr = (unsigned long)p->addr;
|
||||||
|
kprobe_decode_insn_t *decode_insn;
|
||||||
int is;
|
int is;
|
||||||
|
|
||||||
if (addr & 0x3 || in_exception_text(addr))
|
if (in_exception_text(addr))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
#ifdef CONFIG_THUMB2_KERNEL
|
||||||
|
addr &= ~1; /* Bit 0 would normally be set to indicate Thumb code */
|
||||||
|
insn = ((u16 *)addr)[0];
|
||||||
|
if (is_wide_instruction(insn)) {
|
||||||
|
insn <<= 16;
|
||||||
|
insn |= ((u16 *)addr)[1];
|
||||||
|
decode_insn = thumb32_kprobe_decode_insn;
|
||||||
|
} else
|
||||||
|
decode_insn = thumb16_kprobe_decode_insn;
|
||||||
|
#else /* !CONFIG_THUMB2_KERNEL */
|
||||||
|
if (addr & 0x3)
|
||||||
|
return -EINVAL;
|
||||||
insn = *p->addr;
|
insn = *p->addr;
|
||||||
|
decode_insn = arm_kprobe_decode_insn;
|
||||||
|
#endif
|
||||||
|
|
||||||
p->opcode = insn;
|
p->opcode = insn;
|
||||||
p->ainsn.insn = tmp_insn;
|
p->ainsn.insn = tmp_insn;
|
||||||
|
|
||||||
switch (arm_kprobe_decode_insn(insn, &p->ainsn)) {
|
switch ((*decode_insn)(insn, &p->ainsn)) {
|
||||||
case INSN_REJECTED: /* not supported */
|
case INSN_REJECTED: /* not supported */
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,21 @@ enum kprobe_insn {
|
||||||
INSN_GOOD_NO_SLOT
|
INSN_GOOD_NO_SLOT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum kprobe_insn (kprobe_decode_insn_t)(kprobe_opcode_t,
|
||||||
|
struct arch_specific_insn *);
|
||||||
|
|
||||||
|
#ifdef CONFIG_THUMB2_KERNEL
|
||||||
|
|
||||||
|
enum kprobe_insn thumb16_kprobe_decode_insn(kprobe_opcode_t,
|
||||||
|
struct arch_specific_insn *);
|
||||||
|
enum kprobe_insn thumb32_kprobe_decode_insn(kprobe_opcode_t,
|
||||||
|
struct arch_specific_insn *);
|
||||||
|
|
||||||
|
#else /* !CONFIG_THUMB2_KERNEL */
|
||||||
|
|
||||||
enum kprobe_insn arm_kprobe_decode_insn(kprobe_opcode_t,
|
enum kprobe_insn arm_kprobe_decode_insn(kprobe_opcode_t,
|
||||||
struct arch_specific_insn *);
|
struct arch_specific_insn *);
|
||||||
|
#endif
|
||||||
|
|
||||||
void __init arm_kprobe_decode_init(void);
|
void __init arm_kprobe_decode_init(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue