Skip to content

Commit 548b762

Browse files
rnavmpe
authored andcommitted
powerpc/bpf ppc32: Fix BPF_SUB when imm == 0x80000000
Special case handling of the smallest 32-bit negative number for BPF_SUB. Fixes: 51c66ad ("powerpc/bpf: Implement extended BPF on PPC32") Signed-off-by: Naveen N. Rao <[email protected]> Reviewed-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/7135360a0cdf70adedbccf9863128b8daef18764.1633464148.git.naveen.n.rao@linux.vnet.ibm.com
1 parent 48164fc commit 548b762

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/powerpc/net/bpf_jit_comp32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context *
357357
PPC_LI32(_R0, imm);
358358
EMIT(PPC_RAW_ADDC(dst_reg, dst_reg, _R0));
359359
}
360-
if (imm >= 0)
360+
if (imm >= 0 || (BPF_OP(code) == BPF_SUB && imm == 0x80000000))
361361
EMIT(PPC_RAW_ADDZE(dst_reg_h, dst_reg_h));
362362
else
363363
EMIT(PPC_RAW_ADDME(dst_reg_h, dst_reg_h));

0 commit comments

Comments
 (0)