aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel
diff options
context:
space:
mode:
authorRabin Vincent <rabin@rab.in>2012-02-18 11:52:41 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-03-24 05:38:56 -0400
commit09f05d8529ff4aa92311c1a55ce35ac98cb59b8c (patch)
tree0196ddc9e80d74c8d3e3473bd7bc21b3e520c3d9 /arch/arm/kernel
parenta9468f30b5eac6957c86aea97954553bfb7c1f18 (diff)
ARM: 7334/1: add jump label support
Add the arch-specific code to support jump labels for ARM and Thumb-2. This code will only be activated on compilers that are capable of building it. It has been tested with GCC 4.6 patched with the patch from GCC bug 48637. Cc: Jason Baron <jbaron@redhat.com> Signed-off-by: Rabin Vincent <rabin@rab.in> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r--arch/arm/kernel/Makefile1
-rw-r--r--arch/arm/kernel/insn.h10
-rw-r--r--arch/arm/kernel/jump_label.c39
3 files changed, 50 insertions, 0 deletions
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 8c63ee8d3c4..1b7d9a39097 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o
38obj-$(CONFIG_HAVE_ARM_TWD) += smp_twd.o 38obj-$(CONFIG_HAVE_ARM_TWD) += smp_twd.o
39obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o 39obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o
40obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o 40obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o
41obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o
41obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o 42obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
42obj-$(CONFIG_KPROBES) += kprobes.o kprobes-common.o patch.o 43obj-$(CONFIG_KPROBES) += kprobes.o kprobes-common.o patch.o
43ifdef CONFIG_THUMB2_KERNEL 44ifdef CONFIG_THUMB2_KERNEL
diff --git a/arch/arm/kernel/insn.h b/arch/arm/kernel/insn.h
index 994d60fd3ff..e96065da4da 100644
--- a/arch/arm/kernel/insn.h
+++ b/arch/arm/kernel/insn.h
@@ -1,6 +1,16 @@
1#ifndef __ASM_ARM_INSN_H 1#ifndef __ASM_ARM_INSN_H
2#define __ASM_ARM_INSN_H 2#define __ASM_ARM_INSN_H
3 3
4static inline unsigned long
5arm_gen_nop(void)
6{
7#ifdef CONFIG_THUMB2_KERNEL
8 return 0xf3af8000; /* nop.w */
9#else
10 return 0xe1a00000; /* mov r0, r0 */
11#endif
12}
13
4unsigned long 14unsigned long
5__arm_gen_branch(unsigned long pc, unsigned long addr, bool link); 15__arm_gen_branch(unsigned long pc, unsigned long addr, bool link);
6 16
diff --git a/arch/arm/kernel/jump_label.c b/arch/arm/kernel/jump_label.c
new file mode 100644
index 00000000000..4ce4f789446
--- /dev/null
+++ b/arch/arm/kernel/jump_label.c
@@ -0,0 +1,39 @@
1#include <linux/kernel.h>
2#include <linux/jump_label.h>
3
4#include "insn.h"
5#include "patch.h"
6
7#ifdef HAVE_JUMP_LABEL
8
9static void __arch_jump_label_transform(struct jump_entry *entry,
10 enum jump_label_type type,
11 bool is_static)
12{
13 void *addr = (void *)entry->code;
14 unsigned int insn;
15
16 if (type == JUMP_LABEL_ENABLE)
17 insn = arm_gen_branch(entry->code, entry->target);
18 else
19 insn = arm_gen_nop();
20
21 if (is_static)
22 __patch_text(addr, insn);
23 else
24 patch_text(addr, insn);
25}
26
27void arch_jump_label_transform(struct jump_entry *entry,
28 enum jump_label_type type)
29{
30 __arch_jump_label_transform(entry, type, false);
31}
32
33void arch_jump_label_transform_static(struct jump_entry *entry,
34 enum jump_label_type type)
35{
36 __arch_jump_label_transform(entry, type, true);
37}
38
39#endif