Commit b860b934 authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik

s390/ftrace: remove dead code

ftrace_shared_hotpatch_trampoline() never returns NULL,
therefore quite a bit of code can be removed.
Acked-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 9e1ff307
...@@ -80,17 +80,6 @@ asm( ...@@ -80,17 +80,6 @@ asm(
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
static char *ftrace_plt; static char *ftrace_plt;
asm(
" .data\n"
"ftrace_plt_template:\n"
" basr %r1,%r0\n"
" lg %r1,0f-.(%r1)\n"
" br %r1\n"
"0: .quad ftrace_caller\n"
"ftrace_plt_template_end:\n"
" .previous\n"
);
#endif /* CONFIG_MODULES */ #endif /* CONFIG_MODULES */
static const char *ftrace_shared_hotpatch_trampoline(const char **end) static const char *ftrace_shared_hotpatch_trampoline(const char **end)
...@@ -116,7 +105,7 @@ static const char *ftrace_shared_hotpatch_trampoline(const char **end) ...@@ -116,7 +105,7 @@ static const char *ftrace_shared_hotpatch_trampoline(const char **end)
bool ftrace_need_init_nop(void) bool ftrace_need_init_nop(void)
{ {
return ftrace_shared_hotpatch_trampoline(NULL); return true;
} }
int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec) int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
...@@ -175,28 +164,6 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, ...@@ -175,28 +164,6 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
return 0; return 0;
} }
static void ftrace_generate_nop_insn(struct ftrace_insn *insn)
{
/* brcl 0,0 */
insn->opc = 0xc004;
insn->disp = 0;
}
static void ftrace_generate_call_insn(struct ftrace_insn *insn,
unsigned long ip)
{
unsigned long target;
/* brasl r0,ftrace_caller */
target = FTRACE_ADDR;
#ifdef CONFIG_MODULES
if (is_module_addr((void *)ip))
target = (unsigned long)ftrace_plt;
#endif /* CONFIG_MODULES */
insn->opc = 0xc005;
insn->disp = (target - ip) / 2;
}
static void brcl_disable(void *brcl) static void brcl_disable(void *brcl)
{ {
u8 op = 0x04; /* set mask field to zero */ u8 op = 0x04; /* set mask field to zero */
...@@ -207,23 +174,7 @@ static void brcl_disable(void *brcl) ...@@ -207,23 +174,7 @@ static void brcl_disable(void *brcl)
int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
unsigned long addr) unsigned long addr)
{ {
struct ftrace_insn orig, new, old; brcl_disable((void *)rec->ip);
if (ftrace_shared_hotpatch_trampoline(NULL)) {
brcl_disable((void *)rec->ip);
return 0;
}
if (copy_from_kernel_nofault(&old, (void *) rec->ip, sizeof(old)))
return -EFAULT;
/* Replace ftrace call with a nop. */
ftrace_generate_call_insn(&orig, rec->ip);
ftrace_generate_nop_insn(&new);
/* Verify that the to be replaced code matches what we expect. */
if (memcmp(&orig, &old, sizeof(old)))
return -EINVAL;
s390_kernel_write((void *) rec->ip, &new, sizeof(new));
return 0; return 0;
} }
...@@ -236,23 +187,7 @@ static void brcl_enable(void *brcl) ...@@ -236,23 +187,7 @@ static void brcl_enable(void *brcl)
int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
{ {
struct ftrace_insn orig, new, old; brcl_enable((void *)rec->ip);
if (ftrace_shared_hotpatch_trampoline(NULL)) {
brcl_enable((void *)rec->ip);
return 0;
}
if (copy_from_kernel_nofault(&old, (void *) rec->ip, sizeof(old)))
return -EFAULT;
/* Replace nop with an ftrace call. */
ftrace_generate_nop_insn(&orig);
ftrace_generate_call_insn(&new, rec->ip);
/* Verify that the to be replaced code matches what we expect. */
if (memcmp(&orig, &old, sizeof(old)))
return -EINVAL;
s390_kernel_write((void *) rec->ip, &new, sizeof(new));
return 0; return 0;
} }
...@@ -269,10 +204,7 @@ int __init ftrace_dyn_arch_init(void) ...@@ -269,10 +204,7 @@ int __init ftrace_dyn_arch_init(void)
void arch_ftrace_update_code(int command) void arch_ftrace_update_code(int command)
{ {
if (ftrace_shared_hotpatch_trampoline(NULL)) ftrace_modify_all_code(command);
ftrace_modify_all_code(command);
else
ftrace_run_stop_machine(command);
} }
static void __ftrace_sync(void *dummy) static void __ftrace_sync(void *dummy)
...@@ -281,10 +213,8 @@ static void __ftrace_sync(void *dummy) ...@@ -281,10 +213,8 @@ static void __ftrace_sync(void *dummy)
int ftrace_arch_code_modify_post_process(void) int ftrace_arch_code_modify_post_process(void)
{ {
if (ftrace_shared_hotpatch_trampoline(NULL)) { /* Send SIGP to the other CPUs, so they see the new code. */
/* Send SIGP to the other CPUs, so they see the new code. */ smp_call_function(__ftrace_sync, NULL, 1);
smp_call_function(__ftrace_sync, NULL, 1);
}
return 0; return 0;
} }
...@@ -299,10 +229,6 @@ static int __init ftrace_plt_init(void) ...@@ -299,10 +229,6 @@ static int __init ftrace_plt_init(void)
panic("cannot allocate ftrace plt\n"); panic("cannot allocate ftrace plt\n");
start = ftrace_shared_hotpatch_trampoline(&end); start = ftrace_shared_hotpatch_trampoline(&end);
if (!start) {
start = ftrace_plt_template;
end = ftrace_plt_template_end;
}
memcpy(ftrace_plt, start, end - start); memcpy(ftrace_plt, start, end - start);
set_memory_ro((unsigned long)ftrace_plt, 1); set_memory_ro((unsigned long)ftrace_plt, 1);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment