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
6
* Copyright (c) 2010 Cavium Networks, Inc.
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>
16
#include <asm/cacheflush.h>
19
#ifdef HAVE_JUMP_LABEL
21
#define J_RANGE_MASK ((1ul << 28) - 1)
23
void arch_jump_label_transform(struct jump_entry *e,
24
enum jump_label_type type)
26
union mips_instruction insn;
27
union mips_instruction *insn_p =
28
(union mips_instruction *)(unsigned long)e->code;
30
/* Jump only works within a 256MB aligned region. */
31
BUG_ON((e->target & ~J_RANGE_MASK) != (e->code & ~J_RANGE_MASK));
33
/* Target must have 4 byte alignment. */
34
BUG_ON((e->target & 3) != 0);
36
if (type == JUMP_LABEL_ENABLE) {
37
insn.j_format.opcode = j_op;
38
insn.j_format.target = (e->target & J_RANGE_MASK) >> 2;
40
insn.word = 0; /* nop */
44
mutex_lock(&text_mutex);
47
flush_icache_range((unsigned long)insn_p,
48
(unsigned long)insn_p + sizeof(*insn_p));
50
mutex_unlock(&text_mutex);
54
#endif /* HAVE_JUMP_LABEL */