aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorRabin Vincent <rabin@rab.in>2012-02-18 11:47:03 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-03-24 05:38:54 -0400
commit4394e2824c8d97d81a336edb469b13c8806604e4 (patch)
tree68ec90a882dc2df804a4d6e4e5521ad8ebe7743b /arch
parentdc283d7037555aa6891188719be2f1b4af9535c9 (diff)
ARM: 7330/1: ftrace: use canonical Thumb-2 wide instruction format
As commit 592201a9f15 (ARM: Thumb-2: Support Thumb-2 in undefined instruction handler) says: 32-bit Thumb instructions are specified in the form: ((first_half << 16 ) | second_half) which matches the layout used by the ARM ARM. Convert the ftrace code to use the same format to avoid the usage of different formats in kernel code. Acked-by: Dave Martin <dave.martin@linaro.org> Signed-off-by: Rabin Vincent <rabin@rab.in> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/kernel/ftrace.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index 6fd7c4a1e532..5c9cecfaeb21 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -16,10 +16,11 @@
16#include <linux/uaccess.h> 16#include <linux/uaccess.h>
17 17
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19#include <asm/opcodes.h>
19#include <asm/ftrace.h> 20#include <asm/ftrace.h>
20 21
21#ifdef CONFIG_THUMB2_KERNEL 22#ifdef CONFIG_THUMB2_KERNEL
22#define NOP 0xeb04f85d /* pop.w {lr} */ 23#define NOP 0xf85deb04 /* pop.w {lr} */
23#else 24#else
24#define NOP 0xe8bd4000 /* pop {lr} */ 25#define NOP 0xe8bd4000 /* pop {lr} */
25#endif 26#endif
@@ -88,7 +89,7 @@ static unsigned long ftrace_gen_branch(unsigned long pc, unsigned long addr,
88 if (link) 89 if (link)
89 second |= 1 << 14; 90 second |= 1 << 14;
90 91
91 return (second << 16) | first; 92 return __opcode_thumb32_compose(first, second);
92} 93}
93#else 94#else
94static unsigned long ftrace_gen_branch(unsigned long pc, unsigned long addr, 95static unsigned long ftrace_gen_branch(unsigned long pc, unsigned long addr,
@@ -125,6 +126,14 @@ static int ftrace_modify_code(unsigned long pc, unsigned long old,
125{ 126{
126 unsigned long replaced; 127 unsigned long replaced;
127 128
129 if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) {
130 old = __opcode_to_mem_thumb32(old);
131 new = __opcode_to_mem_thumb32(new);
132 } else {
133 old = __opcode_to_mem_arm(old);
134 new = __opcode_to_mem_arm(new);
135 }
136
128 if (validate) { 137 if (validate) {
129 if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE)) 138 if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE))
130 return -EFAULT; 139 return -EFAULT;