nfp: bpf: fix code-gen bug on BPF_ALU | BPF_XOR | BPF_K
authorJiong Wang <jiong.wang@netronome.com>
Fri, 22 Feb 2019 22:36:03 +0000 (22:36 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 22 Feb 2019 23:07:47 +0000 (00:07 +0100)
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 <jakub.kicinski@netronome.com>
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
drivers/net/ethernet/netronome/nfp/bpf/jit.c

index e23ca90289f71ca5776bab7e66659640de1857c2..a09696540171e76a2ea385de5f265354b9b51f32 100644 (file)
@@ -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)