0001
0002
0003
0004
0005 #ifndef __ASM_MODULE_H
0006 #define __ASM_MODULE_H
0007
0008 #include <asm-generic/module.h>
0009
0010 #ifdef CONFIG_ARM64_MODULE_PLTS
0011 struct mod_plt_sec {
0012 int plt_shndx;
0013 int plt_num_entries;
0014 int plt_max_entries;
0015 };
0016
0017 struct mod_arch_specific {
0018 struct mod_plt_sec core;
0019 struct mod_plt_sec init;
0020
0021
0022 struct plt_entry *ftrace_trampolines;
0023 };
0024 #endif
0025
0026 u64 module_emit_plt_entry(struct module *mod, Elf64_Shdr *sechdrs,
0027 void *loc, const Elf64_Rela *rela,
0028 Elf64_Sym *sym);
0029
0030 u64 module_emit_veneer_for_adrp(struct module *mod, Elf64_Shdr *sechdrs,
0031 void *loc, u64 val);
0032
0033 #ifdef CONFIG_RANDOMIZE_BASE
0034 extern u64 module_alloc_base;
0035 #else
0036 #define module_alloc_base ((u64)_etext - MODULES_VSIZE)
0037 #endif
0038
0039 struct plt_entry {
0040
0041
0042
0043
0044
0045
0046
0047
0048 __le32 adrp;
0049 __le32 add;
0050 __le32 br;
0051 };
0052
0053 static inline bool is_forbidden_offset_for_adrp(void *place)
0054 {
0055 return IS_ENABLED(CONFIG_ARM64_ERRATUM_843419) &&
0056 cpus_have_const_cap(ARM64_WORKAROUND_843419) &&
0057 ((u64)place & 0xfff) >= 0xff8;
0058 }
0059
0060 struct plt_entry get_plt_entry(u64 dst, void *pc);
0061 bool plt_entries_equal(const struct plt_entry *a, const struct plt_entry *b);
0062
0063 static inline bool plt_entry_is_initialized(const struct plt_entry *e)
0064 {
0065 return e->adrp || e->add || e->br;
0066 }
0067
0068 #endif