Add RISC-V (RV64G) BPF JIT
Subsystems (7)
cover Add RISC-V (RV64G) BPF JIT
From: Björn Töpel <[email protected]>
Hi!
This series adds an RV64G BPF JIT to the kernel. I've sent out a RFC for a couple of weeks ago, and think this code is feature-complete/stable enough (famous last words) for a proper patch.
Unfortunately, kprobes isn't supported by RISC-V yet (Patrick Stählin sent out an RFC last year), which means that all tests involving BPF_PROG_TYPE_TRACEPOINT, BPF_PROG_TYPE_PERF_EVENT, BPF_PROG_TYPE_KPROBE and BPF_PROG_TYPE_RAW_TRACEPOINT will fail.
Further, the implementation does not support "far branching" (>4KiB).
The implementation passes all the test_bpf.ko tests: test_bpf:
Summary: 378 PASSED, 0 FAILED, [366/366 JIT'ed]
All the tail_call tests in the selftest/bpf/test_verifier program passes.
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.
Thanks for all the comments!
Cheers,
Björn
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 (3):
bpf, riscv: add BPF JIT for RV64G
MAINTAINERS: add RISC-V BPF JIT maintainer
bpf, doc: add RISC-V to filter.txt
Documentation/networking/filter.txt | 16 +- MAINTAINERS | 6 + arch/riscv/Kconfig | 1 + arch/riscv/Makefile | 2 +- arch/riscv/net/Makefile | 1 + arch/riscv/net/bpf_jit_comp.c | 1502 +++++++++++++++++++++++++++ 6 files changed, 1520 insertions(+), 8 deletions(-) create mode 100644 arch/riscv/net/Makefile create mode 100644 arch/riscv/net/bpf_jit_comp.c
Signature · 1 line
2.19.1
PATCH 1/3 bpf, riscv: add BPF JIT for RV64G
From: Björn Töpel <[email protected]>
This commit adds BPF JIT for RV64G.
The JIT is a two-pass JIT, and has a dynamic prolog/epilogue (similar to the MIPS64 BPF JIT) instead of static ones (e.g. x86_64).
At the moment the RISC-V Linux port does not support HAVE_KPROBES, which means that CONFIG_BPF_EVENTS is not supported. Thus, no tests involving BPF_PROG_TYPE_TRACEPOINT passes.
Further, the implementation does not support "far branching" (>4KiB).
The implementation passes all the test_bpf.ko tests:
test_bpf: Summary: 378 PASSED, 0 FAILED, [366/366 JIT'ed]
All the tail_call tests in the selftest/bpf/test_verifier program passes.
All tests where done on QEMU (QEMU emulator version 3.1.50 (v3.1.0-688-g8ae951fbc106)).
--- arch/riscv/Kconfig | 1 + arch/riscv/Makefile | 2 +- arch/riscv/net/Makefile | 1 + arch/riscv/net/bpf_jit_comp.c | 1502 +++++++++++++++++++++++++++++++++ 4 files changed, 1505 insertions(+), 1 deletion(-) create mode 100644 arch/riscv/net/Makefile create mode 100644 arch/riscv/net/bpf_jit_comp.c
arch/riscv/Kconfig +1 -0
@@ -49,6 +49,7 @@ config RISCV select RISCV_TIMER select GENERIC_IRQ_MULTI_HANDLER select ARCH_HAS_PTE_SPECIAL + select HAVE_EBPF_JIT if 64BIT config MMU def_bool y
arch/riscv/Makefile +1 -1
@@ -77,7 +77,7 @@ KBUILD_IMAGE := $(boot)/Image.gz head-y := arch/riscv/kernel/head.o -core-y += arch/riscv/kernel/ arch/riscv/mm/ +core-y += arch/riscv/kernel/ arch/riscv/mm/ arch/riscv/net/ libs-y += arch/riscv/lib/
arch/riscv/net/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o
arch/riscv/net/bpf_jit_comp.c new file +1502 -0
1,502 lines not on this page · raw message
Signature · 1 line
2.19.1
Re: [PATCH bpf-next 1/3] bpf, riscv: add BPF JIT for RV64G
From: [email protected]
Date: Sun, 3 Feb 2019 12:51:29 +0100
Quoted 16 lines
From: Björn Töpel <[email protected]>
This commit adds BPF JIT for RV64G.
The JIT is a two-pass JIT, and has a dynamic prolog/epilogue (similar to the MIPS64 BPF JIT) instead of static ones (e.g.
x86_64).At the moment the RISC-V Linux port does not support
HAVE_KPROBES, which means thatCONFIG_BPF_EVENTSis not supported. Thus, no tests involvingBPF_PROG_TYPE_TRACEPOINTpasses.Further, the implementation does not support "far branching" (>4KiB).
The implementation passes all the test_bpf.ko tests:
test_bpf: Summary: 378 PASSED, 0 FAILED, [366/366 JIT'ed]
Quoted 7 lines
All the
tail_calltests in the selftest/bpf/test_verifier program passes.All tests where done on QEMU (QEMU emulator version 3.1.50 (v3.1.0-688-g8ae951fbc106)).
Signed-off-by Björn Töpel <[email protected]>
Daniel Borkmann
maintainerRe: [PATCH bpf-next 1/3] bpf, riscv: add BPF JIT for RV64G
In reply to [email protected]Quoted 16 lines · On 02/03/2019 12:51 PM, [email protected] wrote:
From: Björn Töpel <[email protected]>
This commit adds BPF JIT for RV64G.
The JIT is a two-pass JIT, and has a dynamic prolog/epilogue (similar to the MIPS64 BPF JIT) instead of static ones (e.g.
x86_64).At the moment the RISC-V Linux port does not support
HAVE_KPROBES, which means thatCONFIG_BPF_EVENTSis not supported. Thus, no tests involvingBPF_PROG_TYPE_TRACEPOINTpasses.Further, the implementation does not support "far branching" (>4KiB).
The implementation passes all the test_bpf.ko tests:
test_bpf: Summary: 378 PASSED, 0 FAILED, [366/366 JIT'ed]
Quoted 7 lines
All the
tail_calltests in the selftest/bpf/test_verifier program passes.All tests where done on QEMU (QEMU emulator version 3.1.50 (v3.1.0-688-g8ae951fbc106)).
Signed-off-by Björn Töpel <[email protected]>
Some minor comments:
Looks like all the BPF_JMP32 instructions are missing. Would probably make sense to include these into the initial merge as well unless there is some good reason not to; presumably the test_verifier parts with BPF_JMP32 haven't been tried out?
[...]
Quoted 58 lines
arch/riscv/net/bpf_jit_comp.c new file +58
-0+ +enum { +RV_CTX_F_SEEN_TAIL_CALL =0 , +RV_CTX_F_SEEN_CALL =RV_REG_RA , +RV_CTX_F_SEEN_S1 =RV_REG_S1 , +RV_CTX_F_SEEN_S2 =RV_REG_S2 , +RV_CTX_F_SEEN_S3 =RV_REG_S3 , +RV_CTX_F_SEEN_S4 =RV_REG_S4 , +RV_CTX_F_SEEN_S5 =RV_REG_S5 , +RV_CTX_F_SEEN_S6 =RV_REG_S6 , +}; + +struct rv_jit_context { +struct bpf_prog *prog; +u32 *insns;/* RV insns */ +int ninsns; +int epilogue_offset; +int *offset;/* BPF to RV */ +unsigned long flags; +int stack_size; +}; + +struct rv_jit_data { +struct bpf_binary_header *header; +u8 *image; +struct rv_jit_context ctx; +}; + +static u8 bpf_to_rv_reg (int bpf_reg,struct rv_jit_context *ctx) +{ +u8 reg = regmap[bpf_reg]; + +switch (reg) { +case RV_CTX_F_SEEN_S1 : +case RV_CTX_F_SEEN_S2 : +case RV_CTX_F_SEEN_S3 : +case RV_CTX_F_SEEN_S4 : +case RV_CTX_F_SEEN_S5 : +case RV_CTX_F_SEEN_S6 : +__set_bit (reg, &ctx->flags); + } +return reg; +}; + +static bool seen_reg (int reg,struct rv_jit_context *ctx) +{ +switch (reg) { +case RV_CTX_F_SEEN_CALL : +case RV_CTX_F_SEEN_S1 : +case RV_CTX_F_SEEN_S2 : +case RV_CTX_F_SEEN_S3 : +case RV_CTX_F_SEEN_S4 : +case RV_CTX_F_SEEN_S5 : +case RV_CTX_F_SEEN_S6 : +return test_bit (reg, &ctx->flags); + } +return false; +}
arch/riscv/net/bpf_jit_comp.c line 131
Quoted 10 lines
arch/riscv/net/bpf_jit_comp.c new file +10
-0+ +static void mark_call (struct rv_jit_context *ctx) +{ +__set_bit (RV_CTX_F_SEEN_CALL , &ctx->flags); +} + +static bool seen_call (struct rv_jit_context *ctx) +{ +return seen_reg (RV_REG_RA , ctx); +}
Just nit: probably might be more obvious to remove this asymmetry in seen_reg() and do __set_bit()/test_bit() for RV_CTX_F_SEEN_CALL similar like below.
Quoted 31 lines
arch/riscv/net/bpf_jit_comp.c new file +31
-0+static void mark_tail_call (struct rv_jit_context *ctx) +{ +__set_bit (RV_CTX_F_SEEN_TAIL_CALL , &ctx->flags); +} + +static bool seen_tail_call (struct rv_jit_context *ctx) +{ +return test_bit (RV_CTX_F_SEEN_TAIL_CALL , &ctx->flags); +} + +static u8 rv_tail_call_reg (struct rv_jit_context *ctx) +{ +mark_tail_call (ctx); + +if (seen_call (ctx)) { +__set_bit (RV_CTX_F_SEEN_S6 , &ctx->flags); +return RV_REG_S6 ; + } +return RV_REG_A6 ; +} + +static void emit (const u32 insn,struct rv_jit_context *ctx) +{ +if (ctx->insns) + ctx->insns[ctx->ninsns] = insn; + + ctx->ninsns++; +} + +static u32 rv_r_insn (u8 funct7,u8 rs2,u8 rs1,u8 funct3,u8 rd,u8 opcode) +{
[...]
Quoted 21 lines
arch/riscv/net/bpf_jit_comp.c new file +21
-0+/* Allocate image, now that we know the size. */ + image_size =sizeof (u32) * ctx->ninsns; + jit_data->header =bpf_jit_binary_alloc (image_size, &jit_data->image, +sizeof (u32), + bpf_fill_ill_insns); +if (!jit_data->header) { + prog = orig_prog; + goto out_offset; + } + +/* Second, real pass, that acutally emits the image. */ + ctx->insns = (u32 *)jit_data->image; +skip_init_ctx: + ctx->ninsns =0 ; + +build_prologue (ctx); +if (build_body (ctx, extra_pass)) { +bpf_jit_binary_free (jit_data->header); + prog = orig_prog; + goto out_offset; + }
arch/riscv/net/bpf_jit_comp.c line 1489
Quoted 10 lines
arch/riscv/net/bpf_jit_comp.c new file +10
-0+build_epilogue (ctx); + +if (bpf_jit_enable >1 ) +bpf_jit_dump (prog->len, image_size,2 , ctx->insns); + + prog->bpf_func = (void *)ctx->insns; + prog->jited =1 ; + prog->jited_len = image_size; + +bpf_flush_icache (jit_data->header, (u8 *)ctx->insns + ctx->ninsns);
Shouldn't this be '(u32 *)ctx->insns + ctx->ninsns' to cover the range?
Quoted 14 lines
arch/riscv/net/bpf_jit_comp.c new file +13
-0+ +if (!prog->is_func || extra_pass) { +out_offset: +kfree (ctx->offset); +kfree (jit_data); + prog->aux->jit_data =NULL ; + } +out: +if (tmp_blinded) +bpf_jit_prog_release_other (prog, prog == orig_prog ? + tmp : orig_prog); +return prog; +}
Re: [PATCH bpf-next 1/3] bpf, riscv: add BPF JIT for RV64G
Den mån 4 feb. 2019 kl 21:06 skrev Daniel Borkmann <[email protected]>:
Quoted 24 lines · On 02/03/2019 12:51 PM, [email protected] wrote:
Quoted 22 lines
From: Björn Töpel <[email protected]>
This commit adds BPF JIT for RV64G.
The JIT is a two-pass JIT, and has a dynamic prolog/epilogue (similar to the MIPS64 BPF JIT) instead of static ones (e.g.
x86_64).At the moment the RISC-V Linux port does not support
HAVE_KPROBES, which means thatCONFIG_BPF_EVENTSis not supported. Thus, no tests involvingBPF_PROG_TYPE_TRACEPOINTpasses.Further, the implementation does not support "far branching" (>4KiB).
The implementation passes all the test_bpf.ko tests:
test_bpf: Summary: 378 PASSED, 0 FAILED, [366/366 JIT'ed]All the
tail_calltests in the selftest/bpf/test_verifier program passes.All tests where done on QEMU (QEMU emulator version 3.1.50 (v3.1.0-688-g8ae951fbc106)).
Quoted 9 lines
Quoted 1 line
Signed-off-by Björn Töpel <[email protected]>Some minor comments:
Looks like all the
BPF_JMP32instructions are missing. Would probably make sense to include these into the initial merge as well unless there is some good reason not to; presumably thetest_verifierparts withBPF_JMP32haven't been tried out?
Yes indeed. My bad, I didn't realize that Jiong's patches were in the tree! BPF_JMP32 should definitely be in the initial merge.
Quoted 65 lines
[...]
Quoted 64 lines
arch/riscv/net/bpf_jit_comp.c new file +64
-0+ +enum { +RV_CTX_F_SEEN_TAIL_CALL =0 , +RV_CTX_F_SEEN_CALL =RV_REG_RA , +RV_CTX_F_SEEN_S1 =RV_REG_S1 , +RV_CTX_F_SEEN_S2 =RV_REG_S2 , +RV_CTX_F_SEEN_S3 =RV_REG_S3 , +RV_CTX_F_SEEN_S4 =RV_REG_S4 , +RV_CTX_F_SEEN_S5 =RV_REG_S5 , +RV_CTX_F_SEEN_S6 =RV_REG_S6 , +}; + +struct rv_jit_context { +struct bpf_prog *prog; +u32 *insns;/* RV insns */ +int ninsns; +int epilogue_offset; +int *offset;/* BPF to RV */ +unsigned long flags; +int stack_size; +}; + +struct rv_jit_data { +struct bpf_binary_header *header; +u8 *image; +struct rv_jit_context ctx; +}; + +static u8 bpf_to_rv_reg (int bpf_reg,struct rv_jit_context *ctx) +{ +u8 reg = regmap[bpf_reg]; + +switch (reg) { +case RV_CTX_F_SEEN_S1 : +case RV_CTX_F_SEEN_S2 : +case RV_CTX_F_SEEN_S3 : +case RV_CTX_F_SEEN_S4 : +case RV_CTX_F_SEEN_S5 : +case RV_CTX_F_SEEN_S6 : +__set_bit (reg, &ctx->flags); + } +return reg; +}; + +static bool seen_reg (int reg,struct rv_jit_context *ctx) +{ +switch (reg) { +case RV_CTX_F_SEEN_CALL : +case RV_CTX_F_SEEN_S1 : +case RV_CTX_F_SEEN_S2 : +case RV_CTX_F_SEEN_S3 : +case RV_CTX_F_SEEN_S4 : +case RV_CTX_F_SEEN_S5 : +case RV_CTX_F_SEEN_S6 : +return test_bit (reg, &ctx->flags); + } +return false; +} + +static void mark_call (struct rv_jit_context *ctx) +{ +__set_bit (RV_CTX_F_SEEN_CALL , &ctx->flags); +} +
Quoted 9 lines
arch/riscv/net/bpf_jit_comp.c line 131
Quoted 4 lines
arch/riscv/net/bpf_jit_comp.c new file +4
-0+static bool seen_call (struct rv_jit_context *ctx) +{ +return seen_reg (RV_REG_RA , ctx); +}Just nit: probably might be more obvious to remove this asymmetry in
seen_reg()and do __set_bit()/test_bit() forRV_CTX_F_SEEN_CALLsimilar like below.
Yeah, let's do that.
Quoted 57 lines
Quoted 31 lines
arch/riscv/net/bpf_jit_comp.c new file +31
-0+static void mark_tail_call (struct rv_jit_context *ctx) +{ +__set_bit (RV_CTX_F_SEEN_TAIL_CALL , &ctx->flags); +} + +static bool seen_tail_call (struct rv_jit_context *ctx) +{ +return test_bit (RV_CTX_F_SEEN_TAIL_CALL , &ctx->flags); +} + +static u8 rv_tail_call_reg (struct rv_jit_context *ctx) +{ +mark_tail_call (ctx); + +if (seen_call (ctx)) { +__set_bit (RV_CTX_F_SEEN_S6 , &ctx->flags); +return RV_REG_S6 ; + } +return RV_REG_A6 ; +} + +static void emit (const u32 insn,struct rv_jit_context *ctx) +{ +if (ctx->insns) + ctx->insns[ctx->ninsns] = insn; + + ctx->ninsns++; +} + +static u32 rv_r_insn (u8 funct7,u8 rs2,u8 rs1,u8 funct3,u8 rd,u8 opcode) +{[...]
Quoted 25 lines
arch/riscv/net/bpf_jit_comp.c new file +25
-0+/* Allocate image, now that we know the size. */ + image_size =sizeof (u32) * ctx->ninsns; + jit_data->header =bpf_jit_binary_alloc (image_size, &jit_data->image, +sizeof (u32), + bpf_fill_ill_insns); +if (!jit_data->header) { + prog = orig_prog; + goto out_offset; + } + +/* Second, real pass, that acutally emits the image. */ + ctx->insns = (u32 *)jit_data->image; +skip_init_ctx: + ctx->ninsns =0 ; + +build_prologue (ctx); +if (build_body (ctx, extra_pass)) { +bpf_jit_binary_free (jit_data->header); + prog = orig_prog; + goto out_offset; + } +build_epilogue (ctx); + +if (bpf_jit_enable >1 ) +bpf_jit_dump (prog->len, image_size,2 , ctx->insns);
Quoted 9 lines
arch/riscv/net/bpf_jit_comp.c line 1489
Quoted 6 lines
arch/riscv/net/bpf_jit_comp.c new file +6
-0+ + prog->bpf_func = (void *)ctx->insns; + prog->jited =1 ; + prog->jited_len = image_size; + +bpf_flush_icache (jit_data->header, (u8 *)ctx->insns + ctx->ninsns);Shouldn't this be '(u32 *)ctx->insns +
ctx->ninsns' to cover the range?
Yikes! Indeed so, I'll make sure this is corrected!
Thanks for the comments!
Björn
Quoted 15 lines
Quoted 14 lines
arch/riscv/net/bpf_jit_comp.c new file +13
-0+ +if (!prog->is_func || extra_pass) { +out_offset: +kfree (ctx->offset); +kfree (jit_data); + prog->aux->jit_data =NULL ; + } +out: +if (tmp_blinded) +bpf_jit_prog_release_other (prog, prog == orig_prog ? + tmp : orig_prog); +return prog; +}
PATCH 2/3 MAINTAINERS: add RISC-V BPF JIT maintainer
In reply to [email protected]From: Björn Töpel <[email protected]>
Add Björn Töpel as RISC-V BPF JIT maintainer.
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -2907,6 +2907,12 @@ L: [email protected] S: Maintained F: arch/powerpc/net/ +BPF JIT for RISC-V (RV64G) +M: Björn Töpel <[email protected]> +L: [email protected] +S: Maintained +F: arch/riscv/net/ + BPF JIT for S390 M: Martin Schwidefsky <[email protected]> M: Heiko Carstens <[email protected]>
Signature · 1 line
2.19.1
Re: [PATCH bpf-next 2/3] MAINTAINERS: add RISC-V BPF JIT maintainer
From: [email protected]
Date: Sun, 3 Feb 2019 12:51:30 +0100
Quoted 5 lines
From: Björn Töpel <[email protected]>
Add Björn Töpel as RISC-V BPF JIT maintainer.
Signed-off-by Björn Töpel <[email protected]>
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH 3/3 bpf, doc: add RISC-V to filter.txt
In reply to [email protected]From: Björn Töpel <[email protected]>
Update Documentation/networking/filter.txt to mention RISC-V.
--- Documentation/networking/filter.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
Documentation/networking/filter.txt +9 -7
@@ -464,10 +464,11 @@ breakpoints: 0 1 JIT compiler ------------ -The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, PowerPC, -ARM, ARM64, MIPS and s390 and can be enabled through CONFIG_BPF_JIT. The JIT -compiler is transparently invoked for each attached filter from user space -or for internal kernel users if it has been previously enabled by root: +The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, +PowerPC, ARM, ARM64, MIPS, RISC-V and s390 and can be enabled through +CONFIG_BPF_JIT. The JIT compiler is transparently invoked for each +attached filter from user space or for internal kernel users if it has +been previously enabled by root: echo 1 > /proc/sys/net/core/bpf_jit_enable
@@ -603,9 +604,10 @@ got from bpf_prog_create(), and 'ctx' the given context (e.g. skb pointer). All constraints and restrictions from bpf_check_classic() apply before a conversion to the new layout is being done behind the scenes! -Currently, the classic BPF format is being used for JITing on most 32-bit -architectures, whereas x86-64, aarch64, s390x, powerpc64, sparc64, arm32 perform -JIT compilation from eBPF instruction set. +Currently, the classic BPF format is being used for JITing on most +32-bit architectures, whereas x86-64, aarch64, s390x, powerpc64, +sparc64, arm32, riscv (RV64G) perform JIT compilation from eBPF +instruction set. Some core changes of the new internal format:
Signature · 1 line
2.19.1
Re: [PATCH bpf-next 3/3] bpf, doc: add RISC-V to filter.txt
From: [email protected]
Date: Sun, 3 Feb 2019 12:51:31 +0100
Quoted 5 lines
From: Björn Töpel <[email protected]>
Update
Documentation/networking/filter.txtto mention RISC-V.Signed-off-by Björn Töpel <[email protected]>
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Daniel Borkmann
maintainerRe: [PATCH bpf-next 3/3] bpf, doc: add RISC-V to filter.txt
In reply to [email protected]Quoted 5 lines · On 02/03/2019 12:51 PM, [email protected] wrote:
From: Björn Töpel <[email protected]>
Update
Documentation/networking/filter.txtto mention RISC-V.Signed-off-by Björn Töpel <[email protected]>
Nit: in Documentation/sysctl/net.txt under bpf_jit_enable there is also a concrete list of eBPF/cBPF JITs, would be good to add riscv64 there as well.
Quoted 38 lines
Documentation/networking/filter.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)Documentation/networking/filter.txt +9
-7@@ -464,10 +464,11 @@ breakpoints: 0 1 JIT compiler ------------ -The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, PowerPC, -ARM, ARM64, MIPS and s390 and can be enabled through CONFIG_BPF_JIT. The JIT -compiler is transparently invoked for each attached filter from user space -or for internal kernel users if it has been previously enabled by root: +The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, +PowerPC, ARM, ARM64, MIPS, RISC-V and s390 and can be enabled through +CONFIG_BPF_JIT. The JIT compiler is transparently invoked for each +attached filter from user space or for internal kernel users if it has +been previously enabled by root: echo 1 > /proc/sys/net/core/bpf_jit_enable@@ -603,9 +604,10 @@ got from bpf_prog_create(), and 'ctx' the given context (e.g. skb pointer). All constraints and restrictions from bpf_check_classic() apply before a conversion to the new layout is being done behind the scenes! -Currently, the classic BPF format is being used for JITing on most 32-bit -architectures, whereas x86-64, aarch64, s390x, powerpc64, sparc64, arm32 perform -JIT compilation from eBPF instruction set. +Currently, the classic BPF format is being used for JITing on most +32-bit architectures, whereas x86-64, aarch64, s390x, powerpc64, +sparc64, arm32, riscv (RV64G) perform JIT compilation from eBPF +instruction set. Some core changes of the new internal format:
Re: [PATCH bpf-next 3/3] bpf, doc: add RISC-V to filter.txt
Den mån 4 feb. 2019 kl 21:09 skrev Daniel Borkmann <[email protected]>:
Quoted 12 lines · On 02/03/2019 12:51 PM, [email protected] wrote:
Quoted 5 lines
From: Björn Töpel <[email protected]>
Update
Documentation/networking/filter.txtto mention RISC-V.Signed-off-by Björn Töpel <[email protected]>Nit: in
Documentation/sysctl/net.txtunderbpf_jit_enablethere is also a concrete list of eBPF/cBPF JITs, would be good to add riscv64 there as well.
Thanks for pointing this out! I'll do a v2.
Björn
Quoted 39 lines
Quoted 38 lines
Documentation/networking/filter.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)Documentation/networking/filter.txt +9
-7@@ -464,10 +464,11 @@ breakpoints: 0 1 JIT compiler ------------ -The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, PowerPC, -ARM, ARM64, MIPS and s390 and can be enabled through CONFIG_BPF_JIT. The JIT -compiler is transparently invoked for each attached filter from user space -or for internal kernel users if it has been previously enabled by root: +The Linux kernel has a built-in BPF JIT compiler for x86_64, SPARC, +PowerPC, ARM, ARM64, MIPS, RISC-V and s390 and can be enabled through +CONFIG_BPF_JIT. The JIT compiler is transparently invoked for each +attached filter from user space or for internal kernel users if it has +been previously enabled by root: echo 1 > /proc/sys/net/core/bpf_jit_enable@@ -603,9 +604,10 @@ got from bpf_prog_create(), and 'ctx' the given context (e.g. skb pointer). All constraints and restrictions from bpf_check_classic() apply before a conversion to the new layout is being done behind the scenes! -Currently, the classic BPF format is being used for JITing on most 32-bit -architectures, whereas x86-64, aarch64, s390x, powerpc64, sparc64, arm32 perform -JIT compilation from eBPF instruction set. +Currently, the classic BPF format is being used for JITing on most +32-bit architectures, whereas x86-64, aarch64, s390x, powerpc64, +sparc64, arm32, riscv (RV64G) perform JIT compilation from eBPF +instruction set. Some core changes of the new internal format: