On Tue, Jun 16, 2020 at 3:06 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > Now when we moved the helpers btf_id into .BTF_ids section, > we can remove the code that resolve those IDs in runtime. > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > --- Nice! :) BTW, have you looked at bpf_ctx_convert stuff? Would we be able to replace it with your btfids thing as well? > kernel/bpf/btf.c | 88 +++--------------------------------------------- > 1 file changed, 4 insertions(+), 84 deletions(-) > > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > index 58c9af1d4808..aea7b2cc8d26 100644 > --- a/kernel/bpf/btf.c > +++ b/kernel/bpf/btf.c > @@ -4049,96 +4049,16 @@ int btf_struct_access(struct bpf_verifier_log *log, > return -EINVAL; > } > [...] > int btf_resolve_helper_id(struct bpf_verifier_log *log, > const struct bpf_func_proto *fn, int arg) > { > - int *btf_id = &fn->btf_id[arg]; > - int ret; > - > if (fn->arg_type[arg] != ARG_PTR_TO_BTF_ID) > return -EINVAL; > > - ret = READ_ONCE(*btf_id); > - if (ret) > - return ret; > - /* ok to race the search. The result is the same */ > - ret = __btf_resolve_helper_id(log, fn->func, arg); > - if (!ret) { > - /* Function argument cannot be type 'void' */ > - bpf_log(log, "BTF resolution bug\n"); > - return -EFAULT; > - } > - WRITE_ONCE(*btf_id, ret); > - return ret; > + if (WARN_ON_ONCE(!fn->btf_id)) > + return -EINVAL; > + > + return fn->btf_id[arg]; It probably would be a good idea to add some sanity checking here, making sure that btf_id is >0 (void is never a right type) and <= nr_types in vmlinux_btf? > } > > static int __get_type_size(struct btf *btf, u32 btf_id, > -- > 2.25.4 >