Skip to contentSkip to conversation

eBPF JIT for RV32G

PATCH Superseded Luke Nelson 4 participants 18 messages Mar 3, 2020 – Mar 4, 2020

Subsystems (7)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover eBPF JIT for RV32G

This series adds an eBPF JIT for 32-bit RISC-V (RV32G) to the kernel, adapted from the RV64 JIT and the 32-bit ARM JIT.

There are two main changes required for this to work compared to the RV64 JIT.

First, eBPF registers are 64-bit, while RV32G registers are 32-bit. BPF registers either map directly to 2 RISC-V registers, or reside in stack scratch space and are saved and restored when used.

Second, many 64-bit ALU operations do not trivially map to 32-bit operations. Operations that move bits between high and low words, such as ADD, LSH, MUL, and others must emulate the 64-bit behavior in terms of 32-bit instructions.

Supported features:

The RV32 JIT supports the same features and instructions as the RV64 JIT, with the following exceptions:

- ALU64 DIV/MOD: Requires loops to implement on 32-bit hardware.

- BPF_XADD | BPF_DW: There's no 8-byte atomic instruction in RV32.

These features are also unsupported on other BPF JITs for 32-bit architectures.

Testing:

- lib/test_bpf.c
test_bpf: Summary: 378 PASSED, 0 FAILED, [349/366 JIT'ed]
test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED

- tools/testing/selftests/bpf/test_verifier.c
Summary: 1415 PASSED, 122 SKIPPED, 43 FAILED

Tested both with and without BPF JIT hardening.

This is the same set of tests that pass using the BPF interpreter with the JIT disabled.

Running the BPF kernel tests / selftests on riscv32 is non-trivial, to help others reproduce the test results I made a guide here:
https://github.com/lukenels/meta-linux-utils/tree/master/rv32-linux

Verification and synthesis:

We developed the RV32 JIT using our automated verification tool, Serval. We have used Serval in the past to verify patches to the RV64 JIT. We also used Serval to superoptimize the resulting code through program synthesis.

You can find the tool and a guide to the approach and results here:
https://github.com/uw-unsat/serval-bpf/tree/rv32-jit-v4

Thanks again for all the comments!

Changelog:

v3 -> v4:
* Added more comments and cleaned up style nits (Björn Töpel).
* Factored common code in RV64 and RV32 JITs into a separate header (Song Liu, Björn Töpel).
* Added an optimization in the BPF_ALU64 BPF_ADD BPF_X case.
* Updated MAINTAINERS and kernel documentation (Björn Töpel).

v2 -> v3:
* Added support for far jumps / branches similar to RV64 JIT.
* Added support for tail calls.
* Cleaned up code with more optimizations and comments.
* Removed special zero-extension instruction from BPF_ALU64 case (Jiong Wang).

v1 -> v2:
* Added support for far conditional branches.
* Added the zero-extension optimization (Jiong Wang).
* Added more optimizations for operations with an immediate operand.

Luke Nelson (4):
riscv, bpf: move common riscv JIT code to header riscv, bpf: add RV32G eBPF JIT
bpf, doc: add BPF JIT for RV32G to BPF documentation
MAINTAINERS: Add entry for RV32G BPF JIT

 Documentation/admin-guide/sysctl/net.rst |    3 +-
 Documentation/networking/filter.txt      |    2 +-
 MAINTAINERS                              |   13 +-
 arch/riscv/Kconfig                       |    2 +-
 arch/riscv/net/Makefile                  |    7 +-
 arch/riscv/net/bpf_jit.h                 |  504 ++++++++
 arch/riscv/net/bpf_jit_comp.c            |  443 +------
 arch/riscv/net/bpf_jit_comp32.c          | 1466 ++++++++++++++++++++++
 8 files changed, 1992 insertions(+), 448 deletions(-)
 create mode 100644 arch/riscv/net/bpf_jit.h
 create mode 100644 arch/riscv/net/bpf_jit_comp32.c
Cc Jonathan Corbet <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Song Liu <[email protected]>
Cc Yonghong Song <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Albert Ou <[email protected]>
Cc "Björn Töpel" <[email protected]>
Cc Luke Nelson <[email protected]>
Cc Xi Wang <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Rob Herring <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Andy Shevchenko <[email protected]>
Signature · 1 line
2.20.1
#1 lore raw

PATCH v4 1/4 riscv, bpf: move common riscv JIT code to header

This patch factors out code that can be used by both the RV64 and RV32 JITs to a common header.

Rename rv_sb_insn/rv_uj_insn to rv_b_insn/rv_j_insn to match the RISC-V specification.

---
We could put more code into a shared .c file in the future (e.g., build_body). It seems to make sense right now to first factor common data structures and helper functions into a header.

---
 arch/riscv/net/bpf_jit.h      | 504 ++++++++++++++++++++++++++++++++++
 arch/riscv/net/bpf_jit_comp.c | 443 +-----------------------------
 2 files changed, 505 insertions(+), 442 deletions(-)
 create mode 100644 arch/riscv/net/bpf_jit.h
arch/riscv/net/bpf_jit.h new file +504 -0
new file mode 100644
index 000000000000..6f45f95bc4d0
@@ -0,0 +1,504 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Common functionality for RV32 and RV64 BPF JIT compilers
+ *
+ * Copyright (c) 2019 Björn Töpel <[email protected]>
+ * Copyright (c) 2020 Luke Nelson <[email protected]>
+ * Copyright (c) 2020 Xi Wang <[email protected]>
+ */
+
+#ifndef _BPF_JIT_H
+#define _BPF_JIT_H
+
+#include <linux/bpf.h>
+#include <linux/filter.h>
+#include <asm/cacheflush.h>
+
+enum {
+	RV_REG_ZERO =	0,	/* The constant value 0 */
+	RV_REG_RA =	1,	/* Return address */
+	RV_REG_SP =	2,	/* Stack pointer */
+	RV_REG_GP =	3,	/* Global pointer */
+	RV_REG_TP =	4,	/* Thread pointer */
+	RV_REG_T0 =	5,	/* Temporaries */
+	RV_REG_T1 =	6,
+	RV_REG_T2 =	7,
+	RV_REG_FP =	8,	/* Saved register/frame pointer */
+	RV_REG_S1 =	9,	/* Saved register */
+	RV_REG_A0 =	10,	/* Function argument/return values */
+	RV_REG_A1 =	11,	/* Function arguments */
+	RV_REG_A2 =	12,
+	RV_REG_A3 =	13,
+	RV_REG_A4 =	14,
+	RV_REG_A5 =	15,
+	RV_REG_A6 =	16,
+	RV_REG_A7 =	17,
+	RV_REG_S2 =	18,	/* Saved registers */
+	RV_REG_S3 =	19,
+	RV_REG_S4 =	20,
+	RV_REG_S5 =	21,
+	RV_REG_S6 =	22,
+	RV_REG_S7 =	23,
+	RV_REG_S8 =	24,
+	RV_REG_S9 =	25,
+	RV_REG_S10 =	26,
+	RV_REG_S11 =	27,
+	RV_REG_T3 =	28,	/* Temporaries */
+	RV_REG_T4 =	29,
+	RV_REG_T5 =	30,
+	RV_REG_T6 =	31,
+};
+
+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 inline void bpf_fill_ill_insns(void *area, unsigned int size)
+{
+	memset(area, 0, size);
+}
+
+static inline void bpf_flush_icache(void *start, void *end)
+{
+	flush_icache_range((unsigned long)start, (unsigned long)end);
+}
+
+static inline void emit(const u32 insn, struct rv_jit_context *ctx)
+{
+	if (ctx->insns)
+		ctx->insns[ctx->ninsns] = insn;
+
+	ctx->ninsns++;
+}
+
+static inline int epilogue_offset(struct rv_jit_context *ctx)
+{
+	int to = ctx->epilogue_offset, from = ctx->ninsns;
+
+	return (to - from) << 2;
+}
+
+/* Return -1 or inverted cond. */
+static inline int invert_bpf_cond(u8 cond)
+{
+	switch (cond) {
+	case BPF_JEQ:
+		return BPF_JNE;
+	case BPF_JGT:
+		return BPF_JLE;
+	case BPF_JLT:
+		return BPF_JGE;
+	case BPF_JGE:
+		return BPF_JLT;
+	case BPF_JLE:
+		return BPF_JGT;
+	case BPF_JNE:
+		return BPF_JEQ;
+	case BPF_JSGT:
+		return BPF_JSLE;
+	case BPF_JSLT:
+		return BPF_JSGE;
+	case BPF_JSGE:
+		return BPF_JSLT;
+	case BPF_JSLE:
+		return BPF_JSGT;
+	}
+	return -1;
+}
+
+static inline bool is_12b_int(long val)
+{
+	return -(1L << 11) <= val && val < (1L << 11);
+}
+
+static inline int is_12b_check(int off, int insn)
+{
+	if (!is_12b_int(off)) {
+		pr_err("bpf-jit: insn=%d 12b < offset=%d not supported yet!\n",
+		       insn, (int)off);
+		return -1;
+	}
+	return 0;
+}
+
+static inline bool is_13b_int(long val)
+{
+	return -(1L << 12) <= val && val < (1L << 12);
+}
+
+static inline bool is_21b_int(long val)
+{
+	return -(1L << 20) <= val && val < (1L << 20);
+}
+
+static inline int rv_offset(int insn, int off, struct rv_jit_context *ctx)
+{
+	int from, to;
+
+	off++; /* BPF branch is from PC+1, RV is from PC */
+	from = (insn > 0) ? ctx->offset[insn - 1] : 0;
+	to = (insn + off > 0) ? ctx->offset[insn + off - 1] : 0;
+	return (to - from) << 2;
+}
+
+/* Instruction formats. */
+
+static inline u32 rv_r_insn(u8 funct7, u8 rs2, u8 rs1, u8 funct3, u8 rd,
+			    u8 opcode)
+{
+	return (funct7 << 25) | (rs2 << 20) | (rs1 << 15) | (funct3 << 12) |
+		(rd << 7) | opcode;
+}
+
+static inline u32 rv_i_insn(u16 imm11_0, u8 rs1, u8 funct3, u8 rd, u8 opcode)
+{
+	return (imm11_0 << 20) | (rs1 << 15) | (funct3 << 12) | (rd << 7) |
+		opcode;
+}
+
+static inline u32 rv_s_insn(u16 imm11_0, u8 rs2, u8 rs1, u8 funct3, u8 opcode)
+{
+	u8 imm11_5 = imm11_0 >> 5, imm4_0 = imm11_0 & 0x1f;
+
+	return (imm11_5 << 25) | (rs2 << 20) | (rs1 << 15) | (funct3 << 12) |
+		(imm4_0 << 7) | opcode;
+}
+
+static inline u32 rv_b_insn(u16 imm12_1, u8 rs2, u8 rs1, u8 funct3, u8 opcode)
+{
+	u8 imm12 = ((imm12_1 & 0x800) >> 5) | ((imm12_1 & 0x3f0) >> 4);
+	u8 imm4_1 = ((imm12_1 & 0xf) << 1) | ((imm12_1 & 0x400) >> 10);
+
+	return (imm12 << 25) | (rs2 << 20) | (rs1 << 15) | (funct3 << 12) |
+		(imm4_1 << 7) | opcode;
+}
+
+static inline u32 rv_u_insn(u32 imm31_12, u8 rd, u8 opcode)
+{
+	return (imm31_12 << 12) | (rd << 7) | opcode;
+}
+
+static inline u32 rv_j_insn(u32 imm20_1, u8 rd, u8 opcode)
+{
+	u32 imm;
+
+	imm = (imm20_1 & 0x80000) | ((imm20_1 & 0x3ff) << 9) |
+		((imm20_1 & 0x400) >> 2) | ((imm20_1 & 0x7f800) >> 11);
+
+	return (imm << 12) | (rd << 7) | opcode;
+}
+
+static inline u32 rv_amo_insn(u8 funct5, u8 aq, u8 rl, u8 rs2, u8 rs1,
+			      u8 funct3, u8 rd, u8 opcode)
+{
+	u8 funct7 = (funct5 << 2) | (aq << 1) | rl;
+
+	return rv_r_insn(funct7, rs2, rs1, funct3, rd, opcode);
+}
+
+/* Instructions shared by both RV32 and RV64. */
+
+static inline u32 rv_addi(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 0, rd, 0x13);
+}
+
+static inline u32 rv_andi(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 7, rd, 0x13);
+}
+
+static inline u32 rv_ori(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 6, rd, 0x13);
+}
+
+static inline u32 rv_xori(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 4, rd, 0x13);
+}
+
+static inline u32 rv_slli(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 1, rd, 0x13);
+}
+
+static inline u32 rv_srli(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 5, rd, 0x13);
+}
+
+static inline u32 rv_srai(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(0x400 | imm11_0, rs1, 5, rd, 0x13);
+}
+
+static inline u32 rv_lui(u8 rd, u32 imm31_12)
+{
+	return rv_u_insn(imm31_12, rd, 0x37);
+}
+
+static inline u32 rv_auipc(u8 rd, u32 imm31_12)
+{
+	return rv_u_insn(imm31_12, rd, 0x17);
+}
+
+static inline u32 rv_add(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 0, rd, 0x33);
+}
+
+static inline u32 rv_sub(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0x20, rs2, rs1, 0, rd, 0x33);
+}
+
+static inline u32 rv_sltu(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 3, rd, 0x33);
+}
+
+static inline u32 rv_and(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 7, rd, 0x33);
+}
+
+static inline u32 rv_or(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 6, rd, 0x33);
+}
+
+static inline u32 rv_xor(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 4, rd, 0x33);
+}
+
+static inline u32 rv_sll(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 1, rd, 0x33);
+}
+
+static inline u32 rv_srl(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 5, rd, 0x33);
+}
+
+static inline u32 rv_sra(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0x20, rs2, rs1, 5, rd, 0x33);
+}
+
+static inline u32 rv_mul(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(1, rs2, rs1, 0, rd, 0x33);
+}
+
+static inline u32 rv_mulhu(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(1, rs2, rs1, 3, rd, 0x33);
+}
+
+static inline u32 rv_divu(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(1, rs2, rs1, 5, rd, 0x33);
+}
+
+static inline u32 rv_remu(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(1, rs2, rs1, 7, rd, 0x33);
+}
+
+static inline u32 rv_jal(u8 rd, u32 imm20_1)
+{
+	return rv_j_insn(imm20_1, rd, 0x6f);
+}
+
+static inline u32 rv_jalr(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 0, rd, 0x67);
+}
+
+static inline u32 rv_beq(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs2, rs1, 0, 0x63);
+}
+
+static inline u32 rv_bne(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs2, rs1, 1, 0x63);
+}
+
+static inline u32 rv_bltu(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs2, rs1, 6, 0x63);
+}
+
+static inline u32 rv_bgtu(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs1, rs2, 6, 0x63);
+}
+
+static inline u32 rv_bgeu(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs2, rs1, 7, 0x63);
+}
+
+static inline u32 rv_bleu(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs1, rs2, 7, 0x63);
+}
+
+static inline u32 rv_blt(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs2, rs1, 4, 0x63);
+}
+
+static inline u32 rv_bgt(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs1, rs2, 4, 0x63);
+}
+
+static inline u32 rv_bge(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs2, rs1, 5, 0x63);
+}
+
+static inline u32 rv_ble(u8 rs1, u8 rs2, u16 imm12_1)
+{
+	return rv_b_insn(imm12_1, rs1, rs2, 5, 0x63);
+}
+
+static inline u32 rv_lw(u8 rd, u16 imm11_0, u8 rs1)
+{
+	return rv_i_insn(imm11_0, rs1, 2, rd, 0x03);
+}
+
+static inline u32 rv_lbu(u8 rd, u16 imm11_0, u8 rs1)
+{
+	return rv_i_insn(imm11_0, rs1, 4, rd, 0x03);
+}
+
+static inline u32 rv_lhu(u8 rd, u16 imm11_0, u8 rs1)
+{
+	return rv_i_insn(imm11_0, rs1, 5, rd, 0x03);
+}
+
+static inline u32 rv_sb(u8 rs1, u16 imm11_0, u8 rs2)
+{
+	return rv_s_insn(imm11_0, rs2, rs1, 0, 0x23);
+}
+
+static inline u32 rv_sh(u8 rs1, u16 imm11_0, u8 rs2)
+{
+	return rv_s_insn(imm11_0, rs2, rs1, 1, 0x23);
+}
+
+static inline u32 rv_sw(u8 rs1, u16 imm11_0, u8 rs2)
+{
+	return rv_s_insn(imm11_0, rs2, rs1, 2, 0x23);
+}
+
+static inline u32 rv_amoadd_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl)
+{
+	return rv_amo_insn(0, aq, rl, rs2, rs1, 2, rd, 0x2f);
+}
+
+#if __riscv_xlen == 64
+
+/* RV64-only instructions. */
+
+static inline u32 rv_addiw(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 0, rd, 0x1b);
+}
+
+static inline u32 rv_slliw(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 1, rd, 0x1b);
+}
+
+static inline u32 rv_srliw(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(imm11_0, rs1, 5, rd, 0x1b);
+}
+
+static inline u32 rv_sraiw(u8 rd, u8 rs1, u16 imm11_0)
+{
+	return rv_i_insn(0x400 | imm11_0, rs1, 5, rd, 0x1b);
+}
+
+static inline u32 rv_addw(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 0, rd, 0x3b);
+}
+
+static inline u32 rv_subw(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0x20, rs2, rs1, 0, rd, 0x3b);
+}
+
+static inline u32 rv_sllw(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 1, rd, 0x3b);
+}
+
+static inline u32 rv_srlw(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0, rs2, rs1, 5, rd, 0x3b);
+}
+
+static inline u32 rv_sraw(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(0x20, rs2, rs1, 5, rd, 0x3b);
+}
+
+static inline u32 rv_mulw(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(1, rs2, rs1, 0, rd, 0x3b);
+}
+
+static inline u32 rv_divuw(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(1, rs2, rs1, 5, rd, 0x3b);
+}
+
+static inline u32 rv_remuw(u8 rd, u8 rs1, u8 rs2)
+{
+	return rv_r_insn(1, rs2, rs1, 7, rd, 0x3b);
+}
+
+static inline u32 rv_ld(u8 rd, u16 imm11_0, u8 rs1)
+{
+	return rv_i_insn(imm11_0, rs1, 3, rd, 0x03);
+}
+
+static inline u32 rv_lwu(u8 rd, u16 imm11_0, u8 rs1)
+{
+	return rv_i_insn(imm11_0, rs1, 6, rd, 0x03);
+}
+
+static inline u32 rv_sd(u8 rs1, u16 imm11_0, u8 rs2)
+{
+	return rv_s_insn(imm11_0, rs2, rs1, 3, 0x23);
+}
+
+static inline u32 rv_amoadd_d(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl)
+{
+	return rv_amo_insn(0, aq, rl, rs2, rs1, 3, rd, 0x2f);
+}
+
+#endif /* __riscv_xlen == 64 */
+
+#endif /* _BPF_JIT_H */
arch/riscv/net/bpf_jit_comp.c +1 -442

