Skip to content

Commit 03b5141

Browse files
rnavmpe
authored andcommitted
powerpc/module_64: Consolidate ftrace code
module_trampoline_target() is only used by ftrace. Move the prototype within the appropriate #ifdef in the header. Also, move the function body to the end of module_64.c so as to consolidate all ftrace code in one place. No functional changes. Signed-off-by: Naveen N. Rao <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/2527351f65c53c5866068ae130dc34c5d4ee8ad9.1587488954.git.naveen.n.rao@linux.vnet.ibm.com
1 parent 888468c commit 03b5141

File tree

2 files changed

+33
-39
lines changed

2 files changed

+33
-39
lines changed

arch/powerpc/include/asm/module.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,9 @@ struct mod_arch_specific {
9090
# ifdef MODULE
9191
asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
9292
# endif /* MODULE */
93-
#endif
9493

9594
int module_trampoline_target(struct module *mod, unsigned long trampoline,
9695
unsigned long *target);
97-
98-
#ifdef CONFIG_DYNAMIC_FTRACE
9996
int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
10097
#else
10198
static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)

arch/powerpc/kernel/module_64.c

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -145,42 +145,6 @@ static u32 ppc64_stub_insns[] = {
145145
PPC_INST_BCTR,
146146
};
147147

148-
#ifdef CONFIG_DYNAMIC_FTRACE
149-
int module_trampoline_target(struct module *mod, unsigned long addr,
150-
unsigned long *target)
151-
{
152-
struct ppc64_stub_entry *stub;
153-
func_desc_t funcdata;
154-
u32 magic;
155-
156-
if (!within_module_core(addr, mod)) {
157-
pr_err("%s: stub %lx not in module %s\n", __func__, addr, mod->name);
158-
return -EFAULT;
159-
}
160-
161-
stub = (struct ppc64_stub_entry *)addr;
162-
163-
if (probe_kernel_read(&magic, &stub->magic, sizeof(magic))) {
164-
pr_err("%s: fault reading magic for stub %lx for %s\n", __func__, addr, mod->name);
165-
return -EFAULT;
166-
}
167-
168-
if (magic != STUB_MAGIC) {
169-
pr_err("%s: bad magic for stub %lx for %s\n", __func__, addr, mod->name);
170-
return -EFAULT;
171-
}
172-
173-
if (probe_kernel_read(&funcdata, &stub->funcdata, sizeof(funcdata))) {
174-
pr_err("%s: fault reading funcdata for stub %lx for %s\n", __func__, addr, mod->name);
175-
return -EFAULT;
176-
}
177-
178-
*target = stub_func_addr(funcdata);
179-
180-
return 0;
181-
}
182-
#endif
183-
184148
/* Count how many different 24-bit relocations (different symbol,
185149
different addend) */
186150
static unsigned int count_relocs(const Elf64_Rela *rela, unsigned int num)
@@ -731,6 +695,39 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
731695
}
732696

733697
#ifdef CONFIG_DYNAMIC_FTRACE
698+
int module_trampoline_target(struct module *mod, unsigned long addr,
699+
unsigned long *target)
700+
{
701+
struct ppc64_stub_entry *stub;
702+
func_desc_t funcdata;
703+
u32 magic;
704+
705+
if (!within_module_core(addr, mod)) {
706+
pr_err("%s: stub %lx not in module %s\n", __func__, addr, mod->name);
707+
return -EFAULT;
708+
}
709+
710+
stub = (struct ppc64_stub_entry *)addr;
711+
712+
if (probe_kernel_read(&magic, &stub->magic, sizeof(magic))) {
713+
pr_err("%s: fault reading magic for stub %lx for %s\n", __func__, addr, mod->name);
714+
return -EFAULT;
715+
}
716+
717+
if (magic != STUB_MAGIC) {
718+
pr_err("%s: bad magic for stub %lx for %s\n", __func__, addr, mod->name);
719+
return -EFAULT;
720+
}
721+
722+
if (probe_kernel_read(&funcdata, &stub->funcdata, sizeof(funcdata))) {
723+
pr_err("%s: fault reading funcdata for stub %lx for %s\n", __func__, addr, mod->name);
724+
return -EFAULT;
725+
}
726+
727+
*target = stub_func_addr(funcdata);
728+
729+
return 0;
730+
}
734731

735732
#ifdef CONFIG_MPROFILE_KERNEL
736733

0 commit comments

Comments
 (0)