aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/kernel
diff options
context:
space:
mode:
authorZhigang Lu <zlu@ezchip.com>2015-09-29 22:11:45 -0400
committerChris Metcalf <cmetcalf@ezchip.com>2016-01-04 15:09:31 -0500
commit65a792e84f25d1436698f999224b2cf5d7594546 (patch)
treefe87043a2d810dbb94fde139db4f6ea3da0e0a25 /arch/tile/kernel
parentf419e6f63c5afea00d7c17ebf54f2d265f5c4d7e (diff)
tile/jump_label: add jump label support for TILE-Gx
Add the arch-specific code to support jump label for TILE-Gx. This code shares NOP instruction with ftrace, so we move it to a common header file. Reviewed-by: Chris Metcalf <cmetcalf@ezchip.com> Signed-off-by: Zhigang Lu <zlu@ezchip.com> Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
Diffstat (limited to 'arch/tile/kernel')
-rw-r--r--arch/tile/kernel/Makefile1
-rw-r--r--arch/tile/kernel/ftrace.c11
-rw-r--r--arch/tile/kernel/jump_label.c64
3 files changed, 66 insertions, 10 deletions
diff --git a/arch/tile/kernel/Makefile b/arch/tile/kernel/Makefile
index 21f77bf68c69..09936d0bcb42 100644
--- a/arch/tile/kernel/Makefile
+++ b/arch/tile/kernel/Makefile
@@ -32,5 +32,6 @@ obj-$(CONFIG_TILE_HVGLUE_TRACE) += hvglue_trace.o
32obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o mcount_64.o 32obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o mcount_64.o
33obj-$(CONFIG_KPROBES) += kprobes.o 33obj-$(CONFIG_KPROBES) += kprobes.o
34obj-$(CONFIG_KGDB) += kgdb.o 34obj-$(CONFIG_KGDB) += kgdb.o
35obj-$(CONFIG_JUMP_LABEL) += jump_label.o
35 36
36obj-y += vdso/ 37obj-y += vdso/
diff --git a/arch/tile/kernel/ftrace.c b/arch/tile/kernel/ftrace.c
index 4180ccdf9cd0..4a572088b270 100644
--- a/arch/tile/kernel/ftrace.c
+++ b/arch/tile/kernel/ftrace.c
@@ -20,21 +20,12 @@
20#include <asm/cacheflush.h> 20#include <asm/cacheflush.h>
21#include <asm/ftrace.h> 21#include <asm/ftrace.h>
22#include <asm/sections.h> 22#include <asm/sections.h>
23#include <asm/insn.h>
23 24
24#include <arch/opcode.h> 25#include <arch/opcode.h>
25 26
26#ifdef CONFIG_DYNAMIC_FTRACE 27#ifdef CONFIG_DYNAMIC_FTRACE
27 28
28static inline tilegx_bundle_bits NOP(void)
29{
30 return create_UnaryOpcodeExtension_X0(FNOP_UNARY_OPCODE_X0) |
31 create_RRROpcodeExtension_X0(UNARY_RRR_0_OPCODE_X0) |
32 create_Opcode_X0(RRR_0_OPCODE_X0) |
33 create_UnaryOpcodeExtension_X1(NOP_UNARY_OPCODE_X1) |
34 create_RRROpcodeExtension_X1(UNARY_RRR_0_OPCODE_X1) |
35 create_Opcode_X1(RRR_0_OPCODE_X1);
36}
37
38static int machine_stopped __read_mostly; 29static int machine_stopped __read_mostly;
39 30
40int ftrace_arch_code_modify_prepare(void) 31int ftrace_arch_code_modify_prepare(void)
diff --git a/arch/tile/kernel/jump_label.c b/arch/tile/kernel/jump_label.c
new file mode 100644
index 000000000000..07802d586988
--- /dev/null
+++ b/arch/tile/kernel/jump_label.c
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2015 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 *
14 * jump label TILE-Gx support
15 */
16
17#include <linux/jump_label.h>
18#include <linux/memory.h>
19#include <linux/module.h>
20#include <linux/mutex.h>
21#include <linux/cpu.h>
22
23#include <asm/cacheflush.h>
24#include <asm/insn.h>
25
26#ifdef HAVE_JUMP_LABEL
27
28static void __jump_label_transform(struct jump_entry *e,
29 enum jump_label_type type)
30{
31 tilegx_bundle_bits opcode;
32 /* Operate on writable kernel text mapping. */
33 unsigned long pc_wr = ktext_writable_addr(e->code);
34
35 if (type == JUMP_LABEL_JMP)
36 opcode = tilegx_gen_branch(e->code, e->target, false);
37 else
38 opcode = NOP();
39
40 *(tilegx_bundle_bits *)pc_wr = opcode;
41 /* Make sure that above mem writes were issued towards the memory. */
42 smp_wmb();
43}
44
45void arch_jump_label_transform(struct jump_entry *e,
46 enum jump_label_type type)
47{
48 get_online_cpus();
49 mutex_lock(&text_mutex);
50
51 __jump_label_transform(e, type);
52 flush_icache_range(e->code, e->code + sizeof(tilegx_bundle_bits));
53
54 mutex_unlock(&text_mutex);
55 put_online_cpus();
56}
57
58__init_or_module void arch_jump_label_transform_static(struct jump_entry *e,
59 enum jump_label_type type)
60{
61 __jump_label_transform(e, type);
62}
63
64#endif /* HAVE_JUMP_LABEL */