]> Pileus Git - ~andy/linux/commitdiff
ARM: kprobes: Add bx_write_pc()
authorJon Medhurst <tixy@yxit.co.uk>
Thu, 9 Jun 2011 10:01:54 +0000 (11:01 +0100)
committerTixy <tixy@medhuaa1.miniserver.com>
Wed, 13 Jul 2011 17:32:43 +0000 (17:32 +0000)
This writes a value to PC, with interworking. I.e. switches to Thumb or
ARM mode depending on the state of the least significant bit.

Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
arch/arm/kernel/kprobes.h

index 36e07684fe080d675857dae974e74de5d271bfe1..12627a376bf68090bf3187f944fd5b414ba8ca55 100644 (file)
@@ -95,6 +95,20 @@ static inline unsigned long it_advance(unsigned long cpsr)
        return cpsr;
 }
 
+static inline void __kprobes bx_write_pc(long pcv, struct pt_regs *regs)
+{
+       long cpsr = regs->ARM_cpsr;
+       if (pcv & 0x1) {
+               cpsr |= PSR_T_BIT;
+               pcv &= ~0x1;
+       } else {
+               cpsr &= ~PSR_T_BIT;
+               pcv &= ~0x2;    /* Avoid UNPREDICTABLE address allignment */
+       }
+       regs->ARM_cpsr = cpsr;
+       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);