From: Jiong Wang <jiong.wang@netronome.com>
To: Luke Nelson <lukenels@cs.washington.edu>
Cc: linux-kernel@vger.kernel.org,
"Luke Nelson" <luke.r.nels@gmail.com>,
"Xi Wang" <xi.wang@gmail.com>,
"Palmer Dabbelt" <palmer@sifive.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"Björn Töpel" <bjorn.topel@gmail.com>,
linux-riscv@lists.infradead.org, netdev@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next] RV32G eBPF JIT
Date: Thu, 27 Jun 2019 13:18:35 +0100 [thread overview]
Message-ID: <87y31nuspw.fsf@netronome.com> (raw)
In-Reply-To: <20190626231257.14495-1-lukenels@cs.washington.edu>
Luke Nelson writes:
<snip>
> +
> +static int emit_insn(const struct bpf_insn *insn,
> + struct rv_jit_context *ctx,
> + bool extra_pass)
> +{
> + int rvoff, i = insn - ctx->prog->insnsi;
> + u8 code = insn->code;
> + s16 off = insn->off;
> + s32 imm = insn->imm;
> +
> + const s8 *dst = bpf2rv32[insn->dst_reg];
> + const s8 *src = bpf2rv32[insn->src_reg];
> + const s8 *tmp1 = bpf2rv32[TMP_REG_1];
> + const s8 *tmp2 = bpf2rv32[TMP_REG_2];
> +
> + switch (code) {
> + case BPF_ALU64 | BPF_MOV | BPF_X:
> + if (imm == 1) {
> + /* Special mov32 for zext */
> + emit_rv32_zext64(dst, ctx);
> + break;
> + }
Thanks for adding the 32-bit opt!
Just want to mention ZEXT is a special mov32, see include/linux/filter.h:
#define BPF_ZEXT_REG(DST)
((struct bpf_insn) {
.code = BPF_ALU | BPF_MOV | BPF_X
So it can't be BPF_ALU64. It is safe to remove this chunk of code.
For backend like arm, riscv etc, they are grouping several CASE label
together and are sharing code. imm == 1 check is done inside the shared
code to avoid moving code around given imm == 1 can't be true for ALU64 as
if there is such insn (register format using imm) it should have been
rejected by verifier. While mov32 variant is inserted by verifier at very
late stage after main verification finished.
Regards,
Jiong
next prev parent reply other threads:[~2019-06-27 12:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 23:12 [PATCH v2 bpf-next] RV32G eBPF JIT Luke Nelson
2019-06-27 12:18 ` Jiong Wang [this message]
2019-06-28 17:41 ` Luke Nelson
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=87y31nuspw.fsf@netronome.com \
--to=jiong.wang@netronome.com \
--cc=aou@eecs.berkeley.edu \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=luke.r.nels@gmail.com \
--cc=lukenels@cs.washington.edu \
--cc=netdev@vger.kernel.org \
--cc=palmer@sifive.com \
--cc=songliubraving@fb.com \
--cc=xi.wang@gmail.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).