Commit 7f08ae53 authored by Mark Rutland's avatar Mark Rutland

arm64: ftrace: minimize ifdeffery

Now that we no longer refer to mod->arch.ftrace_trampolines in the body
of ftrace_make_call(), we can use IS_ENABLED() rather than ifdeffery,
and make the code easier to follow. Likewise in ftrace_make_nop().

Let's do so.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Reviewed-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: default avatarTorsten Duwe <duwe@suse.de>
Tested-by: default avatarAmit Daniel Kachhap <amit.kachhap@arm.com>
Tested-by: default avatarTorsten Duwe <duwe@suse.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
parent 3b23e499
...@@ -62,18 +62,18 @@ int ftrace_update_ftrace_func(ftrace_func_t func) ...@@ -62,18 +62,18 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return ftrace_modify_code(pc, 0, new, false); return ftrace_modify_code(pc, 0, new, false);
} }
#ifdef CONFIG_ARM64_MODULE_PLTS
static struct plt_entry *get_ftrace_plt(struct module *mod, unsigned long addr) static struct plt_entry *get_ftrace_plt(struct module *mod, unsigned long addr)
{ {
#ifdef CONFIG_ARM64_MODULE_PLTS
struct plt_entry *plt = mod->arch.ftrace_trampolines; struct plt_entry *plt = mod->arch.ftrace_trampolines;
if (addr == FTRACE_ADDR) if (addr == FTRACE_ADDR)
return &plt[FTRACE_PLT_IDX]; return &plt[FTRACE_PLT_IDX];
if (addr == FTRACE_REGS_ADDR && IS_ENABLED(CONFIG_FTRACE_WITH_REGS)) if (addr == FTRACE_REGS_ADDR && IS_ENABLED(CONFIG_FTRACE_WITH_REGS))
return &plt[FTRACE_REGS_PLT_IDX]; return &plt[FTRACE_REGS_PLT_IDX];
#endif
return NULL; return NULL;
} }
#endif
/* /*
* Turn on the call to ftrace_caller() in instrumented function * Turn on the call to ftrace_caller() in instrumented function
...@@ -85,10 +85,12 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) ...@@ -85,10 +85,12 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
long offset = (long)pc - (long)addr; long offset = (long)pc - (long)addr;
if (offset < -SZ_128M || offset >= SZ_128M) { if (offset < -SZ_128M || offset >= SZ_128M) {
#ifdef CONFIG_ARM64_MODULE_PLTS
struct module *mod; struct module *mod;
struct plt_entry *plt; struct plt_entry *plt;
if (!IS_ENABLED(CONFIG_ARM64_MODULE_PLTS))
return -EINVAL;
/* /*
* On kernels that support module PLTs, the offset between the * On kernels that support module PLTs, the offset between the
* branch instruction and its target may legally exceed the * branch instruction and its target may legally exceed the
...@@ -113,9 +115,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) ...@@ -113,9 +115,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
} }
addr = (unsigned long)plt; addr = (unsigned long)plt;
#else /* CONFIG_ARM64_MODULE_PLTS */
return -EINVAL;
#endif /* CONFIG_ARM64_MODULE_PLTS */
} }
old = aarch64_insn_gen_nop(); old = aarch64_insn_gen_nop();
...@@ -185,9 +184,11 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, ...@@ -185,9 +184,11 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
long offset = (long)pc - (long)addr; long offset = (long)pc - (long)addr;
if (offset < -SZ_128M || offset >= SZ_128M) { if (offset < -SZ_128M || offset >= SZ_128M) {
#ifdef CONFIG_ARM64_MODULE_PLTS
u32 replaced; u32 replaced;
if (!IS_ENABLED(CONFIG_ARM64_MODULE_PLTS))
return -EINVAL;
/* /*
* 'mod' is only set at module load time, but if we end up * 'mod' is only set at module load time, but if we end up
* dealing with an out-of-range condition, we can assume it * dealing with an out-of-range condition, we can assume it
...@@ -218,9 +219,6 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, ...@@ -218,9 +219,6 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
return -EINVAL; return -EINVAL;
validate = false; validate = false;
#else /* CONFIG_ARM64_MODULE_PLTS */
return -EINVAL;
#endif /* CONFIG_ARM64_MODULE_PLTS */
} else { } else {
old = aarch64_insn_gen_branch_imm(pc, addr, old = aarch64_insn_gen_branch_imm(pc, addr,
AARCH64_INSN_BRANCH_LINK); AARCH64_INSN_BRANCH_LINK);
......
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