Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef _ASM_POWERPC_MODULE_H
0003 #define _ASM_POWERPC_MODULE_H
0004 #ifdef __KERNEL__
0005 
0006 #include <linux/list.h>
0007 #include <asm/bug.h>
0008 #include <asm-generic/module.h>
0009 
0010 #ifndef __powerpc64__
0011 /*
0012  * Thanks to Paul M for explaining this.
0013  *
0014  * PPC can only do rel jumps += 32MB, and often the kernel and other
0015  * modules are further away than this.  So, we jump to a table of
0016  * trampolines attached to the module (the Procedure Linkage Table)
0017  * whenever that happens.
0018  */
0019 
0020 struct ppc_plt_entry {
0021     /* 16 byte jump instruction sequence (4 instructions) */
0022     unsigned int jump[4];
0023 };
0024 #endif  /* __powerpc64__ */
0025 
0026 
0027 struct mod_arch_specific {
0028 #ifdef __powerpc64__
0029     unsigned int stubs_section; /* Index of stubs section in module */
0030     unsigned int toc_section;   /* What section is the TOC? */
0031     bool toc_fixed;         /* Have we fixed up .TOC.? */
0032 
0033     /* For module function descriptor dereference */
0034     unsigned long start_opd;
0035     unsigned long end_opd;
0036 #else /* powerpc64 */
0037     /* Indices of PLT sections within module. */
0038     unsigned int core_plt_section;
0039     unsigned int init_plt_section;
0040 #endif /* powerpc64 */
0041 
0042 #ifdef CONFIG_DYNAMIC_FTRACE
0043     unsigned long tramp;
0044     unsigned long tramp_regs;
0045 #endif
0046 
0047     /* List of BUG addresses, source line numbers and filenames */
0048     struct list_head bug_list;
0049     struct bug_entry *bug_table;
0050     unsigned int num_bugs;
0051 };
0052 
0053 /*
0054  * Select ELF headers.
0055  * Make empty section for module_frob_arch_sections to expand.
0056  */
0057 
0058 #ifdef __powerpc64__
0059 #    ifdef MODULE
0060     asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
0061 #    endif
0062 #else
0063 #    ifdef MODULE
0064     asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
0065     asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
0066 #    endif  /* MODULE */
0067 #endif
0068 
0069 #ifdef CONFIG_DYNAMIC_FTRACE
0070 #    ifdef MODULE
0071     asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
0072 #    endif  /* MODULE */
0073 
0074 int module_trampoline_target(struct module *mod, unsigned long trampoline,
0075                  unsigned long *target);
0076 int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
0077 #else
0078 static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)
0079 {
0080     return 0;
0081 }
0082 #endif
0083 
0084 #endif /* __KERNEL__ */
0085 #endif  /* _ASM_POWERPC_MODULE_H */