Skip to content

Commit e2effa2

Browse files
rpptmcgrof
authored andcommitted
arm64: extend execmem_info for generated code allocations
The memory allocations for kprobes and BPF on arm64 can be placed anywhere in vmalloc address space and currently this is implemented with overrides of alloc_insn_page() and bpf_jit_alloc_exec() in arm64. Define EXECMEM_KPROBES and EXECMEM_BPF ranges in arm64::execmem_info and drop overrides of alloc_insn_page() and bpf_jit_alloc_exec(). Signed-off-by: Mike Rapoport (IBM) <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 4d7b321 commit e2effa2

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

arch/arm64/kernel/module.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ struct execmem_info __init *execmem_arch_setup(void)
146146
.fallback_start = fallback_start,
147147
.fallback_end = fallback_end,
148148
},
149+
[EXECMEM_KPROBES] = {
150+
.start = VMALLOC_START,
151+
.end = VMALLOC_END,
152+
.pgprot = PAGE_KERNEL_ROX,
153+
.alignment = 1,
154+
},
155+
[EXECMEM_BPF] = {
156+
.start = VMALLOC_START,
157+
.end = VMALLOC_END,
158+
.pgprot = PAGE_KERNEL,
159+
.alignment = 1,
160+
},
149161
},
150162
};
151163

arch/arm64/kernel/probes/kprobes.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
129129
return 0;
130130
}
131131

132-
void *alloc_insn_page(void)
133-
{
134-
return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
135-
GFP_KERNEL, PAGE_KERNEL_ROX, VM_FLUSH_RESET_PERMS,
136-
NUMA_NO_NODE, __builtin_return_address(0));
137-
}
138-
139132
/* arm kprobe: install breakpoint in text */
140133
void __kprobes arch_arm_kprobe(struct kprobe *p)
141134
{

arch/arm64/net/bpf_jit_comp.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,17 +1793,6 @@ u64 bpf_jit_alloc_exec_limit(void)
17931793
return VMALLOC_END - VMALLOC_START;
17941794
}
17951795

1796-
void *bpf_jit_alloc_exec(unsigned long size)
1797-
{
1798-
/* Memory is intended to be executable, reset the pointer tag. */
1799-
return kasan_reset_tag(vmalloc(size));
1800-
}
1801-
1802-
void bpf_jit_free_exec(void *addr)
1803-
{
1804-
return vfree(addr);
1805-
}
1806-
18071796
/* Indicate the JIT backend supports mixing bpf2bpf and tailcalls. */
18081797
bool bpf_jit_supports_subprog_tailcalls(void)
18091798
{

0 commit comments

Comments
 (0)