Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/modules: Create module_trampoline_target()

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>

+31
+2
arch/powerpc/include/asm/module.h
··· 79 79 #endif 80 80 81 81 bool is_module_trampoline(u32 *insns); 82 + int module_trampoline_target(struct module *mod, u32 *trampoline, 83 + unsigned long *target); 82 84 83 85 struct exception_table_entry; 84 86 void sort_ex_table(struct exception_table_entry *start,
+29
arch/powerpc/kernel/module_64.c
··· 176 176 return true; 177 177 } 178 178 179 + int module_trampoline_target(struct module *mod, u32 *trampoline, 180 + unsigned long *target) 181 + { 182 + u32 buf[2]; 183 + u16 upper, lower; 184 + long offset; 185 + void *toc_entry; 186 + 187 + if (probe_kernel_read(buf, trampoline, sizeof(buf))) 188 + return -EFAULT; 189 + 190 + upper = buf[0] & 0xffff; 191 + lower = buf[1] & 0xffff; 192 + 193 + /* perform the addis/addi, both signed */ 194 + offset = ((short)upper << 16) + (short)lower; 195 + 196 + /* 197 + * Now get the address this trampoline jumps to. This 198 + * is always 32 bytes into our trampoline stub. 199 + */ 200 + toc_entry = (void *)mod->arch.toc + offset + 32; 201 + 202 + if (probe_kernel_read(target, toc_entry, sizeof(*target))) 203 + return -EFAULT; 204 + 205 + return 0; 206 + } 207 + 179 208 #endif 180 209 181 210 /* Count how many different 24-bit relocations (different symbol,