-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Daney
authored and
Ralf Baechle
committed
Jan 18, 2011
1 parent
03dae7a
commit c300439
Showing
6 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 8d662c8d34a05e8e47deaa9e22fe770dc557c2d3 | ||
refs/heads/master: 94bb0c1ab293c298a8852e4f10c4215bad6daa9b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is subject to the terms and conditions of the GNU General Public | ||
* License. See the file "COPYING" in the main directory of this archive | ||
* for more details. | ||
* | ||
* Copyright (c) 2010 Cavium Networks, Inc. | ||
*/ | ||
#ifndef _ASM_MIPS_JUMP_LABEL_H | ||
#define _ASM_MIPS_JUMP_LABEL_H | ||
|
||
#include <linux/types.h> | ||
|
||
#ifdef __KERNEL__ | ||
|
||
#define JUMP_LABEL_NOP_SIZE 4 | ||
|
||
#ifdef CONFIG_64BIT | ||
#define WORD_INSN ".dword" | ||
#else | ||
#define WORD_INSN ".word" | ||
#endif | ||
|
||
#define JUMP_LABEL(key, label) \ | ||
do { \ | ||
asm goto("1:\tnop\n\t" \ | ||
"nop\n\t" \ | ||
".pushsection __jump_table, \"a\"\n\t" \ | ||
WORD_INSN " 1b, %l[" #label "], %0\n\t" \ | ||
".popsection\n\t" \ | ||
: : "i" (key) : : label); \ | ||
} while (0) | ||
|
||
|
||
#endif /* __KERNEL__ */ | ||
|
||
#ifdef CONFIG_64BIT | ||
typedef u64 jump_label_t; | ||
#else | ||
typedef u32 jump_label_t; | ||
#endif | ||
|
||
struct jump_entry { | ||
jump_label_t code; | ||
jump_label_t target; | ||
jump_label_t key; | ||
}; | ||
|
||
#endif /* _ASM_MIPS_JUMP_LABEL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* This file is subject to the terms and conditions of the GNU General Public | ||
* License. See the file "COPYING" in the main directory of this archive | ||
* for more details. | ||
* | ||
* Copyright (c) 2010 Cavium Networks, Inc. | ||
*/ | ||
|
||
#include <linux/jump_label.h> | ||
#include <linux/kernel.h> | ||
#include <linux/memory.h> | ||
#include <linux/mutex.h> | ||
#include <linux/types.h> | ||
#include <linux/cpu.h> | ||
|
||
#include <asm/cacheflush.h> | ||
#include <asm/inst.h> | ||
|
||
#ifdef HAVE_JUMP_LABEL | ||
|
||
#define J_RANGE_MASK ((1ul << 28) - 1) | ||
|
||
void arch_jump_label_transform(struct jump_entry *e, | ||
enum jump_label_type type) | ||
{ | ||
union mips_instruction insn; | ||
union mips_instruction *insn_p = | ||
(union mips_instruction *)(unsigned long)e->code; | ||
|
||
/* Jump only works within a 256MB aligned region. */ | ||
BUG_ON((e->target & ~J_RANGE_MASK) != (e->code & ~J_RANGE_MASK)); | ||
|
||
/* Target must have 4 byte alignment. */ | ||
BUG_ON((e->target & 3) != 0); | ||
|
||
if (type == JUMP_LABEL_ENABLE) { | ||
insn.j_format.opcode = j_op; | ||
insn.j_format.target = (e->target & J_RANGE_MASK) >> 2; | ||
} else { | ||
insn.word = 0; /* nop */ | ||
} | ||
|
||
get_online_cpus(); | ||
mutex_lock(&text_mutex); | ||
*insn_p = insn; | ||
|
||
flush_icache_range((unsigned long)insn_p, | ||
(unsigned long)insn_p + sizeof(*insn_p)); | ||
|
||
mutex_unlock(&text_mutex); | ||
put_online_cpus(); | ||
} | ||
|
||
#endif /* HAVE_JUMP_LABEL */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters