linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: bjorn.topel@gmail.com
To: linux-riscv@lists.infradead.org, daniel@iogearbox.net,
	ast@kernel.org, netdev@vger.kernel.org
Cc: hch@infradead.org, "Björn Töpel" <bjorn.topel@gmail.com>,
	palmer@sifive.com
Subject: [PATCH bpf-next v2 0/4] Add RISC-V (RV64G) BPF JIT
Date: Tue,  5 Feb 2019 13:41:21 +0100	[thread overview]
Message-ID: <20190205124125.5553-1-bjorn.topel@gmail.com> (raw)

From: Björn Töpel <bjorn.topel@gmail.com>

Hi!

This v2 series adds an RV64G BPF JIT to the kernel.

At the moment the RISC-V Linux port does not support
CONFIG_HAVE_KPROBES (Patrick Stählin sent out an RFC last year), which
means that CONFIG_BPF_EVENTS is not supported. Thus, no tests
involving BPF_PROG_TYPE_TRACEPOINT, BPF_PROG_TYPE_PERF_EVENT,
BPF_PROG_TYPE_KPROBE and BPF_PROG_TYPE_RAW_TRACEPOINT passes.

The implementation does not support "far branching" (>4KiB).

Test results:
  # modprobe test_bpf
  test_bpf: Summary: 378 PASSED, 0 FAILED, [366/366 JIT'ed]

  # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled
  # ./test_verifier
  ...
  Summary: 761 PASSED, 507 SKIPPED, 2 FAILED

Note that "test_verifier" was run with one build with
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y and one without, otherwise
many of the the tests that require unaligned access were skipped.

CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y:
  # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled
  # ./test_verifier | grep -c 'NOTE.*unknown align'
  0

No CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS:
  # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled
  # ./test_verifier | grep -c 'NOTE.*unknown align'
  59

The two failing test_verifier tests are:
  "ld_abs: vlan + abs, test 1"
  "ld_abs: jump around ld_abs"

This is due to that "far branching" involved in those tests.
All tests where done on QEMU emulator version 3.1.50
(v3.1.0-688-g8ae951fbc106). I'll test it on real hardware, when I get
access to it.

I'm routing this patch via bpf-next/netdev mailing list (after a
conversation with Palmer at FOSDEM), mainly because the other JITs
went that path.

Again, thanks for all the comments!

Cheers,
Björn

v1 -> v2:
* Added JMP32 support. (Daniel)
* Add RISC-V to Documentation/sysctl/net.txt. (Daniel)
* Fixed seen_call() asymmetry. (Daniel)
* Fixed broken bpf_flush_icache() range. (Daniel)
* Added alignment annotations to some selftests.

RFCv1 -> v1:
* Cleaned up the Kconfig and net/Makefile. (Christoph)
* Removed the entry-stub and squashed the build/config changes to be
  part of the JIT implementation. (Christoph)
* Simplified the register tracking code. (Daniel)
* Removed unused macros. (Daniel)
* Added myself as maintainer and updated documentation. (Daniel)
* Removed HAVE_EFFICIENT_UNALIGNED_ACCESS. (Christoph, Palmer)
* Added tail-calls and cleaned up the code.


Björn Töpel (4):
  bpf, riscv: add BPF JIT for RV64G
  MAINTAINERS: add RISC-V BPF JIT maintainer
  bpf, doc: add RISC-V JIT to BPF documentation
  selftests/bpf: add "any alignment" annotation for some tests

 Documentation/networking/filter.txt           |   16 +-
 Documentation/sysctl/net.txt                  |    1 +
 MAINTAINERS                                   |    6 +
 arch/riscv/Kconfig                            |    1 +
 arch/riscv/Makefile                           |    2 +-
 arch/riscv/net/Makefile                       |    1 +
 arch/riscv/net/bpf_jit_comp.c                 | 1602 +++++++++++++++++
 .../selftests/bpf/verifier/ctx_sk_msg.c       |    1 +
 .../testing/selftests/bpf/verifier/ctx_skb.c  |    1 +
 tools/testing/selftests/bpf/verifier/jmp32.c  |   22 +
 tools/testing/selftests/bpf/verifier/jset.c   |    2 +
 .../selftests/bpf/verifier/spill_fill.c       |    1 +
 .../selftests/bpf/verifier/spin_lock.c        |    2 +
 .../selftests/bpf/verifier/value_ptr_arith.c  |    4 +
 14 files changed, 1654 insertions(+), 8 deletions(-)
 create mode 100644 arch/riscv/net/Makefile
 create mode 100644 arch/riscv/net/bpf_jit_comp.c

-- 
2.19.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2019-02-05 12:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 12:41 bjorn.topel [this message]
2019-02-05 12:41 ` [PATCH bpf-next v2 1/4] bpf, riscv: add BPF JIT for RV64G bjorn.topel
2019-02-05 12:41 ` [PATCH bpf-next v2 2/4] MAINTAINERS: add RISC-V BPF JIT maintainer bjorn.topel
2019-02-05 12:41 ` [PATCH bpf-next v2 3/4] bpf, doc: add RISC-V JIT to BPF documentation bjorn.topel
2019-02-05 12:41 ` [PATCH bpf-next v2 4/4] selftests/bpf: add "any alignment" annotation for some tests bjorn.topel
2019-02-05 16:05 ` [PATCH bpf-next v2 0/4] Add RISC-V (RV64G) BPF JIT Daniel Borkmann

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=20190205124125.5553-1-bjorn.topel@gmail.com \
    --to=bjorn.topel@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hch@infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=palmer@sifive.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).