Skip to content

Commit 6876442

Browse files
committed
arm64: ftrace: fix building without CONFIG_MODULES
When CONFIG_MODULES is disabled, we cannot dereference a module pointer: arch/arm64/kernel/ftrace.c: In function 'ftrace_make_call': arch/arm64/kernel/ftrace.c:107:36: error: dereferencing pointer to incomplete type 'struct module' trampoline = (unsigned long *)mod->arch.ftrace_trampoline; Also, the within_module() function is not defined: arch/arm64/kernel/ftrace.c: In function 'ftrace_make_nop': arch/arm64/kernel/ftrace.c:171:8: error: implicit declaration of function 'within_module'; did you mean 'init_module'? [-Werror=implicit-function-declaration] This addresses both by adding replacing the IS_ENABLED(CONFIG_ARM64_MODULE_PLTS) checks with #ifdef versions. Fixes: e71a4e1 ("arm64: ftrace: add support for far branches to dynamic ftrace") Reported-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 1eb34b6 commit 6876442

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

arch/arm64/kernel/ftrace.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
7171
int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
7272
{
7373
unsigned long pc = rec->ip;
74-
long offset = (long)pc - (long)addr;
7574
u32 old, new;
7675

77-
if (IS_ENABLED(CONFIG_ARM64_MODULE_PLTS) &&
78-
(offset < -SZ_128M || offset >= SZ_128M)) {
76+
#ifdef CONFIG_ARM64_MODULE_PLTS
77+
long offset = (long)pc - (long)addr;
78+
79+
if (offset < -SZ_128M || offset >= SZ_128M) {
7980
unsigned long *trampoline;
8081
struct module *mod;
8182

@@ -121,6 +122,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
121122
}
122123
addr = (unsigned long)&trampoline[1];
123124
}
125+
#endif /* CONFIG_ARM64_MODULE_PLTS */
124126

125127
old = aarch64_insn_gen_nop();
126128
new = aarch64_insn_gen_branch_imm(pc, addr, AARCH64_INSN_BRANCH_LINK);
@@ -135,12 +137,13 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
135137
unsigned long addr)
136138
{
137139
unsigned long pc = rec->ip;
138-
long offset = (long)pc - (long)addr;
139140
bool validate = true;
140141
u32 old = 0, new;
141142

142-
if (IS_ENABLED(CONFIG_ARM64_MODULE_PLTS) &&
143-
(offset < -SZ_128M || offset >= SZ_128M)) {
143+
#ifdef CONFIG_ARM64_MODULE_PLTS
144+
long offset = (long)pc - (long)addr;
145+
146+
if (offset < -SZ_128M || offset >= SZ_128M) {
144147
u32 replaced;
145148

146149
/*
@@ -177,6 +180,7 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
177180
old = aarch64_insn_gen_branch_imm(pc, addr,
178181
AARCH64_INSN_BRANCH_LINK);
179182
}
183+
#endif /* CONFIG_ARM64_MODULE_PLTS */
180184

181185
new = aarch64_insn_gen_nop();
182186

0 commit comments

Comments
 (0)