[PATCH v2 08/12] riscv: extend execmem_params for kprobes allocations
Song Liu
song at kernel.org
Sat Jun 17 06:09:02 AEST 2023
On Fri, Jun 16, 2023 at 1:52 AM Mike Rapoport <rppt at kernel.org> wrote:
>
> From: "Mike Rapoport (IBM)" <rppt at kernel.org>
>
> RISC-V overrides kprobes::alloc_insn_range() to use the entire vmalloc area
> rather than limit the allocations to the modules area.
>
> Slightly reorder execmem_params initialization to support both 32 and 64
> bit variantsi and add definition of jit area to execmem_params to support
> generic kprobes::alloc_insn_page().
>
> Signed-off-by: Mike Rapoport (IBM) <rppt at kernel.org>
Acked-by: Song Liu <song at kernel.org>
> ---
> arch/riscv/kernel/module.c | 16 +++++++++++++++-
> arch/riscv/kernel/probes/kprobes.c | 10 ----------
> 2 files changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
> index ee5e04cd3f21..cca6ed4e9340 100644
> --- a/arch/riscv/kernel/module.c
> +++ b/arch/riscv/kernel/module.c
> @@ -436,7 +436,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
> return 0;
> }
>
> -#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
> +#ifdef CONFIG_MMU
> static struct execmem_params execmem_params = {
> .modules = {
> .text = {
> @@ -444,12 +444,26 @@ static struct execmem_params execmem_params = {
> .alignment = 1,
> },
> },
> + .jit = {
> + .text = {
> + .pgprot = PAGE_KERNEL_READ_EXEC,
> + .alignment = 1,
> + },
> + },
> };
>
> struct execmem_params __init *execmem_arch_params(void)
> {
> +#ifdef CONFIG_64BIT
> execmem_params.modules.text.start = MODULES_VADDR;
> execmem_params.modules.text.end = MODULES_END;
> +#else
> + execmem_params.modules.text.start = VMALLOC_START;
> + execmem_params.modules.text.end = VMALLOC_END;
> +#endif
> +
> + execmem_params.jit.text.start = VMALLOC_START;
> + execmem_params.jit.text.end = VMALLOC_END;
>
> return &execmem_params;
> }
> diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c
> index 2f08c14a933d..e64f2f3064eb 100644
> --- a/arch/riscv/kernel/probes/kprobes.c
> +++ b/arch/riscv/kernel/probes/kprobes.c
> @@ -104,16 +104,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
> 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 */
> void __kprobes arch_arm_kprobe(struct kprobe *p)
> {
> --
> 2.35.1
>
More information about the Linuxppc-dev
mailing list