[PATCH bpf-next v5 3/3] bpf, arm64: use bpf_jit_binary_pack_alloc
Xu Kuohai
xukuohai at huaweicloud.com
Sat Sep 9 01:59:57 PDT 2023
On 9/8/2023 10:43 PM, Puranjay Mohan wrote:
[ ... ]
> +
> +void bpf_jit_free(struct bpf_prog *prog)
> +{
> + if (prog->jited) {
> + struct arm64_jit_data *jit_data = prog->aux->jit_data;
> + struct bpf_binary_header *hdr;
> +
> + /*
> + * If we fail the final pass of JIT (from jit_subprogs),
> + * the program may not be finalized yet. Call finalize here
> + * before freeing it.
> + */
> + if (jit_data) {
> + bpf_jit_binary_pack_finalize(prog, jit_data->ro_header,
> + jit_data->header);
bpf_jit_binary_pack_finalize copies all instructions on the rw image to
the ro_image, which is unnecessary in a free function.
> + kfree(jit_data);
> + }
> + hdr = bpf_jit_binary_pack_hdr(prog);
> + bpf_jit_binary_pack_free(hdr, NULL);
> + WARN_ON_ONCE(!bpf_prog_kallsyms_verify_off(prog));
> + }
> +
> + bpf_prog_unlock_free(prog);
> +}
More information about the linux-arm-kernel
mailing list