The PPC32 eBPF JIT folds MOVs followed by an ALU operation to the same destination into 3-operand PPC instructions, but currently it doesn't check whether the MOV is supposed to perform sign-extension, so MOVSX effectively gets transformed into a plain MOV. To fix this, just skip 3-op folding for MOVSX. Fixes: 8ecf3c1dab1c ("powerpc/bpf/32: Fix failing test_bpf tests") Signed-off-by: Lukas Stockner --- arch/powerpc/net/bpf_jit_comp32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c index 7414e350d2d4..c6cc562cf88c 100644 --- a/arch/powerpc/net/bpf_jit_comp32.c +++ b/arch/powerpc/net/bpf_jit_comp32.c @@ -367,7 +367,8 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code if (i && (BPF_CLASS(code) == BPF_ALU64 || BPF_CLASS(code) == BPF_ALU) && (BPF_CLASS(prevcode) == BPF_ALU64 || BPF_CLASS(prevcode) == BPF_ALU) && BPF_OP(prevcode) == BPF_MOV && BPF_SRC(prevcode) == BPF_X && - insn[i - 1].dst_reg == insn[i].dst_reg && insn[i - 1].imm != 1) { + insn[i - 1].dst_reg == insn[i].dst_reg && insn[i - 1].imm != 1 && + insn[i - 1].off == 0) { src2_reg = bpf_to_ppc(insn[i - 1].src_reg); src2_reg_h = src2_reg - 1; ctx->idx = addrs[i - 1] / 4; -- 2.56.0