blob: 356658711a864e0587aead0ebd7c5f9e030cda02 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
jdl@freescale.coma37c8872005-09-07 15:27:09 -05002#ifndef _ASM_POWERPC_MODULE_H
3#define _ASM_POWERPC_MODULE_H
Arnd Bergmann88ced032005-12-16 22:43:46 +01004#ifdef __KERNEL__
Jon Loeliger6b9269a2005-09-01 15:51:52 -05005
6/*
Jon Loeliger6b9269a2005-09-01 15:51:52 -05007 */
8
9#include <linux/list.h>
10#include <asm/bug.h>
David Howells786d35d2012-09-28 14:31:03 +093011#include <asm-generic/module.h>
Jon Loeliger6b9269a2005-09-01 15:51:52 -050012
13
Nicholas Pigginabba7592018-05-30 22:19:22 +100014#ifdef CONFIG_MPROFILE_KERNEL
Michael Ellerman73aca172018-03-26 19:27:01 +110015#define MODULE_ARCH_VERMAGIC_FTRACE "mprofile-kernel "
16#else
17#define MODULE_ARCH_VERMAGIC_FTRACE ""
Michael Ellerman43e24e82017-05-10 16:57:49 +100018#endif
19
Michael Ellerman73aca172018-03-26 19:27:01 +110020#ifdef CONFIG_RELOCATABLE
21#define MODULE_ARCH_VERMAGIC_RELOCATABLE "relocatable "
22#else
23#define MODULE_ARCH_VERMAGIC_RELOCATABLE ""
24#endif
25
26#define MODULE_ARCH_VERMAGIC MODULE_ARCH_VERMAGIC_FTRACE MODULE_ARCH_VERMAGIC_RELOCATABLE
27
Jon Loeliger6b9269a2005-09-01 15:51:52 -050028#ifndef __powerpc64__
29/*
30 * Thanks to Paul M for explaining this.
31 *
32 * PPC can only do rel jumps += 32MB, and often the kernel and other
Adam Buchbinder446957b2016-02-24 10:51:11 -080033 * modules are further away than this. So, we jump to a table of
Jon Loeliger6b9269a2005-09-01 15:51:52 -050034 * trampolines attached to the module (the Procedure Linkage Table)
35 * whenever that happens.
36 */
37
38struct ppc_plt_entry {
39 /* 16 byte jump instruction sequence (4 instructions) */
40 unsigned int jump[4];
41};
42#endif /* __powerpc64__ */
43
44
45struct mod_arch_specific {
46#ifdef __powerpc64__
47 unsigned int stubs_section; /* Index of stubs section in module */
48 unsigned int toc_section; /* What section is the TOC? */
Rusty Russell4edebbe2014-03-18 19:59:26 +103049 bool toc_fixed; /* Have we fixed up .TOC.? */
Steven Rostedtf48cb8b2008-11-14 20:47:03 -080050
Sergey Senozhatsky5633e852017-11-10 08:48:27 +090051 /* For module function descriptor dereference */
52 unsigned long start_opd;
53 unsigned long end_opd;
Steven Rostedt7cc45e62008-11-15 02:39:05 -050054#else /* powerpc64 */
Jon Loeliger6b9269a2005-09-01 15:51:52 -050055 /* Indices of PLT sections within module. */
56 unsigned int core_plt_section;
57 unsigned int init_plt_section;
Josh Poimboeuf8ce621e12018-05-24 22:48:34 -050058#endif /* powerpc64 */
59
Steven Rostedt7cc45e62008-11-15 02:39:05 -050060#ifdef CONFIG_DYNAMIC_FTRACE
61 unsigned long tramp;
Josh Poimboeuf8ce621e12018-05-24 22:48:34 -050062#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
63 unsigned long tramp_regs;
Jon Loeliger6b9269a2005-09-01 15:51:52 -050064#endif
Josh Poimboeuf8ce621e12018-05-24 22:48:34 -050065#endif
Jon Loeliger6b9269a2005-09-01 15:51:52 -050066
67 /* List of BUG addresses, source line numbers and filenames */
68 struct list_head bug_list;
69 struct bug_entry *bug_table;
70 unsigned int num_bugs;
71};
72
Jon Loeliger6b9269a2005-09-01 15:51:52 -050073/*
74 * Select ELF headers.
75 * Make empty section for module_frob_arch_sections to expand.
76 */
77
78#ifdef __powerpc64__
Jon Loeliger6b9269a2005-09-01 15:51:52 -050079# ifdef MODULE
80 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
81# endif
82#else
Jon Loeliger6b9269a2005-09-01 15:51:52 -050083# ifdef MODULE
84 asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
85 asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
86# endif /* MODULE */
87#endif
88
Steven Rostedtf48cb8b2008-11-14 20:47:03 -080089#ifdef CONFIG_DYNAMIC_FTRACE
90# ifdef MODULE
91 asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
92# endif /* MODULE */
93#endif
94
Michael Ellermanf17c4e02016-03-03 15:26:55 +110095int module_trampoline_target(struct module *mod, unsigned long trampoline,
Anton Blancharddd9fa162014-04-04 15:58:42 +110096 unsigned long *target);
Jon Loeliger6b9269a2005-09-01 15:51:52 -050097
Michael Ellerman136cd342016-03-03 15:26:54 +110098#ifdef CONFIG_DYNAMIC_FTRACE
99int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
100#else
101static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)
102{
103 return 0;
104}
105#endif
106
Arnd Bergmann88ced032005-12-16 22:43:46 +0100107#endif /* __KERNEL__ */
jdl@freescale.coma37c8872005-09-07 15:27:09 -0500108#endif /* _ASM_POWERPC_MODULE_H */