mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
riscv: extend execmem_params for generated code allocations
The memory allocations for kprobes and BPF on RISC-V are not placed in the modules area and these custom allocations are implemented with overrides of alloc_insn_page() and bpf_jit_alloc_exec(). Define MODULES_VADDR and MODULES_END as VMALLOC_START and VMALLOC_END for 32 bit and slightly reorder execmem_params initialization to support both 32 and 64 bit variants, define EXECMEM_KPROBES and EXECMEM_BPF ranges in riscv::execmem_params and drop overrides of alloc_insn_page() and bpf_jit_alloc_exec(). Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
parent
223b5e57d0
commit
4d7b321a9c
4 changed files with 16 additions and 24 deletions
|
@ -55,6 +55,9 @@
|
||||||
#define MODULES_LOWEST_VADDR (KERNEL_LINK_ADDR - SZ_2G)
|
#define MODULES_LOWEST_VADDR (KERNEL_LINK_ADDR - SZ_2G)
|
||||||
#define MODULES_VADDR (PFN_ALIGN((unsigned long)&_end) - SZ_2G)
|
#define MODULES_VADDR (PFN_ALIGN((unsigned long)&_end) - SZ_2G)
|
||||||
#define MODULES_END (PFN_ALIGN((unsigned long)&_start))
|
#define MODULES_END (PFN_ALIGN((unsigned long)&_start))
|
||||||
|
#else
|
||||||
|
#define MODULES_VADDR VMALLOC_START
|
||||||
|
#define MODULES_END VMALLOC_END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -906,7 +906,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
|
#ifdef CONFIG_MMU
|
||||||
static struct execmem_info execmem_info __ro_after_init;
|
static struct execmem_info execmem_info __ro_after_init;
|
||||||
|
|
||||||
struct execmem_info __init *execmem_arch_setup(void)
|
struct execmem_info __init *execmem_arch_setup(void)
|
||||||
|
@ -919,6 +919,18 @@ struct execmem_info __init *execmem_arch_setup(void)
|
||||||
.pgprot = PAGE_KERNEL,
|
.pgprot = PAGE_KERNEL,
|
||||||
.alignment = 1,
|
.alignment = 1,
|
||||||
},
|
},
|
||||||
|
[EXECMEM_KPROBES] = {
|
||||||
|
.start = VMALLOC_START,
|
||||||
|
.end = VMALLOC_END,
|
||||||
|
.pgprot = PAGE_KERNEL_READ_EXEC,
|
||||||
|
.alignment = 1,
|
||||||
|
},
|
||||||
|
[EXECMEM_BPF] = {
|
||||||
|
.start = BPF_JIT_REGION_START,
|
||||||
|
.end = BPF_JIT_REGION_END,
|
||||||
|
.pgprot = PAGE_KERNEL,
|
||||||
|
.alignment = PAGE_SIZE,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -104,16 +104,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MMU
|
|
||||||
void *alloc_insn_page(void)
|
|
||||||
{
|
|
||||||
return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
|
|
||||||
GFP_KERNEL, PAGE_KERNEL_READ_EXEC,
|
|
||||||
VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
|
|
||||||
__builtin_return_address(0));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* install breakpoint in text */
|
/* install breakpoint in text */
|
||||||
void __kprobes arch_arm_kprobe(struct kprobe *p)
|
void __kprobes arch_arm_kprobe(struct kprobe *p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -219,19 +219,6 @@ u64 bpf_jit_alloc_exec_limit(void)
|
||||||
return BPF_JIT_REGION_SIZE;
|
return BPF_JIT_REGION_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *bpf_jit_alloc_exec(unsigned long size)
|
|
||||||
{
|
|
||||||
return __vmalloc_node_range(size, PAGE_SIZE, BPF_JIT_REGION_START,
|
|
||||||
BPF_JIT_REGION_END, GFP_KERNEL,
|
|
||||||
PAGE_KERNEL, 0, NUMA_NO_NODE,
|
|
||||||
__builtin_return_address(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
void bpf_jit_free_exec(void *addr)
|
|
||||||
{
|
|
||||||
return vfree(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *bpf_arch_text_copy(void *dst, void *src, size_t len)
|
void *bpf_arch_text_copy(void *dst, void *src, size_t len)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
Loading…
Add table
Reference in a new issue