Re: [PATCH v1 bpf-next 10/11] libbpf: support llvm-generated indirect jumps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2025-08-16 at 18:06 +0000, Anton Protopopov wrote:

[...]

> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index fe4fc5438678..a5f04544c09c 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c

[...]

> @@ -6101,6 +6124,60 @@ static void poison_kfunc_call(struct bpf_program *prog, int relo_idx,
>  	insn->imm = POISON_CALL_KFUNC_BASE + ext_idx;
>  }
>  
> +static int create_jt_map(struct bpf_object *obj, int off, int size, int adjust_off)
> +{
> +	static union bpf_attr attr = {
> +		.map_type = BPF_MAP_TYPE_INSN_ARRAY,
> +		.key_size = 4,
> +		.value_size = sizeof(struct bpf_insn_array_value),
> +		.max_entries = 0,
> +	};
> +	struct bpf_insn_array_value val = {};
> +	int map_fd;
> +	int err;
> +	__u32 i;
> +	__u32 *jt;
> +
> +	attr.max_entries = size / 8;
> +
> +	map_fd = syscall(__NR_bpf, BPF_MAP_CREATE, &attr, sizeof(attr));
> +	if (map_fd < 0)
> +		return map_fd;
> +
> +	jt = (__u32 *)(obj->efile.jumptables_data.d_buf + off);
  	     ^^^^^^^^^
    Jump table entries are u64 now, e.g. see test case:
    https://github.com/llvm/llvm-project/blob/39dc3c41e459e6c847c1e45e7e93c53aaf74c1de/llvm/test/CodeGen/BPF/jump_table_swith_stmt.ll#L68

[...]

> @@ -6389,36 +6481,58 @@ static int append_subprog_relos(struct bpf_program *main_prog, struct bpf_progra

[...]

>  static int
>  bpf_object__append_subprog_code(struct bpf_object *obj, struct bpf_program *main_prog,
> -				struct bpf_program *subprog)
> +		struct bpf_program *subprog)
>  {
> -       struct bpf_insn *insns;
> -       size_t new_cnt;
> -       int err;
> +	struct bpf_insn *insns;
> +	size_t new_cnt;
> +	int err;

Could you please extract spaces vs tabs fix for this function as a separate commit?
Just to make diff easier to read.

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux