2021-09-24 11:21:51

by Lorenz Bauer

[permalink] [raw]
Subject: [PATCH bpf-next 2/4] bpf: define bpf_jit_alloc_exec_limit for arm64 JIT

Expose the maximum amount of useable memory from the arm64 JIT.

Signed-off-by: Lorenz Bauer <[email protected]>
---
arch/arm64/net/bpf_jit_comp.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 41c23f474ea6..803e7773fa86 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -1136,6 +1136,11 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
return prog;
}

+u64 bpf_jit_alloc_exec_limit(void)
+{
+ return BPF_JIT_REGION_SIZE;
+}
+
void *bpf_jit_alloc_exec(unsigned long size)
{
return __vmalloc_node_range(size, PAGE_SIZE, BPF_JIT_REGION_START,
--
2.30.2


2021-09-29 16:21:39

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH bpf-next 2/4] bpf: define bpf_jit_alloc_exec_limit for arm64 JIT

On Fri, Sep 24, 2021 at 10:55:40AM +0100, Lorenz Bauer wrote:
> Expose the maximum amount of useable memory from the arm64 JIT.
>
> Signed-off-by: Lorenz Bauer <[email protected]>
> ---
> arch/arm64/net/bpf_jit_comp.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index 41c23f474ea6..803e7773fa86 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -1136,6 +1136,11 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
> return prog;
> }
>
> +u64 bpf_jit_alloc_exec_limit(void)
> +{
> + return BPF_JIT_REGION_SIZE;
> +}

Looks like this won't result in a functional change, as we happen to return
SZ_128M anyway thanks to the way in which the modules area is constructed.

But making this explicit is definitely better, so:

Acked-by: Will Deacon <[email protected]>

(I'm assuming this will go via the bpf tree, but please shout if I should
take it via arm64 instead)

Will