diff options
author | Jon Medhurst <tixy@yxit.co.uk> | 2011-06-10 21:29:04 +0200 |
---|---|---|
committer | Tixy <tixy@medhuaa1.miniserver.com> | 2011-07-13 19:32:45 +0200 |
commit | 263e368a2f1f960db07d7524a4a3e7df951f1f72 (patch) | |
tree | eb8b1ba0a5d07368de5bd65b579a5f69233ddb07 | |
parent | ARM: kprobes: Decode 32-bit Thumb hint instructions (diff) | |
download | linux-263e368a2f1f960db07d7524a4a3e7df951f1f72.tar.xz linux-263e368a2f1f960db07d7524a4a3e7df951f1f72.zip |
ARM: kprobes: Add load_write_pc()
This writes a value to PC which was obtained as the result of a
LDR or LDM instruction. For ARMv5T and later this must perform
interworking.
Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
-rw-r--r-- | arch/arm/kernel/kprobes-common.c | 15 | ||||
-rw-r--r-- | arch/arm/kernel/kprobes.h | 24 |
2 files changed, 39 insertions, 0 deletions
diff --git a/arch/arm/kernel/kprobes-common.c b/arch/arm/kernel/kprobes-common.c index 3a3e765d2090..86fdc4c4c2ce 100644 --- a/arch/arm/kernel/kprobes-common.c +++ b/arch/arm/kernel/kprobes-common.c @@ -45,9 +45,24 @@ void __init find_str_pc_offset(void) #endif /* !find_str_pc_offset */ +#ifndef test_load_write_pc_interworking + +bool load_write_pc_interworks; + +void __init test_load_write_pc_interworking(void) +{ + int arch = cpu_architecture(); + BUG_ON(arch == CPU_ARCH_UNKNOWN); + load_write_pc_interworks = arch >= CPU_ARCH_ARMv5T; +} + +#endif /* !test_load_write_pc_interworking */ + + void __init arm_kprobe_decode_init(void) { find_str_pc_offset(); + test_load_write_pc_interworking(); } diff --git a/arch/arm/kernel/kprobes.h b/arch/arm/kernel/kprobes.h index 12627a376bf6..5d6bf0d0a18a 100644 --- a/arch/arm/kernel/kprobes.h +++ b/arch/arm/kernel/kprobes.h @@ -109,6 +109,30 @@ static inline void __kprobes bx_write_pc(long pcv, struct pt_regs *regs) regs->ARM_pc = pcv; } + +#if __LINUX_ARM_ARCH__ >= 6 + +/* Kernels built for >= ARMv6 should never run on <= ARMv5 hardware, so... */ +#define load_write_pc_interworks true +#define test_load_write_pc_interworking() + +#else /* __LINUX_ARM_ARCH__ < 6 */ + +/* We need run-time testing to determine if load_write_pc() should interwork. */ +extern bool load_write_pc_interworks; +void __init test_load_write_pc_interworking(void); + +#endif + +static inline void __kprobes load_write_pc(long pcv, struct pt_regs *regs) +{ + if (load_write_pc_interworks) + bx_write_pc(pcv, regs); + else + regs->ARM_pc = pcv; +} + + void __kprobes kprobe_simulate_nop(struct kprobe *p, struct pt_regs *regs); void __kprobes kprobe_emulate_none(struct kprobe *p, struct pt_regs *regs); |