For setting compartment bounds it's useful to know the overall size of the eBPF JIT image.
Signed-off-by: Zachary Leaf zachary.leaf@arm.com --- arch/arm64/net/bpf_jit_comp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index d8ecb79dbb74..85810908dc15 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -78,6 +78,7 @@ struct jit_ctx { int *offset; int exentry_idx; __le32 *image; + int image_size; u32 stack_size; int fpb_offset; }; @@ -1514,7 +1515,7 @@ struct arm64_jit_data {
struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) { - int image_size, prog_size, extable_size, extable_align, extable_offset; + int prog_size, extable_size, extable_align, extable_offset; struct bpf_prog *tmp, *orig_prog = prog; struct bpf_binary_header *header; struct arm64_jit_data *jit_data; @@ -1594,8 +1595,8 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) prog_size = sizeof(u32) * ctx.idx; /* also allocate space for plt target */ extable_offset = round_up(prog_size + PLT_TARGET_SIZE, extable_align); - image_size = extable_offset + extable_size; - header = bpf_jit_binary_alloc(image_size, &image_ptr, + ctx.image_size = extable_offset + extable_size; + header = bpf_jit_binary_alloc(ctx.image_size, &image_ptr, sizeof(u32), jit_fill_hole); if (header == NULL) { prog = orig_prog;