nfp: bpf: fix code-gen bug on BPF_ALU | BPF_XOR | BPF_K [Linux 5.0]

This Linux kernel change "nfp: bpf: fix code-gen bug on BPF_ALU | BPF_XOR | BPF_K" is included in the Linux 5.0 release. This change is authored by Jiong Wang < [at]> on Fri Feb 22 22:36:03 2019 +0000. The commit for this change in Linux stable tree is 71c1902 (patch).

nfp: bpf: fix code-gen bug on BPF_ALU | BPF_XOR | BPF_K

The intended optimization should be A ^ 0 = A, not A ^ -1 = A.

Fixes: cd7df56ed3e6 ("nfp: add BPF to NFP code translator")
Reviewed-by: Jakub Kicinski <[email protected]>
Signed-off-by: Jiong Wang <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>

There are 2 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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/jit.c b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
index e23ca90..a096965 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/jit.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
@@ -2309,7 +2309,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, !meta->insn.imm);

 static int and_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 *