From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Dmitrii Banshchikov <me@ubique.spb.ru>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, kafai@fb.com, songliubraving@fb.com,
yhs@fb.com, john.fastabend@gmail.com, kpsingh@chromium.org,
rdna@fb.com
Subject: Re: [PATCH v3 bpf-next 3/4] bpf: Support pointers in global func args
Date: Fri, 12 Feb 2021 18:09:37 -0800 [thread overview]
Message-ID: <20210213020937.g6lt3pczqbjj5h2u@ast-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210212205642.620788-4-me@ubique.spb.ru>
On Sat, Feb 13, 2021 at 12:56:41AM +0400, Dmitrii Banshchikov wrote:
> Add an ability to pass a pointer to a type with known size in arguments
> of a global function. Such pointers may be used to overcome the limit on
> the maximum number of arguments, avoid expensive and tricky workarounds
> and to have multiple output arguments.
Thanks a lot for adding this feature and exhaustive tests.
It's a massive improvement in function-by-function verification.
Hopefully it will increase its adoption.
I've applied the set to bpf-next.
> @@ -5349,10 +5352,6 @@ int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
> goto out;
> }
> if (btf_type_is_ptr(t)) {
> - if (reg->type == SCALAR_VALUE) {
> - bpf_log(log, "R%d is not a pointer\n", i + 1);
> - goto out;
> - }
Thanks for nuking this annoying warning along the way.
People complained that the verification log for normal static functions
contains above inexplicable message.
> /* If function expects ctx type in BTF check that caller
> * is passing PTR_TO_CTX.
> */
> @@ -5367,6 +5366,25 @@ int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
> goto out;
> continue;
> }
> +
> + if (!is_global)
> + goto out;
> +
> + t = btf_type_skip_modifiers(btf, t->type, NULL);
> +
> + ref_t = btf_resolve_size(btf, t, &type_size);
> + if (IS_ERR(ref_t)) {
> + bpf_log(log,
> + "arg#%d reference type('%s %s') size cannot be determined: %ld\n",
> + i, btf_type_str(t), btf_name_by_offset(btf, t->name_off),
> + PTR_ERR(ref_t));
Hopefully one annoying message won't get replaced with this annoying message :)
I think the type size should be known most of the time. So it should be fine.
> + if (btf_type_is_ptr(t)) {
> + if (btf_get_prog_ctx_type(log, btf, t, prog_type, i)) {
> + reg->type = PTR_TO_CTX;
> + continue;
> + }
Do you think it would make sense to nuke another message in btf_get_prog_ctx_type ?
With this newly gained usability of global function the message
"arg#0 type is not a struct"
is not useful.
It was marginally useful in the past. Because global funcs supported
ptr_to_ctx only it wasn't seen as often.
Now this message probably can simply be removed. wdyt?
next prev parent reply other threads:[~2021-02-13 2:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-12 20:56 [PATCH v3 bpf-next 0/4] Add support of pointer to struct in global functions Dmitrii Banshchikov
2021-02-12 20:56 ` [PATCH v3 bpf-next 1/4] bpf: Rename bpf_reg_state variables Dmitrii Banshchikov
2021-02-12 21:11 ` Andrii Nakryiko
2021-02-12 20:56 ` [PATCH v3 bpf-next 2/4] bpf: Extract nullable reg type conversion into a helper function Dmitrii Banshchikov
2021-02-12 21:12 ` Andrii Nakryiko
2021-02-12 20:56 ` [PATCH v3 bpf-next 3/4] bpf: Support pointers in global func args Dmitrii Banshchikov
2021-02-12 21:14 ` Andrii Nakryiko
2021-02-13 2:09 ` Alexei Starovoitov [this message]
2021-02-15 6:25 ` Dmitrii Banshchikov
2021-02-12 20:56 ` [PATCH v3 bpf-next 4/4] selftests/bpf: Add unit tests for pointers in global functions Dmitrii Banshchikov
2021-02-12 21:15 ` Andrii Nakryiko
2021-02-23 6:43 ` Andrii Nakryiko
2021-02-23 8:22 ` [PATCH] selftests/bpf: Fix a compiler warning in global func test Dmitrii Banshchikov
2021-02-24 15:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210213020937.g6lt3pczqbjj5h2u@ast-mbp.dhcp.thefacebook.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=me@ubique.spb.ru \
--cc=rdna@fb.com \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).