s390/bpf: fix lcgr instruction encoding
Subsystems (5)
Ilya Leoshkevich
maintainerPATCH 1/1 s390/bpf: fix lcgr instruction encoding
"masking, test in bounds 3" fails on s390, because BPF_ALU64_IMM(BPF_NEG, BPF_REG_2, 0) ignores the top 32 bits of BPF_REG_2. The reason is that JIT emits lcgfr instead of lcgr. The associated comment indicates that the code was intended to emit lcgr in the first place, it's just that the wrong opcode was used.
Fix by using the correct opcode.
--- arch/s390/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/net/bpf_jit_comp.c +1 -1
@@ -863,7 +863,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int ibreak ;case BPF_ALU64 |BPF_NEG :/* dst = -dst */ /* lcgr %dst,%dst */ -EMIT4 (0xb9130000 , dst_reg, dst_reg); +EMIT4 (0xb9030000 , dst_reg, dst_reg);break ;/* * BPF_FROM_BE/LE
Signature · 1 line
2.21.0
Quoted 29 lines · Ilya Leoshkevich
"masking, test in bounds 3" fails on s390, because
BPF_ALU64_IMM(BPF_NEG, BPF_REG_2, 0)ignores the top 32 bits ofBPF_REG_2. The reason is that JIT emits lcgfr instead of lcgr. The associated comment indicates that the code was intended to emit lcgr in the first place, it's just that the wrong opcode was used.Fix by using the correct opcode.
Signed-off-by Ilya Leoshkevich <[email protected]>--- arch/s390/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/net/bpf_jit_comp.c +1
-1@@ -863,7 +863,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int ibreak ;case BPF_ALU64 |BPF_NEG :/* dst = -dst */ /* lcgr %dst,%dst */ -EMIT4 (0xb9130000 , dst_reg, dst_reg); +EMIT4 (0xb9030000 , dst_reg, dst_reg);break ;/* * BPF_FROM_BE/LE Signature · 1 line
2.21.0
Please add
or whatever it should be. With that:
Quoted 9 lines · Ilya Leoshkevich
"masking, test in bounds 3" fails on s390, because
BPF_ALU64_IMM(BPF_NEG, BPF_REG_2, 0)ignores the top 32 bits ofBPF_REG_2. The reason is that JIT emits lcgfr instead of lcgr. The associated comment indicates that the code was intended to emit lcgr in the first place, it's just that the wrong opcode was used.Fix by using the correct opcode.
Signed-off-by Ilya Leoshkevich <[email protected]>
Applied, thanks!