From 9144d23739b4a0711aa66513268654143eff7341 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 11 Feb 2016 20:28:55 +0300 Subject: [PATCH] [FIX] set correct CPU mode Change-Id: I202c34f31152126eedd8f53303444bbd98816c45 Signed-off-by: Vyacheslav Cherkashin --- kprobe/arch/arm/swap-asm/swap_kprobes.h | 10 ++++++++-- preload/preload_module.c | 4 +--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/kprobe/arch/arm/swap-asm/swap_kprobes.h b/kprobe/arch/arm/swap-asm/swap_kprobes.h index 7eb0834..b961a0c 100644 --- a/kprobe/arch/arm/swap-asm/swap_kprobes.h +++ b/kprobe/arch/arm/swap-asm/swap_kprobes.h @@ -166,7 +166,7 @@ static inline void swap_set_stack_ptr(struct pt_regs *regs, unsigned long sp) */ static inline unsigned long swap_get_instr_ptr(struct pt_regs *regs) { - return regs->ARM_pc; + return regs->ARM_pc | !!thumb_mode(regs); } /** @@ -178,7 +178,13 @@ static inline unsigned long swap_get_instr_ptr(struct pt_regs *regs) */ static inline void swap_set_instr_ptr(struct pt_regs *regs, unsigned long val) { - regs->ARM_pc = val; + if (val & 1) { + regs->ARM_pc = val & ~1; + regs->ARM_cpsr |= PSR_T_BIT; + } else { + regs->ARM_pc = val; + regs->ARM_cpsr &= ~PSR_T_BIT; + } } /** diff --git a/preload/preload_module.c b/preload/preload_module.c index e155149..0071a7b 100644 --- a/preload/preload_module.c +++ b/preload/preload_module.c @@ -116,10 +116,8 @@ static inline void __prepare_ujump(struct uretprobe_instance *ri, swap_set_instr_ptr(regs, vaddr); #ifdef CONFIG_ARM - if (thumb_mode(regs)) { - regs->ARM_cpsr &= ~PSR_T_BIT; + if (thumb_mode(regs)) ri->preload_thumb = 1; - } #endif /* CONFIG_ARM */ } -- 2.7.4