484 lines not on this page · raw message

Signature · 1 line
2.20.1
#5 lore raw

PATCH v4 2/4 riscv, bpf: add RV32G eBPF JIT

In reply to Luke Nelson

This is an eBPF JIT for RV32G, adapted from the JIT for RV64G and the 32-bit ARM JIT.

There are two main changes required for this to work compared to the RV64 JIT.

First, eBPF registers are 64-bit, while RV32G registers are 32-bit. BPF registers either map directly to 2 RISC-V registers, or reside in stack scratch space and are saved and restored when used.

Second, many 64-bit ALU operations do not trivially map to 32-bit operations. Operations that move bits between high and low words, such as ADD, LSH, MUL, and others must emulate the 64-bit behavior in terms of 32-bit instructions.

Supported features:

The RV32 JIT supports the same features and instructions as the RV64 JIT, with the following exceptions:

- ALU64 DIV/MOD: Requires loops to implement on 32-bit hardware.

- BPF_XADD | BPF_DW: There's no 8-byte atomic instruction in RV32.

These features are also unsupported on other BPF JITs for 32-bit architectures.

Testing:

- lib/test_bpf.c
test_bpf: Summary: 378 PASSED, 0 FAILED, [349/366 JIT'ed]
test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED

- tools/testing/selftests/bpf/test_verifier.c
Summary: 1415 PASSED, 122 SKIPPED, 43 FAILED

Tested both with and without BPF JIT hardening.

This is the same set of tests that pass using the BPF interpreter with the JIT disabled.

Verification and synthesis:

We developed the RV32 JIT using our automated verification tool, Serval. We have used Serval in the past to verify patches to the RV64 JIT. We also used Serval to superoptimize the resulting code through program synthesis.

You can find the tool and a guide to the approach and results here:
https://github.com/uw-unsat/serval-bpf/tree/rv32-jit-v4

---
 arch/riscv/Kconfig              |    2 +-
 arch/riscv/net/Makefile         |    7 +-
 arch/riscv/net/bpf_jit_comp32.c | 1466 +++++++++++++++++++++++++++++++
 3 files changed, 1473 insertions(+), 2 deletions(-)
 create mode 100644 arch/riscv/net/bpf_jit_comp32.c
arch/riscv/Kconfig +1 -1
index 73f029eae0cc..e9791717e006 100644
@@ -56,7 +56,7 @@ config RISCV
 	select ARCH_HAS_PTE_SPECIAL
 	select ARCH_HAS_MMIOWB
 	select ARCH_HAS_DEBUG_VIRTUAL
-	select HAVE_EBPF_JIT if 64BIT
+	select HAVE_EBPF_JIT
 	select EDAC_SUPPORT
 	select ARCH_HAS_GIGANTIC_PAGE
 	select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
arch/riscv/net/Makefile +6 -1
index ec5b14763316..5511fb1dd40e 100644
@@ -1,2 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o
+
+ifeq ($(CONFIG_ARCH_RV64I),y)
+	obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o
+else
+	obj-$(CONFIG_BPF_JIT) += bpf_jit_comp32.o
+endif
arch/riscv/net/bpf_jit_comp32.c new file +1466 -0

1,466 lines not on this page · raw message

Signature · 1 line
2.20.1
#11 lore raw

PATCH v4 3/4 bpf, doc: add BPF JIT for RV32G to BPF documentation

In reply to Luke Nelson

Update filter.txt and admin-guide to mention the BPF JIT for RV32G.

---
 Documentation/admin-guide/sysctl/net.rst | 3 ++-
 Documentation/networking/filter.txt      | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Documentation/admin-guide/sysctl/net.rst +2 -1
index 287b98708a40..e043c9213388 100644
@@ -67,7 +67,8 @@ two flavors of JITs, the newer eBPF JIT currently supported on:
   - sparc64
   - mips64
   - s390x
-  - riscv
+  - riscv64
+  - riscv32
 
 And the older cBPF JIT supported on the following archs:
 
Documentation/networking/filter.txt +1 -1
index c4a328f2d57a..2f0f8b17dade 100644
@@ -606,7 +606,7 @@ 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, riscv (RV64G) perform JIT compilation from eBPF
+sparc64, arm32, riscv64, riscv32 perform JIT compilation from eBPF
 instruction set.
 
 Some core changes of the new internal format:
Signature · 1 line
2.20.1
#13 lore raw

PATCH v4 4/4 MAINTAINERS: Add entry for RV32G BPF JIT

In reply to Luke Nelson
---
 MAINTAINERS | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
MAINTAINERS +11 -2
index 8f27f40d22bb..fdd8b99f18db 100644
@@ -3213,11 +3213,20 @@ L:	[email protected]
 S:	Maintained
 F:	arch/powerpc/net/
 
-BPF JIT for RISC-V (RV64G)
+BPF JIT for 32-bit RISC-V (RV32G)
+M:	Luke Nelson <[email protected]>
+M:	Xi Wang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	arch/riscv/net/
+X:	arch/riscv/net/bpf_jit_comp.c
+
+BPF JIT for 64-bit RISC-V (RV64G)
 M:	Björn Töpel <[email protected]>
-L:	[email protected]
+L:	[email protected]
 S:	Maintained
 F:	arch/riscv/net/
+X:	arch/riscv/net/bpf_jit_comp32.c
 
 BPF JIT for S390
 M:	Ilya Leoshkevich <[email protected]>
Signature · 1 line
2.20.1
Acked-by on v4 4/4
#14 lore raw

Re: [PATCH bpf-next v4 4/4] MAINTAINERS: Add entry for RV32G BPF JIT

Quoted 23 lines · Luke Nelson
---
 MAINTAINERS | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
MAINTAINERS +6 -1
index 8f27f40d22bb..fdd8b99f18db 100644
@@ -3213,11 +3213,20 @@ L:      [email protected]
 S:     Maintained
 F:     arch/powerpc/net/
 
-BPF JIT for RISC-V (RV64G)
+BPF JIT for 32-bit RISC-V (RV32G)
+M:     Luke Nelson <[email protected]>
+M:     Xi Wang <[email protected]>
+L:     [email protected]
+S:     Maintained
+F:     arch/riscv/net/

MAINTAINERS L: [email protected] · line 3230

Quoted 10 lines
MAINTAINERS +5 -1
+X:     arch/riscv/net/bpf_jit_comp.c
+
+BPF JIT for 64-bit RISC-V (RV64G)
 M:     Björn Töpel <[email protected]>
-L:     [email protected]
+L:     [email protected]
 S:     Maintained
 F:     arch/riscv/net/
+X:     arch/riscv/net/bpf_jit_comp32.c
 

Empty commit message body, but maybe that's OK. The removal of netdev list is following the new guidelines from commit e42da4c62abb ("docs/bpf: Update bpf development Q/A file").

Quoted 5 lines
MAINTAINERS +0 -1
 BPF JIT for S390
 M:     Ilya Leoshkevich <[email protected]>
--

2.20.1

Acked-by on v4 3/4
#12 lore raw

Re: [PATCH bpf-next v4 3/4] bpf, doc: add BPF JIT for RV32G to BPF documentation

In reply to Luke Nelson
Quoted 5 lines · Luke Nelson

Update filter.txt and admin-guide to mention the BPF JIT for RV32G.

Quoted 32 lines
---
 Documentation/admin-guide/sysctl/net.rst | 3 ++-
 Documentation/networking/filter.txt      | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Documentation/admin-guide/sysctl/net.rst +2 -1
index 287b98708a40..e043c9213388 100644
@@ -67,7 +67,8 @@ two flavors of JITs, the newer eBPF JIT currently supported on:
   - sparc64
   - mips64
   - s390x
-  - riscv
+  - riscv64
+  - riscv32
 
 And the older cBPF JIT supported on the following archs:
 
Documentation/networking/filter.txt +1 -1
index c4a328f2d57a..2f0f8b17dade 100644
@@ -606,7 +606,7 @@ 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, riscv (RV64G) perform JIT compilation from eBPF
+sparc64, arm32, riscv64, riscv32 perform JIT compilation from eBPF
 instruction set.
 
 Some core changes of the new internal format:
#6 lore raw

Re: [PATCH bpf-next v4 2/4] riscv, bpf: add RV32G eBPF JIT

In reply to Luke Nelson
Quoted 25 lines · Luke Nelson

This is an eBPF JIT for RV32G, adapted from the JIT for RV64G and the 32-bit ARM JIT.

There are two main changes required for this to work compared to the RV64 JIT.

First, eBPF registers are 64-bit, while RV32G registers are 32-bit. BPF registers either map directly to 2 RISC-V registers, or reside in stack scratch space and are saved and restored when used.

Second, many 64-bit ALU operations do not trivially map to 32-bit operations. Operations that move bits between high and low words, such as ADD, LSH, MUL, and others must emulate the 64-bit behavior in terms of 32-bit instructions.

Supported features:

The RV32 JIT supports the same features and instructions as the RV64 JIT, with the following exceptions:

- ALU64 DIV/MOD: Requires loops to implement on 32-bit hardware.

- BPF_XADD | BPF_DW: There's no 8-byte atomic instruction in RV32.

Quoted 7 lines

These features are also unsupported on other BPF JITs for 32-bit architectures.

Testing:

- lib/test_bpf.c
test_bpf: Summary: 378 PASSED, 0 FAILED, [349/366 JIT'ed]

Which are the tests that fail to JIT, and is that due to div/mod + xadd?

Quoted 12 lines

test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED

- tools/testing/selftests/bpf/test_verifier.c
Summary: 1415 PASSED, 122 SKIPPED, 43 FAILED

Tested both with and without BPF JIT hardening.

This is the same set of tests that pass using the BPF interpreter with the JIT disabled.

Verification and synthesis:

Quoted 8 lines

We developed the RV32 JIT using our automated verification tool, Serval. We have used Serval in the past to verify patches to the RV64 JIT. We also used Serval to superoptimize the resulting code through program synthesis.

You can find the tool and a guide to the approach and results here:
https://github.com/uw-unsat/serval-bpf/tree/rv32-jit-v4

Very interesting work!

Quoted 9 lines
---
 arch/riscv/Kconfig              |    2 +-
 arch/riscv/net/Makefile         |    7 +-
 arch/riscv/net/bpf_jit_comp32.c | 1466 +++++++++++++++++++++++++++++++
 3 files changed, 1473 insertions(+), 2 deletions(-)
 create mode 100644 arch/riscv/net/bpf_jit_comp32.c

[...]

arch/riscv/net/bpf_jit_comp32.c line 165

Quoted 3 lines
arch/riscv/net/bpf_jit_comp32.c new file +3 -0
+
+static const s8 *rv32_bpf_get_reg64(const s8 *reg, const s8 *tmp,
+                    struct rv_jit_context *ctx)

Really a nit, but you're using rv32 as prefix, and also as part of many of the functions (e.g. emit_rv32). Everything is this file is just for RV32, so maybe remove that implicit information from the function name? Just a thought! :-)

Quoted 92 lines
arch/riscv/net/bpf_jit_comp32.c new file +92 -0
+{
+    if (is_stacked(hi(reg))) {
+        emit(rv_lw(hi(tmp), hi(reg), RV_REG_FP), ctx);
+        emit(rv_lw(lo(tmp), lo(reg), RV_REG_FP), ctx);
+        reg = tmp;
+    }
+    return reg;
+}
+
+static void rv32_bpf_put_reg64(const s8 *reg, const s8 *src,
+                   struct rv_jit_context *ctx)
+{
+    if (is_stacked(hi(reg))) {
+        emit(rv_sw(RV_REG_FP, hi(reg), hi(src)), ctx);
+        emit(rv_sw(RV_REG_FP, lo(reg), lo(src)), ctx);
+    }
+}
+
+static const s8 *rv32_bpf_get_reg32(const s8 *reg, const s8 *tmp,
+                    struct rv_jit_context *ctx)
+{
+    if (is_stacked(lo(reg))) {
+        emit(rv_lw(lo(tmp), lo(reg), RV_REG_FP), ctx);
+        reg = tmp;
+    }
+    return reg;
+}
+
+static void rv32_bpf_put_reg32(const s8 *reg, const s8 *src,
+                   struct rv_jit_context *ctx)
+{
+    if (is_stacked(lo(reg))) {
+        emit(rv_sw(RV_REG_FP, lo(reg), lo(src)), ctx);
+        if (!ctx->prog->aux->verifier_zext)
+            emit(rv_sw(RV_REG_FP, hi(reg), RV_REG_ZERO), ctx);
+    } else if (!ctx->prog->aux->verifier_zext) {
+        emit(rv_addi(hi(reg), RV_REG_ZERO, 0), ctx);
+    }
+}
+
+static void emit_jump_and_link(u8 rd, s32 rvoff, bool force_jalr,
+                   struct rv_jit_context *ctx)
+{
+    s32 upper, lower;
+
+    if (rvoff && is_21b_int(rvoff) && !force_jalr) {
+        emit(rv_jal(rd, rvoff >> 1), ctx);
+        return;
+    }
+
+    upper = (rvoff + (1 << 11)) >> 12;
+    lower = rvoff & 0xfff;
+    emit(rv_auipc(RV_REG_T1, upper), ctx);
+    emit(rv_jalr(rd, RV_REG_T1, lower), ctx);
+}
+
+static void emit_rv32_alu_i64(const s8 *dst, s32 imm,
+                  struct rv_jit_context *ctx, const u8 op)
+{
+    const s8 *tmp1 = bpf2rv32[TMP_REG_1];
+    const s8 *rd = rv32_bpf_get_reg64(dst, tmp1, ctx);
+
+    switch (op) {
+    case BPF_MOV:
+        emit_imm32(rd, imm, ctx);
+        break;
+    case BPF_AND:
+        if (is_12b_int(imm)) {
+            emit(rv_andi(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_and(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        if (imm >= 0)
+            emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx);
+        break;
+    case BPF_OR:
+        if (is_12b_int(imm)) {
+            emit(rv_ori(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_or(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        if (imm < 0)
+            emit(rv_ori(hi(rd), RV_REG_ZERO, -1), ctx);
+        break;
+    case BPF_XOR:
+        if (is_12b_int(imm)) {
+            emit(rv_xori(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_xor(lo(rd), lo(rd), RV_REG_T0), ctx);

arch/riscv/net/bpf_jit_comp32.c line 267

Quoted 10 lines
arch/riscv/net/bpf_jit_comp32.c new file +10 -0
+        }
+        if (imm < 0)
+            emit(rv_xori(hi(rd), hi(rd), -1), ctx);
+        break;
+    case BPF_LSH:
+        if (imm >= 32) {
+            emit(rv_slli(hi(rd), lo(rd), imm - 32), ctx);
+            emit(rv_addi(lo(rd), RV_REG_ZERO, 0), ctx);
+        } else if (imm == 0) {
+            /* nop */

Can we get rid of this, and just do if/else if?

arch/riscv/net/bpf_jit_comp32.c line 280

Quoted 13 lines
arch/riscv/net/bpf_jit_comp32.c new file +13 -0
+        } else {
+            emit(rv_srli(RV_REG_T0, lo(rd), 32 - imm), ctx);
+            emit(rv_slli(hi(rd), hi(rd), imm), ctx);
+            emit(rv_or(hi(rd), RV_REG_T0, hi(rd)), ctx);
+            emit(rv_slli(lo(rd), lo(rd), imm), ctx);
+        }
+        break;
+    case BPF_RSH:
+        if (imm >= 32) {
+            emit(rv_srli(lo(rd), hi(rd), imm - 32), ctx);
+            emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx);
+        } else if (imm == 0) {
+            /* nop */

Dito.

arch/riscv/net/bpf_jit_comp32.c line 293

Quoted 13 lines
arch/riscv/net/bpf_jit_comp32.c new file +13 -0
+        } else {
+            emit(rv_slli(RV_REG_T0, hi(rd), 32 - imm), ctx);
+            emit(rv_srli(lo(rd), lo(rd), imm), ctx);
+            emit(rv_or(lo(rd), RV_REG_T0, lo(rd)), ctx);
+            emit(rv_srli(hi(rd), hi(rd), imm), ctx);
+        }
+        break;
+    case BPF_ARSH:
+        if (imm >= 32) {
+            emit(rv_srai(lo(rd), hi(rd), imm - 32), ctx);
+            emit(rv_srai(hi(rd), hi(rd), 31), ctx);
+        } else if (imm == 0) {
+            /* nop */

Dito.

Quoted 76 lines
arch/riscv/net/bpf_jit_comp32.c new file +76 -0
+        } else {
+            emit(rv_slli(RV_REG_T0, hi(rd), 32 - imm), ctx);
+            emit(rv_srli(lo(rd), lo(rd), imm), ctx);
+            emit(rv_or(lo(rd), RV_REG_T0, lo(rd)), ctx);
+            emit(rv_srai(hi(rd), hi(rd), imm), ctx);
+        }
+        break;
+    }
+
+    rv32_bpf_put_reg64(dst, rd, ctx);
+}
+
+static void emit_rv32_alu_i32(const s8 *dst, s32 imm,
+                  struct rv_jit_context *ctx, const u8 op)
+{
+    const s8 *tmp1 = bpf2rv32[TMP_REG_1];
+    const s8 *rd = rv32_bpf_get_reg32(dst, tmp1, ctx);
+
+    switch (op) {
+    case BPF_MOV:
+        emit_imm(lo(rd), imm, ctx);
+        break;
+    case BPF_ADD:
+        if (is_12b_int(imm)) {
+            emit(rv_addi(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_add(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;
+    case BPF_SUB:
+        if (is_12b_int(-imm)) {
+            emit(rv_addi(lo(rd), lo(rd), -imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_sub(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;
+    case BPF_AND:
+        if (is_12b_int(imm)) {
+            emit(rv_andi(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_and(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;
+    case BPF_OR:
+        if (is_12b_int(imm)) {
+            emit(rv_ori(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_or(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;
+    case BPF_XOR:
+        if (is_12b_int(imm)) {
+            emit(rv_xori(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_xor(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;
+    case BPF_LSH:
+        if (is_12b_int(imm)) {
+            emit(rv_slli(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_sll(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;
+    case BPF_RSH:
+        if (is_12b_int(imm)) {
+            emit(rv_srli(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_srl(lo(rd), lo(rd), RV_REG_T0), ctx);

arch/riscv/net/bpf_jit_comp32.c line 379

Quoted 10 lines
arch/riscv/net/bpf_jit_comp32.c new file +10 -0
+        }
+        break;
+    case BPF_ARSH:
+        if (is_12b_int(imm)) {
+            emit(rv_srai(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_sra(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;

Again nit; I like "early exit" code if possible. Instead of:

if (bleh) {
foo();
} else {
bar();
}

do:

if (bleh) {
foo()
return/break;
}
bar();

I find the latter easier to read -- but really a nit, and a matter of style. There are number of places where that could be applied in the file.

Quoted 1 line

+ }

[...]

Quoted 141 lines
arch/riscv/net/bpf_jit_comp32.c new file +141 -0
+
+static int build_body(struct rv_jit_context *ctx, bool extra_pass, int *offset)
+{
+    const struct bpf_prog *prog = ctx->prog;
+    int i;
+
+    for (i = 0; i < prog->len; i++) {
+        const struct bpf_insn *insn = &prog->insnsi[i];
+        int ret;
+
+        ret = emit_insn(insn, ctx, extra_pass);
+        if (ret > 0)
+            /*
+             * BPF_LD | BPF_IMM | BPF_DW:
+             * Skip the next instruction.
+             */
+            i++;
+        if (offset)
+            offset[i] = ctx->ninsns;
+        if (ret < 0)
+            return ret;
+    }
+    return 0;
+}
+
+bool bpf_jit_needs_zext(void)
+{
+    return true;
+}
+
+struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
+{
+    bool tmp_blinded = false, extra_pass = false;
+    struct bpf_prog *tmp, *orig_prog = prog;
+    int pass = 0, prev_ninsns = 0, i;
+    struct rv_jit_data *jit_data;
+    struct rv_jit_context *ctx;
+    unsigned int image_size = 0;
+
+    if (!prog->jit_requested)
+        return orig_prog;
+
+    tmp = bpf_jit_blind_constants(prog);
+    if (IS_ERR(tmp))
+        return orig_prog;
+    if (tmp != prog) {
+        tmp_blinded = true;
+        prog = tmp;
+    }
+
+    jit_data = prog->aux->jit_data;
+    if (!jit_data) {
+        jit_data = kzalloc(sizeof(*jit_data), GFP_KERNEL);
+        if (!jit_data) {
+            prog = orig_prog;
+            goto out;
+        }
+        prog->aux->jit_data = jit_data;
+    }
+
+    ctx = &jit_data->ctx;
+
+    if (ctx->offset) {
+        extra_pass = true;
+        image_size = sizeof(u32) * ctx->ninsns;
+        goto skip_init_ctx;
+    }
+
+    ctx->prog = prog;
+    ctx->offset = kcalloc(prog->len, sizeof(int), GFP_KERNEL);
+    if (!ctx->offset) {
+        prog = orig_prog;
+        goto out_offset;
+    }
+    for (i = 0; i < prog->len; i++) {
+        prev_ninsns += 32;
+        ctx->offset[i] = prev_ninsns;
+    }
+
+    for (i = 0; i < NR_JIT_ITERATIONS; i++) {
+        pass++;
+        ctx->ninsns = 0;
+        if (build_body(ctx, extra_pass, ctx->offset)) {
+            prog = orig_prog;
+            goto out_offset;
+        }
+        build_prologue(ctx);
+        ctx->epilogue_offset = ctx->ninsns;
+        build_epilogue(ctx);
+
+        if (ctx->ninsns == prev_ninsns) {
+            if (jit_data->header)
+                break;
+
+            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;
+            }
+
+            ctx->insns = (u32 *)jit_data->image;
+        }
+        prev_ninsns = ctx->ninsns;
+    }
+
+    if (i == NR_JIT_ITERATIONS) {
+        pr_err("bpf-jit: image did not converge in <%d passes!\n", i);
+        bpf_jit_binary_free(jit_data->header);
+        prog = orig_prog;
+        goto out_offset;
+    }
+
+skip_init_ctx:
+    pass++;
+    ctx->ninsns = 0;
+
+    build_prologue(ctx);
+    if (build_body(ctx, extra_pass, NULL)) {
+        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);
+
+    prog->bpf_func = (void *)ctx->insns;
+    prog->jited = 1;
+    prog->jited_len = image_size;
+
+    bpf_flush_icache(jit_data->header, ctx->insns + ctx->ninsns);
+
+    if (!prog->is_func || extra_pass) {
+out_offset:
+        kfree(ctx->offset);

arch/riscv/net/bpf_jit_comp32.c line 1466

Quoted 10 lines
arch/riscv/net/bpf_jit_comp32.c new file +10 -0
+        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;
+}

At this point of the series, let's introduce the shared code .c-file containing implementation for bpf_int_jit_compile() (with build_body part of that)and bpf_jit_needs_zext(). That will make it easier to catch bugs in both JITs and to avoid code duplication! Also, when adding the stronger invariant suggested by Palmer [1], we only need to do it in one place.

The pull out refactoring can be a separate commit.

Thanks!
Björn

[1] https://lore.kernel.org/bpf/mhng-6be38b2a-78df-4016-aaea-f35aa0acd7e0@palmerdabbelt-glaptop/

#2 lore raw

Re: [PATCH bpf-next v4 1/4] riscv, bpf: move common riscv JIT code to header

In reply to Luke Nelson
Quoted 7 lines · Luke Nelson

This patch factors out code that can be used by both the RV64 and RV32 JITs to a common header.

Rename rv_sb_insn/rv_uj_insn to rv_b_insn/rv_j_insn to match the RISC-V specification.

Thanks for clearing this up!

Quoted 7 lines

---
We could put more code into a shared .c file in the future (e.g., build_body). It seems to make sense right now to first factor common data structures and helper functions into a header.

Yes, I agree.

Quoted 12 lines
---
 arch/riscv/net/bpf_jit.h      | 504 ++++++++++++++++++++++++++++++++++
 arch/riscv/net/bpf_jit_comp.c | 443 +-----------------------------
 2 files changed, 505 insertions(+), 442 deletions(-)
 create mode 100644 arch/riscv/net/bpf_jit.h
arch/riscv/net/bpf_jit.h new file +0 -0
new file mode 100644
index 000000000000..6f45f95bc4d0

arch/riscv/net/bpf_jit.h line 7

Quoted 7 lines
arch/riscv/net/bpf_jit.h new file +7 -0
@@ -0,0 +1,504 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Common functionality for RV32 and RV64 BPF JIT compilers
+ *
+ * Copyright (c) 2019 Björn Töpel <[email protected]>
+ * Copyright (c) 2020 Luke Nelson <[email protected]>
+ * Copyright (c) 2020 Xi Wang <[email protected]>

I'm no lawyer, so this is more of a question; You've pulled out code into a header, and renamed two functions. Does that warrant copyright line additions? Should my line be removed?

Quoted 8 lines
arch/riscv/net/bpf_jit.h new file +8 -0
+ */
+
+#ifndef _BPF_JIT_H
+#define _BPF_JIT_H
+
+#include <linux/bpf.h>
+#include <linux/filter.h>
+#include <asm/cacheflush.h>

[...]

arch/riscv/net/bpf_jit.h line 418

Quoted 7 lines
arch/riscv/net/bpf_jit.h new file +7 -0
+
+static inline u32 rv_amoadd_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl)
+{
+    return rv_amo_insn(0, aq, rl, rs2, rs1, 2, rd, 0x2f);
+}
+
+#if __riscv_xlen == 64

Please remove this. If the inlined functions are not used, they're not part of the binary. This adds complexity to the code, and without it we can catch build errors early on!

Quoted 3 lines
arch/riscv/net/bpf_jit.h new file +3 -0
+
+/* RV64-only instructions. */
+

[...]

arch/riscv/net/bpf_jit.h line 502

Quoted 5 lines
arch/riscv/net/bpf_jit.h new file +5 -0
+{
+    return rv_amo_insn(0, aq, rl, rs2, rs1, 3, rd, 0x2f);
+}
+
+#endif /* __riscv_xlen == 64 */

...and this.

Thanks!
Björn

#15 lore raw

Re: [PATCH bpf-next v4 4/4] MAINTAINERS: Add entry for RV32G BPF JIT

In reply to Luke Nelson

On Mon, Mar 02, 2020 at 04:50:35PM -0800, Luke Nelson wrote:

Commit message?

Quoted 14 lines
MAINTAINERS +5 -1
@@ -3213,11 +3213,20 @@ L:	[email protected]
 S:	Maintained
 F:	arch/powerpc/net/
 
-BPF JIT for RISC-V (RV64G)
+BPF JIT for 32-bit RISC-V (RV32G)
+M:	Luke Nelson <[email protected]>
+M:	Xi Wang <[email protected]>
+L:	[email protected]
+S:	Maintained

MAINTAINERS L: [email protected] · line 3229

Quoted 10 lines
MAINTAINERS +6 -1
+F:	arch/riscv/net/
+X:	arch/riscv/net/bpf_jit_comp.c
+
+BPF JIT for 64-bit RISC-V (RV64G)
 M:	Björn Töpel <[email protected]>
-L:	[email protected]
+L:	[email protected]
 S:	Maintained
 F:	arch/riscv/net/
+X:	arch/riscv/net/bpf_jit_comp32.c

Obviously this breaks an order. Please, fix.
Hint: run parse-maintainers.pl after the change.

Quoted 2 lines
MAINTAINERS +0 -0
 BPF JIT for S390
 M:	Ilya Leoshkevich <[email protected]>
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH bpf-next v4 1/4] riscv, bpf: move common riscv JIT code to header

In reply to Björn Töpel

Hi Björn,

Thanks for the comments! Inlined responses below:

Quoted 12 lines · Björn Töpel

arch/riscv/net/bpf_jit.h line 7

Quoted 8 lines
arch/riscv/net/bpf_jit.h new file +7 -0
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Common functionality for RV32 and RV64 BPF JIT compilers
+ *
+ * Copyright (c) 2019 Björn Töpel <[email protected]>
+ * Copyright (c) 2020 Luke Nelson <[email protected]>
+ * Copyright (c) 2020 Xi Wang <[email protected]>

I'm no lawyer, so this is more of a question; You've pulled out code into a header, and renamed two functions. Does that warrant copyright line additions? Should my line be removed?

This header also includes new code for emitting instructions required for the RV32 JIT (e.g., sltu) and some additional pseudoinstructions (e.g., bgtu and similar). I'm also no lawyer, so I don't know either if this rises to the level of adding copyright lines. I'm happy to do the following in v5 if it looks better:

+ * Copyright (c) 2019 Björn Töpel <[email protected]>
+ *
+ * Modified by ...

Quoted 5 lines
Quoted 1 line

+#if __riscv_xlen == 64

Please remove this. If the inlined functions are not used, they're not part of the binary. This adds complexity to the code, and without it we can catch build errors early on!

I agree in general we should avoid #if. The reason for using it here is to cause build errors if the RV32 JIT ever tries to emit an RV64-only instruction by mistake. Otherwise, what is now a build error would be delayed to an illegal instruction trap when the JITed code is executed, which is much harder to find and diagnose.

We could use separate files, bpf_jit_32.h and bpf_jit_64.h (the latter will include the former), if we want to avoid #if. Though this adds another form of complexity.

So the options here are 1) using no #if, with the risk of hiding subtle bugs in the RV32 JIT; 2) using #if as is; and 3) using separate headers. What do you think?

Thanks!

Luke

#7 lore raw

Re: [PATCH bpf-next v4 2/4] riscv, bpf: add RV32G eBPF JIT

In reply to Björn Töpel

Hi Björn,

Thanks again for the comments, responses below:

Quoted 3 lines · Björn Töpel

Which are the tests that fail to JIT, and is that due to div/mod + xadd?

Yes, all of the cases that fail to JIT are because of unsupported div/mod or xadd. I'll make that clear in next revision.

Quoted 11 lines
Quoted 10 lines
---
 arch/riscv/Kconfig              |    2 +-
 arch/riscv/net/Makefile         |    7 +-
 arch/riscv/net/bpf_jit_comp32.c | 1466 +++++++++++++++++++++++++++++++
 3 files changed, 1473 insertions(+), 2 deletions(-)
 create mode 100644 arch/riscv/net/bpf_jit_comp32.c

[...]

Quoted 8 lines

arch/riscv/net/bpf_jit_comp32.c line 165

Quoted 3 lines
arch/riscv/net/bpf_jit_comp32.c new file +3 -0
+
+static const s8 *rv32_bpf_get_reg64(const s8 *reg, const s8 *tmp,
+                    struct rv_jit_context *ctx)

Really a nit, but you're using rv32 as prefix, and also as part of many of the functions (e.g. emit_rv32). Everything is this file is just for RV32, so maybe remove that implicit information from the function name? Just a thought! :-)

I got so used to reading these I never noticed how redundant they were :) I'll change the next revision to remove all of the "rv32"s in function names.

Quoted 8 lines

arch/riscv/net/bpf_jit_comp32.c line 267

Quoted 6 lines
arch/riscv/net/bpf_jit_comp32.c new file +6 -0
+    case BPF_LSH:
+        if (imm >= 32) {
+            emit(rv_slli(hi(rd), lo(rd), imm - 32), ctx);
+            emit(rv_addi(lo(rd), RV_REG_ZERO, 0), ctx);
+        } else if (imm == 0) {
+            /* nop */

Can we get rid of this, and just do if/else if?

imm == 0 has been a tricky case for 32-bit JITs; see 6fa632e719ee ("bpf, x32: Fix bug with ALU64 {LSH, RSH, ARSH} BPF_K shift by 0"). We wanted to make the imm == 0 case explicit and help future readers see that this case is handled correctly here.

We could do the following if we really wanted to get rid of the check:

if (imm >= 32) {
...
} else if (imm != 0) {
...
}
/* Do nothing for imm == 0. */

Though it's unclear if this is easier to read.

Quoted 23 lines

arch/riscv/net/bpf_jit_comp32.c line 379

Quoted 8 lines
arch/riscv/net/bpf_jit_comp32.c new file +8 -0
+    case BPF_ARSH:
+        if (is_12b_int(imm)) {
+            emit(rv_srai(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_sra(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;

Again nit; I like "early exit" code if possible. Instead of:

if (bleh) {
   foo();
} else {

bar();
}

do:

if (bleh) {
   foo()
   return/break;
}
Quoted 5 lines

bar();

I find the latter easier to read -- but really a nit, and a matter of style. There are number of places where that could be applied in the file.

I like "early exit" code, too, and agree that it's easier to read in general, especially when handling error conditions.

But here we wanted to make it explicit that both branches are emitting equivalent instruction sequences (under different paths). Structured control flow seems a better fit for this particular context.

Quoted 8 lines

At this point of the series, let's introduce the shared code .c-file containing implementation for bpf_int_jit_compile() (with build_body part of that)and bpf_jit_needs_zext(). That will make it easier to catch bugs in both JITs and to avoid code duplication! Also, when adding the stronger invariant suggested by Palmer [1], we only need to do it in one place.

The pull out refactoring can be a separate commit.

I think the idea of deduplicating bpf_int_jit_compile is good and will lead to more maintainable JITs. How does the following proposal for v5 sound?

In patch 1 of this series:

- Factor structs and common helpers to bpf_jit.h (just like v4).

- Factor out bpf_int_jit_compile(), bpf_jit_needs_zext(), and build_body() to a new file bpf_jit_core.c and tweak the code as in v4.

- Rename emit_insn() and build_{prologue,epilogue}() to bpf_jit_emit_insn() and bpf_jit_build_{prologue,epilogue}, since these functions are now extern rather than static.

- Rename bpf_jit_comp.c to bpf_jit_comp64.c to be more explicit about its contents (as the next patch will add bpf_jit_comp32.c).

Then patch 2 can reuse the new header and won't need to define its own bpf_int_jit_compile() etc.

Thanks!

Luke

#16 lore raw

Re: [PATCH bpf-next v4 4/4] MAINTAINERS: Add entry for RV32G BPF JIT

In reply to Andy Shevchenko
Quoted 11 lines · Andy Shevchenko
Quoted 11 lines
MAINTAINERS +9 -1
-BPF JIT for RISC-V (RV64G)
+BPF JIT for 32-bit RISC-V (RV32G)
+M:   Luke Nelson <[email protected]>
+M:   Xi Wang <[email protected]>
+L:   [email protected]
+S:   Maintained
+F:   arch/riscv/net/
+X:   arch/riscv/net/bpf_jit_comp.c
+
+BPF JIT for 64-bit RISC-V (RV64G)
 M:   Björn Töpel <[email protected]>
Quoted 8 lines

MAINTAINERS L: [email protected] · line 3229

Quoted 5 lines
MAINTAINERS +2 -1
-L:   [email protected]
+L:   [email protected]
 S:   Maintained
 F:   arch/riscv/net/
+X:   arch/riscv/net/bpf_jit_comp32.c

Obviously this breaks an order. Please, fix.
Hint: run parse-maintainers.pl after the change.

Hi,

Thanks for the comment!

I'll change the entry names in v5 to be "BPF JIT for RISC-V (32-bit)" and "BPF JIT for RISC-V (64-bit)", similar to the x86 JIT entries. This will pass parse-maintainers.pl and the entries are still in order.

Thanks again,

Luke

#4 lore raw

Re: [PATCH bpf-next v4 1/4] riscv, bpf: move common riscv JIT code to header

In reply to Luke Nelson
Quoted 25 lines · Luke Nelson

Hi Björn,

Thanks for the comments! Inlined responses below:

Quoted 12 lines · Björn Töpel

arch/riscv/net/bpf_jit.h line 7

Quoted 8 lines
arch/riscv/net/bpf_jit.h new file +7 -0
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Common functionality for RV32 and RV64 BPF JIT compilers
+ *
+ * Copyright (c) 2019 Björn Töpel <[email protected]>
+ * Copyright (c) 2020 Luke Nelson <[email protected]>
+ * Copyright (c) 2020 Xi Wang <[email protected]>

I'm no lawyer, so this is more of a question; You've pulled out code into a header, and renamed two functions. Does that warrant copyright line additions? Should my line be removed?

This header also includes new code for emitting instructions required for the RV32 JIT (e.g., sltu) and some additional pseudoinstructions (e.g., bgtu and similar). I'm also no lawyer, so I don't know either if this rises to the level of adding copyright lines. I'm happy to do the following in v5 if it looks better:

Quoted 4 lines

+ * Copyright (c) 2019 Björn Töpel <[email protected]>
+ *
+ * Modified by ...

Ah, my mistake! Feel free to keep the Copyright. I was honestly just curious what the correct way (if any) was. So; Keep your copyright! Sorry for the noise!

Quoted 12 lines
Quoted 5 lines
Quoted 1 line

+#if __riscv_xlen == 64

Please remove this. If the inlined functions are not used, they're not part of the binary. This adds complexity to the code, and without it we can catch build errors early on!

I agree in general we should avoid #if. The reason for using it here is to cause build errors if the RV32 JIT ever tries to emit an RV64-only instruction by mistake. Otherwise, what is now a build error would be delayed to an illegal instruction trap when the JITed code is executed, which is much harder to find and diagnose.

Quoted 8 lines

We could use separate files, bpf_jit_32.h and bpf_jit_64.h (the latter will include the former), if we want to avoid #if. Though this adds another form of complexity.

So the options here are 1) using no #if, with the risk of hiding subtle bugs in the RV32 JIT; 2) using #if as is; and 3) using separate headers. What do you think?

Ok, that is a valid concern. We could go the route of compile-time checking:

if (__riscv_xlen != 64)

    bad_usage();

That's overkill in this case. Keep the #if.

Cheers,
Björn

Quoted 3 lines

Thanks!

Luke

#8 lore raw

Re: [PATCH bpf-next v4 2/4] riscv, bpf: add RV32G eBPF JIT

In reply to Luke Nelson
Quoted 1 line · Luke Nelson

[...]

Quoted 18 lines
Quoted 9 lines

arch/riscv/net/bpf_jit_comp32.c line 267

Quoted 7 lines
arch/riscv/net/bpf_jit_comp32.c new file +6 -0
+    case BPF_LSH:
+        if (imm >= 32) {
+            emit(rv_slli(hi(rd), lo(rd), imm - 32), ctx);
+            emit(rv_addi(lo(rd), RV_REG_ZERO, 0), ctx);
+        } else if (imm == 0) {
+            /* nop */

Can we get rid of this, and just do if/else if?

imm == 0 has been a tricky case for 32-bit JITs; see 6fa632e719ee ("bpf, x32: Fix bug with ALU64 {LSH, RSH, ARSH} BPF_K shift by 0"). We wanted to make the imm == 0 case explicit and help future readers see that this case is handled correctly here.

We could do the following if we really wanted to get rid of the check:

Quoted 9 lines

if (imm >= 32) {
...
} else if (imm != 0) {
...
}
/* Do nothing for imm == 0. */

Though it's unclear if this is easier to read.

Thanks for clearing that up. *I* prefer the latter, but that's really up to you! Keep the current one, if you prefer that! :-)

Quoted 29 lines
Quoted 23 lines

arch/riscv/net/bpf_jit_comp32.c line 379

Quoted 8 lines
arch/riscv/net/bpf_jit_comp32.c new file +8 -0
+    case BPF_ARSH:
+        if (is_12b_int(imm)) {
+            emit(rv_srai(lo(rd), lo(rd), imm), ctx);
+        } else {
+            emit_imm(RV_REG_T0, imm, ctx);
+            emit(rv_sra(lo(rd), lo(rd), RV_REG_T0), ctx);
+        }
+        break;

Again nit; I like "early exit" code if possible. Instead of:

if (bleh) {
   foo();
} else {

bar();
}

do:

if (bleh) {
   foo()
   return/break;
}
Quoted 5 lines

bar();

I find the latter easier to read -- but really a nit, and a matter of style. There are number of places where that could be applied in the file.

Quoted 8 lines

I like "early exit" code, too, and agree that it's easier to read in general, especially when handling error conditions.

But here we wanted to make it explicit that both branches are emitting equivalent instruction sequences (under different paths). Structured control flow seems a better fit for this particular context.

Ok!

Quoted 24 lines
Quoted 8 lines

At this point of the series, let's introduce the shared code .c-file containing implementation for bpf_int_jit_compile() (with build_body part of that)and bpf_jit_needs_zext(). That will make it easier to catch bugs in both JITs and to avoid code duplication! Also, when adding the stronger invariant suggested by Palmer [1], we only need to do it in one place.

The pull out refactoring can be a separate commit.

I think the idea of deduplicating bpf_int_jit_compile is good and will lead to more maintainable JITs. How does the following proposal for v5 sound?

In patch 1 of this series:

- Factor structs and common helpers to bpf_jit.h (just like v4).

- Factor out bpf_int_jit_compile(), bpf_jit_needs_zext(), and build_body() to a new file bpf_jit_core.c and tweak the code as in v4.

- Rename emit_insn() and build_{prologue,epilogue}() to bpf_jit_emit_insn() and bpf_jit_build_{prologue,epilogue}, since these functions are now extern rather than static.

Quoted 6 lines

- Rename bpf_jit_comp.c to bpf_jit_comp64.c to be more explicit about its contents (as the next patch will add bpf_jit_comp32.c).

Then patch 2 can reuse the new header and won't need to define its own bpf_int_jit_compile() etc.

I like that, but keep the first patch as a refactoring patch only, and then in a *new* patch 2 you add the rv32 specific code (sltu and pseudo instructions + the xlen preprocessor check + copyright-things ;-)). Patch 3 will be the old patch 2. Wdyt?

Thanks for working on this!
Björn

Quoted 3 lines

Thanks!

Luke

#9 lore raw

Re: [PATCH bpf-next v4 2/4] riscv, bpf: add RV32G eBPF JIT

Quoted 4 lines

I like that, but keep the first patch as a refactoring patch only, and then in a *new* patch 2 you add the rv32 specific code (sltu and pseudo instructions + the xlen preprocessor check + copyright-things ;-)). Patch 3 will be the old patch 2. Wdyt?

Thanks! I'll make sure that patch 1 is for renaming bpf_jit_comp.c and factoring code out. Do you think it's reasonable to add the RV32-specific code to the header in the same patch that adds the RV32 JIT implementation (patch 2)? It might make sense to commit them together.

The full plan for v5 would be:

Patch 1

- Refactor existing code to bpf_jit.h and bpf_jit_core.c
+ Including the minor modifications to build_body() and bpf_int_jit_compile() (These are unrelated to RV32 and we could forego these tweaks).
+ Also making emit_insn and build_{prologue,epilogue} non-static and renaming them to be prefixed with "bpf_jit_".
- Rename bpf_jit_comp.c to bpf_jit_comp64.c

Patch 2

- Add the RV32 BPF JIT implementation to bpf_jit_comp32.c and RV32-specific changes to bpf_jit.h.

Patch 3

- Update documentation.

Patch 4

- Update MAINTAINERS.

Thanks again,

Luke

#10 lore raw

Re: [PATCH bpf-next v4 2/4] riscv, bpf: add RV32G eBPF JIT

Quoted 31 lines · Luke Nelson
Quoted 5 lines

I like that, but keep the first patch as a refactoring patch only, and then in a *new* patch 2 you add the rv32 specific code (sltu and pseudo instructions + the xlen preprocessor check + copyright-things ;-)). Patch 3 will be the old patch 2. Wdyt?

Thanks! I'll make sure that patch 1 is for renaming bpf_jit_comp.c and factoring code out. Do you think it's reasonable to add the RV32-specific code to the header in the same patch that adds the RV32 JIT implementation (patch 2)? It might make sense to commit them together.

The full plan for v5 would be:

Patch 1

- Refactor existing code to bpf_jit.h and bpf_jit_core.c
+ Including the minor modifications to build_body() and bpf_int_jit_compile() (These are unrelated to RV32 and we could forego these tweaks).
+ Also making emit_insn and build_{prologue,epilogue} non-static and renaming them to be prefixed with "bpf_jit_".
- Rename bpf_jit_comp.c to bpf_jit_comp64.c

Patch 2

- Add the RV32 BPF JIT implementation to bpf_jit_comp32.c and RV32-specific changes to bpf_jit.h.

Patch 3

Quoted 8 lines

- Update documentation.

Patch 4

- Update MAINTAINERS.

Thanks again,

Perfect! Thank you!

Quoted 1 line

Luke

#17 lore raw

Re: [PATCH bpf-next v4 4/4] MAINTAINERS: Add entry for RV32G BPF JIT

In reply to Luke Nelson
Quoted 22 lines · Luke Nelson
Quoted 11 lines · Andy Shevchenko
Quoted 11 lines
MAINTAINERS +9 -1
-BPF JIT for RISC-V (RV64G)
+BPF JIT for 32-bit RISC-V (RV32G)
+M:   Luke Nelson <[email protected]>
+M:   Xi Wang <[email protected]>
+L:   [email protected]
+S:   Maintained
+F:   arch/riscv/net/
+X:   arch/riscv/net/bpf_jit_comp.c
+
+BPF JIT for 64-bit RISC-V (RV64G)
 M:   Björn Töpel <[email protected]>
Quoted 8 lines

MAINTAINERS L: [email protected] · line 3229

Quoted 5 lines
MAINTAINERS +2 -1
-L:   [email protected]
+L:   [email protected]
 S:   Maintained
 F:   arch/riscv/net/
+X:   arch/riscv/net/bpf_jit_comp32.c

Obviously this breaks an order. Please, fix.
Hint: run parse-maintainers.pl after the change.

Quoted 6 lines

Thanks for the comment!

I'll change the entry names in v5 to be "BPF JIT for RISC-V (32-bit)" and "BPF JIT for RISC-V (64-bit)", similar to the x86 JIT entries. This will pass parse-maintainers.pl and the entries are still in order.

Thank you!

Signature · 2 lines
With Best Regards,
Andy Shevchenko