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>
This commit is contained in:
parent
53255c9a4d
commit
0cccdda8d1
|
@ -138,28 +138,24 @@ out:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Patch the kernel code at ftrace_graph_caller location. The instruction
|
* Patch the kernel code at ftrace_graph_caller location. The instruction
|
||||||
* there is branch relative and save to prepare_ftrace_return. To disable
|
* there is branch relative on condition. To enable the ftrace graph code
|
||||||
* the call to prepare_ftrace_return we patch the bras offset to point
|
* block, we simply patch the mask field of the instruction to zero and
|
||||||
* directly after the instructions. To enable the call we calculate
|
* turn the instruction into a nop.
|
||||||
* the original offset to prepare_ftrace_return and put it back.
|
* To disable the ftrace graph code the mask field will be patched to
|
||||||
|
* all ones, which turns the instruction into an unconditional branch.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int ftrace_enable_ftrace_graph_caller(void)
|
int ftrace_enable_ftrace_graph_caller(void)
|
||||||
{
|
{
|
||||||
static unsigned short offset = 0x0002;
|
u8 op = 0x04; /* set mask field to zero */
|
||||||
|
|
||||||
return probe_kernel_write((void *) ftrace_graph_caller + 2,
|
return probe_kernel_write(__va(ftrace_graph_caller)+1, &op, sizeof(op));
|
||||||
&offset, sizeof(offset));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ftrace_disable_ftrace_graph_caller(void)
|
int ftrace_disable_ftrace_graph_caller(void)
|
||||||
{
|
{
|
||||||
unsigned short offset;
|
u8 op = 0xf4; /* set mask field to all ones */
|
||||||
|
|
||||||
offset = ((void *) &ftrace_graph_caller_end -
|
return probe_kernel_write(__va(ftrace_graph_caller)+1, &op, sizeof(op));
|
||||||
(void *) ftrace_graph_caller) / 2;
|
|
||||||
return probe_kernel_write((void *) ftrace_graph_caller + 2,
|
|
||||||
&offset, sizeof(offset));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
|
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
|
||||||
|
|
|
@ -49,8 +49,7 @@ ENTRY(ftrace_caller)
|
||||||
basr %r14,%r1
|
basr %r14,%r1
|
||||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
||||||
# The j instruction gets runtime patched to a nop instruction.
|
# The j instruction gets runtime patched to a nop instruction.
|
||||||
# See ftrace_enable_ftrace_graph_caller. The patched instruction is:
|
# See ftrace_enable_ftrace_graph_caller.
|
||||||
# j .+4
|
|
||||||
ENTRY(ftrace_graph_caller)
|
ENTRY(ftrace_graph_caller)
|
||||||
j ftrace_graph_caller_end
|
j ftrace_graph_caller_end
|
||||||
lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
|
lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
|
||||||
|
|
Loading…
Reference in New Issue