diff options
author | David Daney <ddaney@caviumnetworks.com> | 2010-12-28 16:26:23 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-01-18 13:30:24 -0500 |
commit | 94bb0c1ab293c298a8852e4f10c4215bad6daa9b (patch) | |
tree | e4e7dfa18bf2ffd832a97d7ab67863b1b363c6fe /arch/mips/kernel/jump_label.c | |
parent | 8d662c8d34a05e8e47deaa9e22fe770dc557c2d3 (diff) |
MIPS: jump label: Add MIPS support.
In order not to be left behind, we add jump label support for MIPS.
Tested on 64-bit big endian (Octeon), and 32-bit little endian
(malta/qemu).
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
To: linux-mips@linux-mips.org
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jason Baron <jbaron@redhat.com>
Patchwork: https://patchwork.linux-mips.org/patch/1923/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/jump_label.c')
-rw-r--r-- | arch/mips/kernel/jump_label.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c new file mode 100644 index 000000000000..6001610cfe55 --- /dev/null +++ b/arch/mips/kernel/jump_label.c | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (c) 2010 Cavium Networks, Inc. | ||
7 | */ | ||
8 | |||
9 | #include <linux/jump_label.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/memory.h> | ||
12 | #include <linux/mutex.h> | ||
13 | #include <linux/types.h> | ||
14 | #include <linux/cpu.h> | ||
15 | |||
16 | #include <asm/cacheflush.h> | ||
17 | #include <asm/inst.h> | ||
18 | |||
19 | #ifdef HAVE_JUMP_LABEL | ||
20 | |||
21 | #define J_RANGE_MASK ((1ul << 28) - 1) | ||
22 | |||
23 | void arch_jump_label_transform(struct jump_entry *e, | ||
24 | enum jump_label_type type) | ||
25 | { | ||
26 | union mips_instruction insn; | ||
27 | union mips_instruction *insn_p = | ||
28 | (union mips_instruction *)(unsigned long)e->code; | ||
29 | |||
30 | /* Jump only works within a 256MB aligned region. */ | ||
31 | BUG_ON((e->target & ~J_RANGE_MASK) != (e->code & ~J_RANGE_MASK)); | ||
32 | |||
33 | /* Target must have 4 byte alignment. */ | ||
34 | BUG_ON((e->target & 3) != 0); | ||
35 | |||
36 | if (type == JUMP_LABEL_ENABLE) { | ||
37 | insn.j_format.opcode = j_op; | ||
38 | insn.j_format.target = (e->target & J_RANGE_MASK) >> 2; | ||
39 | } else { | ||
40 | insn.word = 0; /* nop */ | ||
41 | } | ||
42 | |||
43 | get_online_cpus(); | ||
44 | mutex_lock(&text_mutex); | ||
45 | *insn_p = insn; | ||
46 | |||
47 | flush_icache_range((unsigned long)insn_p, | ||
48 | (unsigned long)insn_p + sizeof(*insn_p)); | ||
49 | |||
50 | mutex_unlock(&text_mutex); | ||
51 | put_online_cpus(); | ||
52 | } | ||
53 | |||
54 | #endif /* HAVE_JUMP_LABEL */ | ||