[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzYw0VciF-7CS164Nk8LLnZ4odtdYQyX1MS4eWDN5WbcSg@mail.gmail.com>
Date: Thu, 18 Jun 2020 18:10:29 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Jiri Olsa <jolsa@...nel.org>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Martin KaFai Lau <kafai@...com>,
David Miller <davem@...hat.com>,
John Fastabend <john.fastabend@...il.com>,
Wenbo Zhang <ethercflow@...il.com>,
KP Singh <kpsingh@...omium.org>,
Andrii Nakryiko <andriin@...com>,
Brendan Gregg <bgregg@...flix.com>,
Florent Revest <revest@...omium.org>,
Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH 05/11] bpf: Remove btf_id helpers resolving
On Tue, Jun 16, 2020 at 3:06 AM Jiri Olsa <jolsa@...nel.org> 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@...nel.org>
> ---
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
>
Powered by blists - more mailing lists