diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2014-10-08 04:03:08 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2014-10-09 03:14:20 -0400 |
commit | 0cccdda8d1512af4d3f6913044e8c8e58e15ef37 (patch) | |
tree | 8e93043ede994d899a625819cb871684f2cfe1a9 /arch/s390 | |
parent | 53255c9a4dade6ff2162121430d13aaadb38a69c (diff) |
s390/ftrace: simplify enabling/disabling of ftrace_graph_caller
We can simply patch the mask field within the branch relative on
condition instruction at the beginning of the ftrace_graph_caller
code block.
This makes the logic even simpler and we get rid of the displacement
calculation.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/kernel/ftrace.c | 22 | ||||
-rw-r--r-- | arch/s390/kernel/mcount.S | 3 |
2 files changed, 10 insertions, 15 deletions
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c index f0072125926c..51d14fe5eb9a 100644 --- a/arch/s390/kernel/ftrace.c +++ b/arch/s390/kernel/ftrace.c | |||
@@ -138,28 +138,24 @@ out: | |||
138 | 138 | ||
139 | /* | 139 | /* |
140 | * Patch the kernel code at ftrace_graph_caller location. The instruction | 140 | * Patch the kernel code at ftrace_graph_caller location. The instruction |
141 | * there is branch relative and save to prepare_ftrace_return. To disable | 141 | * there is branch relative on condition. To enable the ftrace graph code |
142 | * the call to prepare_ftrace_return we patch the bras offset to point | 142 | * block, we simply patch the mask field of the instruction to zero and |
143 | * directly after the instructions. To enable the call we calculate | 143 | * turn the instruction into a nop. |
144 | * the original offset to prepare_ftrace_return and put it back. | 144 | * To disable the ftrace graph code the mask field will be patched to |
145 | * all ones, which turns the instruction into an unconditional branch. | ||
145 | */ | 146 | */ |
146 | |||
147 | int ftrace_enable_ftrace_graph_caller(void) | 147 | int ftrace_enable_ftrace_graph_caller(void) |
148 | { | 148 | { |
149 | static unsigned short offset = 0x0002; | 149 | u8 op = 0x04; /* set mask field to zero */ |
150 | 150 | ||
151 | return probe_kernel_write((void *) ftrace_graph_caller + 2, | 151 | return probe_kernel_write(__va(ftrace_graph_caller)+1, &op, sizeof(op)); |
152 | &offset, sizeof(offset)); | ||
153 | } | 152 | } |
154 | 153 | ||
155 | int ftrace_disable_ftrace_graph_caller(void) | 154 | int ftrace_disable_ftrace_graph_caller(void) |
156 | { | 155 | { |
157 | unsigned short offset; | 156 | u8 op = 0xf4; /* set mask field to all ones */ |
158 | 157 | ||
159 | offset = ((void *) &ftrace_graph_caller_end - | 158 | return probe_kernel_write(__va(ftrace_graph_caller)+1, &op, sizeof(op)); |
160 | (void *) ftrace_graph_caller) / 2; | ||
161 | return probe_kernel_write((void *) ftrace_graph_caller + 2, | ||
162 | &offset, sizeof(offset)); | ||
163 | } | 159 | } |
164 | 160 | ||
165 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | 161 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ |
diff --git a/arch/s390/kernel/mcount.S b/arch/s390/kernel/mcount.S index 07abe8d464d4..4300ea374826 100644 --- a/arch/s390/kernel/mcount.S +++ b/arch/s390/kernel/mcount.S | |||
@@ -49,8 +49,7 @@ ENTRY(ftrace_caller) | |||
49 | basr %r14,%r1 | 49 | basr %r14,%r1 |
50 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 50 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
51 | # The j instruction gets runtime patched to a nop instruction. | 51 | # The j instruction gets runtime patched to a nop instruction. |
52 | # See ftrace_enable_ftrace_graph_caller. The patched instruction is: | 52 | # See ftrace_enable_ftrace_graph_caller. |
53 | # j .+4 | ||
54 | ENTRY(ftrace_graph_caller) | 53 | ENTRY(ftrace_graph_caller) |
55 | j ftrace_graph_caller_end | 54 | j ftrace_graph_caller_end |
56 | lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15) | 55 | lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15) |