Skip to content

Commit

Permalink
powerpc/modules: Create module_trampoline_target()
Browse files Browse the repository at this point in the history
ftrace has way too much knowledge of our kernel module trampoline
layout hidden inside it. Create module_trampoline_target() that gives
the target address of a kernel module trampoline.

Signed-off-by: Anton Blanchard <anton@samba.org>
  • Loading branch information
Anton Blanchard committed Apr 23, 2014
1 parent 83775b8 commit dd9fa16
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/powerpc/include/asm/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct mod_arch_specific {
#endif

bool is_module_trampoline(u32 *insns);
int module_trampoline_target(struct module *mod, u32 *trampoline,
unsigned long *target);

struct exception_table_entry;
void sort_ex_table(struct exception_table_entry *start,
Expand Down
29 changes: 29 additions & 0 deletions arch/powerpc/kernel/module_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,35 @@ bool is_module_trampoline(u32 *p)
return true;
}

int module_trampoline_target(struct module *mod, u32 *trampoline,
unsigned long *target)
{
u32 buf[2];
u16 upper, lower;
long offset;
void *toc_entry;

if (probe_kernel_read(buf, trampoline, sizeof(buf)))
return -EFAULT;

upper = buf[0] & 0xffff;
lower = buf[1] & 0xffff;

/* perform the addis/addi, both signed */
offset = ((short)upper << 16) + (short)lower;

/*
* Now get the address this trampoline jumps to. This
* is always 32 bytes into our trampoline stub.
*/
toc_entry = (void *)mod->arch.toc + offset + 32;

if (probe_kernel_read(target, toc_entry, sizeof(*target)))
return -EFAULT;

return 0;
}

#endif

/* Count how many different 24-bit relocations (different symbol,
Expand Down

0 comments on commit dd9fa16

Please sign in to comment.