From: Gary Lin <glin@suse.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
andreas.taschner@suse.com
Subject: Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily
Date: Mon, 14 Dec 2020 13:12:12 +0800 [thread overview]
Message-ID: <X9b0LHBvj4UDGIwe@GaryWorkstation> (raw)
In-Reply-To: <CAADnVQKr9XYS3ijsiFiEH3sUAx-HjqkzybSZ379SLkyiXBkNhQ@mail.gmail.com>
On Fri, Dec 11, 2020 at 06:24:47PM -0800, Alexei Starovoitov wrote:
> On Fri, Dec 11, 2020 at 1:13 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
> > >> + }
> > >> emit_jmp:
> > >> if (is_imm8(jmp_offset)) {
> > >> + if (jmp_padding)
> > >> + cnt += emit_nops(&prog, INSN_SZ_DIFF - 2);
>
> Could you describe all possible numbers of bytes in padding?
> Is it 0, 2, 4 ?
> Would be good to add warn_on_once to make sure the number
> of nops is expected.
>
For the conditional jumps, it could be 0 or 4. As for nop jumps, it may be
0, 2, or 5. For the pure jumps, 0 or 3. Will add the warning in the next
version.
> > >> struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
> > >> {
> > >> struct bpf_binary_header *header = NULL;
> > >> @@ -1981,6 +1997,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
> > >> struct jit_context ctx = {};
> > >> bool tmp_blinded = false;
> > >> bool extra_pass = false;
> > >> + bool padding = prog->padded;
> > >
> > > can this ever be true on assignment? I.e., can the program be jitted twice?
> >
> > Yes, progs can be passed into the JIT twice, see also jit_subprogs(). In one of
> > the earlier patches it would still potentially change the image size a second
> > time which would break subprogs aka bpf2bpf calls.
>
> Right. I think memorized padded flag shouldn't be in sticky bits
> of the prog structure.
> It's only needed between the last pass and extra pass for bpf2bpf calls.
> I think it would be cleaner to keep it in struct x64_jit_data *jit_data.
>
Okay, jit_data is surely a better place for the flag.
> As others have said the selftests are must have.
> Especially for bpf2bpf calls where one subprog is padded.
>
Will try to craft some test cases for this patch in v2.
Gary Lin
next prev parent reply other threads:[~2020-12-14 5:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 8:19 [PATCH] bpf,x64: pad NOPs to make images converge more easily Gary Lin
2020-12-11 20:05 ` Daniel Borkmann
2020-12-14 3:56 ` Gary Lin
2020-12-14 8:15 ` Gary Lin
2020-12-14 15:31 ` Daniel Borkmann
2020-12-15 1:50 ` Gary Lin
2020-12-11 20:58 ` Andrii Nakryiko
2020-12-11 21:13 ` Daniel Borkmann
2020-12-12 2:24 ` Alexei Starovoitov
2020-12-14 5:12 ` Gary Lin [this message]
2020-12-14 3:51 ` Gary Lin
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=X9b0LHBvj4UDGIwe@GaryWorkstation \
--to=glin@suse.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andreas.taschner@suse.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eric.dumazet@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.