History

nfp: bpf: fix ALU32 high bits clearance bug

NFP BPF JIT compiler is doing a couple of small optimizations when jitting ALU imm instructions, some of these optimizations could save code-gen, for example: A & -1 = A A | 0 = A A ^ 0 = A However, for ALU32, high 32-bit of the 64-bit register should still be cleared according to ISA semantics.

Jiong Wang committed 7 years ago

Commit f036ebd1 parent 71c19021 file · +6 −11Browse files

Unified · Split

drivers/net/ethernet/netronome/nfp/bpf/jit.c+6−11
@@ -1291,15 +1291,10 @@ wrp_alu64_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta, · 1290 unmodified lines
12911291
12921292 static int
12931293 wrp_alu32_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta,
1294− enum alu_op alu_op, bool skip)
1294+ enum alu_op alu_op)
12951295 {
12961296 const struct bpf_insn *insn = &meta->insn;
12971297
1298− if (skip) {
1299− meta->skip = true;
1300− return 0;
1301− }
1302−
13031298 wrp_alu_imm(nfp_prog, insn->dst_reg * 2, alu_op, insn->imm);
13041299 wrp_immed(nfp_prog, reg_both(insn->dst_reg * 2 + 1), 0);
13051300
@@ -2309,7 +2304,7 @@ static int xor_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) · 1003 unmodified lines
23092304
23102305 static int xor_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
23112306 {
2312− return wrp_alu32_imm(nfp_prog, meta, ALU_OP_XOR, !meta->insn.imm);
2307+ return wrp_alu32_imm(nfp_prog, meta, ALU_OP_XOR);
23132308 }
23142309
23152310 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) · 3 unmodified lines
23192314
23202315 static int and_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
23212316 {
2322− return wrp_alu32_imm(nfp_prog, meta, ALU_OP_AND, !~meta->insn.imm);
2317+ return wrp_alu32_imm(nfp_prog, meta, ALU_OP_AND);
23232318 }
23242319
23252320 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) · 3 unmodified lines
23292324
23302325 static int or_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
23312326 {
2332− return wrp_alu32_imm(nfp_prog, meta, ALU_OP_OR, !meta->insn.imm);
2327+ return wrp_alu32_imm(nfp_prog, meta, ALU_OP_OR);
23332328 }
23342329
23352330 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) · 3 unmodified lines
23392334
23402335 static int add_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
23412336 {
2342− return wrp_alu32_imm(nfp_prog, meta, ALU_OP_ADD, !meta->insn.imm);
2337+ return wrp_alu32_imm(nfp_prog, meta, ALU_OP_ADD);
23432338 }
23442339
23452340 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) · 3 unmodified lines
23492344
23502345 static int sub_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
23512346 {
2352− return wrp_alu32_imm(nfp_prog, meta, ALU_OP_SUB, !meta->insn.imm);
2347+ return wrp_alu32_imm(nfp_prog, meta, ALU_OP_SUB);
23532348 }
23542349
23552350 static int mul_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)