mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 08:58:07 +00:00
7fbc22ce29
In order to allow allocation of modules outside of vmalloc space, use MODULES_VADDR and MODULES_END when MODULES_VADDR is defined. Redefine module_alloc() when MODULES_VADDR defined. Unmap corresponding KASAN shadow memory. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/7ecf5fff1eef67d450e73fc412b6ec3818483d75.1593428200.git.christophe.leroy@csgroup.eu
99 lines
2.6 KiB
C
99 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/* Kernel module help for powerpc.
|
|
Copyright (C) 2001, 2003 Rusty Russell IBM Corporation.
|
|
Copyright (C) 2008 Freescale Semiconductor, Inc.
|
|
|
|
*/
|
|
#include <linux/elf.h>
|
|
#include <linux/moduleloader.h>
|
|
#include <linux/err.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/bug.h>
|
|
#include <asm/module.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm/firmware.h>
|
|
#include <linux/sort.h>
|
|
#include <asm/setup.h>
|
|
|
|
static LIST_HEAD(module_bug_list);
|
|
|
|
static const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
|
|
const Elf_Shdr *sechdrs,
|
|
const char *name)
|
|
{
|
|
char *secstrings;
|
|
unsigned int i;
|
|
|
|
secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
|
|
for (i = 1; i < hdr->e_shnum; i++)
|
|
if (strcmp(secstrings+sechdrs[i].sh_name, name) == 0)
|
|
return &sechdrs[i];
|
|
return NULL;
|
|
}
|
|
|
|
int module_finalize(const Elf_Ehdr *hdr,
|
|
const Elf_Shdr *sechdrs, struct module *me)
|
|
{
|
|
const Elf_Shdr *sect;
|
|
int rc;
|
|
|
|
rc = module_finalize_ftrace(me, sechdrs);
|
|
if (rc)
|
|
return rc;
|
|
|
|
/* Apply feature fixups */
|
|
sect = find_section(hdr, sechdrs, "__ftr_fixup");
|
|
if (sect != NULL)
|
|
do_feature_fixups(cur_cpu_spec->cpu_features,
|
|
(void *)sect->sh_addr,
|
|
(void *)sect->sh_addr + sect->sh_size);
|
|
|
|
sect = find_section(hdr, sechdrs, "__mmu_ftr_fixup");
|
|
if (sect != NULL)
|
|
do_feature_fixups(cur_cpu_spec->mmu_features,
|
|
(void *)sect->sh_addr,
|
|
(void *)sect->sh_addr + sect->sh_size);
|
|
|
|
#ifdef CONFIG_PPC64
|
|
sect = find_section(hdr, sechdrs, "__fw_ftr_fixup");
|
|
if (sect != NULL)
|
|
do_feature_fixups(powerpc_firmware_features,
|
|
(void *)sect->sh_addr,
|
|
(void *)sect->sh_addr + sect->sh_size);
|
|
#endif /* CONFIG_PPC64 */
|
|
|
|
#ifdef PPC64_ELF_ABI_v1
|
|
sect = find_section(hdr, sechdrs, ".opd");
|
|
if (sect != NULL) {
|
|
me->arch.start_opd = sect->sh_addr;
|
|
me->arch.end_opd = sect->sh_addr + sect->sh_size;
|
|
}
|
|
#endif /* PPC64_ELF_ABI_v1 */
|
|
|
|
#ifdef CONFIG_PPC_BARRIER_NOSPEC
|
|
sect = find_section(hdr, sechdrs, "__spec_barrier_fixup");
|
|
if (sect != NULL)
|
|
do_barrier_nospec_fixups_range(barrier_nospec_enabled,
|
|
(void *)sect->sh_addr,
|
|
(void *)sect->sh_addr + sect->sh_size);
|
|
#endif /* CONFIG_PPC_BARRIER_NOSPEC */
|
|
|
|
sect = find_section(hdr, sechdrs, "__lwsync_fixup");
|
|
if (sect != NULL)
|
|
do_lwsync_fixups(cur_cpu_spec->cpu_features,
|
|
(void *)sect->sh_addr,
|
|
(void *)sect->sh_addr + sect->sh_size);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef MODULES_VADDR
|
|
void *module_alloc(unsigned long size)
|
|
{
|
|
BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR);
|
|
|
|
return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, GFP_KERNEL,
|
|
PAGE_KERNEL_EXEC, VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
|
|
__builtin_return_address(0));
|
|
}
|
|
#endif
|