Merge branch ‘bpf-nfp-codegen-fixes’ [Linux 5.0]

Merge branch ‘bpf-nfp-codegen-fixes’ [Linux 5.0]

This Linux kernel change "Merge branch ‘bpf-nfp-codegen-fixes’" is included in the Linux 5.0 release. This change is authored by Daniel Borkmann <daniel [at] iogearbox.net> on Sat Feb 23 00:07:48 2019 +0100. The commit for this change in Linux stable tree is 7d466e5 (patch). Other info about this change: Merge: 7c0cdf0 f036ebd

Merge branch 'bpf-nfp-codegen-fixes'

Jiong Wang says:

====================
Code-gen for BPF_ALU | BPF_XOR | BPF_K is wrong when imm is -1,
also high 32-bit of 64-bit register should always be cleared.

This set fixed both bugs.
====================

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

There is no are 0 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/netronome/nfp/bpf/jit.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/jit.c b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
index a096965..0a868c8 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/jit.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
@@ -1291,15 +1291,10 @@ static int construct_data_ld(struct nfp_prog *nfp_prog, u16 offset, u8 size)

 static int
 wrp_alu32_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta,
-         enum alu_op alu_op, bool skip)
+         enum alu_op alu_op)
 {
    const struct bpf_insn *insn = &meta->insn;

-   if (skip) {
-       meta->skip = true;
-       return 0;
-   }
-
    wrp_alu_imm(nfp_prog, insn->dst_reg * 2, alu_op, insn->imm);
    wrp_immed(nfp_prog, reg_both(insn->dst_reg * 2 + 1), 0);

@@ -2309,7 +2304,7 @@ static int xor_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)

 static int xor_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
 {
-   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_XOR, !meta->insn.imm);
+   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_XOR);
 }

 static int and_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
@@ -2319,7 +2314,7 @@ static int and_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)

 static int and_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
 {
-   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_AND, !~meta->insn.imm);
+   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_AND);
 }

 static int or_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
@@ -2329,7 +2324,7 @@ static int or_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)

 static int or_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
 {
-   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_OR, !meta->insn.imm);
+   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_OR);
 }

 static int add_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
@@ -2339,7 +2334,7 @@ static int add_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)

 static int add_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
 {
-   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_ADD, !meta->insn.imm);
+   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_ADD);
 }

 static int sub_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
@@ -2349,7 +2344,7 @@ static int sub_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)

 static int sub_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
 {
-   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_SUB, !meta->insn.imm);
+   return wrp_alu32_imm(nfp_prog, meta, ALU_OP_SUB);
 }

 static int mul_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)

Leave a Reply

Your email address will not be published. Required fields are marked *