From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: ast@kernel.org, daniel@iogearbox.net
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
bjorn.topel@intel.com, magnus.karlsson@intel.com,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Subject: [PATCH v8 bpf-next 6/7] bpf: allow for tailcalls in BPF subprograms for x64 JIT
Date: Wed, 16 Sep 2020 23:10:09 +0200 [thread overview]
Message-ID: <20200916211010.3685-7-maciej.fijalkowski@intel.com> (raw)
In-Reply-To: <20200916211010.3685-1-maciej.fijalkowski@intel.com>
Relax verifier's restriction that was meant to forbid tailcall usage
when subprog count was higher than 1.
Also, do not max out the stack depth of program that utilizes tailcalls.
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
kernel/bpf/verifier.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 644ee9286ecf..05034cff89ca 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4384,10 +4384,12 @@ static int check_map_func_compatibility(struct bpf_verifier_env *env,
case BPF_FUNC_tail_call:
if (map->map_type != BPF_MAP_TYPE_PROG_ARRAY)
goto error;
+#if !defined(CONFIG_X86_64) || !defined(CONFIG_BPF_JIT_ALWAYS_ON)
if (env->subprog_cnt > 1) {
verbose(env, "tail_calls are not allowed in programs with bpf-to-bpf calls\n");
return -EINVAL;
}
+#endif
break;
case BPF_FUNC_perf_event_read:
case BPF_FUNC_perf_event_output:
@@ -10633,7 +10635,9 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
* the program array.
*/
prog->cb_access = 1;
+#if !defined(CONFIG_X86_64) || !defined(CONFIG_BPF_JIT_ALWAYS_ON)
env->prog->aux->stack_depth = MAX_BPF_STACK;
+#endif
env->prog->aux->max_pkt_offset = MAX_PACKET_OFF;
/* mark bpf_tail_call as different opcode to avoid
--
2.20.1
next parent reply other threads:[~2020-09-16 22:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200916211010.3685-1-maciej.fijalkowski@intel.com>
2020-09-16 21:10 ` Maciej Fijalkowski [this message]
2020-09-17 21:03 ` [PATCH v8 bpf-next 6/7] bpf: allow for tailcalls in BPF subprograms for x64 JIT Andrii Nakryiko
2020-09-17 22:44 ` Maciej Fijalkowski
2020-09-17 22:52 ` Alexei Starovoitov
2020-09-16 21:10 ` [PATCH v8 bpf-next 7/7] selftests: bpf: introduce tailcall_bpf2bpf test suite Maciej Fijalkowski
2020-09-18 3:26 ` [PATCH v8 bpf-next 0/7] bpf: tailcalls in BPF subprograms Alexei Starovoitov
2020-09-21 16:05 ` Maciej Fijalkowski
2020-09-23 16:11 ` Lorenz Bauer
2020-09-23 16:24 ` Andrii Nakryiko
2020-09-23 16:43 ` Lorenz Bauer
2020-09-23 16:55 ` Andrii Nakryiko
2020-09-23 18:41 ` Alexei Starovoitov
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=20200916211010.3685-7-maciej.fijalkowski@intel.com \
--to=maciej.fijalkowski@intel.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
/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