diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2015-01-29 08:10:22 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2015-01-29 10:33:34 -0500 |
commit | d5caa4dbf9bd2ad8cd7f6be0ca76722be947182b (patch) | |
tree | 6d58cdd140333e17c881667e9691b17f7dcd6e4d | |
parent | 5c6497c50f8d809eac6d01512c291a1f67382abd (diff) |
s390/jump label: use different nop instruction
Use a brcl 0,2 instruction for jump label nops during compile time,
so we don't mix up the different nops during mcount/hotpatch call
site detection.
The initial jump label code instruction replacement will exchange
these instructions with either a branch or a brcl 0,0 instruction.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r-- | arch/s390/include/asm/jump_label.h | 7 | ||||
-rw-r--r-- | arch/s390/kernel/jump_label.c | 19 |
2 files changed, 19 insertions, 7 deletions
diff --git a/arch/s390/include/asm/jump_label.h b/arch/s390/include/asm/jump_label.h index 346b1c85ffb4..58642fd29c87 100644 --- a/arch/s390/include/asm/jump_label.h +++ b/arch/s390/include/asm/jump_label.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | 5 | ||
6 | #define JUMP_LABEL_NOP_SIZE 6 | 6 | #define JUMP_LABEL_NOP_SIZE 6 |
7 | #define JUMP_LABEL_NOP_OFFSET 2 | ||
7 | 8 | ||
8 | #ifdef CONFIG_64BIT | 9 | #ifdef CONFIG_64BIT |
9 | #define ASM_PTR ".quad" | 10 | #define ASM_PTR ".quad" |
@@ -13,9 +14,13 @@ | |||
13 | #define ASM_ALIGN ".balign 4" | 14 | #define ASM_ALIGN ".balign 4" |
14 | #endif | 15 | #endif |
15 | 16 | ||
17 | /* | ||
18 | * We use a brcl 0,2 instruction for jump labels at compile time so it | ||
19 | * can be easily distinguished from a hotpatch generated instruction. | ||
20 | */ | ||
16 | static __always_inline bool arch_static_branch(struct static_key *key) | 21 | static __always_inline bool arch_static_branch(struct static_key *key) |
17 | { | 22 | { |
18 | asm_volatile_goto("0: brcl 0,0\n" | 23 | asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n" |
19 | ".pushsection __jump_table, \"aw\"\n" | 24 | ".pushsection __jump_table, \"aw\"\n" |
20 | ASM_ALIGN "\n" | 25 | ASM_ALIGN "\n" |
21 | ASM_PTR " 0b, %l[label], %0\n" | 26 | ASM_PTR " 0b, %l[label], %0\n" |
diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c index 25aef40584f7..cb2d51e779df 100644 --- a/arch/s390/kernel/jump_label.c +++ b/arch/s390/kernel/jump_label.c | |||
@@ -49,6 +49,11 @@ static void jump_label_bug(struct jump_entry *entry, struct insn *insn) | |||
49 | panic("Corrupted kernel text"); | 49 | panic("Corrupted kernel text"); |
50 | } | 50 | } |
51 | 51 | ||
52 | static struct insn orignop = { | ||
53 | .opcode = 0xc004, | ||
54 | .offset = JUMP_LABEL_NOP_OFFSET >> 1, | ||
55 | }; | ||
56 | |||
52 | static void __jump_label_transform(struct jump_entry *entry, | 57 | static void __jump_label_transform(struct jump_entry *entry, |
53 | enum jump_label_type type, | 58 | enum jump_label_type type, |
54 | int init) | 59 | int init) |
@@ -59,14 +64,16 @@ static void __jump_label_transform(struct jump_entry *entry, | |||
59 | jump_label_make_nop(entry, &old); | 64 | jump_label_make_nop(entry, &old); |
60 | jump_label_make_branch(entry, &new); | 65 | jump_label_make_branch(entry, &new); |
61 | } else { | 66 | } else { |
62 | if (init) | 67 | jump_label_make_branch(entry, &old); |
63 | jump_label_make_nop(entry, &old); | ||
64 | else | ||
65 | jump_label_make_branch(entry, &old); | ||
66 | jump_label_make_nop(entry, &new); | 68 | jump_label_make_nop(entry, &new); |
67 | } | 69 | } |
68 | if (memcmp((void *)entry->code, &old, sizeof(old))) | 70 | if (init) { |
69 | jump_label_bug(entry, &old); | 71 | if (memcmp((void *)entry->code, &orignop, sizeof(orignop))) |
72 | jump_label_bug(entry, &old); | ||
73 | } else { | ||
74 | if (memcmp((void *)entry->code, &old, sizeof(old))) | ||
75 | jump_label_bug(entry, &old); | ||
76 | } | ||
70 | probe_kernel_write((void *)entry->code, &new, sizeof(new)); | 77 | probe_kernel_write((void *)entry->code, &new, sizeof(new)); |
71 | } | 78 | } |
72 | 79 | ||