^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_POWERPC_MODULE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_POWERPC_MODULE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <asm/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm-generic/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef __powerpc64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Thanks to Paul M for explaining this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * PPC can only do rel jumps += 32MB, and often the kernel and other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * modules are further away than this. So, we jump to a table of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * trampolines attached to the module (the Procedure Linkage Table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * whenever that happens.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct ppc_plt_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* 16 byte jump instruction sequence (4 instructions) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned int jump[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #endif /* __powerpc64__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct mod_arch_specific {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #ifdef __powerpc64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned int stubs_section; /* Index of stubs section in module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int toc_section; /* What section is the TOC? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) bool toc_fixed; /* Have we fixed up .TOC.? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* For module function descriptor dereference */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned long start_opd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned long end_opd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #else /* powerpc64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* Indices of PLT sections within module. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) unsigned int core_plt_section;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned int init_plt_section;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #endif /* powerpc64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #ifdef CONFIG_DYNAMIC_FTRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned long tramp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned long tramp_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* List of BUG addresses, source line numbers and filenames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct list_head bug_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct bug_entry *bug_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) unsigned int num_bugs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * Select ELF headers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * Make empty section for module_frob_arch_sections to expand.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #ifdef __powerpc64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) # ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) # endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) # ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) # endif /* MODULE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #ifdef CONFIG_DYNAMIC_FTRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) # ifdef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) # endif /* MODULE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int module_trampoline_target(struct module *mod, unsigned long trampoline,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) unsigned long *target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #endif /* __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #endif /* _ASM_POWERPC_MODULE_H */