arm64: dts: Revert "specify console via command line"
[linux/fpc-iii.git] / arch / powerpc / kernel / module.c
blobdf649acb563190c36816f26e60a5f3c93b0a89f3
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Kernel module help for powerpc.
3 Copyright (C) 2001, 2003 Rusty Russell IBM Corporation.
4 Copyright (C) 2008 Freescale Semiconductor, Inc.
6 */
7 #include <linux/elf.h>
8 #include <linux/moduleloader.h>
9 #include <linux/err.h>
10 #include <linux/vmalloc.h>
11 #include <linux/bug.h>
12 #include <asm/module.h>
13 #include <linux/uaccess.h>
14 #include <asm/firmware.h>
15 #include <linux/sort.h>
16 #include <asm/setup.h>
18 static LIST_HEAD(module_bug_list);
20 static const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
21 const Elf_Shdr *sechdrs,
22 const char *name)
24 char *secstrings;
25 unsigned int i;
27 secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
28 for (i = 1; i < hdr->e_shnum; i++)
29 if (strcmp(secstrings+sechdrs[i].sh_name, name) == 0)
30 return &sechdrs[i];
31 return NULL;
34 int module_finalize(const Elf_Ehdr *hdr,
35 const Elf_Shdr *sechdrs, struct module *me)
37 const Elf_Shdr *sect;
38 int rc;
40 rc = module_finalize_ftrace(me, sechdrs);
41 if (rc)
42 return rc;
44 /* Apply feature fixups */
45 sect = find_section(hdr, sechdrs, "__ftr_fixup");
46 if (sect != NULL)
47 do_feature_fixups(cur_cpu_spec->cpu_features,
48 (void *)sect->sh_addr,
49 (void *)sect->sh_addr + sect->sh_size);
51 sect = find_section(hdr, sechdrs, "__mmu_ftr_fixup");
52 if (sect != NULL)
53 do_feature_fixups(cur_cpu_spec->mmu_features,
54 (void *)sect->sh_addr,
55 (void *)sect->sh_addr + sect->sh_size);
57 #ifdef CONFIG_PPC64
58 sect = find_section(hdr, sechdrs, "__fw_ftr_fixup");
59 if (sect != NULL)
60 do_feature_fixups(powerpc_firmware_features,
61 (void *)sect->sh_addr,
62 (void *)sect->sh_addr + sect->sh_size);
63 #endif /* CONFIG_PPC64 */
65 #ifdef PPC64_ELF_ABI_v1
66 sect = find_section(hdr, sechdrs, ".opd");
67 if (sect != NULL) {
68 me->arch.start_opd = sect->sh_addr;
69 me->arch.end_opd = sect->sh_addr + sect->sh_size;
71 #endif /* PPC64_ELF_ABI_v1 */
73 #ifdef CONFIG_PPC_BARRIER_NOSPEC
74 sect = find_section(hdr, sechdrs, "__spec_barrier_fixup");
75 if (sect != NULL)
76 do_barrier_nospec_fixups_range(barrier_nospec_enabled,
77 (void *)sect->sh_addr,
78 (void *)sect->sh_addr + sect->sh_size);
79 #endif /* CONFIG_PPC_BARRIER_NOSPEC */
81 sect = find_section(hdr, sechdrs, "__lwsync_fixup");
82 if (sect != NULL)
83 do_lwsync_fixups(cur_cpu_spec->cpu_features,
84 (void *)sect->sh_addr,
85 (void *)sect->sh_addr + sect->sh_size);
87 return 0;