From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: alexei.starovoitov@gmail.com, daniel@iogearbox.net
Cc: yhs@fb.com, netdev@vger.kernel.org, oss-drivers@netronome.com,
kafai@fb.com, Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH bpf-next v5 06/12] bpf: verifier: record original instruction index
Date: Tue, 22 Jan 2019 22:45:23 -0800 [thread overview]
Message-ID: <20190123064529.13518-7-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20190123064529.13518-1-jakub.kicinski@netronome.com>
The communication between the verifier and advanced JITs is based
on instruction indexes. We have to keep them stable throughout
the optimizations otherwise referring to a particular instruction
gets messy quickly.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
include/linux/bpf_verifier.h | 1 +
kernel/bpf/verifier.c | 8 +++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 573cca00a0e6..f3ae00ee5516 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -187,6 +187,7 @@ struct bpf_insn_aux_data {
int sanitize_stack_off; /* stack slot to be cleared */
bool seen; /* this insn was processed by the verifier */
u8 alu_state; /* used in combination with alu_limit */
+ unsigned int orig_idx; /* original instruction index */
};
#define MAX_USED_MAPS 64 /* max number of maps accessed by one eBPF program */
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index f39bca188a5c..f2c49b4235df 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7371,7 +7371,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr,
{
struct bpf_verifier_env *env;
struct bpf_verifier_log *log;
- int ret = -EINVAL;
+ int i, len, ret = -EINVAL;
bool is_priv;
/* no program is valid */
@@ -7386,12 +7386,14 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr,
return -ENOMEM;
log = &env->log;
+ len = (*prog)->len;
env->insn_aux_data =
- vzalloc(array_size(sizeof(struct bpf_insn_aux_data),
- (*prog)->len));
+ vzalloc(array_size(sizeof(struct bpf_insn_aux_data), len));
ret = -ENOMEM;
if (!env->insn_aux_data)
goto err_free_env;
+ for (i = 0; i < len; i++)
+ env->insn_aux_data[i].orig_idx = i;
env->prog = *prog;
env->ops = bpf_verifier_ops[env->prog->type];
--
2.19.2
next prev parent reply other threads:[~2019-01-23 6:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-23 6:45 [PATCH bpf-next v5 00/12] bpf: dead code elimination Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 01/12] bpf: change parameters of call/branch offset adjustment Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 02/12] bpf: verifier: hard wire branches to dead code Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 03/12] bpf: verifier: remove " Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 04/12] bpf: verifier: remove unconditional branches by 0 Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 05/12] selftests: bpf: add tests for dead code removal Jakub Kicinski
2019-01-23 6:45 ` Jakub Kicinski [this message]
2019-01-23 6:45 ` [PATCH bpf-next v5 07/12] bpf: notify offload JITs about optimizations Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 08/12] nfp: bpf: don't use instruction number for jump target Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 09/12] nfp: bpf: split up the skip flag Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 10/12] nfp: bpf: save original program length Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 11/12] nfp: bpf: support optimizing dead branches Jakub Kicinski
2019-01-23 6:45 ` [PATCH bpf-next v5 12/12] nfp: bpf: support removing dead code Jakub Kicinski
2019-01-24 1:42 ` [PATCH bpf-next v5 00/12] bpf: dead code elimination Alexei Starovoitov
-- strict thread matches above, loose matches on Subject: below --
2019-01-19 18:06 [PATCH bpf-next v4 " Jakub Kicinski
2019-01-19 18:06 ` [PATCH bpf-next v5 06/12] bpf: verifier: record original instruction index Jakub Kicinski
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=20190123064529.13518-7-jakub.kicinski@netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.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