powerpc/mm: Fixup tlbie vs mtpidr/mtlpidr ordering issue on POWER9
[linux-2.6-block.git] / arch / powerpc / include / asm / module.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
a37c8875 2#ifndef _ASM_POWERPC_MODULE_H
3#define _ASM_POWERPC_MODULE_H
88ced031 4#ifdef __KERNEL__
6b9269ab
JL
5
6/*
6b9269ab
JL
7 */
8
9#include <linux/list.h>
10#include <asm/bug.h>
786d35d4 11#include <asm-generic/module.h>
6b9269ab
JL
12
13
abba7597 14#ifdef CONFIG_MPROFILE_KERNEL
73aca179
ME
15#define MODULE_ARCH_VERMAGIC_FTRACE "mprofile-kernel "
16#else
17#define MODULE_ARCH_VERMAGIC_FTRACE ""
43e24e82
ME
18#endif
19
73aca179
ME
20#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
6b9269ab
JL
28#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
446957ba 33 * modules are further away than this. So, we jump to a table of
6b9269ab
JL
34 * 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? */
4edebbea 49 bool toc_fixed; /* Have we fixed up .TOC.? */
f48cb8b4 50
5633e85b
SS
51 /* For module function descriptor dereference */
52 unsigned long start_opd;
53 unsigned long end_opd;
7cc45e64 54#else /* powerpc64 */
6b9269ab
JL
55 /* Indices of PLT sections within module. */
56 unsigned int core_plt_section;
57 unsigned int init_plt_section;
8ce621e1
JP
58#endif /* powerpc64 */
59
7cc45e64
SR
60#ifdef CONFIG_DYNAMIC_FTRACE
61 unsigned long tramp;
8ce621e1
JP
62#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
63 unsigned long tramp_regs;
64#endif
6b9269ab
JL
65#endif
66
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
6b9269ab
JL
73/*
74 * Select ELF headers.
75 * Make empty section for module_frob_arch_sections to expand.
76 */
77
78#ifdef __powerpc64__
6b9269ab
JL
79# ifdef MODULE
80 asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
81# endif
82#else
6b9269ab
JL
83# 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
f48cb8b4
SR
89#ifdef CONFIG_DYNAMIC_FTRACE
90# ifdef MODULE
91 asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
92# endif /* MODULE */
93#endif
94
f17c4e01 95int module_trampoline_target(struct module *mod, unsigned long trampoline,
dd9fa162 96 unsigned long *target);
6b9269ab 97
136cd345
ME
98#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
88ced031 107#endif /* __KERNEL__ */
a37c8875 108#endif /* _ASM_POWERPC_MODULE_H */